Skip to content

fix(scripts): Gate tab and pick on the webview settle, not just dump - #800

Merged
omesser merged 1 commit into
mainfrom
fix/779-settle-gate-on-tab-and-pick
Sep 17, 2026
Merged

omesser merged 1 commit into
mainfrom
fix/779-settle-gate-on-tab-and-pick

Conversation

@omesser

@omesser omesser commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Why

A WKWebView publishes its accessibility subtree only when a client asks for it, and the real children land about 107 ms after the first ask. #779 taught scripts/ax-settings.swift to wait for that, but it defined webContentSettled inside the case "dump": block, so only dump got the gate. tab and pick walk the same subtree and had none.

Measured on AI_BUDDY_SETTINGS_WEBVIEW=1, five app launches each, before this change:

tab Presence on a freshly opened window .... failed 4 of 5
pick after close-and-reopen ................ lost the popup scan 5 of 5

Both die because find and scan walk a window whose content view is still a childless AXGroup. tab Presence is the first thing scripts/verify-settings-macos.sh does after opening Settings, which is why the step 7 run in #706 reported could not dump the Presence tab.

What changed

webContentSettled moves out of the dump block to file scope, unchanged, and a new settledWindow(titled:) pairs it with the existing waitFor. tab, pick and dump all resolve their window through it.

Hoisted rather than copied into each block, so the wait has one definition and one timeout. open and frame keep the ungated settingsWindow(): open presses the tray status item and waits for the window to exist, frame reads the window rectangle, and neither descends into web content. open succeeded on all 40 invocations across these runs, before and after.

Out of scope: scripts/verify-settings-macos.sh is untouched, and so are the dump line format, the depth bound, and every other subcommand's behaviour.

How to verify

swiftc -O scripts/ax-settings.swift is clean with no warnings, and pre-commit run --files scripts/ax-settings.swift passes.

The two reproductions, same trees, after this change:

tab Presence on a freshly opened window .... failed 0 of 5
pick after close-and-reopen ................ lost the popup scan 0 of 5

scripts/verify-settings-macos.sh unmodified against the native Settings window holds its baseline: 18 PASS, 2 SKIP, 0 FAIL, exit 0.

The same script unmodified with AI_BUDDY_SETTINGS_WEBVIEW=1 moves from 9 PASS / 0 SKIP / 5 FAIL to 10 PASS / 0 SKIP / 4 FAIL, exit 1 either way. Both sides were run here on the same tree, and the before reproduces the step 7 figures on #706 exactly. The after is identical on two consecutive runs. tab Presence dumped is the check that flipped.

Notes

The webview run is still red, and this change was never going to make it green. Two of the three causes in the step 7 comment on #706 are untouched:

  • Three should be editable failures. WebKit publishes <label for=…> as two consecutive AXStaticText nodes, so the script's "the control is the next line after the label" rule lands on the duplicate. That is row addressing in verify-settings-macos.sh, which this pull request deliberately does not touch.
  • could not pick Harness · claude. The <select> options are not in the accessibility tree at all, anywhere under the application element. The gate is visible in the failure that moved one stage later: pick now finds and presses the popup and fails on the option search, where before the reopen it never found the popup. The Harness half of the script is still unreached, and this is the same shape as macOS Settings Off pick does not leave the Harness popup #634.

One correction to the step 7 write-up. It recorded that accessibility priming is per client process. It is not: tab AI in one process primed the tree for a pick in the next. What does tear the subtree down is the close-and-reopen, which is why pick needs its own gate rather than inheriting one from an earlier command.

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

🤖 Generated with Claude Code

#779 defined webContentSettled inside the dump block. tab and pick walk
the same WKWebView subtree and raced its priming.

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.

1 participant