Skip to content

fix(browser): agent bringToFront and activateTarget no longer take your keyboard (1/3) - #28452

Merged
nwparker merged 1 commit into
mainfrom
nwparker/agent-browser-focus-1-cdp
Oct 14, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/agent-browser-focus-1-cdp

Conversation

@nwparker

@nwparker nwparker commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​96 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92

ELI5

When an agent drives Orca's browser, some of its commands could pull your keyboard away from the terminal you were typing in. This first step stops two of them, "bring this page to the front" and "activate this page", from touching your keyboard at all. It also adds a short design doc for the whole fix.

What Changed

  • Before: an agent (through the bundled browser helper) sending Page.bringToFront made Orca call webContents.focus() on the page, so your typing jumped into the browser. Target.activateTarget was passed straight through to the page.
  • After: the CDP proxy answers both commands with success and does nothing else. A page never needs native focus to receive agent input, so nothing an agent does depends on these focusing it.
  • Adds docs/reference/agent-browser-focus-isolation.md. It records what Chromium actually does with each kind of input on a <webview> page (measured in a hidden Electron window) and the plan for the two follow-up PRs.

This is PR 1 of 3. The next two handle keys and text, then clicks.

Why

These two commands exist only to raise a page, and raising it is exactly the side effect the issue reports. Making them do nothing is the smallest safe change, and the design doc explains why the rest of the fix routes input differently instead of focusing pages.

Linked Issue

Part of #20595 (the last PR in the stack closes it). Related: #16674.

Visual Proof

N/A. Focus routing only, with no visible UI change. The stack's end-to-end spec (PR 2 and 3) checks the terminal keeps focus.

Testing

  • pnpm tc, browser and main-process unit suites, and the changed-code quality gate pass.

  • New unit tests: both commands return {} without focusing or forwarding.

  • Platforms: macOS (hidden-window Electron runs). The change has no platform branches.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new surface.
  • Cross-platform: no platform-specific code.
  • SSH / remote: pages hosted on a paired client run the same proxy code, so they get the same behaviour.
  • Backwards compatibility: agents that sent bringToFront to make typing work never needed it to land input.
  • Performance: none.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker
nwparker force-pushed the nwparker/agent-browser-focus-1-cdp branch from 2e5560e to 7bef672 Compare October 14, 2026 04:48
@nwparker
nwparker marked this pull request as ready for review October 14, 2026 04:49
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45f28fe1-c810-4448-b8b0-802764de4bfe
📥 Commits

Reviewing files that changed from the base of the PR and between 33352e2 and e31a7fa.

📒 Files selected for processing: 4
  • docs/reference/agent-browser-focus-isolation.md
  • src/main/browser/cdp-ws-proxy-focus-replay.test.ts
  • src/main/browser/cdp-ws-proxy.test.ts
  • src/main/browser/cdp-ws-proxy.ts
📝 Walkthrough

The documentation describes agent browser focus isolation, measured webview input behavior, CDP focus requirements, and known limitations. The proxy now returns an empty result for Page.bringToFront and Target.activateTarget without focusing the guest. Tests verify the responses and focus behavior.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 791ac

The new focus-isolation guidance overstates current behavior: Input.insertText can request native focus, and user keystrokes may reach a page during a press. Clarify these exceptions before relying on the guidance.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: preventing agent browser commands from taking keyboard focus.
Description check Passed The description covers the required sections, explains the user impact and implementation, links related issues, documents testing and platform considerations, and marks visual proof as not applicable…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nwparker
nwparker force-pushed the nwparker/agent-browser-focus-1-cdp branch from 7bef672 to 791acf2 Compare October 14, 2026 05:58

@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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59de1128-44f0-4c75-86ca-460534a4c23a
📥 Commits

Reviewing files that changed from the base of the PR and between 7bef672 and 791acf2.

📒 Files selected for processing: 1
  • docs/reference/agent-browser-focus-isolation.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

…e user's focus

Adds docs/reference/agent-browser-focus-isolation.md: measured input routing for
<webview> guests and the plan for #20595.
@nwparker
nwparker force-pushed the nwparker/agent-browser-focus-1-cdp branch from 33352e2 to e31a7fa Compare October 14, 2026 06:50
@nwparker
nwparker merged commit b5c568e into main Oct 14, 2026
30 checks passed
@nwparker
nwparker deleted the nwparker/agent-browser-focus-1-cdp branch October 14, 2026 09:40
brennanb2025 pushed a commit that referenced this pull request Oct 15, 2026
…e user's focus (#28452)

Adds docs/reference/agent-browser-focus-isolation.md: measured input routing for
<webview> guests and the plan for #20595.

(cherry picked from commit b5c568e)
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.

1 participant