Skip to content

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

Merged
gshost1 merged 15 commits into
mainfrom
fix/popup-window-viewport
Nov 8, 2026
Merged

gshost1 merged 15 commits into
mainfrom
fix/popup-window-viewport

Conversation

@gshost1

@gshost1 gshost1 commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

What

This carries upstream PR #453 by joeVenner, "find the window of a control that omits AXWindow", as its two commits, with review fixes on top.

Some pop-up buttons answer kAXErrorNoValue for AXWindow, such as the Where and File Format pop-ups in a save sheet and System Settings pop-ups. Their live offscreen state then stayed unknown. Their expandable role never publishes AXExpanded, so their states also count as incomplete. With both, the core visibility gate returns unknown, and a click, select or expand waits out the 5 s actionability budget and fails with TIMEOUT. ancestor_viewport now takes the viewport from the first AXWindow in the parent chain when AXWindow has no value.

Review fixes added here:

  • The search starts at the element itself, so an AXMenu or AXPopover used as the start element no longer takes its host window as its viewport. Before this fix it would have read as offscreen.
  • AXPopover joins the menu roles that stop the search, because popover content draws outside its window.
  • A read failure anywhere in the fallback leaves the viewport unknown, as it was before the fallback existed. The primary AXWindow path and its clipping walk are unchanged.
  • element_bounds tests move to element_bounds_tests.rs for the 400-line cap. A stale doc comment is corrected.

Why

In the speed bench's TextEdit Save task, pop-up actions in the Save sheet waited out the full 5 s and then failed with TIMEOUT, about 170 s over 10 runs, and the model retried each time.

How tested

  • Every host test target passes in the pre-commit hook, along with fmt, clippy -D warnings, the source rules and the architecture check.
  • Tests:
  • Live A/B (bench/probe_savepanel.sh): TextEdit, new document, cmd+s, then a click on the first pop-up in the Save sheet. Base is fork main c4d3961.
Binary Result Time
base TIMEOUT, visible: live offscreen state unavailable 5,095 ms
head (vercel-labs#453 commits) delivered_verified, AXPress 183 ms

The review fixes came after this A/B. They change only menu, popover and read-failure cases, not a pop-up button inside a sheet. A re-run on the final binary is queued in the next lock round.

  • Save-sheet pop-up click A/B re-run on the final binary (bench/probe_savepanel.sh, 2026-11-07): base 5,080 ms TIMEOUT, head 179 ms ok. The sheet snapshot took 396–441 ms with 82 refs, complete: true.
  • bash scripts/perf-baseline-compare.sh --base origin/main (bench/perf_compare_branches.sh, 2026-11-07): neutral. Every case is within 5%, with the same ok rate and output shape on both binaries.
Case (AgentDeskFixture, 10 rounds) base p50 ms head p50 ms change
snapshot -i 251.6 240.3 -4.5%
snapshot skeleton 221.5 228.8 +3.3%
snapshot d30 244.5 246.1 +0.7%
get 49.9 49.6 -0.6%
is visible 49.3 49.5 +0.4%
click 116.4 117.1 +0.6%
set-value 65.4 65.1 -0.5%
type 72.9 72.2 -1.0%

Risks

  • An element whose AXWindow resolves directly but which draws outside the window is unchanged; that path is not part of this PR.
  • The fallback walks the parent chain twice (once to find the window, once to clip). It runs only for elements whose AXWindow has no value, which used to fail after 5 s instead.

What's left

macOS E2E, against the main baseline

AGENT_DESKTOP_E2E_EXCLUSIVE=1 bash tests/e2e/run.sh on this branch (head dc598931, which contains fork main 4e9420d0) and on main 4e9420d0 itself:

Checkout Result
main 4e9420d0 stops at the strict headless gate: "fixture did not expose one unambiguous owned window"
this branch dc598931 the same gate, the same message; no other failure

No new failure, so no regression. The gate fails on every checkout because Screen Recording is off on this Mac. macOS then gives CoreGraphics windows no name, list-windows falls back to the app name AgentDeskFixture, and the guard requires the window title AgentDesk Fixture, which AX reports correctly. A fix for that title fallback is tracked separately.

joeVenner and others added 10 commits November 7, 2026 15:12
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.
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.
…e 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.
@gshost1
gshost1 merged commit 45236e6 into main Nov 8, 2026
13 checks passed
gshost1 added a commit that referenced this pull request Nov 8, 2026
Main carries #6 as a squash, so its element_bounds conflicts with this branch's copy. Main's clip_by_ancestors is the version this fix was written against; both hunks keep this branch's side.
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