Skip to content

fix(cua-driver-rs/windows): more honest hotkey no-match error message#1612

Merged
f-trycua merged 1 commit into
mainfrom
fix/cua-driver-rs-hotkey-error-wording
May 20, 2026
Merged

fix(cua-driver-rs/windows): more honest hotkey no-match error message#1612
f-trycua merged 1 commit into
mainfrom
fix/cua-driver-rs-hotkey-error-wording

Conversation

@f-trycua
Copy link
Copy Markdown
Collaborator

@f-trycua f-trycua commented May 20, 2026

Summary

Tiny wording fix on the hotkey UIA no-match error. The scan in #1611 tries TWO ways to match a shortcut: the UIA_AcceleratorKeyPropertyId property AND the (Ctrl+X)-style hint in element Names (added because modern Notepad doesn't set AcceleratorKey). The error message only mentioned the first, which was misleading.

Found in end-to-end testing of #1611 — Claude Code received the error after cua-driver call hotkey ctrl+s on modern Notepad and flagged the wording as not quite honest about what was tried.

Diff

-                     could not find a descendant UIA AcceleratorKey matching \
-                     `{key_display_for_result}` (scanned {scanned} element(s)). \
+                     could not find a UIA AcceleratorKey or `(Ctrl+X)`-style name hint \
+                     matching `{key_display_for_result}` (scanned {scanned} element(s)). \
                      PostMessage WM_KEYDOWN/UP is ignored by this target's input pipeline. \
+                     Common cause: the action is nested behind a closed menu (e.g. modern \
+                     Notepad's Save under the File menu) — its element isn't in the visible \
+                     subtree until the menu is opened. Call ...

Also added a one-line hint about the most common root cause (menu-nested actions) so the caller knows what to look for in get_window_state output.

Test plan

  • cargo build -p cua-driver -p cua-driver-uia --release clean on VM
  • No behavioral change — pure error-string update

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced diagnostic messages for HotkeyTool errors, providing clearer guidance when matching hotkeys cannot be located and suggesting troubleshooting steps.

Review Change Stack

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview May 20, 2026 9:37pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 30d62a62-02a7-4578-bbf9-e59d3a3b8110

📥 Commits

Reviewing files that changed from the base of the PR and between 5a8d468 and d3dd063.

📒 Files selected for processing (1)
  • libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs

📝 Walkthrough

Walkthrough

The PR refines the error message reported when HotkeyTool cannot find a matching accelerator key in a XAML/UWP window. The updated message now clarifies that Windows message delivery is not used, identifies a common failure cause (nested elements behind closed menus), and recommends diagnostic steps.

Changes

Enhanced UIA failure diagnostics

Layer / File(s) Summary
UIA no-match error message improvement
libs/cua-driver-rs/crates/platform-windows/src/tools/impl_.rs
The error string returned when HotkeyTool cannot locate a matching AcceleratorKey in the UIA subtree now explains that WM_KEYDOWN/UP is not used, identifies a common cause (action nested behind a closed menu), and instructs users to inspect with get_window_state or click the element directly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • trycua/cua#1611: Directly refines the same UIA-routing error message path in the HotkeyTool invoke method.

Poem

🐰 A hotkey's cry when keys won't hide,
Now whispers why the menu's still denied—
"Try get_window_state, or click it clear,
Behind closed doors, the action's here!" 🎯

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cua-driver-rs-hotkey-error-wording

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The error returned when the UIA accelerator scan finds nothing said:
  "could not find a descendant UIA AcceleratorKey matching ..."

But the scan tries BOTH approaches: the `UIA_AcceleratorKeyPropertyId`
property AND the `(Ctrl+X)`-style hint in element Names (added for
modern Notepad, which doesn't set AcceleratorKey). The original wording
implied only the first was tried, which is misleading when 30+ elements
were scanned and nothing matched.

Updated to:
  "could not find a UIA AcceleratorKey or `(Ctrl+X)`-style name hint
   matching ..."

Also added a one-line hint about the most common cause (menu-nested
actions like modern Notepad's Save behind the File menu) so the caller
knows what to look for in `get_window_state` output.

Found via end-to-end Claude Code test in #1611 review — Claude noted
the wording was a touch misleading after seeing the actual error
message it received from `cua-driver call hotkey ctrl+s` on modern
Notepad.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@f-trycua f-trycua force-pushed the fix/cua-driver-rs-hotkey-error-wording branch from 35a5d70 to d3dd063 Compare May 20, 2026 21:37
@f-trycua f-trycua merged commit 8003993 into main May 20, 2026
4 checks passed
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.

1 participant