fix(query-devtools): name the PiP window per origin so another origin's popup is never reused #12711
main fromrefs/pull/12711/head·opened View on GitHub🎯 Changes#
Fixes #12700.
The picture-in-picture popup is opened under the fixed window name TSQD-Devtools-Panel. If another origin in the same browsing context group already owns a popup with that name, window.open returns that cross-origin window and the first pip.document access throws a SecurityError (on the PiP button, or in the auto-open effect when pip_open is persisted).
The window name now includes window.location.origin, so each origin gets its own popup and never touches another origin's. A page still reuses the popup its own origin opened.
Tests: the three assertions on the old name now expect the per-origin name, and a new test opens the popup under two stubbed origins and checks the names differ. A patch changeset is included.
Note: #12702 addresses the same issue with the same approach; opened independently, happy to close this in favor of it if preferred.
✅ 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.- Ran
pnpm nx run @tanstack/query-devtools:test:lib(377 tests pass, no type errors); fulltest:prnot run.
- Ran
- 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 name specific to the current page origin, preventing windows opened from different origins from sharing the same name.
- 1
mgarcia-improving(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 popup name now includes the current page origin. Tests expect the origin-specific name and verify that different origins produce different names. A changeset records the patch.
Changes: Picture-in-picture naming
Layer / File(s) Summary Origin-specific popup name and validation
packages/query-devtools/src/contexts/PiPContext.tsx,packages/query-devtools/src/__tests__/*,.changeset/devtools-pip-origin-window-name.mdrequestPipWindownow includeswindow.location.originin the popup name. Tests cover the updated name for regular opening, auto-open, and different origins. A changeset records a patch release.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- TanStack/query#12702: Makes the same origin-specific PiP window naming change and addresses the same issue.
Suggested reviewers:
sukvvon,tkdodo
Merge Risk:
Minimal · up to56e29-
Each app origin now opens and reuses its own picture-in-picture popup. This fixes the cross-origin SecurityError described in the issue for ordinary http(s) apps. The change is small and easy to revert, and no actionable merge-blocking risk remains.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: the query-devtools PiP popup window is now named per origin, so one origin does not reuse another origin's popup. It is specific and matches the changeset, tests, and … Description check The description follows the template. It has the Changes section with motivation and a reference to issue #12700, which explains the SecurityError failure and the fix. The checklist is filled in. Test…Linked Issues check [ #12700] The issue requires that each app's devtools open or reuse its own PiP popup, and that a same-named popup from another origin is never touched. The reviewed head changes the popup name in `PiP…Out of Scope Changes check The changes are: a one-line name change plus explanatory comment in PiPContext.tsx, updated expectations in Devtools.test.tsx and PiPContext.test.tsx with one new origin-separation test, and a patch c… Full details: Title check
-
Explanation
The title names the main change: the query-devtools PiP popup window is now named per origin, so one origin does not reuse another origin's popup. It is specific and matches the changeset, tests, and linked issue
#12700. It is a single sentence and uses the conventional fix(scope) prefix.
Full details: Description check
-
Explanation
The description follows the template. It has the Changes section with motivation and a reference to issue
#12700, which explains the SecurityError failure and the fix. The checklist is filled in. Tests were run partially, with 377 passing and no type errors, and the full test:pr run was not done. The release impact section is marked with a changeset. Two checklist items are left unchecked, and the description does not state the full test status, so the template is mostly but not fully complete.
Full details: Linked Issues check
-
Explanation
[
#12700] The issue requires that each app's devtools open or reuse its own PiP popup, and that a same-named popup from another origin is never touched. The reviewed head changes the popup name inPiPProvider.requestPipWindow(packages/query-devtools/src/contexts/PiPContext.tsx) from the fixedTSQD-Devtools-Panelto`TSQD-Devtools-Panel-${window.location.origin}`. Origins that differ in scheme, host, or port now get different names, sowindow.openno longer returns another origin's window for this name. A page with the same origin still reuses its own popup. This matches the origin-specific-name fix the issue proposes. The auto-open effect calls the same function, so the persistedpip_openpath is covered too. The PR description reports tests for the new name and a two-origin test. I did not inspect the test files directly; this verdict relies on the diff of the source file and the summary of the test changes. The issue's second option (a try/catch fallback) is not implemented, but the issue presents it as an alternative, so it is not required.
Full details: Out of Scope Changes check
-
Explanation
The changes are: a one-line name change plus explanatory comment in PiPContext.tsx, updated expectations in Devtools.test.tsx and PiPContext.test.tsx with one new origin-separation test, and a patch changeset for
@tanstack/query-devtools. Each change supports the origin-specific popup name required by#12700. No unrelated behavior or files appear in the summary or the source diff. Test and changeset files were checked only through the summary, not through a direct read.
-
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: 635aad6
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f1601d49-cf34-48d4-a285-f0b00c69e12e
Commits-
Reviewing files that changed from the base of the PR and between 635aad6a95b08dffc91ba1973c043b219f085cd6 and 56e2904ba5f756f85be445db5b19f4f9069fb5ed.
Files selected for processing: 4-
.changeset/devtools-pip-origin-window-name.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: 56e2904ba5f756f85be445db5b19f4f9069fb5ed
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