Repository navigation
fix(computer-use): give web text fields real keyboard focus on macOS - #3846
Merged
bobleer merged 2 commits intoNov 9, 2026
Merged
Conversation
AXPress and AXFocused on a text control inside an AXWebArea succeed but only move the page's DOM focus. The window's first responder stays where it was, so later directed text, Delete and Return are lost while the tool reports them as submitted. Route node targets and the focus parameter for these controls through the directed click and keyboard path; native controls keep the AX path. Report when the window image is byte-identical to the previous observation although the accessibility tree changed, keep the full value of the focused text field so a draft can be read to the end, stop rendering Chromium's AXExpanded noise on structural nodes and AXScrollToVisible, and include the valid bounds in the zoom region error.
A real click on every focus request collapsed the selection and moved the caret. Remember the field a real click focused and send no further click while its focus is known to hold; other pointer or semantic input, shortcuts that can move focus and focus-loss events end that state. Report a web text field scrolled out of view instead of clicking the viewport edge, include web comboboxes in the route, and put the repaint note first because long trees are clipped at the end.
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.
Summary
On macOS, clicking a web text field by
node_idx(or passing it asfocus) did not give it keyboard focus, so later typing, Delete and Return were silently lost while the tool reportedsubmitted. These controls now use a real directed click and the directed keyboard route. Native controls keep the AX path.The same session exposed smaller observation problems, also addressed here:
WINDOW_NOT_REPAINTEDnote. It goes first because long trees are clipped at the end.AXExpanded = falseon nearly every web node.[collapsed]is no longer rendered for structural roles, andAXScrollToVisibleis no longer listed. Digests are unchanged, since they are computed from the nodes rather than the rendered text. On the 85 KB tree from the failing session this noise was up to about a third of the text.Type and Areas
Type: bug fix
Areas: Computer Use native service (macOS focus routing, shared observation note), tool contracts (error text)
Motivation / Impact
AXPressandAXFocusedsucceed on a text control inside anAXWebArea, but only move the page's DOM focus. The window's first responder stays where it was. In the reported Feishu/Lark session,node_idxclicks on the composer were followed by lost text, Delete and Return, andcommand+aselected the message list instead of the draft. The agent had to fall back to the clipboard and the send button.Behavior of the new route:
AXComboBoxwith anAXWebAreaancestor, in a bounded parent walk), so there are no application name rules.image_xyclick.command+afollowed by typing withfocusstill replaces the selection. Other pointer or semantic input, shortcuts that can move focus, focus-loss events and Stop end that state, and the next request clicks again.TARGET_COORDINATES_OUTSIDE_WINDOWand sends no click. Chromium clips such a node's frame to the viewport edge, so without this the click would land on the edge.Verification
Commands, on macOS 27.2:
cargo test --locked -p openbitfun-computer-use --lib: 224 passed, 10 ignored.node scripts/test-computer-use-context.mjs: passed.node scripts/test-macos-computer-use-self.mjs: passed (same-process AppKit and WebKit, node and image clicks, Unicode text, Stop).node scripts/test-windows-computer-use-native.mjs --check --target x86_64-pc-windows-msvc: type-checks only, no Windows execution.pnpm run check:repo-hygiene: passed.pnpm run check:core-boundariespassed on the first commit; the follow-up does not change Cargo manifests.Manual reproduction through the devtools JSONL probe, on a disposable Electron window with two
WebContentsViews, with the target confirmed not frontmost and results read back from the DOM over CDP:app_clickwithnode_idx, then text, Delete,command+a, Returndocument.hasFocus()falseapp_type_textwithfocus: node_idxcommand+awithfocus_idx, type withfocusfocuson the first fieldnode_idxclickNot verified:
node scripts/test-macos-input-controls.mjs --semanticwas inconclusive: it exited with its 3-second input-idle gate unmet because the machine was in use, so no case ran.node_idxroute (its web nodes were not exposed during the fixture run).Reviewer Notes
tree_text, asCAPTURE_UNAVAILABLEalready is.image_xyclick behaves the same way.visibilityState: hiddenand exposed no web nodes until occlusion handling was disabled for the fixture.AI-assisted. Testing level: lightly tested.
Checklist