Skip to content

fix(macos): find the window of a control that omits AXWindow - #453

Closed
joeVenner wants to merge 2 commits into
vercel-labs:mainfrom
joeVenner:fix/macos-popup-button-actionability
Closed

joeVenner wants to merge 2 commits into
vercel-labs:mainfrom
joeVenner:fix/macos-popup-button-actionability

Conversation

@joeVenner

Copy link
Copy Markdown

Summary

select, click, and expand on a System Settings popup button waited out the 5 s actionability budget and failed with TIMEOUT and the suggestion "The target application may be busy or unresponsive". The live viewport read now finds the popup's window through its parent chain, so the visibility check can pass.

Related issues

None found. On System Settings, select also needs the menu-search fix in #399: after this PR the gate passes, but without #399 the menu search stops at an invalid node and select fails with ELEMENT_NOT_FOUND. With both changes, select changes the value.

Type of change

  • fix: — bug fix

Changes

The popup buttons in System Settings answer kAXErrorNoValue (-25212) for AXWindow, although their parent chain reaches an AXWindow seven levels up whose bounds read normally. ancestor_viewport returned None as soon as AXWindow had no value, so the live offscreen state stayed unknown.

A popup button maps to the combobox role. That role is expandable, and the button never exposes AXExpanded, so states_are_complete reports false. The core visibility gate (gates.rs) treats an unknown offscreen with incomplete states as unknown, and the actionability wait never ends. The same failure hit the File Format popup in TextEdit's save sheet.

When AXWindow has no value, ancestor_viewport now starts from the first AXWindow ancestor and runs the existing clipping walk unchanged. first_window_ancestor stops without a window at AXApplication, at a missing role, or at the first menu role (AXMenu, AXMenuItem, AXMenuBarItem, or AXMenuBar). Menu content therefore keeps no viewport, as before: an open menu draws outside the window and would otherwise read as offscreen.

I kept the core gate as it is because Windows and Linux share it. The fix supplies the evidence the gate is missing rather than loosening the gate.

How tested

  • cargo fmt --all -- --check
  • cargo clippy "${HOST_PKGS[@]}" --all-targets -- -D warnings
  • cargo test "${HOST_PKGS[@]}" --lib
  • cargo test -p agent-desktop
  • cargo test -p agent-desktop-ffi --tests
  • AGENT_DESKTOP_E2E_EXCLUSIVE=1 bash tests/e2e/run.sh (requires --release build + AX permission; run when behavior changes)

New tests in element_bounds.rs cover a popup button chain that reaches its window, a menu-bar chain, a popup menu item inside a window, an ancestor without a role, and an unbounded chain. The window test fails if the fallback returns None, and the popup-menu test fails without the menu-role guard.

Live, on macOS 26 (Darwin 25.5), with #399's change applied: select on Window title bar double-click action in Desktop & Dock returned delivered_verified. defaults read -g AppleActionOnDoubleClick changed from unset to Minimize, and back to Maximize after selecting Zoom. I deleted the key afterwards. Each select takes about 2.9 s with and without the menu-role guard. Before the change, the same call returned TIMEOUT after 5,031 ms with the single failing check visible: live offscreen state unavailable.

E2E and perf ran on a merge of this PR with my three other macOS fix PRs, compared with main at 9eb9b296.

  • E2E: 58 passed, 13 failed, 1 skipped. The failures also occur on main. On this machine (macOS 26, 5K display), the fixture's AXScrollArea reports a frame that covers only the right half of its 1770×1080 window. The 27 controls in the left column read offscreen, and actions on them fail the visibility check. Both binaries list the same 27 controls as offscreen, and every failing assertion targets one of them. On main the suite stops earlier, at the safe-semantic.sh gate, for the same reason.

  • Perf (scripts/perf-baseline-compare.sh, 10 rounds, p50, this PR then main):

    Case This PR main
    Fixture snapshot -i 144.2 ms 144.9 ms
    Fixture get 30.1 ms 30.0 ms
    Fixture type 48.1 ms 48.7 ms
    Finder snapshot -i 197.9 ms 198.0 ms
    System Settings snapshot -i 1,176.5 ms 1,152.5 ms
    System Settings snapshot d30 1,136.0 ms 1,137.7 ms
    System Settings find --role button --first 553.3 ms 556.3 ms

    The fixture click case fails on both binaries for the offscreen reason above. That failure ends the script early, so I ran its remaining steps by hand.

Checklist

  • PR title uses a conventional-commit prefix (type: description, lowercase, no capital after colon)
  • cargo fmt and cargo clippy -D warnings are clean
  • All tests pass (the cargo suites; E2E results are under How tested)
  • No unwrap() added in non-test code
  • No inline comments added (only /// doc-comments on public items)
  • All modified files are within the 400 LOC limit
  • Skill docs updated if a command, flag, or JSON output changed (no command, flag, or output shape changed)
  • README / other docs updated if the public interface changed (no public interface change)

System Settings popup buttons answer kAXErrorNoValue for AXWindow even
though an AXWindow encloses them. ancestor_viewport then had no
viewport, the live offscreen state stayed unknown, and because a
popup button never reports AXExpanded the actionability gate waited out
its whole 5 s budget. select, click and expand on these popups failed
with TIMEOUT and a "target may be busy" suggestion.

When AXWindow has no value, the viewport now starts from the first
AXWindow in the parent chain. A chain that reaches the application
without a window, as open menu content does, still has no viewport.
An open popup menu hangs off its popup button, so its parent chain
passes through the enclosing AXWindow. The window-ancestor fallback
would have given menu items that window's viewport, and an item drawn
outside the window would read as offscreen. The search now stops at
the first menu role, so menu content keeps no viewport, as it had
before the fallback.

Measured on a System Settings popup: select takes about 2.9 s with
and without this guard, and changes the value in both builds.
@vercel

vercel Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@joeVenner is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

gshost1 added a commit to gshost1/agent-desktop that referenced this pull request Nov 8, 2026
…ercel-labs#453) (#6)

* fix(macos): find the window of a control that omits AXWindow

System Settings popup buttons answer kAXErrorNoValue for AXWindow even
though an AXWindow encloses them. ancestor_viewport then had no
viewport, the live offscreen state stayed unknown, and because a
popup button never reports AXExpanded the actionability gate waited out
its whole 5 s budget. select, click and expand on these popups failed
with TIMEOUT and a "target may be busy" suggestion.

When AXWindow has no value, the viewport now starts from the first
AXWindow in the parent chain. A chain that reaches the application
without a window, as open menu content does, still has no viewport.

* fix(macos): keep menu content out of the window-ancestor fallback

An open popup menu hangs off its popup button, so its parent chain
passes through the enclosing AXWindow. The window-ancestor fallback
would have given menu items that window's viewport, and an item drawn
outside the window would read as offscreen. The search now stops at
the first menu role, so menu content keeps no viewport, as it had
before the fallback.

Measured on a System Settings popup: select takes about 2.9 s with
and without this guard, and changes the value in both builds.

* test(macos): move element_bounds tests beside the module

The carried window-ancestor fallback put element_bounds.rs at 406 lines, over
the 400-line cap; its inline tests now live in element_bounds_tests.rs as the
layout rule asks.

* fix(macos): keep the window-ancestor fallback from judging own-surface content or failing reads

Review of the carried fallback found three gaps. A menu or popover used as
the start element still walked up to its host window and read as offscreen;
a popover's content was not stopped at all; and an unreadable parent chain on
the fallback now failed state reads that used to report an unknown viewport.
The search now starts at the element itself, stops at AXPopover as well as
the menu roles, and any fallback read failure leaves the viewport unknown as
before. The primary AXWindow path and its clipping walk are unchanged.

---------

Co-authored-by: joeVenner <ylafrimi@gmail.com>
@lahfir

lahfir commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

closing as fixed in #705 on main (element_bounds now falls back to walking AXParent for AXWindow). thanks @joeVenner

@lahfir lahfir closed this Nov 28, 2026
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.

2 participants