feat(cua-driver-rs)(macos): enable Chromium/Electron AX trees (AXManualAccessibility) for get_window_state#1756
Draft
f-trycua wants to merge 1 commit into
Draft
feat(cua-driver-rs)(macos): enable Chromium/Electron AX trees (AXManualAccessibility) for get_window_state#1756f-trycua wants to merge 1 commit into
f-trycua wants to merge 1 commit into
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
…_window_state Chromium/Electron apps (Arc, VS Code, Electron shells) ship their web-content accessibility tree off and only build it once an assistive client requests it. Without enablement the first AX walk returns an empty/title-bar-only tree. Flip AXManualAccessibility (modern, side-effect-free) on the application root, falling back to AXEnhancedUserInterface when the modern attribute is unsupported. When the flip actually takes, let the asynchronously-built tree settle (~500ms run-loop pump) before walking. Cache per-pid so repeat snapshots skip the settle. Native Cocoa apps reject the attribute and pay no cost. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
df5ddd5 to
d9491d3
Compare
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.
Problem
Chromium-based apps (Arc, VS Code, Electron shells) ship their web-content accessibility tree off and only build it once an assistive client requests it. Without enablement, the first
get_window_stateAX walk of such an app returns an empty / title-bar-only tree — the macOS/AX analog of the empty-tree symptom tracked in #1616 (VS Code exposing only its title-bar elements). With enablement the full tree materializes.Change
In
walk_tree's app-setup path (right afterAXUIElementCreateApplication(pid)):AXManualAccessibility = trueon the app root (the modern, side-effect-free opt-in). If the app reports the attribute unsupported (kAXErrorAttributeUnsupported/ -25205), fall back toAXEnhancedUserInterface = true(the legacy flag some Electron builds expose instead). Native Cocoa apps (Finder, Calculator, TextEdit) reject both — they take no further action.pump_run_loop_brieflyhelper) so the tree has time to materialize before the walk reads it.HashSet<pid>(guarded by aMutexin aOnceLock) records pids we've already enabled + settled. Repeat snapshots of the same app skip the settle; the tree is already built and stays built for the life of the process.The settle delay fires only when enablement actually flips an app from unsupported→supported, so apps that never needed it (every native Cocoa app) pay zero added latency.
Hard dependency
This is intentionally higher-risk and must land after the Phase 1 messaging-timeout PR. Enablement makes the tree bigger (fully materialized instead of empty/partial) — which is exactly why it depends on the per-element AX messaging timeout (so a wedged element fails fast rather than stalling the now-larger walk) plus the node cap to keep the materialized tree bounded. Shipping this without those bounds would trade "empty/partial" for "complete but potentially huge."
Test
cargo build --release -p cua-driverpasses.cargo test --no-run -p platform-macoscompiles cleanly (the crate's test binary has a pre-existing, unrelatedlibswift_Concurrency.dylibrpath issue at the run step only).Refs #1616
🤖 Generated with Claude Code