Repository navigation
macOS engine: Show Menu answers ok only once a menu opens, else menuUnconfirmed (#374) - #391
Conversation
…rmed (refs #374) perform_secondary_action "Show Menu" (AXShowMenu) used to answer ok as soon as the Accessibility call returned success. It now looks for a new AXMenu for up to 1 s, polling every 20 ms (the Linux engine's MENU_WAIT). A menu counts when it is a child of the application element (the serving process's or the app's), a child of the element, or the app's focused element or one of its 3 nearest ancestors (a page's ARIA menu). A menu already open before the action does not count. When no menu is seen the answer is menuUnconfirmed, from the "sent, effect not seen" family. It is not a refusal, because a page that handles contextmenu itself shows no native menu even though the request worked. An AXShowMenu that times out (cannotComplete) counts as sent and its menu is looked for. Every other AXError stays actionFailed. The confirmation's record rides as meta cua/menu. The model's document gains one sentence. The Decision Log records the departure from the vendor, including why no comparison cell needs a declaration and why a posted right click keeps click's own contract. Sminos-Session: cursor235#b93055dd (cua on macbook)
…read baseline source confirms nothing (refs #374) These fix the two P2 findings from the review of 74d674c. - The deadline is now checked before every AX read, including each child's role read. Before this, an app that returned its children and then stalled on each role cost one 1 s messaging timeout per child. Now it ends the wait one read past the window. - The baseline now tells "none" from "unknown": a failed children or focus read, a role that did not read, or a parent missing below the window leaves that source unread (MenuReading.unread, meta unreadBefore). A menu seen during the wait through such a source confirms nothing, because it may have been open before the action. AXOps gains childrenRead and focusedElement, which report a failed read. Sminos-Session: cursor235#b93055dd (cua on macbook)
…not the application's (refs #374) The hosted diagnostic smoke (run 44004726498) found that no family puts its context menu under the application element. In each, the menu hangs under the view that popped it up: - AppKit's text view: the element; - Chrome for Testing: the page's scroll area; - Electron: the window; - Firefox and Safari: a group under the window. So the candidate answered menuUnconfirmed on every browser menu that was on screen. Following ruling 1ea561bc:752, the "application" source is replaced by "ancestor": a new AXMenu child of one of the element's ancestors up to its window, leaving out the web area and its inside. The hosts are read once before the action. The rejected alternative was a pop-up-level window: it ties nothing to the request, and Firefox's datalist suggestions also show as a layer-101 window. The Decision Log records the finding, the rule, and that rejection. The same run verified the cannotComplete reading of the blocking view. Sminos-Session: cursor235#b93055dd (cua on macbook)
… nodes are never taken for them (refs #374) This fixes the P2 from the review of 5cdc968. If the walk stopped inside the page, the web area was never reached, so the page's own nodes became hosts and a menu the page opened under one of them could confirm. That happened when a parent or role did not read, when the application was reached first, or when the level bound was spent. menuHosts now answers nil unless the walk reached the window with every parent and role read. With no hosts, the ancestor source is unread and confirms nothing. Sminos-Session: cursor235#b93055dd (cua on macbook)
#374) Ruling 1ea561bc:753 ships the ancestor and focus rule with no discriminator and states its limit: a menu that something else opens in the same window within the 1 s wait (under a host of the element, or taking the focus) is taken for the request's. - agent-cursor.md tells the model to check the next observation before choosing an item. The surface inventory's #374 addition says the same. - The Decision Log gives the evidence: the negative controls that confirmed, and what the rule excludes. It also records why no discriminator was added: position fails both ways, with Electron's menu at the pointer 256 pt away and Firefox's select 13 pt away. Sminos-Session: cursor235#b93055dd (cua on macbook)
…#374) Run 44012053373, reps 10, macOS 26.7.2 hosted, five app families, both placements. Request cells: - False ok: 0 of 400 on the candidate, against 120 of 400 on main. - own: 80 of 80 menuUnconfirmed. ignored: 20 of 20 menuUnconfirmed. - Native and popup menus: 119 of 120 confirmed. The one miss was a cold first poll in Firefox. - ARIA: 80 of 80 confirmed through focus. - blocking: 20 of 20 cannotComplete with the menu open, answered ok. The negative controls' rates are recorded as the stated limit's evidence. Sminos-Session: cursor235#b93055dd (cua on macbook)
… (refs #374) Sminos-Session: cursor235#b93055dd (cua on macbook)
Sminos-Session: cursor235#b93055dd (cua on macbook)
…ow Menu sentences (refs #374) scripts/repl-parity/docs-oracle.mjs keeps its own copy of the shipped agent-cursor.md, and test/repl-parity/docs-oracle.test.mjs checks the two match. #374's model-facing sentences (the Show Menu answer, then the limit that a success means a menu appeared, not which one) were missing from that copy, so the CI test gate failed on b736aef. The paragraph in the copy is now the shipped one. Sminos-Session: cursor235#b93055dd (cua on macbook)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f94498be84
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let showsMenu = chosen.name == kAXShowMenuAction | ||
| let menuScope = showsMenu ? MenuScope(element: target.element, hosts: menuHosts(of: target.element, ax: ax), | ||
| applications: menuApplicationPids(owner: target.owner, appPid: appPid).map { prepare(AXUIElementCreateApplication($0)) }) : nil | ||
| let menusBefore = menuScope.map { openMenus($0, ax: ax) } ?? MenuReading() |
There was a problem hiding this comment.
Bound the pre-action menu baseline read
If an app returns its children but stalls on their role reads, this baseline invokes openMenus with its default infinite deadline. That function continues through every child even after a role read fails, and each live AX read can consume the one-second messaging timeout defined in AX.swift. A container with hundreds of children can therefore block Show Menu for minutes before the action is even sent, potentially exceeding the client's 120-second request deadline. The finite deadline in awaitShownMenu only protects post-action polling. Give the baseline a finite budget too; its existing unread handling can conservatively exclude any sources whose reads are cut short.
Useful? React with 👍 / 👎.
What changes
On macOS,
perform_secondary_action"Show Menu" (AXShowMenu) answered ok as soon as the accessibility call returned success, without checking that a menu appeared. Now it answers ok only once a new menu is seen within 1 s (polled every 20 ms, the Linux engine's menu wait). Otherwise it answersmenuUnconfirmed:What counts as a menu (rulings 1ea561bc:687, 752):
A menu already open before the action doesn't count. Neither does a source whose pre-action read was incomplete, or a host walk cut short before the window. The
cua/menumeta records{seen, openBefore, polls, ms, actionError?, unreadBefore?}.AXShowMenu returning cannotComplete (−25204) now counts as sent, and the menu is still looked for. AppKit can run the menu's tracking loop inside the action, past the 1 s AX timeout. Main answered
actionFailedthere with the menu open; this branch answers ok (verified live, 20/20).Unchanged: posted right clicks keep click's own contract, matching Linux (ruling 739). No macOS click route sends AXShowMenu.
This departs from the vendor's answer on purpose (#117's terms). No
compare --engines, parity or matrix cell performs Show Menu, so no comparison row moves.Evidence
Full hosted run 44012053373: reps 10, foreground and background; AppKit fixture, Chrome for Testing 155, Electron 44.9, Firefox 159, Safari 27.2. Candidate 7ad0362 against main b99232d. The oracle is independent of the engine: the pid's pop-up-level CGWindows, its AXMenu tree, and the page's own counters. Tables: docs/evidence/2026-11-16-show-menu/README.md.
Latency (
cua/menums, p50): AppKit 12–28, Electron ~21, Safari 99–123, CfT 123–160, Firefox 188–260, ARIA 3–84.menuUnconfirmedends at 1,004–1,073 ms.Limits
<select>20/20 confirm. A sibling view's menu, popover AXMenus (Firefox's datalist) and Chrome's datalist are excluded. Position can't separate them: Electron's real menu opens at the pointer, 256 pt from the element, while Firefox's select was 13 pt away (ruling 753). Linux carries the same limit. The ticket text is below, for both platforms.menuUnconfirmed.Ticket text for the coincident-menu limit (one per platform)
Show Menu confirms a menu that appeared, not necessarily the requested one
Problem
An element action that asks for a context menu answers success only once a new menu is seen to open within the menu
wait (1 s), and
menuUnconfirmedotherwise. This covers perform_secondary_action "Show Menu" on macOS, andshowContextMenu (and the callers that run it) on Linux. The confirmation looks for a menu in the places the request's
menu appears. It cannot tell which request opened a menu it sees there.
So if something else opens a menu in the same window during the wait, the answer is success even when the request
itself opened nothing. Examples: a page script opening an ARIA menu on a timer, an app popping up a menu of its own, a
<select>popup opened by the page. The agent is told a menu is open, and one is, but it may not be the element'smenu.
What was measured
probe/374-measure). Each negative control opens a menu300 ms into the wait, after a Show Menu that opens nothing.
<select>popup opened on a timer.Firefox's select 20 of 20, Firefox's datalist 1 of the 7 rows where it fired.
Why it is not simply fixed
The menu's position against the element was measured on macOS and fails both ways. A real menu can open far from the
element: Electron's Menu.popup() opens at the pointer, 256 points away in the measurement. A coincident menu can open
right beside it: Firefox's select was 13 points away. "Appeared after the request" holds for every coincident menu. The
menu's place in the accessibility tree is the same for a real menu and a coincident one popped up in the same view.
Current handling
This is a stated limit. The model's document says that a successful Show Menu means a menu appeared, not which one,
and that the agent's next observation shows which menu is open, to be checked before choosing an item.
What would close it
A signal that ties a menu to the request. Candidates to investigate:
Each needs measuring per app family before it can replace the stated limit. Then measure Linux's exposure with the same
controls.
Not in scope
The
menuUnconfirmedanswer itself, and the menu wait's length.Verification
swift test(native/engine): 1,155 tests, 0 failures, after merging main. 21 new MenuConfirm tests. Focused node tests: 82/82; the agent-cursor doc consumers: 718/724 pass, the rest skipped, 0 fail.Plugin 0.28.3.
Closes #374
Sminos-Session: cursor235#b93055dd (cua on macbook)