Consistent Tab IDs & Global Tag Targeting#892
Open
DJRHails wants to merge 7 commits intovercel-labs:mainfrom
Open
Consistent Tab IDs & Global Tag Targeting#892DJRHails wants to merge 7 commits intovercel-labs:mainfrom
DJRHails wants to merge 7 commits intovercel-labs:mainfrom
Conversation
Contributor
|
@DJRHails is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Author
ad6eaca to
654c33c
Compare
patch-stack-bot bot
pushed a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 17, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
9d2cff6 to
ceb7451
Compare
ceb7451 to
29b2ee1
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 18, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
Contributor
29b2ee1 to
ceb7451
Compare
ceb7451 to
656ff18
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 18, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
656ff18 to
b251966
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 19, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
b251966 to
a10a668
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 20, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
915231e to
e909a8e
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 22, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
Contributor
Replace positional indices with stable integer tab IDs throughout the browser tab management system. Tab IDs are monotonically increasing (starting at 1) and persist across tab open/close operations, making them reliable identifiers for AI agents. Changes: - browser.rs: Add tab_id field to PageInfo, next_tab_id counter to BrowserManager, tab_switch_by_id/tab_close_by_id methods - actions.rs: Read tabId instead of index for tab_switch/tab_close, assign tab IDs in window_new and target-created event handlers - commands.rs: Emit tabId instead of index in tab switch/close commands - flags.rs: Add --tab <id> flag to Config and Flags structs - main.rs: Inject tabId from --tab flag into commands - output.rs: Display tab IDs in list/new/close output, add --tab to all command help Global Options sections
Add pre-dispatch tab switch in execute_command so any command with a tabId field (injected by --tab CLI flag) runs against the specified tab. Previously only tab_switch and tab_close honoured tabId. Add e2e tests for tab ID non-reuse after close and global targeting.
`tab select 3` and other unknown subcommands silently fell through to `tab_list`, making it appear the tab switch succeeded when it didn't. Now errors with valid subcommand suggestions, matching the pattern used by `window` and other commands. Bare `tab` (no args) still defaults to `tab_list`.
Tests snapshot returns correct content when targeting a specific tab via tabId, including non-contiguous tab IDs after closing a tab.
The condition `data.get("tabId").is_some()` matched any response
containing tabId, including tab_switch. Now only checks for
`data.get("closed").is_some()` and adds a dedicated tab_switch
output handler showing "Switched to tab [id] (url)".
e909a8e to
58b773d
Compare
patch-stack-bot bot
added a commit
to DJRHails/agent-browser
that referenced
this pull request
Mar 23, 2026
Patch-Stack-Branch: patch/tab-targeting Upstream PR: vercel-labs#892
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
--tab <id>so page-scoped commands can target a tab directly--tabrouting so commands restore the previous active tab when they temporarily target a different tabMotivation
Shared-browser CDP workflows break down when tabs are addressed by positional index because unrelated tab churn changes what a given index points to.
Example:
$ agent-browser tab list [0] App - https://app.example.com [1] Docs - https://docs.example.com → [2] Google - https://www.google.com/ # Another workflow closes a different tab $ agent-browser tab close 1 ✓ Tab 1 closed $ agent-browser tab list [0] App - https://app.example.com → [1] Google - https://www.google.com/ (should be [2])Or another page opens a popup/new tab:
$ agent-browser tab list → [0] App - https://app.example.com [1] Google - https://www.google.com/ # Another workflow opens a popup (you expect it at tab 11) $ agent-browser tab list [0] App - https://app.example.com [1] Google - https://www.google.com/ [2] Popup - https://accounts.example.com/With tab IDs, existing tabs keep the same identifier even when other tabs are closed or popups appear, so agents can continue targeting the same tab across commands.
Testing
pnpm exec vitest run src/browser.test.ts src/protocol.test.ts src/daemon.test.tspnpm exec tsc --noEmitcargo test --manifest-path cli/Cargo.toml tab_cargo test --manifest-path cli/Cargo.toml parse_tab_flagcargo test --manifest-path cli/Cargo.toml clean_args_removes_tab_flag