Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add option to keep watching inactive tabs#156

Merged
twschiller merged 4 commits into
mainfrom
worktree-moonlit-leaping-cray
Jun 5, 2026
Merged

Add option to keep watching inactive tabs#156
twschiller merged 4 commits into
mainfrom
worktree-moonlit-leaping-cray

Conversation

@twschiller

@twschiller twschiller commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New runOnInactiveTabs option (default off, matching current behavior) controls whether the shared subtree watcher keeps observing while document.hidden is true.
  • Exposed in the Options page with a description explaining the use case: chat copilots, accessibility-tree agents, or sidebar extensions can keep reading a page after the user switches tabs, and a page that mutates while hidden would otherwise reach those consumers unredacted.
  • Wired through the build-time defaults file as a reserved key, mirroring the optionsButton pattern, so operators can flip the baseline.

Test plan

  • subtree-watcher unit tests cover both toggle states (start-up, runtime flip-on while hidden, flip-off while hidden, no-op while visible, route-change sweep while hidden).
  • load-default-overrides tests cover the new reserved key (success + non-boolean rejection).
  • Full jest suite (1361 tests) passes; coverage above ratchet.
  • tsc (app + test configs), biome, eslint, knip all clean.
  • bun run build succeeds; --defaults with {\"runOnInactiveTabs\": true} is recognized.

Rebase notes

Rebased onto origin/main past the #164 shadow-DOM tier (PRs #165#169) and PRs #170#171. Reconciled with #165: the shared per-shadow-root MutationObservers added in #165 now also respect the runOnInactiveTabs setting — detachRouterObserver disconnects shadow observers when the tab pauses, refreshObservation reattaches them, and adoptShadowRoot skips observation on hosts attached while the watcher is paused. The existing shadow-DOM regression tests still pass; the new runOnInactiveTabs tests exercise the body router but the same code paths cover shadows.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 7:14pm

Request Review

@unblocked unblocked Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found.

About Unblocked

Unblocked has been set up to automatically review your team's pull requests to identify genuine bugs and issues.

📖 Documentation — Learn more in our docs.

💬 Ask questions — Mention @unblocked to request a review or summary, or ask follow-up questions.

👍 Give feedback — React to comments with 👍 or 👎 to help us improve.

⚙️ Customize — Adjust settings in your preferences.

Comment thread extension/src/lib/subtree-watcher.ts Outdated
Comment thread extension/build.ts
@twschiller twschiller self-assigned this Jun 5, 2026
@twschiller twschiller added bug Something isn't working enhancement New feature or request labels Jun 5, 2026
@twschiller twschiller force-pushed the worktree-moonlit-leaping-cray branch from ab70591 to c6ed5fa Compare June 5, 2026 14:38
@twschiller twschiller force-pushed the worktree-moonlit-leaping-cray branch from c6ed5fa to 774903f Compare June 5, 2026 17:32
The subtree watcher disconnects on visibilitychange to skip work the user
can't see. That's unsafe when something else still reads the page — a chat
copilot, accessibility-tree agent, or sidebar extension can consume content
from an inactive tab, and a page that mutates while hidden (lazy widgets,
periodic refreshes, late prompt-injection payloads) would otherwise reach
those consumers unredacted. Expose a user-controlled toggle (default off,
matching current behavior) and a build-time override key for operators.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- Route-change body sweep falls back to setTimeout when scheduled while
  document.hidden is true. Chromium pauses requestAnimationFrame entirely
  in background tabs, so the safety-net sweep for runOnInactiveTabs=true
  would never fire — pointed out by unblocked[bot]. Added a regression
  test that spies on the schedulers directly (Jest's fake rAF does not
  simulate the pause).
- Document the runOnInactiveTabs reserved key in SKILL.md and install.md
  alongside the existing optionsButton entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Chrome documents rAF as paused for background tabs, but exemptions
(audible audio, WebRTC, devtools attached) keep it firing in many
real-world cases. The setTimeout fallback is still the right defensive
choice for the runOnInactive safety-net sweep — operators flipping
that flag should not depend on those exemptions being present — but
the inline comments should not claim rAF is "entirely paused."

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@twschiller twschiller merged commit 204a038 into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the worktree-moonlit-leaping-cray branch June 5, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant