fix(cua-driver-rs)(windows)(#1621): x,y click skips UIA Invoke on canvas-like surfaces#1622
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refines Windows UIA click invocation to respect pixel-coordinate precision. It adds control-type classification to identify elements whose primary action is coordinate-independent (buttons, checkboxes, menus), then filters click candidates in ChangesUIA Coordinate-Independence Filtering
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Runtime verification (2026-05-21, daemon in Session 2 / interactive RDP)Routing fix — PASS ✅
Surfaced a deeper Chromium bug — see #1623
RecommendationMerge #1621 anyway — silent reroute to centre was worse than honest failure, and the control-type whitelist is the correct semantics. #1623 (Chromium SendInput) is a separate fix that unlocks coord-click on Chromium content; without #1621, that work would have been blocked at the dispatcher level by silent UIA fallback. |
…vas-like surfaces `click(x, y)` previously routed through `try_invoke_in_window_at_point` for any UIA element advertising InvokePattern at the click coordinates. For container surfaces (Pane / Image / Custom / Document / Group) `Invoke()` fires the element's default action at its centre and ignores the requested (x, y) — silently breaking pixel precision on canvases, paint surfaces, image maps, and 3D viewports. ## Repro (from #1621, verified 2026-05-21 on the Windows VM against `libs/cua-driver-fixtures/test_page.html` loaded in Edge) ``` cua-driver call click '{"pid":<edge-pid>,"x":110,"y":677}' # → "✅ Performed UIA Invoke at (110,677)" # But #canvas-status shows: "canvas: clicked at (152,77)" # ─ canvas center, not the requested (110, 677) ``` The canvas's `mousedown` handler fired at synthesised centre coords because UIA `Invoke()` has no notion of "where inside the element". ## Fix Add `is_coord_independent_action()` — a control-type whitelist for elements whose primary action is coord-independent (Button, MenuItem, Hyperlink, TabItem, ListItem, CheckBox, RadioButton, SplitButton, TreeItem). For these, UIA Invoke is the semantically correct path — the element identity *is* the action target, and the click coords don't matter past hit-testing. For everything else (Pane / Image / Custom / Document / Group / etc.), even if the element advertises InvokePattern, fall through to PostMessage with the literal coords. This preserves UWP / WebView2 coverage for buttons + menu items (the original motivation for the UIA-first path) without silently rerouting canvas clicks to "click at centre". ## What this does NOT change - Element-indexed click (`click(element_index=N)`) is unchanged — it takes the UIA Invoke path explicitly via a different code site (`impl_.rs:1168`). Callers asking for "invoke this specific element" by index keep the previous behaviour. - Right-click and multi-click already skipped the UIA path (`use_uia = (btn == "left" || btn == "middle") && count == 1`); they remain on PostMessage. - The ExpandCollapsePattern preference for Qt menu-bar items (added in #1566) is unchanged — that path runs after the new control-type filter and only fires when a whitelisted-type element happens to also have ExpandCollapse. ## Test plan - [x] `cargo check -p platform-windows` clean on the VM (41.82s, 0 new warnings — all 28 warnings are pre-existing) - [x] `cargo build --release -p cua-driver` clean (24.43s release build) - [ ] **Runtime verification deferred to next interactive RDP session**: load `libs/cua-driver-fixtures/test_page.html` in Edge with the four anti-occlusion + a11y flags (see #1620), call `click(pid, x, y)` at a non-centre point inside the canvas, expect tool response to say `"✅ Posted click to pid <pid>"` (not `"Performed UIA Invoke"`) and `#canvas-status` to report the requested coords ±2px. The SSH-only session in tonight's autonomous run can't reach an interactive desktop (daemon ends up in Session 0; `list_windows` returns empty) so the click test couldn't run end-to-end — user needs to RDP in to verify. ## Related - #1620 — Chromium anti-throttling flags (separate fix; needed for any Edge/Chrome DOM verification on hidden launches, including this test) Closes #1621. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
029d228 to
9325054
Compare
Summary
click(x, y)was routing throughtry_invoke_in_window_at_pointfor any UIA element advertising InvokePattern at the click coordinates. For container surfaces (Pane / Image / Custom / Document / Group)Invoke()fires the element's default action at its centre and ignores the requested(x, y)— silently breaking pixel precision on canvases, paint surfaces, image maps, and 3D viewports.The fix adds
is_coord_independent_action()— a control-type whitelist for elements whose primary action is coord-independent (Button, MenuItem, Hyperlink, TabItem, ListItem, CheckBox, RadioButton, SplitButton, TreeItem). For these, UIA Invoke is semantically correct. For everything else, even if the element advertises InvokePattern, fall through to PostMessage with the literal coords.Why this asymmetry
The UIA-first path was added so
click(x, y)could reach UWP / WebView2 / DirectComposition surfaces wherePostMessage(WM_LBUTTONDOWN)no-ops (input routes viaWindows.UI.Inputinstead of the message queue). That's still valuable for buttons + menu items in those targets — which is exactly what the whitelist preserves. But invoking the container of a canvas, paint surface, or 3D viewport gives the caller the canvas's geometric centre instead of the requested coords — that's the user-visible bug from #1621.Repro (from issue #1621)
What this does NOT change
click(element_index=N)) is unchanged — different code site (impl_.rs:1168). Callers asking for "invoke this specific element" by index keep the previous behaviour, regardless of control type.use_uia = (btn == "left" || btn == "middle") && count == 1); they remain on PostMessage.Test plan
cargo check -p platform-windowsclean (41.82s, 0 new warnings)cargo build --release -p cua-driverclean (24.43s release)Runtime verification on RDP-connected interactive session:
libs/cua-driver-fixtures/test_page.htmlwith the four flags from cua-driver-rs Windows: launch_app should auto-inject anti-throttling flags for hidden Chromium browsers #1620.get_window_stateto find the canvas bounding rectangle.click(pid, x, y)at a non-centre point inside the canvas (e.g. canvas-relative(30, 30))."✅ Posted click to pid X"(not"Performed UIA Invoke").#canvas-statusshould report the requested coords ±2px.The SSH-only session in tonight's autonomous run couldn't reach an interactive desktop (daemon ends up in Session 0;
list_windowsreturns empty), so the live click test couldn't run end-to-end. Verification needs an RDP'd interactive session.Related
test_page.htmlon Windows)Closes #1621.
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes