Skip to content

fix(browser): an agent's next command after tab create uses its new tab, not the user's This-device page - #41953

Merged
AmoabaKelvin merged 1 commit into
mainfrom
fix/agent-tab-create-takes-client-selection
Nov 13, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
fix/agent-tab-create-takes-client-selection

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

On a server set to "This device", an agent that opened a new browser tab and then ran its next command (a snapshot, a click) without naming a page got the user's page instead of its own. Now the agent's new tab becomes the one its next command uses, the same way it already worked on Linux servers.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

What Changed

  • Before: on an Electron orca serve, the user has a This-device tab open in a workspace. An agent runs orca tab create --url … and then orca snapshot. The snapshot reads the user's page, and tab current reports the user's page.
  • After: the snapshot and tab current both report the agent's new tab. The user's page stays open and listed.
  • Mechanism: a pageless command goes to the workspace's active This-device page before the server's own tabs (runtime-browser-client-automation.ts). Creating a server tab moved the agent's routing to the new tab but never cleared that This-device selection. publishCreatedBrowserSessionTab already decides when a create takes the agent's routing. It now clears the This-device selection in that same place, for the offscreen (headless serve) and renderer paths. It clears only when the create actually activated the new tab and starts active. It clears before the bridge publishes, so paired clients get the cleared row in the same update.
  • The registry gets one yieldSelection(workspaceId) method. The tab-switch path and orcad's yieldClientPageSelection now use it instead of their own copies.

Why

orcad already takes the selection on create (orcad-client-page-commands.ts, yieldClientPageSelection), and tab switch already does on Electron serve. Only Electron serve's create skipped it. Moving the clear into the publication step, next to the bridge activation it has to follow, keeps the two selections changing together instead of adding a second rule elsewhere.

Not changed:

  • A create with no workspace clears only the global selection, not every workspace's.
  • activate: false creates don't take the selection.
  • Background page-link opens don't take it either.

Linked Issue

Part of #41682: this PR fixes the part where an agent's next command after tab create hits the user's This-device page. The rest of #41682 is not fixed here: invisible agent tabs on Linux servers, popups, large screenshots, streamed dialogs, and input. The follow-up PR places agent tabs on the paired desktop.

Related to #35156. This PR does not change the server-to-desktop tab visibility half; the follow-up PR covers it.

Visual Proof

N/A, there's no UI change. The proof is from a real paired setup: a headless Electron orca serve and a hidden paired desktop on "This device", with commands sent through the server's local socket as an agent (local-cli). The user opens /user as a This-device tab, then the agent runs browser.tabCreate /agent, browser.tabCurrent and a pageless browser.snapshot.

tab current pageless snapshot hit /agent active /user active
main /user the user's page false true
this branch the agent's tab the agent's page true false

Testing

  • I manually tested these changes locally (macOS, paired headless serve plus hidden desktop, before and after, run twice after the fix)
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

One test in orca-runtime-browser.test.ts creates a server tab while a This-device page is active. It checks that the workspace has no active client page afterwards, which is the value pageless routing reads. With the yield reverted, it fails with the user's page still active.

pnpm check:changed passes (the related unit tests ran 27 min under the machine's queue, all green).

Risk

Level: Low

What could change for users: a person who opens a streamed server tab while an agent is using a This-device page now moves the agent's pageless commands to the new tab. That is how a This-device create or switch already behaves, and how orcad already behaves. A hold for a person's pick on client pages, like #36108's for bridge tabs, is separate work. Older paired desktops and phones aren't affected because no wire format changes. A plain revert backs it out.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Cross-platform: main-process logic only, with no platform branches.
  • SSH: the SSH desktop bridge path doesn't use the server's client-page registry, so it's unaffected.
  • Mobile: phones keep their rows. The cleared active flag goes out in the bridge's existing publish.
  • Performance: one pass over the workspace's client pages per create.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…user's This-device page

Pageless agent commands prefer the workspace's active client page, and creating
an offscreen or renderer tab never cleared it, so the next command after
`orca tab create` acted on the user's page. Yield client selection wherever a
create moves the bridge's active tab, as orcad already does.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The runtime browser page registry adds yieldSelection to clear global active-page selection and deactivate pages in an optional workspace. Client-page queries and browser tab switching use this operation. Bridge-tab creation yields selection when the created tab starts active. A test verifies that creating an agent tab selects it and leaves no active client page in the workspace.

Merge Risk: Minimal · up to fc015

This change makes an agent's next command after creating a tab use the new tab instead of the user's This-device page. No concrete merge-blocking risk was identified, and the new test covers the handoff.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: an agent's next pageless browser command after a tab create should use the agent's new tab rather than the user's This-device page. The changeset clears the This-devic…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is thorough and follows the template. It has an ELI5, a What Changed section with before/after and mechanism, a Why section that explains the choice over alternatives, and a Linked Iss…
Full details: Title check

Explanation

The title names the main change: an agent's next pageless browser command after a tab create should use the agent's new tab rather than the user's This-device page. The changeset clears the This-device client-page selection when a create activates a bridge tab, which matches the title. The title uses the fix(browser) convention and is specific, though it is long at 104 characters.

Full details: Description check

Explanation

The description is thorough and follows the template. It has an ELI5, a What Changed section with before/after and mechanism, a Why section that explains the choice over alternatives, and a Linked Issue (Part of #41682, related to #35156). It includes a Visual Proof section with N/A justification plus a before/after table from a manual test, a Testing section with the automated test described, a Risk section with level Low and a revert plan, and the Agent skill boundary checkbox. The Notes and Checklist sections are filled in. Gaps: the Linked Issue line reads "Part of #41682" rather than the template's "Fixes #" form, so the PR does not auto-close an issue. The lint, typecheck, test, and build checklist item is unchecked, and the description does not say whether those commands passed. The AI Disclosure section is blank, which the template allows only for internal maintainers. The author should confirm that no AI disclosure is required.

  • 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4f52740-d6b7-4f85-b6e4-1d497a5fb984
Commits

Reviewing files that changed from the base of the PR and between 7e10540 and fc01512.

Files selected for processing: 5

  • src/main/runtime/browser/client-pages/browser-client-page-queries.ts
  • src/main/runtime/browser/client-pages/orca-runtime-browser.test.ts
  • src/main/runtime/browser/client-pages/runtime-browser-page-registry.ts
  • src/main/runtime/browser/tabs/browser-tab-create-publication.ts
  • src/main/runtime/browser/tabs/browser-tab-queries.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@AmoabaKelvin
AmoabaKelvin merged commit f4d294d into main Nov 13, 2026
53 checks passed
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.

1 participant