Skip to content

fix(daemon): create implicit tabs in the background - #243

Open
lujiawu wants to merge 1 commit into
epiral:mainfrom
lujiawu:fix/background-tab-creation
Open

lujiawu wants to merge 1 commit into
epiral:mainfrom
lujiawu:fix/background-tab-creation

Conversation

@lujiawu

@lujiawu lujiawu commented Nov 9, 2026

Copy link
Copy Markdown

open and tab new already pass background: true to Target.createTarget, but the two paths that create a tab implicitly did not:

  • packages/daemon/src/site-adapter.ts — adapter fallback when no tab matches the site domain
  • packages/daemon/src/command-dispatch.ts — eval --domain resolution fallback

On a real desktop Chrome those calls switch the tab the user is looking at. An agent driving the user's own browser should not steal focus just to collect data.

Change

Pass background: true in both places.

Verification (Chrome 157, real user profile, visibility probe before/after)

call new page visibility rAF steals user's tab
Target.createTarget {url} visible runs yes
Target.createTarget {url, background:true} hidden paused no
Target.createTarget {url, newWindow:true, background:true} visible runs no (new window not focused)

eval, DOM reads, images and lazy loading still work in a background tab; only rAF-driven rendering is paused. Pages that need foreground rendering semantics should be opened with newWindow: true, background: true instead of being switched to the foreground.

Tests

  • pnpm test: daemon 106 passed / 0 failed (13 skipped — no Chrome on port 19222), cli 24 passed / 0 failed.
  • tsc --noEmit for packages/daemon: 8 pre-existing errors both before and after this change; none added.

`open` and `tab new` already pass `background: true` to
Target.createTarget, but the two paths that create a tab implicitly --
the site-adapter fallback and `eval --domain` resolution -- did not. On a
real desktop Chrome that means an adapter run yanks the tab the user is
looking at, which is exactly what an agent driving the user's own browser
must not do.

Pass `background: true` in both places.

Verified on Chrome 157 with a visibility probe: with background:true the
new page reports visibilityState=hidden and keeps the user's visible tab
focused, while eval / DOM / images / lazy loading still work. Request
animation frames are paused in background tabs, so pages that depend on
rAF to render need a separate unfocused window (newWindow:true +
background:true) rather than a foreground switch.

Typecheck: 8 pre-existing errors before and after this change, none added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants