Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
🦋 Changeset detectedLatest commit: 6d2b419 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
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 |
why
Closes #3236
Calling
page.keyPress("w")inserts text into focused inputs, but the dispatched DOMkeydownevent lacks key identity (event.key === ""andevent.code === ""andevent.keyCode === 0). Handlers inspectingevent.keyorevent.code(e.g. shortcut managers and games) ignore the press, even though the subsequentkeyupevent identifies the key.Furthermore, punctuation characters in
describePrintableKeyfell back tovk: ch.toUpperCase().charCodeAt(0). In ASCII,.is charCode 46, which collides with Windows Virtual KeyVK_DELETE(46). In Chromium, passingwindowsVirtualKeyCode: 46for.causes the browser's editing command handler to trigger Delete instead of inserting the period.what changed
PRINTABLE_PUNCTUATIONlookup covering printable punctuation and shifted symbol keys (e.g..maps tocode: "Period", vk: 190rather than VK 46 /VK_DELETE).Page.describePrintableKey():PRINTABLE_PUNCTUATION.ch === upper).Page.keyDown()for single printable characters (length 1) in the typing path to includekey: desc.key,code: desc.code, andwindowsVirtualKeyCode: desc.vk.Page.type()to sharedescribePrintableKey()for consistent keyboard event metadata acrosstype()andkeyPress().packages/extension/tests/page-key-press.test.ts.@browserbasehq/stagehand-extension,@browserbasehq/stagehand,@browserbasehq/stagehand-go, and@browserbasehq/stagehand-python.test plan
pnpm run fmt:check(passes)pnpm run lint(passes)pnpm --filter @browserbasehq/stagehand-extension run typecheck(passes)pnpm vitest run packages/extension/tests/page-key-press.test.ts(passes, 4/4 tests)pnpm --filter @browserbasehq/stagehand-extension run test:unit(passes, 67/67 files, 1007 tests)Summary by cubic
Fixes
page.keyPress()andpage.type()dispatchingkeydownevents without key identity (event.key,event.code, andevent.keyCodewere empty), which caused handlers checking those fields (shortcut managers, games) to ignore the press. Also fixes punctuation collisions where.fell back to VK 46 (VK_DELETE) and triggered Delete in Chromium instead of inserting a period.PRINTABLE_PUNCTUATIONmapping so characters like.dispatchcode: "Period",vk: 190rather than VK 46.describePrintableKey()acrosskeyPress(),keyDown(), andtype()so all typing paths share consistent metadata; uppercase characters passed directly keep their uppercase identity.@browserbasehq/stagehand-*packages.Written for commit 6d2b419. Summary will update on new commits.