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 #12702

Openimadization(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12702/headopened View on GitHub

imadization(GitHub profile, opens in a new tab)commented

🎯 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. 🦋 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
      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

    2. tanstack-source added labelsbug

    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 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.md
      requestPipWindow adds 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 to e15b0

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

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassed[#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 checkPassedWhole-PR diff against merge base 18b1aded shows three coding files and one changeset. The PiPContext.tsx change 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.requestPipWindow in packages/query-devtools/src/contexts/PiPContext.tsx calls window.open('', TSQD-Devtools-Panel-${window.location.origin}, ...). Each origin now gets a distinct window name, so window.open cannot 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 same requestPipWindow path, so the persisted pip_open case is covered by the same name change. The tests in PiPContext.test.tsx and Devtools.test.tsx expect 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.tsx change 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.

      Share

      Recent review info

      Run configuration

      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.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.