Skip to content

Conversation

@akdlsz21
Copy link
Contributor

@akdlsz21 akdlsz21 commented Dec 19, 2025

🎯 Changes

The existing implementation of handling persistent PiP state leaves room for the state to be in an awkward state.

Closing the app while PiP mode is active will cause devtools to try to reopen in PiP mode. The issue with this is that when the browser permissions for pop-ups are disactive, it will fail. The devtools state will reflect that devtools is open and no longer display the devtools button while devtools itself is not open for obvious reasons.

Although the user can workaround this by enabling pop-ups, switch off the PiP state, and disable pop-ups, I thought this was cumbersome. My proposal is to reset the state so that devtools thinks it's closed. So the user can re-open it with the default method.

Screencast.from.2025-12-19.22-42-57.webm

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 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
    • Fixed Picture-in-Picture opening failures by implementing robust error handling. When the popup request fails, the application now gracefully resets persisted state flags, preventing stuck or invalid states from persisting.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Dec 19, 2025

🦋 Changeset detected

Latest commit: 300488d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@tanstack/query-devtools Patch
@tanstack/angular-query-experimental Patch
@tanstack/react-query-devtools Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools Patch
@tanstack/angular-query-persist-client Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 19, 2025

Walkthrough

This patch release introduces error handling for Picture-in-Picture (PiP) popup failures in @tanstack/query-devtools. A new PipOpenError class captures popup-opening failures, and error handling logic wraps the popup request to reset persisted state flags when such errors occur.

Changes

Cohort / File(s) Summary
Changelog Entry
\.changeset/warm-drinks-itch.md
Documents patch release with fix for PiP open failures by resetting persisted state.
PiP Error Handling
packages/query-devtools/src/contexts/PiPContext.tsx
Introduces PipOpenError class for popup failures. Wraps popup request in try/catch; on PipOpenError, logs message and resets pip_open and open localStorage flags to false before gracefully returning. Other errors are rethrown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review the new PipOpenError class definition for correctness
  • Verify try/catch logic properly handles and resets localStorage flags
  • Confirm error logging messages are appropriate and non-disruptive

Poem

🐰 A popup that fails? No despair!
We catch the error with utmost care,
Reset the flags with a gentle touch,
PiP may stumble, but we've got crutch,
Graceful recovery, handled with flair! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: fixing devtools PiP failures by resetting persisted state, which directly matches the PR's purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description follows the required template with all sections completed: detailed explanation of changes and motivation, completed checklist items, and release impact declaration with changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Dec 19, 2025

View your CI Pipeline Execution ↗ for commit 300488d

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 3m 20s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 35s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-19 13:44:23 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/query-devtools/src/contexts/PiPContext.tsx (1)

29-29: LGTM! Clean custom error class.

The PipOpenError class correctly extends Error and enables type-safe error handling via instanceof checks.

Optional: Add name property for better error identification in logs
-class PipOpenError extends Error {}
+class PipOpenError extends Error {
+  constructor(message: string) {
+    super(message)
+    this.name = 'PipOpenError'
+  }
+}

This would make the error more identifiable in stack traces, but it's purely cosmetic.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f15b7fc and 300488d.

📒 Files selected for processing (2)
  • .changeset/warm-drinks-itch.md (1 hunks)
  • packages/query-devtools/src/contexts/PiPContext.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/query-devtools/src/contexts/PiPContext.tsx (1)
packages/query-devtools/src/constants.ts (1)
  • PIP_DEFAULT_HEIGHT (13-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (3)
.changeset/warm-drinks-itch.md (1)

1-5: LGTM! Standard changeset format.

The changeset correctly documents this as a patch release with a clear description of the fix.

packages/query-devtools/src/contexts/PiPContext.tsx (2)

61-65: Excellent improvement to error handling.

Throwing PipOpenError instead of a generic Error enables precise downstream error handling. The error message is clear and actionable, guiding users to allow popups.


139-152: Perfect fix for the PiP state inconsistency issue.

The error handling correctly addresses the problem described in the PR:

  • When popup blocking prevents PiP from opening, the persisted pip_open and open flags are reset to false
  • This restores the devtools button visibility, allowing users to retry without the awkward workaround
  • The instanceof check ensures only popup failures are handled gracefully while other errors propagate
  • The early return prevents cascading failures and infinite effect loops

The implementation is clean and the state reset ensures consistency between the persisted state and actual window state.

@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.24%. Comparing base (f15b7fc) to head (300488d).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #9983       +/-   ##
===========================================
- Coverage   45.89%   21.24%   -24.65%     
===========================================
  Files         200       42      -158     
  Lines        8437     2419     -6018     
  Branches     1943      607     -1336     
===========================================
- Hits         3872      514     -3358     
+ Misses       4116     1667     -2449     
+ Partials      449      238      -211     
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (ø)
@tanstack/eslint-plugin-query ∅ <ø> (∅)
@tanstack/query-async-storage-persister ∅ <ø> (∅)
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods ∅ <ø> (∅)
@tanstack/query-core ∅ <ø> (∅)
@tanstack/query-devtools 3.47% <0.00%> (-0.02%) ⬇️
@tanstack/query-persist-client-core ∅ <ø> (∅)
@tanstack/query-sync-storage-persister ∅ <ø> (∅)
@tanstack/query-test-utils ∅ <ø> (∅)
@tanstack/react-query ∅ <ø> (∅)
@tanstack/react-query-devtools 9.25% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client ∅ <ø> (∅)
@tanstack/solid-query ∅ <ø> (∅)
@tanstack/solid-query-devtools 64.17% <ø> (ø)
@tanstack/solid-query-persist-client ∅ <ø> (∅)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query ∅ <ø> (∅)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

SYSTEM_READY >> ...MS