Repository navigation
fix(computer-use): tell visited AX elements apart by identity, not address - #573
Merged
Merged
Conversation
…dress The walk deduplicated elements by the address of the AXUIElement it was handed. Each child array is released once its subtree is walked, and the next array the system hands out reuses freed addresses, so a node whose reference landed on a released sibling's address was skipped: the first child of a group, typically. Visited elements are now retained for the walk and compared with CFEqual under CFHash.
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.
Changed behaviour
observe_uidropped nodes from the macOS accessibility tree — in practice the first child of a group: the 终端 segment of the compact panel switcher, the ★ tab of the model picker's provider rail, the first approval mode. The walker's cycle guard recorded eachAXUIElementRefby its address. Every child array the system hands out holds fresh objects and is released once its subtree is walked, so the next array can reuse a freed address; a node that landed on a released element's address counted as already visited and was skipped.Visited elements are now retained for the walk and compared as AX identities (
CFEqualunderCFHash), so an address can neither be reused nor stand for a node.Verified it is the observer, not GPUI or the adapter: GPUI's
debug_a11y_tree_jsonlists the toolbar with all four toggles, and a direct AX dump (AXUIElementCopyAttributeValuefrom a Swift script) showsAXToolbarwith 4 children.tcode --cu-smokeagainst the phone example's panel page: 9 nodes before, 10 after (twice each, in both orders).Tests
New
visited_elements_are_told_apart_by_identity_not_address: two references to one element are one node; 256 distinct elements made and released in turn are 256 nodes. Fails on the old address-keyed set at the first assertion (shown locally by swapping the body back).Checks run
cargo fmt --all --check;cargo clippy -p computer-use-mcp --all-targets --locked -- -D warningscargo nextest run -p computer-use-mcp --locked— 35 passed