Skip to content

fix(query-devtools): isolate state per devtools instance#11112

Open
g1mn wants to merge 1 commit into
TanStack:mainfrom
g1mn:fix/devtools-instance-isolation
Open

fix(query-devtools): isolate state per devtools instance#11112
g1mn wants to merge 1 commit into
TanStack:mainfrom
g1mn:fix/devtools-instance-isolation

Conversation

@g1mn

@g1mn g1mn commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Multiple Query DevTools instances (e.g. attached to different QueryClients) shared UI state because selection, panel width, offline toggle, and cache maps lived in module-level signals. Selecting a query, resizing, or toggling offline in one panel leaked into the other (#9681).

This moves that state into a DevtoolsInstanceContext provider so each mounted devtools tree gets its own isolated reactive state and cache batching. Exported component signatures are unchanged.

Test

Added DevtoolsInstanceIsolation.test.tsx:

  • identical query keys across two clients do not leak selection/highlight
  • collapsing panel A below min height does not clear panel B selection
  • toggling mock-offline in instance A does not affect instance B

Existing devtools tests pass; changeset included (patch, @tanstack/query-devtools).

Closes #9681


Independently cross-reviewed with a second AI model before submission.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed state leakage between separately mounted Devtools instances.
    • Selections, panel resizing, offline-mode toggles, and cache updates now remain isolated within each instance.
    • Prevented interactions in one Devtools panel from changing another panel’s UI or details.
  • Tests

    • Added coverage verifying independent selections, panel sizing, and offline-mode behavior across multiple Devtools instances.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

DevTools UI signals and cache subscription maps are moved into an instance-scoped Solid context. Components consume that context, providers are added to the render tree, and tests verify independent selection, resizing, and offline state across multiple instances.

Changes

DevTools instance isolation

Layer / File(s) Summary
Instance context and provider
packages/query-devtools/src/contexts/DevtoolsInstanceContext.tsx, packages/query-devtools/src/contexts/index.ts
Defines per-instance selection, panel width, offline state, and cache subscription maps, then exports the provider and hook.
State and subscription integration
packages/query-devtools/src/Devtools.tsx, packages/query-devtools/src/DevtoolsPanelComponent.tsx
Wraps DevTools with DevtoolsInstanceProvider and updates panels, rows, detail views, and cache subscriptions to use instance-scoped state.
Isolation validation and release metadata
packages/query-devtools/src/__tests__/DevtoolsInstanceIsolation.test.tsx, .changeset/heavy-carpets-divide.md
Tests selection, resizing, and offline mocking across separate instances and adds a patch changeset.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Devtools
  participant DevtoolsInstanceProvider
  participant DevtoolsImpl
  participant QueryClient
  Devtools->>DevtoolsInstanceProvider: create instance-scoped state and maps
  DevtoolsInstanceProvider->>DevtoolsImpl: provide instance context
  DevtoolsImpl->>QueryClient: register cache subscriptions
  QueryClient-->>DevtoolsImpl: send cache updates through instance maps
Loading

Suggested labels: package: query-devtools

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR describes the change and tests, but it omits the required template sections for checklist and release impact. Add the "🎯 Changes", "✅ Checklist", and "🚀 Release Impact" sections, including the required checkbox items and release classification.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes and tests address #9681 by moving UI state and cache batching into per-instance context so devtools instances stay isolated.
Out of Scope Changes check ✅ Passed All modified files support the instance-isolation fix, the new test, or the changeset; no unrelated scope creep is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly states the main change: isolating devtools state per instance.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

Module-level SolidJS signals and cache maps were shared across all mounted
devtools, so selecting a query, resizing, or toggling offline in one instance
leaked into another. Move them into a per-instance context provider so each
devtools tree owns its own reactive state and cache batching.

Closes TanStack#9681
@g1mn
g1mn force-pushed the fix/devtools-instance-isolation branch from c5a459d to adfd798 Compare July 23, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query DevTools is not isolated

1 participant