Skip to content

fix(browser): route page-scoped keyboard input through CDP - #13231

Open
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/page-scoped-input
Open

fix(browser): route page-scoped keyboard input through CDP#13231
innocarpe wants to merge 2 commits into
stablyai:mainfrom
innocarpe:fix/page-scoped-input

Conversation

@innocarpe

Copy link
Copy Markdown
Contributor

Description

Browser type and keypress commands now deliver page-scoped input to the requested browser webContents instead of the OS-focused window.
The bridge uses direct CDP input dispatch for targeted pages and reports success only after the target page accepted the command.

Focused fix

  • In scope: honor --page for focus-based browser text and key input, including chunked text insertion.
  • Out of scope (explicit): changing element-scoped fill/insert-text commands or browser focus policy outside a targeted page.

Preserves

  • Commands without a scoped page continue through the existing target-selection contract.
  • Browser page-unavailable and CDP failures remain explicit bridge errors.

Evidence

  • Test: pnpm exec vitest run --config config/vitest.config.ts src/main/browser/agent-browser-bridge.test.ts
  • Regression: tests verify direct target-page CDP calls, large-text chunking, modifier key dispatch, and no OS helper invocation.

User-regression-tradeoffs

  • Direct CDP key definitions cover the supported browser key forms while avoiding OS focus side effects; unsupported multi-character keys retain their explicit CDP representation.

Fixes #12912

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc5967fe-7d5f-4cd0-a14d-ba71e5c9d2d7

📥 Commits

Reviewing files that changed from the base of the PR and between e790637 and 0412a3b.

📒 Files selected for processing (2)
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/browser/agent-browser-bridge.ts

📝 Walkthrough

Walkthrough

The browser bridge now uses direct CDP operations for text input and keypresses. type inserts large text in chunks through the requested page’s debugger and manages debugger leases and errors. keypress resolves special keys, modifiers, digits, letters, and characters, then dispatches key-down and key-up events through the requested page’s debugger. Tests cover page targeting, chunked insertion, key metadata, modifiers, and the absence of agent-browser keyboard calls.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fix and tests, but it omits the required template sections for screenshots, AI review, security audit, and completed testing checks. Add the required template headings and content, including visual-change status, all relevant test results, cross-platform AI review, and security audit findings.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes routing page-scoped keyboard input through CDP, which matches the main change.
Linked Issues check ✅ Passed The changes address issue #12912 by routing targeted type and keypress input through the requested page and reporting explicit delivery failures.
Out of Scope Changes check ✅ Passed The changes remain within the linked issue scope and do not modify element-scoped commands or unrelated browser focus behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ee5e5969-a8ba-49cb-b282-dfbd999c576c

📥 Commits

Reviewing files that changed from the base of the PR and between 6da7b8e and e790637.

📒 Files selected for processing (2)
  • src/main/browser/agent-browser-bridge.test.ts
  • src/main/browser/agent-browser-bridge.ts

Comment thread src/main/browser/agent-browser-bridge.ts Outdated
Comment thread src/main/browser/agent-browser-bridge.ts Outdated
Comment thread src/main/browser/agent-browser-bridge.ts Outdated
@innocarpe
innocarpe force-pushed the fix/page-scoped-input branch from e790637 to 0412a3b Compare August 9, 2026 01:21
@innocarpe

Copy link
Copy Markdown
Contributor Author

Sync update (0412a3be99)

Address review: preserve trailing plus keypresses, add unmodifiedText for modified CDP keyboard events, and translate direct type/keypress debugger attachment failures. Regression: pnpm exec vitest run --config config/vitest.config.ts src/main/browser/agent-browser-bridge.test.ts (114 passed); typecheck: pnpm exec tsc --noEmit -p config/tsconfig.node.json; lint/format: oxlint and oxfmt on agent-browser-bridge files. Commit: 0412a3b.

@AmethystLiang
AmethystLiang requested a review from OrcaWin August 9, 2026 16:52
@AmethystLiang AmethystLiang added the P1 High priority: bug or day-to-day user frustration label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High priority: bug or day-to-day user frustration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: orca type/keypress ignore --page and deliver keystrokes to the focused window, while reporting typed:true

3 participants