Skip to content

fix(macos): let a sheet or popover frame replace its window's viewport - #27

Merged
gshost1 merged 12 commits into
mainfrom
fix/sheet-viewport
Nov 8, 2026
Merged

gshost1 merged 12 commits into
mainfrom
fix/sheet-viewport

Conversation

@gshost1

@gshost1 gshost1 commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Stacked on #6 (fix/popup-window-viewport). Merge #6 first, then retarget this PR to main.

What and why

TextEdit's Save sheet is wider than its document window. The clipping viewport intersected the sheet with that window, so the actionability gate saw the Save button and the sidebar cells as offscreen and refused to click them. This was the main cause of slow TextEdit Save runs in the bench: the model kept retrying until it fell back to keyboard input.

A sheet or popover draws its own surface, so its frame now replaces the window as the viewport base:

  • draws_own_surface(role) matches AXSheet and AXPopover.
  • clipped_viewport returns an own-surface element's own bounds.
  • clip_by_ancestors stops at the nearest window or own surface. The new viewport_from_clips then folds the clips below that base. Scroll areas inside a sheet still narrow the viewport.
  • hit_test keeps its visible verdict after clipping by an own-surface role.

The lesson is in docs/solutions/runtime-errors/2026-11-07-sheet-wider-than-its-window.md.

How tested

  • The pre-commit hook passed (fmt, clippy -D warnings, library tests over the host set).
  • 5 new tests in element_bounds_tests.rs and 1 in hit_test_tests.rs. Removing the fix made 3 of them fail:
    • a_sheet_wider_than_its_window_keeps_its_far_controls_visible
    • clips_inside_a_sheet_still_narrow_its_viewport
    • snapshot_traversal_entering_a_sheet_takes_the_sheet_frame

Risks

  • A sheet or popover that reports a frame larger than what it actually draws could expose controls that aren't really visible. The macOS sheets and popovers observed so far report their drawn frame.
  • No live check against the real Save sheet yet, and no perf A/B. Both run next under the bench lock (n=3 TextEdit Save).

What's left

joeVenner and others added 11 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.
A Save sheet wider than its document window had every control past the
window's edge judged offscreen, because the sheet's frame was intersected with
the window's. Actionability then refused the Save button and sidebar cells. A
sheet or popover is its own window, so its frame now replaces the inherited
viewport in snapshot traversal, ends the live clip walk, and is the last clip
in the pointer hit test.
gshost1 added a commit that referenced this pull request Nov 8, 2026
The release binary embeds agent-desktop-core's absolute source paths, which
showed main, #25, #26 and #27 arms had been linked with #24's core.
@gshost1
gshost1 changed the base branch from fix/popup-window-viewport to main November 8, 2026 14:34
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.
@gshost1
gshost1 marked this pull request as ready for review November 8, 2026 14:55
@gshost1
gshost1 merged commit 4eb2e47 into main Nov 8, 2026
13 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.

2 participants