You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(browser): keep an agent on its own tab when the user picks or opens another - #36108
When an agent was using a browser tab and you opened or clicked another tab in the same workspace, the agent's next step went to your tab and took it over. Now the agent stays on its own tab while it works, and your tab is left alone.
What Changed
Before: the agent was on tab A. The user opened tab B with "+" (in any tab group of that workspace), and the agent's next goto, click or snapshot ran in tab B. A user reported the workspace as unusable while an agent ran.
After: the agent keeps working in tab A. Once tab A has had no agent command for the activity window (the same ~20 s that drives "An agent is using this page"), the user's last pick applies again, so a new "look at this page" request still starts from the tab the user has open.
Mechanism: commands without --page run on the bridge's active tab for the worktree. browser:activeTabChanged set that tab on every user select or create. Now a person's pick (that IPC, or a tab created over RPC by a paired phone or desktop) is held instead of applied while an agent is driving the current tab. The agent's own tab create and tab switch still move it right away.
The browser skill reference also tells agents to always pass --page <browserPageId>, taken from tab current or tab create, so agents that follow it never depend on the active tab at all.
Why
The bridge is where the wrong fact lived. It treated "the tab the user last selected" as "the tab the agent is working on". The skill change alone wouldn't fix it, because any agent that skips --page would still follow the user. Pinning per agent caller would need every caller to send its identity, including paired and remote ones. Reusing the existing agent-activity state fixes it without that.
Limitation: an agent that pauses longer than the activity window between unpinned steps can still follow a newer user pick. The --page skill rule covers that case.
Linked Issue
No GitHub issue. This came from a user's P0 report with a screen recording.
Visual Proof
N/A: nothing in the UI changed. These are real runs against a hidden dev build, driving the agent side with the orca CLI and opening the second tab the way the "+" button does.
Before (main):
--- agent step 1 (unpinned goto)
tab 0 ACTIVE https://example.com/?agent-step-1
--- user opens a new tab
tab 2 ACTIVE data:text/html,
--- agent step 2 (unpinned goto)
tab 2 ACTIVE https://example.com/?agent-step-2 <- landed in the user's new tab
After (this branch):
--- agent step 1 (unpinned)
tab 0 ACTIVE https://example.com/?fix-step-1
--- user opens a new tab
tab 1 data:text/html,
--- agent step 2 (unpinned)
tab 0 ACTIVE https://example.com/?fix-step-2 <- stays on the agent's tab
--- agent idle 22s, then a new unpinned command
tab 1 ACTIVE https://example.com/?fix-step-3 <- follows the user's pick again
--- agent tab create, then unpinned goto
tab 2 ACTIVE https://example.com/?fix-step-4 <- agent's own new tab
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
On macOS, a hidden dev build with the dev CLI ran the sequence above. New routing tests cover a user pick being held and then applied, and a tab created by a phone versus by an agent. Both fail with the hold removed.
AI Disclosure
Review
The hold lives in selectForPerson and applyHeldPersonSelections in agent-browser-bridge-tabs.ts. setActiveTab uses the RPC caller to tell an agent's tab create from a person's.
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
Only main-process routing changed, so there's no platform code. Remote CLI agents use the same bridge on the host. Phones are paired-device callers, so a tab created on a phone no longer pulls an agent off its tab. There's no wire or contract change.
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)
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)
The reason will be displayed to describe this comment to others. Learn more.
Switched tabs remain unprotected
After an agent switches from tab A to tab B, a user pick can still redirect its next command without --page. tabSwitch queues through enqueueCommand, so beginAgentCommand marks A, not B. pointAgentAt then routes commands to B without marking B as agent-used.
If the user selects C before the next agent command, selectForPerson sees B as idle and immediately routes to C. The agent's next navigation or click then runs on the user's tab. Keep B marked as agent-used after the switch so user picks are held during this gap.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b5efcde. The agent's tab switch or tab create now marks the new tab as agent-used right away, so a pick made before its next command is held too. Covered by the new routing test, and checked live: agent switches to tab 1, the user opens a tab at once, and the next unpinned goto stays on tab 1.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Tab routing now distinguishes agent RPC selections from person selections. Person selections are held while an agent uses the current page and applied when it becomes idle, if the selected tab still exists. Routing updates the global selection and, when provided, the worktree selection. Browser guides show how to obtain and pass a browserPageId to page commands, explain page-targeting defaults, and update stale-reference recovery examples.
Priority: Normal
Merge Risk: Low · previous review 4dd72
The new browser guidance can produce argument errors for certain commands; correcting the documented command scope is localized.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the primary browser-tab routing fix.
Description check
The description is detailed and covers the user impact, mechanism, rationale, limitation, testing, compatibility considerations, and checklist. The Linked Issue section states that no GitHub issue exi…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is detailed and covers the user impact, mechanism, rationale, limitation, testing, compatibility considerations, and checklist. The Linked Issue section states that no GitHub issue exists, but the rest of the required template is substantially complete.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 9 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
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.
⚠️Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Keep a pending person selection when the agent switches tabs.
If a person selects tab B while the agent uses tab A, selectForPerson holds B. If the agent then creates or switches to tab C, pointAgentAt deletes B. After C becomes idle, unpinned commands still target C; the person's selection never takes effect. Route the agent to C immediately, but retain the pending person selection until it can apply or a later person selection replaces it. (raw.githubusercontent.com)
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: 8dcc5e9e-3f12-4bc2-8751-a0aa452cbcfa
Commits
Reviewing files that changed from the base of the PR and between c351825 and 71abcb4.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
On CodeRabbit's unverified note (held pick dropped when the agent switches tabs): fixed in b5efcde. The agent's switch no longer clears a held pick. Its new tab is marked as agent-used, so the pick waits until that tab goes idle and then applies. Covered by the new routing test.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
…ns another
Unpinned agent commands followed the user's UI tab selection, so opening a
new tab pulled the running agent into it. A person's pick now waits until
the agent's tab goes idle, and the browser skill tells agents to always
pass --page.
…s through it
An agent's tab switch or create now marks the new tab as agent-used, so a
user pick before its next command is held too. A held pick survives the
agent's switch and follows a process swap. The browser guide pins --page in
every example and describes where unpinned commands go.
Pass the page ID to the stale-reference recovery snapshot.
The recovery line omits --page, while the same guide says to always pass it. After the 20-second idle window, the unpinned snapshot can capture the user's tab. Refs are scoped per tab, so a retry on the original tab can use refs from the wrong snapshot. Keep the original page ID on the recovery snapshot and on the retry.
Also generate the bundled guide with pnpm run generate:bundled-skill-guides. pnpm run verify:bundled-skill-guides only checks for drift.
🐛 Suggested fix
-- `browser_stale_ref`: run `ORCA snapshot --json` and retry with fresh refs.+- `browser_stale_ref`: run `ORCA snapshot --page <browserPageId> --json` and retry with fresh refs on the same `--page`.
Apply the change in skill-guides/orca-cli/references/browser.md, then run pnpm run generate:bundled-skill-guides.
Minor · Pass the page ID to both recovery commands. · browser.md:55
When the pinned fill or type fails, the fallback omits --page. Orca then resolves each command through the worktree's current tab. After the agent tab becomes idle, that tab can be the user's selected tab. inserttext can therefore insert text into the user's focused field.
Suggested fix
-- If `fill` or `type` fails on a custom input, try `ORCA focus --element @e1 --json` then `ORCA inserttext --text "text" --json`.+- If `fill` or `type` fails on a custom input, try `ORCA focus --page <browserPageId> --element @e1 --json` then `ORCA inserttext --page <browserPageId> --text "text" --json`.
Minor · Pass --page to the exec fallback. · browser.md:55
exec accepts and forwards --page. Without it, the bridge resolves the worktree's active tab. After the 20-second activity window, that tab can be the user's selected tab, so the fallback can run an unlisted browser action on the wrong page.
Suggested fix
-- Anything not listed above goes through `ORCA exec --command "<agent-browser command>"`.+- Anything not listed above goes through `ORCA exec --page <browserPageId> --command "<agent-browser command>"`.
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: b4a82d80-2dd4-42cb-bb01-b059598a5274
Commits
Reviewing files that changed from the base of the PR and between b5efcde and 3be435a.
Files selected for processing: 1
src/cli/bundled-skill-guides.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…guidance
Recovery and exec fallbacks now carry --page, the JSON paths include the result
envelope, and the guide says tab current reports the agent's tab while it is
busy, that tab list/current/create take no --page, and that --page is not
worktree-scoped without --worktree.
The three outside-diff findings from the last CodeRabbit review are fixed in f198a2f. The browser_stale_ref snapshot, the focus/inserttext fallback and the exec fallback all carry --page <browserPageId> now.
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Distinguish the routed tab from an explicitly targeted page.
An agent can operate on page B with --page while page A remains current. In that case, tab current reports A, not the page the agent is using. Clarify that the agent must retain B’s ID rather than recover it from tab current. Update the bundled guide too. (raw.githubusercontent.com)
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: 7cfdab24-6720-4c42-81c3-32481e29caec
Commits
Reviewing files that changed from the base of the PR and between 3be435a and f198a2f.
Files selected for processing: 2
skill-guides/orca-cli/references/browser.md
src/cli/bundled-skill-guides.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Both commands let --page override --index, so pinning them closed or switched to
the agent's own tab. The guide also says to keep the pinned ID for the task,
since tab current shows the routed tab.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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: ad50f684-bed1-4567-8f34-a1d851b10d0e
Commits
Reviewing files that changed from the base of the PR and between f198a2f and 4dd7225.
Files selected for processing: 2
skill-guides/orca-cli/references/browser.md
src/cli/bundled-skill-guides.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When an agent was using a browser tab and you opened or clicked another tab in the same workspace, the agent's next step went to your tab and took it over. Now the agent stays on its own tab while it works, and your tab is left alone.
What Changed
Before: the agent was on tab A. The user opened tab B with "+" (in any tab group of that workspace), and the agent's next
goto,clickorsnapshotran in tab B. A user reported the workspace as unusable while an agent ran.After: the agent keeps working in tab A. Once tab A has had no agent command for the activity window (the same ~20 s that drives "An agent is using this page"), the user's last pick applies again, so a new "look at this page" request still starts from the tab the user has open.
Mechanism: commands without
--pagerun on the bridge's active tab for the worktree.browser:activeTabChangedset that tab on every user select or create. Now a person's pick (that IPC, or a tab created over RPC by a paired phone or desktop) is held instead of applied while an agent is driving the current tab. The agent's owntab createandtab switchstill move it right away.The browser skill reference also tells agents to always pass
--page <browserPageId>, taken fromtab currentortab create, so agents that follow it never depend on the active tab at all.Why
The bridge is where the wrong fact lived. It treated "the tab the user last selected" as "the tab the agent is working on". The skill change alone wouldn't fix it, because any agent that skips
--pagewould still follow the user. Pinning per agent caller would need every caller to send its identity, including paired and remote ones. Reusing the existing agent-activity state fixes it without that.Limitation: an agent that pauses longer than the activity window between unpinned steps can still follow a newer user pick. The
--pageskill rule covers that case.Linked Issue
No GitHub issue. This came from a user's P0 report with a screen recording.
Visual Proof
N/A: nothing in the UI changed. These are real runs against a hidden dev build, driving the agent side with the
orcaCLI and opening the second tab the way the "+" button does.Before (main):
After (this branch):
Testing
On macOS, a hidden dev build with the dev CLI ran the sequence above. New routing tests cover a user pick being held and then applied, and a tab created by a phone versus by an agent. Both fail with the hold removed.
AI Disclosure
Review
The hold lives in
selectForPersonandapplyHeldPersonSelectionsinagent-browser-bridge-tabs.ts.setActiveTabuses the RPC caller to tell an agent's tab create from a person's.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Only main-process routing changed, so there's no platform code. Remote CLI agents use the same bridge on the host. Phones are paired-device callers, so a tab created on a phone no longer pulls an agent off its tab. There's no wire or contract change.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)