feat(cli): add --tab flag for tab-scoped commands#883
Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Open
feat(cli): add --tab flag for tab-scoped commands#883mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Conversation
Add a --tab N global flag that temporarily overrides the active page index for the duration of a single command. This lets users run commands against specific tabs without switching the active tab context. Example: agent-browser --tab 2 screenshot Related: vercel-labs#853 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
… commands - Return error_response when --tab N is out of range instead of silently running against the wrong tab - Skip active page restore after tab_close/tab_new/tab_switch since these commands intentionally change the active tab
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.
Summary
Add a
--tab Nglobal flag that runs a command against a specific tab without switching the active tab. Useful for multi-tab scraping workflows where you need to interact with background tabs without losing your current context.Related: #853
Evidence
Implementation
The
--tabflag is parsed inflags.rsand injected astabIndexinto the command JSON inmain.rs. The daemon'shandle_actioninactions.rstemporarily overrides theactive_page_indexonBrowserManagerfor the duration of the command, then restores the original index afterward. This means all existing handlers work with--tabwithout modification.Files changed
cli/src/flags.rs- parse--tab Nflag, add to clean_args skip listcli/src/main.rs- injecttabIndexinto command JSONcli/src/native/actions.rs- temporarily swap active page index before/after dispatchcli/src/native/browser.rs- addactive_page()andset_active_page()methodscli/src/commands.rs- addtab_indexto test default_flagscli/src/output.rs- add--tabto help textTest plan
cargo fmtpassescargo clippypassescargo testpasses (473 tests, 0 failures)agent-browser --tab 1 urlreturns URL of tab 1 without switching active tabagent-browser --tab 0 screenshottakes screenshot of tab 0This contribution was developed with AI assistance (Claude Code).