fix(browser): forward editing and navigation keys through the remote keyboard - #22
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
browser-sidecar.tsdispatched raw CDPInput.dispatchKeyEventwith only{ type, key, code, modifiers }. WithoutwindowsVirtualKeyCode/nativeVirtualKeyCode, Chromium delivers a DOM key event but never runs its default editing command.tabIndex=0surface, 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
page.keyboard.down/up— the same path the automation commands already use — via a pure, unit-testedtoPuppeteerKeyInputmapping (OS→Meta,Esc→Escape, etc.). Puppeteer tracks modifier state from the forwarded Shift/Control/Alt/Meta events, so Cmd/Ctrl+A/C/V and Shift+Arrow selection work.Coverage
browser-sidecar-keys.test.ts: editing/navigation keys, aliases, printable characters, F1–F12, rejected IME keys.server/modules/automationsuite: 25/25 pass (includes the sidecar restart/protocol tests).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.