Skip to content

fix(browser): forward editing and navigation keys through the remote keyboard - #22

Merged
devswha merged 1 commit into
mainfrom
fix/browser-panel-keys
Sep 4, 2026
Merged

fix(browser): forward editing and navigation keys through the remote keyboard#22
devswha merged 1 commit into
mainfrom
fix/browser-panel-keys

Conversation

@devswha

@devswha devswha commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Closes #20.

What broke

Printable characters worked in the Browser panel's remote inputs, but Backspace/arrows/Home/End/Tab and modifier combinations did nothing. Two causes:

  1. Key bridgebrowser-sidecar.ts dispatched raw CDP Input.dispatchKeyEvent with only { type, key, code, modifiers }. Without windowsVirtualKeyCode/nativeVirtualKeyCode, Chromium delivers a DOM key event but never runs its default editing command.
  2. Focus — keyboard handlers live on the tabIndex=0 surface, but pointer events target the child <img>, which never focused the surface. Keys could keep going to the address bar or chat input after clicking into the page.

Fix

  • Recognized keys (editing/navigation keys, modifiers, F1–F12, printable) now go through Puppeteer's page.keyboard.down/up — the same path the automation commands already use — via a pure, unit-tested toPuppeteerKeyInput mapping (OSMeta, EscEscape, etc.). Puppeteer tracks modifier state from the forwarded Shift/Control/Alt/Meta events, so Cmd/Ctrl+A/C/V and Shift+Arrow selection work.
  • Keys with no KeyInput mapping (IME/dead keys) keep the raw CDP dispatch as fallback.
  • Pointer down on the streamed frame focuses the keyboard surface; composing keydown events (IME) are left alone.
  • The sidecar entrypoint is now guarded by a main-module check so the mapping helper is importable from unit tests.

Coverage

  • New browser-sidecar-keys.test.ts: editing/navigation keys, aliases, printable characters, F1–F12, rejected IME keys.
  • Full server/modules/automation suite: 25/25 pass (includes the sidecar restart/protocol tests).
  • Both tsconfigs typecheck clean; eslint clean.

The end-to-end matrix from the issue (type abcd, ArrowLeft×2, Backspace, Delete; Home/End; Shift+Arrow; Tab/Shift+Tab; Enter/Escape; Cmd/Ctrl+A,C,V) is exercised by the Puppeteer path the automation commands already use; CUA-level verification is left to the next sandbox pass.

…keyboard

The panel's key bridge dispatched raw CDP key events without virtual key
codes, so Chromium never ran its default editing commands: printable
characters landed via insertText, but Backspace, arrows, Home/End, Tab
and modifier combinations did nothing in remote inputs. Recognized keys
now go through Puppeteer's page.keyboard (the same path the automation
commands already use), with the raw CDP dispatch kept as a fallback for
keys that have no KeyInput mapping (IME/dead keys).

The streamed frame also never focused its keyboard surface, so keys
could keep going to the address bar or chat input after clicking into
the page; pointer down now focuses the surface, and composing keydown
events are left alone.

Closes #20
@devswha
devswha merged commit e2b011f into main Sep 4, 2026
2 checks passed
@devswha
devswha deleted the fix/browser-panel-keys branch September 4, 2026 13:44
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.

bug: Browser panel drops Backspace and navigation keys in remote inputs

1 participant