Skip to content

feat: reach the menu, popover and floating window an app shows - #702

Merged
lahfir merged 62 commits into
laf/reliability-14-tabular-surfacesfrom
laf/reliability-15-hard-surfaces
Nov 28, 2026
Merged

lahfir merged 62 commits into
laf/reliability-14-tabular-surfacesfrom
laf/reliability-15-hard-surfaces

Conversation

@lahfir

@lahfir lahfir commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator
  1. An open menu or popover was hard to reach: the search for one could walk an entire window and time out, Escape never closed one in a background window, floating and panel windows were missing from the window list, and a ref carrying its snapshot id twice failed without a suggestion.
  2. The menu search is bounded and keeps a raised popover, Escape closes the open menu or popover on macOS, Linux and Windows even when the window is behind, floating and panel windows are listed while on screen, and the ref error names the duplicate snapshot id and the zsh ${SID}:e4 form.
  3. Builds on feat: give table cells a grid position and write a macOS cell in one call #689.

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
agent-desktop Ignored Ignored Preview, v0 Nov 27, 2026 8:30pm UTC

@lahfir
lahfir added this pull request to stack #669 November 16, 2026 19:07
@Railly
Railly self-requested a review November 16, 2026 23:44

@Railly Railly left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a few comments

Comment thread crates/macos/src/tree/app_menu.rs Resolved
Comment thread crates/core/src/refs/ref_token.rs Resolved
lahfir and others added 10 commits November 16, 2026 17:55
…sed popover when the inventory fails

`list-surfaces`, `snapshot --surface menu` and the surface report after a
click look for an open context menu. When none was open, the search walked
every node of every window of the application. A Finder window in column
view held 2,376 nodes and the walk took 5.8 s, so all three timed out on
that app (at the base of this branch too), and the click on Finder's Share
button took 4 to 7 s and reported no surface although its popover was open.

A menu hangs directly below the element that shows it. The search still
checks every child, but it no longer opens the items of a content
container (more than 16 children: a list, a table, a column of a browser).
On the same window `list-surfaces` now answers in 0.4 to 0.7 s and the
Share click returns in 0.4 s.

The surfaces below the clicked element are read before the inventory and
are kept when the inventory fails, so a failed inventory no longer hides
a popover the action raised.
`press escape --app` sent the key to the application's focus holder. When
the focus holder did not take Escape and a popover was open, as after a
headless click on Finder's Share button, the press failed for lack of a
focused element or went to the window behind the popover, and the popover
stayed on the user's screen.

Escape now reaches, in this order: the focus holder that advertises the
cancel action, as before; then, when no focus holder takes it, the menu or
popover the application shows, through that surface's own cancel action,
verified by reading that the surface is gone; then the key event route, as
before. The surface is found in one pass by the bounded search that finds
an open menu, which now also accepts a popover; the popover snapshot uses
the same search in place of its own unbounded walk.

On Finder the Share popover closes in 0.37 s with `delivered_verified` and
the front application unchanged. With no surface open, the result is the
same as before on Finder and Stickies; the search adds about 0.15 s on a
Finder window of 2,376 elements.
…er trap

A script that put the snapshot id in front of a printed ref_id sent
`@sid:@sid:e4`; the error said "Invalid snapshot_id" with no suggestion. A
zsh script that wrote `$SID:e4` sent a broken ref, because zsh reads `:e` as
a modifier. Both now fail as an invalid ref_id with the one suggestion for
ref syntax, which also says that ref_id already holds the snapshot id and
that zsh needs `${SID}:e4`.
…hey are on screen

The window inventory kept only windows at the normal level (0). An
accessory application often raises its own windows to a floating or panel
level, so its window was missing from `list-windows` while it was on screen
and readable, and an id from an earlier list no longer led to it. Raycast's
panel (level 8) is such a window: `list-windows --app Raycast` returned [],
while `snapshot --app Raycast` read 22 refs in it.

The inventory now also lists a window between the normal level and the
Dock level (20), but only while it is on screen: off screen such a window
is a hidden helper. The Dock, the menu bar, status items, overlays and the
desktop stay out. On this Mac the full list gained exactly the two windows
that are on screen and readable; the Raycast panel resolves by its id and
its snapshot is complete. `list-windows` takes the same time.
`press escape` sends the key only to the active window, so for a window in
the background it was refused with STALE_REF, and a GTK3 combo box popup
that the tool's own click had opened stayed open.

An Escape without modifiers that the key route refuses for focus now looks
in the target window for the deepest open popup owner: a combo box, or a
button that has a popup, whose popup menu shows (GTK3 reports no EXPANDED
state on the combo; its menu child gets SHOWING). Because the owner's
action toggles the popup, the action is sent only after that read shows
the popup open, and the result is `delivered_verified` only when a second
read shows it gone. With no open owner, or on any error, the refusal is
returned as it was. Every result the key route gave before is unchanged,
and a tree row, an expander or a table cell is never an owner.

Measured on real apps against the base of this branch: no surface open,
the same results on GTK3 and Qt, active or in the back; a GTK3 combo popup
in the back closes, read back raw, with the active window unchanged; an
expanded GTK3 tree row stays expanded; a second Escape sends nothing. The
refused path costs about 8 ms more.
…with Escape

`press escape` on Windows needs the target to hold the keyboard, so for a
window in the background it was refused, and an open drop-down of that
window stayed open: the column menu of an Explorer folder window, for one.

An Escape without modifiers that the key route refuses for focus now looks
in the target (the named window, or the process's top-level windows for
`--app`) for the innermost expanded popup owner: a menu item, a combo box
or a split button. It collapses it with `ExpandCollapsePattern.Collapse`
and reports `delivered_verified` once the state reads collapsed. With no
such owner the refusal is returned as it was. A tree item, a group or a
data item is never an owner, and every result the key route gave before
is unchanged.

To add that route after the refusal without copying it, the core default
for a key to a named window is now one public function,
`press_key_in_focused_window`, which the default and the Windows override
both call. Its behaviour is unchanged.

Measured on real apps against the base of this branch: with no popup open,
Notepad and Explorer, in front or in the back, give the same results; an
open Explorer column menu in a folder window in the back closes in 0.29 s,
read back raw, with the foreground unchanged; an expanded tree item in the
navigation pane stays expanded; `press escape` with no popup takes the same
time (51 against 52 ms).
press escape on a background window with an open popup runs the owner's own
action. That call went through the raw bus call, so its reply body was
dropped. A DoAction that answered false counted as delivered, and a call that
timed out after it was sent lost its uncertain delivery on the way back.

The owner's action now goes through the shared write path, which reads the
flag the reply carries and gives a timeout after dispatch its uncertain
disposition. A reply of false is not delivered, so the popup is not read back
and the Escape fails with ACTION_FAILED.

The refused Escape also stopped replacing the popup attempt's own error with
the focus refusal. Only a target window with no open popup owner keeps the
refusal; every other outcome, the popup attempt's failure included, is
reported as it stands.

The Linux skill now says what a rejected owner action and an unanswered one
report.
A cell write typed into the editor and committed with Return, then
reported delivered_unverified without reading the cell. An application
that gives that editor no keyboard input reported success while the
cell stayed empty.

The cell is now read back after the commit: a matching value is
verified, a cell that still shows nothing fails with ACTION_FAILED and
an uncertain delivery, and a cell that shows another value stays
delivered_unverified.
A cell often publishes its text through the name a snapshot shows, not
through AXValue, and it keeps an editing label until its editor closes.
The read-back now reads that name and treats an editor that is still
open as a cell that took nothing. A read that fails is unknown, so it
stays unverified instead of failing a write or verifying a clear.
The suggested "${SID}:e1" dropped the @, so a caller who followed it got
the same INVALID_ARGS again. The two docs examples copy the same text.
@lahfir
lahfir force-pushed the laf/reliability-15-hard-surfaces branch from 587f3e2 to cb48143 Compare November 17, 2026 02:07
lahfir and others added 7 commits November 19, 2026 17:03
… safe dismissal action

Skip web documents during the background-Escape owner walk, require an actually showing popup menu child instead of EXPANDED alone, and replace click_verbs with explicit dismissal verbs (collapse/cancel/close, plus press only for native GTK 3 combo boxes, L4-4). When no safe dismissal verb is advertised, return Ok(None) so the focus refusal stands without invoking any button's primary action.
… limits

Replace unbounded UIA FindAll(Descendants) and FindAll(Children) in the Windows background-Escape fallback with an incremental control-view UITreeWalker using a two-property cache request and Win32 top-level window enumeration. Enforce explicit root, node, depth and child caps, consult Deadline before every step, and return a not-delivered timeout when the deadline expires.
…ty-15-hard-surfaces

# Conflicts:
#	skills/agent-desktop-linux/SKILL.md
Comment thread crates/macos/src/tree/app_menu.rs Resolved
Comment thread crates/macos/src/system/key_dispatch.rs Resolved
Comment thread crates/macos/src/system/key_dispatch.rs Resolved
…obe, and update cell-write docs

- Match AXPopover via AXSubrole as well as AXRole in app_menu::find_menu_descendant so Escape finds subrole-identified popovers.\n- Cap the Escape open-surface probe to 500 ms and fall back to the key event route when that sub-budget times out while the caller's deadline still has time remaining.\n- Update docs/json-output.md to describe macOS cell write read-back verification (delivered_verified on match, ACTION_FAILED when empty).
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.

3 participants