Skip to content

feat: support explicit page targets for browser actions - #28

Merged
254808127 merged 3 commits into
mainfrom
feat/page-target-selection
Sep 15, 2026
Merged

254808127 merged 3 commits into
mainfrom
feat/page-target-selection

Conversation

@254808127

@254808127 254808127 commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add explicit page selection for multi-tab browser sessions:

  • All 10 action subcommands accept optional --target-id, before or after the action subcommand.
  • SDK callers can use Cdp::connect_to_target(ws_url, page_id).
  • Missing/closed or non-page targets fail without selecting another page or creating a blank page. Attachment races propagate the CDP error.
  • Document how an agent discovers a popup through existing session targets, selects its page ID, and uses it on subsequent commands.

This is an additive capability: the existing default selects the first page and cannot promise to follow a newly opened tab. Explicit target selection makes that choice independent of target enumeration order.

Example

browser-cli session targets --session-id SESSION_ID
browser-cli action snapshot --session-id SESSION_ID --target-id PAGE_ID
browser-cli action click --session-id SESSION_ID --target-id PAGE_ID --selector '#search'
# Re-list and choose the result page if the click opens a new tab.
browser-cli session targets --session-id SESSION_ID
browser-cli action snapshot --session-id SESSION_ID --target-id RESULT_PAGE_ID

Compatibility and scope

  • Without the flag, existing behavior and action JSON output shapes remain unchanged.
  • No implicit popup switching, persisted active-page state, click-semantics change, new dependency, or authentication change.
  • Prepare version 1.2.0 in Cargo.toml, the root Cargo.lock package entry, and both platform bootstrap pins. No dependencies or installer behavior change beyond the pin.
  • Skill instructions still check the actual binary's action --help; published 1.1.15 does not support the feature. Updating a Skill does not replace its existing executable. The pinned 1.2.0 assets must be published before installation/upgrade can succeed.
  • No tag or release is created by this PR update. Publication remains a separate step with matching versioned assets and Skill package.
  • No test-machine deployment or cloud/Harness evaluation results are included.

Local verification

Verified on Windows with isolated loopback HTTP/CDP fixtures and a separate headless Chromium profile:

  • cargo fmt --all -- --check
  • cargo test --all-targets --locked --offline — 27 passed; optional browser test ignored in the default suite.
  • cargo clippy --all-targets --locked --offline -- -D warnings
  • cargo test --doc --locked --offline
  • cargo test --locked --offline --test page_targets_browser -- --ignored --nocapture with BROWSER_CLI_TEST_CHROME — 1 passed, HeadlessChrome 145.0.7632.6 / CDP 1.3.
  • Skill frontmatter/reference validation, shell syntax, and whitespace checks.
  • Rebuilt CLI reports 1.2.0, its action --help exposes --target-id, and Cargo/lock/both bootstrap versions agree. Dependency entries and the remaining installer logic are unchanged.
  • 19 Windows PowerShell 5.1 bootstrap-selection regressions pass after synchronizing the merged CI fix.

Tests cover all action routes, reversed target order, invalid targets, target closure between listing/attachment, legacy defaults, output/file invariants, actual popup discovery, three independent CLI reconnects, unrelated tab lifecycle, result-page mutation, and closed-target failure without touching the source page.

macOS/Linux runtime and real cloud/WorkBuddy end-to-end behavior have not been locally verified. Existing CI can run the platform/build checks; this PR does not release the feature.

Self-review before this update

The implementer reviewed the complete feature diff and the version-update increment
before pushing: all action routes, default compatibility, missing/non-page/closed
targets, attachment races, fixture isolation, package/lock/pin consistency, and
release-versus-installation guidance. No blocking findings remain. Existing
capability checks are preserved, and the documentation explicitly distinguishes
Skill updates from executable upgrades and source merges from published assets.
This is self-review, not a claim of independent approval or cloud/Harness validation.

CI baseline

This branch now includes main's separately reviewed fix #29. The earlier
bootstrap failure
was caused by blindly selecting a missing historical release, not the page-target
feature. The CI workflow and selector match the updated main; no checks are skipped.

The bootstrap smoke test checks the newest usable already-published COS release,
while Rust tests/builds exercise this branch's 1.2.0 source. A green bootstrap check
does not claim that 1.2.0 has been published. The current results are shown in the
PR checks; publication and test-machine upgrades are outside this update.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T11:26:31.135564Z a1dc32f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change spans CLI, SDK, browser behavior, tests, and documentation and warrants final human review.

Pull request overview

Adds explicit page-target selection for browser actions and SDK callers while preserving existing default behavior.

Changes:

  • Adds --target-id support to action commands.
  • Adds strict target attachment and validation.
  • Adds protocol, CLI, browser, and documentation coverage.
File summaries
File Description
tests/support/mod.rs Shared isolated CLI test support
tests/page_targets.rs Deterministic target-selection tests
tests/page_targets_browser.rs Browser popup and lifecycle tests
src/main.rs CLI parsing and action routing
src/cdp.rs Target validation and attachment
skills/lexmount-browser/SKILL.md Multi-tab workflow guidance
skills/lexmount-browser/references/troubleshooting.md Target troubleshooting guidance
skills/lexmount-browser/references/commands.md Command reference updates
README.md User-facing documentation
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@254808127
254808127 merged commit b44aa63 into main Sep 15, 2026
4 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.

2 participants