Skip to content

fix(verify): Pick from the webview <select> menu the AX tree never publishes - #801

Merged
omesser merged 2 commits into
mainfrom
fix/settings-webview-select-popup
Sep 17, 2026
Merged

omesser merged 2 commits into
mainfrom
fix/settings-webview-select-popup

Conversation

@omesser

@omesser omesser commented Sep 17, 2026 •

Copy link
Copy Markdown
Owner

Why

ax-settings pick cannot change the AI source in the webview Settings window, which is one of the three root causes behind the five failed assertions in #706's step 7 evidence run. A run that cannot pick reaches only the Model API state, so half of Settings is unverifiable.

#797 asked first whether the menu draws at all, because the two answers have very different severities. It draws. The measurement is on #797: pressing the popup puts a window on the menu layer, 547 points wide, which is the <select>'s own width, and a still taken while it is up shows all nine options with Model API checked. Nobody is blocked from switching AI source by hand. This is a verification gap, and #797 has been retitled to say so.

What cannot see that menu is the accessibility tree, and the menu is absent from every route rather than filed somewhere unexpected. Not under the popup (popup children while open = []), not under the application (APP-CHILD-ROLES ["AXWindow", "AXWindow", "AXWindow", "AXMenuBar", "AXMenuBar"]), and not by hit test, where AXUIElementCopyElementAtPosition returns kAXErrorFailure at three points inside the menu's own window from both the application element and the system-wide element. The app is not merely slow to answer: while the menu tracks, reading the popup's AXValue returns in 0 ms. In WKWebView a <select> popup is presented by WebKit's own popup proxy rather than by an NSPopUpButton, and that path publishes nothing to accessibility. The native renderer's NSPopUpButton does publish its AXMenu, which is the only reason pick has ever worked.

What changed

scripts/ax-settings.swift only. No product code, and scripts/verify-settings-macos.sh is untouched.

Two repairs to pick, both in the instrument.

It now knows two kinds of popup menu. After the press it races the existing subtree search against a new window on the menu layer, rather than waiting the AX search out first, which on the webview never resolves. AppKit's menu wins that race and is pressed exactly as before. WebKit's menu draws without publishing anything, so the option is typed instead: macOS menus select by typed prefix, which keeps this the press-by-name the rest of the file is built on where the tree offers no element to press. Typing only ever happens once a menu is up, and a tracking menu holds the keyboard, so the characters cannot land in the page.

When neither happens, pick now dies with the <label> popup drew no menu instead of has no option. That distinction is the observation #797 needed a human with a screenshot to make, and the script now makes it itself.

Its closing check re-resolves the popup by label. The webview rebuilds its whole tree on a source change, which leaves the element captured before the pick reporting nil while a freshly resolved one reports Harness · claude. The check read the stale one and would have failed on a pick that worked.

This branch is rebased onto #800. Both fixes are live and neither was taken wholesale: pick resolves its window through #800's shared settledWindow(titled:) accessor, and it now does so inside the per-call resolver above, so every re-resolution is gated and not only the first. #800's separate top-level guard let window = settledWindow(…) line is therefore gone, folded into that one call site rather than left beside it as a second settle path.

What this deliberately does not do: no hand-built dropdown, and nothing that lowers the overlay. #706's plan rejects the first and scopes the second to its own issue, and neither is needed. The menu already draws above the overlay panel, which is evidence for artefact 5.

How to verify

The baseline moved while this was in review. #800 landed and its settle gate is now on main, so every number below was re-measured on the rebased head defa7c15 against origin/main at 2c2450b1, on one target/debug/ai-buddy build from that tree. The earlier numbers in this description were taken before #800 and no longer describe this branch.

Native, unchanged assertions, scripts/verify-settings-macos.sh not modified in this branch:

env -u AI_BUDDY_SETTINGS_WEBVIEW ./scripts/verify-settings-macos.sh
exit=0   PASS=18 (+1 summary line)   SKIP=2   FAIL=0
[SKIP] claude never answered; the freeze checks need a signed-in Harness
[SKIP] claude did not answer the second pick

That is the recorded baseline exactly, same two SKIPs, unchanged by the rebase.

The pick repro, driven the way the verify script drives it. The before side is origin/main's own ax-settings.swift, so it already carries #800's gate and the failure is this branch's to fix and nothing else's:

--- pick AI source -> Harness · claude ---
ax-settings: the AI source popup has no option Harness · claude
pick exit=2

After, on defa7c15:

--- pick AI source -> Harness · claude ---
pick exit=0
dump reads: AXPopUpButton|AI source|Harness · claude||true|false
--- pick back to Model API ---
pick exit=0
dump reads: AXPopUpButton|AI source|Model API||true|false

swiftc -O scripts/ax-settings.swift compiles clean with no warnings. pre-commit run --files scripts/ax-settings.swift passes, including the swiftc typecheck hook.

Notes

Step 7 artefact 1 moves but does not close. The webview run now reaches both AI-source states, which it never did before. All three runtime switches happen (Harness · claude, Model API, Harness · claude again), and the run ends on the same two Harness SKIPs as native, which the step 7 evidence comment named as the marker of actually getting there.

Re-measured on the rebased head, the webview run is 12 PASS / 2 SKIP / 6 FAIL / exit 1, against 9 / 0 / 5 in the step 7 evidence run. It read 11 / 2 / 7 when measured on the pre-#800 base earlier in this pull request; the one failure that went away between those two is could not dump the Presence tab, which is #800's gate doing its job and not this branch. FAIL is still higher than the original 5 because the run now travels further: every one of the 6 is row_live landing on WebKit's duplicated AXStaticText label node, and three of them sit in a block the original run never reached. That is cause 1, whose fix means changing the script's awk row addressing, which is yours to decide and out of scope here.

#634 may be the second repair above, not this one. #634 is a native pick Harness Off that exited 0 while a fresh dump still read claude, which is what reading a stale element after a rebuild looks like, and the closing check here was the only thing reading one. That is a hypothesis from the shape. It was not reproduced: #634 needs an attached Harness, and no Harness answered on this host.

Not verified anywhere in this change: Windows and Linux. ax-settings.swift is macOS-only.

Closes #797
Refs #706, #634, #779, #800

🤖 Generated with Claude Code

— Claude Code agent, on @omesser's behalf.

@omesser
omesser force-pushed the fix/settings-webview-select-popup branch from dabe2fd to d3e9282 Compare September 17, 2026 00:56
@omesser

omesser commented Sep 17, 2026

Copy link
Copy Markdown
Owner Author

Overlaps this change. I rebased #802 onto #800 and grafted the menu-layer race and type-select from here (the Mac-measured path), plus node/row_live tests this branch does not have.

If 802 looks right after review, this one can close as the duplicate. I am not closing it from here.

— Cursor agent (Coder), on @omesser's behalf.

omesser and others added 2 commits September 17, 2026 04:01
…blishes

The menu draws; accessibility never sees it. Measured in #797.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Comments only. No statement changed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

bug(verify): The webview AI source menu draws but ax-settings pick cannot see it

1 participant