fix(query-devtools): name the PiP window per origin so another origin's popup is never reused #12702
main fromrefs/pull/12702/head·opened View on GitHub🎯 Changes#
Fixes #12700.
The picture-in-picture popup was opened under one fixed window name, TSQD-Devtools-Panel. window.open returns any window the tab can reach by that name, even one another origin opened, so with the devtools popped out in an app on one origin, an app on another origin in the same tab got that popup back and threw a SecurityError on its first pip.document access: on the picture-in-picture button, or from the auto-open effect when pip_open was saved.
The name now includes window.location.origin, so each origin gets its own popup, and a page still reuses the popup its own origin opened.
Tests: the three assertions on the old name expect the per-origin one, and a new test renders under two stubbed origins and checks each gets its own popup. Also checked in Chrome with examples/react/basic running on two ports: before, the second app's button threw the SecurityError and no popup opened; after, both popups open side by side and a reload reuses its own.
pnpm run test:pr passes apart from the ten Next.js example builds, which compile and then stop on Next's own security notice; main stops the same way here.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 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
- The devtools picture-in-picture window now uses a distinct name for each site origin, preventing windows from different origins from sharing the same popup.
- 1
imadization(GitHub profile, opens in a new tab) linked this to fix #12700
tanstack-source added labelsbug
No actionable comments were generated in the recent review.
Walkthrough
-
The PiP provider now includes the current window origin in the popup name. Tests cover explicit opening at multiple origins and automatic opening. A changeset declares a patch release for
@tanstack/query-devtools.Changes: PiP window naming
Layer / File(s) Summary Set and verify origin-specific names
packages/query-devtools/src/contexts/PiPContext.tsx,packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx,packages/query-devtools/src/__tests__/Devtools.test.tsx,.changeset/query-devtools-pip-window-per-origin.mdrequestPipWindowadds the current origin to the popup name. Tests check the name for explicit opening at multiple origins and for automatic opening. The changeset declares a patch release.Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
sukvvon,tkdodo
Merge Risk:
Minimal · up toe15b0-
This patch gives each origin its own devtools popup, so one origin's popup is no longer reused by another and no longer throws a SecurityError. The change is small and was tested, and no merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: the PiP window name now includes the origin, so another origin's popup is never reused. It matches the raw summary, which says requestPipWindow now names the popup wit… Description check The description follows the template. It has the Changes section with motivation and the root cause, and it links issue #12700. The checklist items are marked, and the release impact section marks the…Linked Issues check [ #12700] The issue asks that each app's devtools open or reuse its own PiP popup, and that a popup from another origin sharing the window name is never touched. At head,PiPProvider.requestPipWindow…Out of Scope Changes check Whole-PR diff against merge base 18b1aded shows three coding files and one changeset. The PiPContext.tsxchange is a single name change with a comment. The test changes update the three old-name ass…Full details: Title check
-
Explanation
The title names the main change: the PiP window name now includes the origin, so another origin's popup is never reused. It matches the raw summary, which says requestPipWindow now names the popup with the current window's origin instead of the fixed TSQD-Devtools-Panel name. It is a single, specific sentence. Its only weakness is length (93 characters), which is acceptable.
Full details: Description check
-
Explanation
The description follows the template. It has the Changes section with motivation and the root cause, and it links issue
#12700. The checklist items are marked, and the release impact section marks the changeset item. It also states the local test run and its result, including the Next.js example build failures that the test run reported. The description does not state which test ran for the example apps, but that is a minor gap.
Full details: Linked Issues check
-
Explanation
[
#12700] The issue asks that each app's devtools open or reuse its own PiP popup, and that a popup from another origin sharing the window name is never touched. At head,PiPProvider.requestPipWindowinpackages/query-devtools/src/contexts/PiPContext.tsxcallswindow.open('',TSQD-Devtools-Panel-${window.location.origin}, ...). Each origin now gets a distinct window name, sowindow.opencannot return another origin's popup for this name. A page still looks up the name built from its own origin, so it reuses its own popup. This implements the first fix option the issue lists. The auto-open effect calls the samerequestPipWindowpath, so the persistedpip_opencase is covered by the same name change. The tests inPiPContext.test.tsxandDevtools.test.tsxexpect the origin-specific name. A new test renders under two stubbed origins and checks that each origin gets its own name. No non-coding requirements were found in the issue.
Full details: Out of Scope Changes check
-
Explanation
Whole-PR diff against merge base 18b1aded shows three coding files and one changeset. The
PiPContext.tsxchange is a single name change with a comment. The test changes update the three old-name assertions and add one two-origin test, which supports the change. The changeset is a patch note for@tanstack/query-devtools, which fits the published change. No unrelated changes were found in the reviewed files. The raw summary lists only these files, so no other files were checked.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/query
- Branch: main
- File: .coderabbit.yaml
- Commit: 18b1ade
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f6b4fe7a-4d25-47f1-8abf-924a643fbfc1
Commits-
Reviewing files that changed from the base of the PR and between 18b1aded329058c074cda6b1c1a08aba73fdc914 and e15b0ec31b6ff0feae1e66981df206796872edce.
Files selected for processing: 4-
.changeset/query-devtools-pip-window-per-origin.mdpackages/query-devtools/src/__tests__/Devtools.test.tsxpackages/query-devtools/src/__tests__/contexts/PiPContext.test.tsxpackages/query-devtools/src/contexts/PiPContext.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
-
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: e15b0ec31b6ff0feae1e66981df206796872edce
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 26 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR