Skip to content

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

Open
BABTUNA wants to merge 1 commit intobrowserbase:mainfrom
BABTUNA:fix-cli-select-multivalue
Open

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

Conversation

@BABTUNA
Copy link
Copy Markdown

@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 browse select so multi-select elements honor all provided values. Bug Fixes Calls page.deepLocator(...).selectOption with a single string for one value, or a string[] for multiple. Adds a regression test for <select multiple> verifying selecting "red" and "blue". Written for commit 0229a82. 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: 0229a82

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.

});

if (hasScreenshot) {
screenshotCount++;
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 19, 2026

Choose a reason for hiding this comment

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

P2: Screenshot pruning enforces maxImages per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/lib/v3/agent/GoogleCUAClient.ts, line 713:

<comment>Screenshot pruning enforces `maxImages` per history entry instead of per actual screenshot, so multi-call turns can retain more images than configured.</comment>

<file context>
@@ -662,6 +673,74 @@ export class GoogleCUAClient extends AgentClient {
+      });
+
+      if (hasScreenshot) {
+        screenshotCount++;
+        if (screenshotCount > this.maxImages) {
+          // Remove inlineData from old screenshots
</file context>
Fix with Cubic

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

whoops that was from a commit that shouldn't have belong to this PR my bad G

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor:awaiting-approval Waiting for a stagehand team member to approve the latest external commit. external-contributor Tracks PRs mirrored from external contributor forks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant