fix(query-devtools): isolate state across multiple mounted instances #11116
main fromrefs/pull/11116/head·opened View on GitHubSelection, panel width, offline-mocking, and cache-subscription state lived in module-level signals/maps in Devtools.tsx, so every mounted Devtools instance (e.g. two panels bound to two different QueryClients) shared the same state. Selecting a query, resizing, or notifying one client's cache leaked into every other mounted panel.
Move this state into a per-instance DevtoolsUiProvider/context so each mount is fully isolated.
Fixes #9681
🎯 Changes#
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
Bug Fixes
- Fixed Devtools panels interfering with one another when multiple instances are mounted simultaneously.
- Selections, panel sizing, offline mode, and cache updates now remain isolated for each panel.
- Each Devtools instance consistently displays data from its associated query client.
Tests
- Added coverage for multi-instance state and cache isolation scenarios.
- 1
TkDodo approved these changes
Note
GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
🤖 Nx Cloud AI Fix Eligible#
To disable these notifications, a workspace admin can disable them [in workspace settings.](https://cloud.nx.app/orgs/6412ca9d1c251d000efa21ba/workspaces/6412c827e6da5d7b4a0b1fe3/settings/self-healing-ci?utm_source=pull-request&utm_medium=comment)An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.
View your CI Pipeline Execution ↗ for commit 1480d3f7489c5e7df0d3b51ed8bc237305a675f7
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...❌ Failed 5m 18s View ↗ nx run-many --target=build --exclude=examples/*...❌ Failed 49s View ↗
☁️ Nx Cloud last updated this comment at
2026-08-22 08:56:07UTCplease take a look at the failing build:
../query-devtools/src/__tests__/MultiInstanceIsolation.test.tsx(117,28): error TS2345: Argument of type 'HTMLElement | undefined' is not assignable to parameter of type 'HTMLElement'.TkDodo closed this
superseded by:
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
96a99bae-27b2-4c4c-a93c-347765ec3620📥 Commits
Reviewing files that changed from the base of the PR and between 5ca904d0688ca6c21600ed67a4c3a90c516bae76 and 1480d3f7489c5e7df0d3b51ed8bc237305a675f7.
📒 Files selected for processing (8)
.changeset/isolate-devtools-instances.mdpackages/query-devtools/src/Devtools.tsxpackages/query-devtools/src/DevtoolsComponent.tsxpackages/query-devtools/src/DevtoolsPanelComponent.tsxpackages/query-devtools/src/__tests__/Devtools.test.tsxpackages/query-devtools/src/__tests__/MultiInstanceIsolation.test.tsxpackages/query-devtools/src/contexts/DevtoolsUiContext.tsxpackages/query-devtools/src/contexts/index.ts🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough#
Devtools UI state and query/mutation cache subscription maps now live in per-instance Solid context. Provider wiring is updated across components and tests, with regression coverage for simultaneous panels using separate
QueryClientinstances.Changes#
Devtools instance isolation
packages/query-devtools/src/contexts/DevtoolsUiContext.tsx,packages/query-devtools/src/contexts/index.tsDevtoolsUiProvider,useDevtoolsUiContext, UI state signals, and per-instance cache subscription maps.packages/query-devtools/src/Devtools.tsx,packages/query-devtools/src/DevtoolsComponent.tsx,packages/query-devtools/src/DevtoolsPanelComponent.tsxpackages/query-devtools/src/__tests__/MultiInstanceIsolation.test.tsx,packages/query-devtools/src/__tests__/Devtools.test.tsx,.changeset/isolate-devtools-instances.mdEstimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to
1480dThe change isolates Devtools state per mounted instance, preventing selections, sizing, and cache notifications from leaking between panels; no actionable merge-blocking risk remains beyond normal checks and review.
Sequence Diagram(s)#
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#9681.✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share