Skip to content

fix(cli): support multi-value selection in browse select#2012

Closed
BABTUNA wants to merge 2 commits intobrowserbase:mainfrom
BABTUNA:fix-cli-select-multivalue
Closed

fix(cli): support multi-value selection in browse select#2012
BABTUNA wants to merge 2 commits intobrowserbase:mainfrom
BABTUNA:fix-cli-select-multivalue

Conversation

@BABTUNA
Copy link
Copy Markdown
Contributor

@BABTUNA BABTUNA commented Apr 19, 2026

Summary

  • Fix browse select to honor all provided values instead of only the first
    one.
  • Add a regression test covering multi-select behavior.

Problem

browse select accepts variadic values (<values...>), but implementation
only forwarded values[0], so multi-select usage was broken :{.

Changes

  • Updated CLI select execution to call deepLocator(...).selectOption(...)
    with:
    • a single string for one value
    • a string array for multiple values
  • Added a CLI test that:
    • opens a page with a runs browse select select red blue verifies both values are selected Files Changed packages/cli/src/index.ts packages/cli/tests/cli.test.ts Validation Prettier check passed on touched files. CLI build passed. Summary by cubic Fixes multi-value selection across the CLI and core so multi-select dropdowns honor all provided values. browse select and the deterministic dropdown action now select all specified options. Bug Fixes CLI: Call page.deepLocator(...).selectOption with a single string or string[], and return the selected values. Core: Support multi-select in selectOptionFromDropdown by forwarding all args to locator.selectOption; adds CLI and core tests verifying multi-select (e.g., "red" and "blue"). Written for commit 1271e2d. Summary will update on new commits. Review in cubic

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 19, 2026

⚠️ No Changeset found

Latest commit: 1271e2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run.
Approving the latest commit mirrors it into an internal PR owned by the approver.
If new commits are pushed later, the internal PR stays open but is marked stale until someone approves the latest external commit and refreshes it.

@github-actions github-actions Bot added external-contributor Tracks PRs mirrored from external contributor forks. external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Apr 19, 2026
@BABTUNA BABTUNA force-pushed the fix-cli-select-multivalue branch from 2cfc3b0 to 0229a82 Compare April 19, 2026 05:16
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Confidence score: 3/5

  • There is a concrete medium-severity bug in packages/core/lib/v3/agent/GoogleCUAClient.ts: screenshot pruning applies maxImages per history entry rather than per screenshot, so limits can be exceeded in multi-call turns.
  • Given the high confidence (9/10) and user-visible behavior drift from configured image caps, this introduces some regression risk and keeps this in the “some risk” range rather than a safe low-risk merge.
  • Pay close attention to packages/core/lib/v3/agent/GoogleCUAClient.ts - pruning logic may retain more screenshots than configured when a turn includes multiple calls.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/lib/v3/agent/GoogleCUAClient.ts">

<violation number="1" location="packages/core/lib/v3/agent/GoogleCUAClient.ts:713">
P2: Screenshot pruning enforces `maxImages` per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant User as CLI / Consumer
    participant Agent as GoogleCUAClient (Agent)
    participant Hist as Session History (In-Memory)
    participant Page as Browser Page (Playwright)
    participant LLM as Gemini API

    Note over User,Page: NEW: Multi-Select Flow (CLI)
    User->>Page: browse select <selector> <val1> <val2>
    Page->>Page: resolveSelector()
    Page->>Page: NEW: deepLocator(selector)
    alt Multiple values provided
        Page->>Page: CHANGED: selectOption(["val1", "val2"])
    else Single value provided
        Page->>Page: CHANGED: selectOption("val1")
    end
    Page-->>User: Return selected values

    Note over Agent,LLM: NEW: Agent History Pruning Flow (Memory Management)
    Agent->>LLM: generateContent(history)
    LLM-->>Agent: Function Call (e.g., screenshot)
    Agent->>Page: Execute tool
    Page-->>Agent: Tool Result (includes inlineData/Image)
    Agent->>Hist: Append Tool Result to history
    
    rect rgb(240, 240, 240)
    Note over Agent,Hist: NEW: maybeRemoveOldScreenshots()
    Agent->>Hist: Count entries with screenshots
    opt Screenshot count > maxImages (Default: 3)
        loop Older History entries
            Agent->>Hist: NEW: Strip 'inlineData' (images)
            Note right of Hist: Preserves metadata but frees memory
        end
        Agent->>User: Log pruning event (Level 2)
    end
    end

    Agent->>LLM: Next turn with pruned history
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

Comment thread packages/core/lib/v3/agent/GoogleCUAClient.ts Outdated
@pirate
Copy link
Copy Markdown
Member

pirate commented Apr 21, 2026

@seanmcguire12 was there a historic reason we only support single selections here?

@seanmcguire12
Copy link
Copy Markdown
Member

@pirate no reason that i can recall.

@BABTUNA this is looking solid! can we add an e2e test or eval to see how act() behaves with multi select here?

@BABTUNA
Copy link
Copy Markdown
Contributor Author

BABTUNA commented Apr 22, 2026

@seanmcguire12 yes sir
image

@BABTUNA
Copy link
Copy Markdown
Contributor Author

BABTUNA commented Apr 23, 2026

@pirate @seanmcguire12 test added

@github-actions github-actions Bot added external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. and removed external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. labels Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR was approved by @pirate and mirrored to #2033. All further discussion should happen on that PR.

@github-actions github-actions Bot closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:mirrored An internal mirrored PR currently exists for this external contributor PR. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants