Skip to content

Conversation

@shrey150
Copy link
Contributor

@shrey150 shrey150 commented Jan 7, 2026

Summary

Fix support for the "ControlOrMeta" modifier key in keyboard event handling. This key is sent by Google CUA when clearBeforeTyping is enabled for form filling. Without this normalization, users saw unexpected "type A, backspace, then fill" behavior.

Test Plan

  • Unit test verifies "ControlOrMeta" maps to "Meta" on Mac and "Control" on other platforms
  • Browser test confirms ControlOrMeta+A correctly selects all text for replacement

🤖 Generated with Claude Code


Summary by cubic

Fix keyboard modifier normalization by mapping "ControlOrMeta" to Meta on macOS and Control on other platforms. This restores shortcuts like Cmd/Ctrl+A during Google CUA clear-before-typing form filling and prevents the "type A, backspace, then fill" behavior.

Written for commit f1106a9. Summary will update on new commits.

Add support for normalizing the "ControlOrMeta" key string to the appropriate
platform modifier. This key is sent by Google CUA when clearBeforeTyping is
enabled for form filling operations. Without this normalization, the modifier
was not recognized and only the "A" character was typed, causing a "type A,
backspace, then fill" pattern that confused users.

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Jan 7, 2026

🦋 Changeset detected

Latest commit: f1106a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch
@browserbasehq/stagehand-server Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
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.

No issues found across 1 file

🤖 Generated with Claude Code

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR adds support for the "ControlOrMeta" modifier key by normalizing it to "Meta" on macOS and "Control" on other platforms in the normalizeModifierKey method. This fixes keyboard shortcuts like Cmd/Ctrl+A when Google CUA uses clearBeforeTyping for form filling.

Key Changes:

  • Added case "controlormeta": to the switch statement in normalizeModifierKey() method (line 1890)
  • Maps to the same logic as "cmd" and "command" cases - returns "Meta" on macOS, "Control" elsewhere
  • Fixes the issue where Google CUA's type_text_at with clearBeforeTyping sends "ControlOrMeta+A" for select-all operations

Context:
Google CUA client sends "ControlOrMeta" as a modifier key (line 747 in GoogleCUAClient.ts) when clearBeforeTyping is enabled. Without this normalization, the key combination would not be recognized, causing unexpected behavior.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a simple, isolated addition to an existing switch statement that adds support for a cross-platform modifier key. It follows the exact same pattern as existing cases ("cmd" and "command"), maps correctly based on platform detection, and directly addresses the documented issue. The implementation is consistent with the codebase's existing architecture.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/core/lib/v3/understudy/page.ts 5/5 Added "controlormeta" case to normalize modifier key for cross-platform keyboard shortcuts (Mac: Meta, others: Control)

Sequence Diagram

sequenceDiagram
    participant GC as Google CUA Client
    participant Page as Page.keyPress()
    participant NK as normalizeModifierKey()
    participant CDP as Chrome DevTools Protocol
    
    Note over GC: clearBeforeTyping enabled
    GC->>Page: keyPress("ControlOrMeta+A")
    Page->>Page: Split key combination
    Page->>NK: normalizeModifierKey("ControlOrMeta")
    
    alt macOS platform
        NK-->>Page: "Meta"
    else Other platforms
        NK-->>Page: "Control"
    end
    
    Page->>Page: keyDown(modifier)
    Page->>Page: keyDown("A")
    Page->>CDP: Input.dispatchKeyEvent (rawKeyDown)
    Note over CDP: Cmd+A on Mac<br/>Ctrl+A on Windows/Linux
    CDP-->>Page: Text selection executed
    Page->>Page: keyUp("A")
    Page->>Page: keyUp(modifier)
Loading

Copy link
Contributor Author

shrey150 commented Jan 7, 2026

Merge activity

  • Jan 7, 5:37 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jan 7, 5:37 PM UTC: @shrey150 merged this pull request with Graphite.

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.

3 participants