Skip to content

[WEB-4390] - Install RTK#1862

Open
henry-tp wants to merge 35 commits intodevelopfrom
WEB-4390-install-rtk
Open

[WEB-4390] - Install RTK#1862
henry-tp wants to merge 35 commits intodevelopfrom
WEB-4390-install-rtk

Conversation

@henry-tp
Copy link
Copy Markdown
Contributor

@henry-tp henry-tp commented Feb 9, 2026

WEB-4390

platform-client: tidepool-org/platform-client#215

I know it's +600 lines but It's not that bad, just renaming a bunch of test cases to use the 'thunk' named export (breaking change)

You can't really test this manually, so here is a branch you can checkout if you want to see it in action:
#1865

@henry-tp henry-tp mentioned this pull request Feb 9, 2026
1 task
@henry-tp henry-tp changed the title WEB-4390 - Install RTK [WEB-4390] - Install RTK Feb 9, 2026
@henry-tp henry-tp marked this pull request as ready for review February 10, 2026 17:34
@henry-tp henry-tp added the Needs Release Target This branch cannot be merged until the feature is assigned to a release version first. label Feb 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request installs Redux Toolkit (RTK) 2.11.2 and upgrades core Redux dependencies to their latest major versions (Redux 5.0.1, redux-thunk 3.1.0, reselect 5.1.0). The primary change is updating all test files to use the named export for redux-thunk middleware, which is a breaking change in redux-thunk 3.x. The PR sets up the foundation for RTK Query by creating a base API configuration with authentication and tracing headers, though no actual API endpoints are defined yet (those will be added in PR #1865).

Changes:

  • Installed @reduxjs/toolkit 2.11.2 and upgraded Redux from 4.2.1 to 5.0.1, redux-thunk from 2.4.2 to 3.1.0, and reselect from 4.1.8 to 5.1.0
  • Updated all test files (60+ files) to import redux-thunk middleware as a named export { thunk } instead of default export
  • Created RTK Query base API configuration with authentication headers, retry logic, and action dispatching for tracking
  • Integrated RTK Query reducer and middleware into both dev and production store configurations
  • Updated tidepool-platform-client to pre-release version 0.65.0-web-4390-install-rtk.1 (likely includes getSessionTrace method)

Reviewed changes

Copilot reviewed 62 out of 63 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package.json Added @reduxjs/toolkit dependency and upgraded redux, redux-thunk, reselect, and tidepool-platform-client versions
yarn.lock Updated lockfile with new dependency versions and their transitive dependencies
app/redux/api/baseApi.js Created new RTK Query base API with authentication, tracing, retry logic, and custom action dispatches
app/redux/constants/actionTypes.js Added RTK_QUERY_REQUEST_SUCCESS and RTK_QUERY_REQUEST_ERROR action type constants
app/redux/store/configureStore.prod.js Integrated RTK Query reducer and middleware into production store configuration
app/redux/store/configureStore.dev.js Integrated RTK Query reducer and middleware into development store configuration with hot module replacement support
test/utils/mountWithProviders.js Updated redux-thunk import to use named export
test/unit/**/*.test.js (30+ files) Updated all test files to import redux-thunk as named export { thunk }
tests/unit/**/*.test.js (28+ files) Updated all Jest test files to import redux-thunk as named export { thunk }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/redux/api/baseApi.js
Comment thread app/redux/api/baseApi.js Outdated
Comment thread package.json
Comment thread __tests__/unit/app/components/incrementalinput/incrementalinput.test.js Outdated
Comment thread app/redux/api/baseApi.js

const getSessionToken = () => {
return keycloak?.token || '';
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The abstraction of getSessionToken() and getSessionTrace() may be a pointless exercise, but I wanted to create some level of separation such that the query call isn't calling on keycloak or tidepoolApi directly. A functional-style dependency-injection, if you will

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this abstraction.

const reducer = combineReducers({
blip: reducers,
router: connectRouter(history),
[RTKQueryApi.reducerPath]: RTKQueryApi.reducer,
Copy link
Copy Markdown
Contributor Author

@henry-tp henry-tp Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a new top-level redux slice called api, so it's neatly separated from all existing blip data which is nice.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

@henry-tp henry-tp requested a review from ginnyyadav February 11, 2026 19:36
@henry-tp
Copy link
Copy Markdown
Contributor Author

henry-tp commented Feb 11, 2026

Hi @ginnyyadav , I am tagging you in case you want to take a look (at your leisure).

The code changes for this are relatively small (<80 lines), the other ~60 file changes are just changing an import style due to breaking changes on a library upgrade for a dependency.

The changes effectively are, across 3 files:

  • Creating the RTK Query API object and setting it up
  • Shoving in the new RTK middleware
  • Making sure our existing middleware knows how to catch erroring requests from RTK Query

Hoping that this can help inform QA effort or help you raise any questions/concerns that should be pre-emptively addressed. As it stands, once we install RTK with this PR, nothing should change; just need to look out for any regressions. There are potential breaking changes with the dependency updates but I haven't found any issues aside from the import style.

@henry-tp henry-tp requested a review from krystophv February 12, 2026 19:37
Comment thread jest.config.js
@@ -1,5 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
testEnvironment: 'jest-fixed-jsdom',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially extend it ourselves instead (it's not a lot of code) if we don't want to rely yet another package.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to pull this in. Doing it ourselves gives us the same result with likely more maintenance.

Comment thread yarn.lock
languageName: node
linkType: hard

"@inquirer/ansi@npm:^1.0.2":
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially all of this stuff is from msw

Comment thread app/redux/api/baseApi.js
};

const apiHost = config.API_HOST;
const apiVersion = 'v1';
Copy link
Copy Markdown
Contributor Author

@henry-tp henry-tp Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that we hardcode v1 in platform-client everywhere instead of putting it in config or something. I was thinking about putting it in config or at some higher level, but it seems like something we are intentionally not doing that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good here for now. Who knows if we ever will see a v2, but it's good to split the version out at any rate.

Comment thread app/redux/api/baseApi.js
},
});

export const RTKQueryApi = createApi({
Copy link
Copy Markdown
Contributor Author

@henry-tp henry-tp Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad name?

A conventional name might be baseApi or emptySplitApi but now we have two api objects in blip.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards baseApi to match the filename. Any good code editor intellisense should allow us to easily find it's definition and what it does.

You're fine to leave the name as-is too. I'm fine either way.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 67 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread __tests__/unit/app/redux/api/baseApi.test.js Outdated
Comment thread jest.setup.js
global.__I18N_ENABLED__ = 'false';
global.__DEV_TOOLS__ = false;

window.config = {
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.config is assigned a new object here, which will overwrite any existing config keys that a test (or another setup file) may have set. To avoid clobbering other settings, consider merging into the existing object (e.g., initialize window.config if missing and then set API_HOST).

Suggested change
window.config = {
window.config = {
...(window.config || {}),

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine as-is for now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the whole window.config init makes me scratch my head every now and again, but agree it's fine.

@henry-tp henry-tp added the Hold for Release This branch is ready for merge, but awaiting its target release version to be the next release label Feb 18, 2026
Copy link
Copy Markdown
Member

@clintonium-119 clintonium-119 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great to me. Nice clean work on this :)
LGTM 🚢

const reducer = combineReducers({
blip: reducers,
router: connectRouter(history),
[RTKQueryApi.reducerPath]: RTKQueryApi.reducer,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

Comment thread jest.config.js
@@ -1,5 +1,5 @@
module.exports = {
testEnvironment: 'jsdom',
testEnvironment: 'jest-fixed-jsdom',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to pull this in. Doing it ourselves gives us the same result with likely more maintenance.

Comment thread jest.setup.js
global.__I18N_ENABLED__ = 'false';
global.__DEV_TOOLS__ = false;

window.config = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the whole window.config init makes me scratch my head every now and again, but agree it's fine.

Comment thread app/redux/api/baseApi.js
},
});

export const RTKQueryApi = createApi({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards baseApi to match the filename. Any good code editor intellisense should allow us to easily find it's definition and what it does.

You're fine to leave the name as-is too. I'm fine either way.

Comment thread app/redux/api/baseApi.js

const getSessionToken = () => {
return keycloak?.token || '';
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this abstraction.

Comment thread app/redux/api/baseApi.js
};

const apiHost = config.API_HOST;
const apiVersion = 'v1';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good here for now. Who knows if we ever will see a v2, but it's good to split the version out at any rate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hold for Release This branch is ready for merge, but awaiting its target release version to be the next release Needs Release Target This branch cannot be merged until the feature is assigned to a release version first.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants