Skip to content
Source
Sign inSign up
TanStack/query

fix(query-devtools): name the PiP window per origin so another origin's popup is never reused #12711

Openmgarcia-improving(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12711/headopened View on GitHub

mgarcia-improving(GitHub profile, opens in a new tab)commented

🎯 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); full test:pr not run.
  • 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. tanstack-source added labelsbug

    2. 🦋 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
      NameType
      @tanstack/query-devtoolsPatch
      @tanstack/angular-query-devtoolsPatch
      @tanstack/preact-query-devtoolsPatch
      @tanstack/react-query-devtoolsPatch
      @tanstack/solid-query-devtoolsPatch
      @tanstack/svelte-query-devtoolsPatch
      @tanstack/vue-query-devtoolsPatch
      @tanstack/angular-query-persist-clientPatch
      @tanstack/angular-queryPatch
      @tanstack/eslint-plugin-queryPatch
      @tanstack/preact-query-persist-clientPatch
      @tanstack/preact-queryPatch
      @tanstack/query-async-storage-persisterPatch
      @tanstack/query-broadcast-client-experimentalPatch
      @tanstack/query-corePatch
      @tanstack/query-persist-client-corePatch
      @tanstack/query-sync-storage-persisterPatch
      @tanstack/react-query-next-experimentalPatch
      @tanstack/react-query-persist-clientPatch
      @tanstack/react-queryPatch
      @tanstack/solid-query-persist-clientPatch
      @tanstack/solid-queryPatch
      @tanstack/vue-queryPatch
      @tanstack/svelte-query-persist-clientPatch
      @tanstack/svelte-queryPatch
      @tanstack/lit-queryPatch

      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

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      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.md
      requestPipWindow now includes window.location.origin in 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 to 56e29

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassed[#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 checkPassedThe 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 in PiPProvider.requestPipWindow (packages/query-devtools/src/contexts/PiPContext.tsx) from the fixed TSQD-Devtools-Panel to `TSQD-Devtools-Panel-${window.location.origin}`. Origins that differ in scheme, host, or port now get different names, so window.open no 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 persisted pip_open path 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.

      Share

      Recent review info

      Run configuration

      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.md
      • packages/query-devtools/src/__tests__/Devtools.test.tsx
      • packages/query-devtools/src/__tests__/contexts/PiPContext.test.tsx
      • packages/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.