Skip to content

macOS engine: Show Menu answers ok only once a menu opens, else menuUnconfirmed (#374) - #391

Merged
SSFSKIM merged 9 commits into
mainfrom
fix/374-menu-unconfirmed
Nov 17, 2026
Merged

SSFSKIM merged 9 commits into
mainfrom
fix/374-menu-unconfirmed

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Nov 17, 2026

Copy link
Copy Markdown
Owner

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 answers menuUnconfirmed:

The Show Menu action was sent to , but no menu was seen to open within 1 s. may have shown a menu of its own that accessibility does not expose (a web page's own menu, for one), or ignored the request. Observe the app (take a screenshot or call getAXState()) before any retry, and never retry blindly.

What counts as a menu (rulings 1ea561bc:687, 752):

  • element: a new AXMenu child of the element (an NSTextView's context menu, a popup button's menu);
  • ancestor: a new AXMenu child of one of the element's ancestors, up to and including its window. The walk skips the web area and everything inside it, and resumes at the web area's parent. This is where Chrome, Electron, Firefox and Safari hang their native context menus; the live run found them never to be children of the application.
  • focus: the app's focused element, or one of its 3 nearest ancestors, has role AXMenu (a page's ARIA menu).

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/menu meta 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 actionFailed there 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.

candidate main
false ok (native, popup, blocking, ARIA, own, ignored) 0 / 400 120 / 400
page draws its own menu (preventDefault): menuUnconfirmed 80 / 80 0
AppKit view that ignores AXShowMenu: menuUnconfirmed 20 / 20 0
native and popup menus, where the oracle saw one: ok 119 / 120 —
ARIA menus: ok through focus (all 4 web families) 80 / 80 —
blocking (cannotComplete with the menu open): ok 20 / 20 actionFailed 20 / 20

Latency (cua/menu ms, p50): AppKit 12–28, Electron ~21, Safari 99–123, CfT 123–160, Firefox 188–260, ARIA 3–84. menuUnconfirmed ends at 1,004–1,073 ms.

Limits

  • Coincident menu. When something else opens a menu in the same window within the 1 s wait, under a host of the element or taking the focus, it is taken for the request's. Success therefore means "a menu appeared", not which one. agent-cursor.md tells the agent to check its next observation before choosing an item. Measured controls: a timer-opened ARIA menu 80/80, an AppKit content-view menu 20/20, and Firefox's timer <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.
  • Cold first poll. 1 false unconfirmed in 100 browser native rows, the first Show Menu of a session, when a single poll took over 1 s. Left as is. The fix, if wanted, is one more poll after the wait when only one completed.
  • An ARIA menu that takes no focus and isn't under a host answers 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 menuUnconfirmed otherwise. This covers perform_secondary_action "Show Menu" on macOS, and
showContextMenu (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's
menu.

What was measured

  • macOS (macOS engine: perform_secondary_action Show Menu answers ok without confirming a menu appeared #374; hosted runs 44010453311 and 44012053373, kit probe/374-measure). Each negative control opens a menu
    300 ms into the wait, after a Show Menu that opens nothing.
    • Confirmed in error:
      • a focused ARIA menu opened by the page on a timer (Chrome for Testing, Electron, Firefox, Safari);
      • a context menu popped up in the same window's content view (AppKit);
      • Firefox's <select> popup opened on a timer.
    • Rates in the full run (reps 10, both placements): the timer ARIA menu 80 of 80, the content-view menu 20 of 20,
      Firefox's select 20 of 20, Firefox's datalist 1 of the 7 rows where it fired.
    • Correctly not confirmed:
      • a sibling view's own context menu;
      • an AXMenu inside a popover (Firefox's datalist suggestions);
      • Chrome's datalist suggestions.
  • Linux: the same exposure by construction (a new menu child of the application within the wait). Not yet measured.

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:

  • a platform event that carries the menu's invoker (an accessibility event naming the source element);
  • the menu's items matched against what the element offers;
  • the pointer or caret position the request used, where a platform exposes it.

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 menuUnconfirmed answer itself, and the menu wait's length.

Verification

Plugin 0.28.3.

Closes #374

Sminos-Session: cursor235#b93055dd (cua on macbook)

…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)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T04:49:20.662023Z f94498b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@SSFSKIM
SSFSKIM merged commit c7eee72 into main Nov 17, 2026
7 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.

macOS engine: perform_secondary_action Show Menu answers ok without confirming a menu appeared

1 participant