Skip to content

fix(desktop): restore macOS WebView self-control - #3600

Merged
bobleer merged 9 commits into
openBitFun:mainfrom
bobleer:bob/fix-macos-self-ax-deadlock
Oct 29, 2026
Merged

bobleer merged 9 commits into
openBitFun:mainfrom
bobleer:bob/fix-macos-self-ax-deadlock

Conversation

@bobleer

@bobleer bobleer commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fix macOS Desktop freezing when ComputerUse observes its own OpenBitFun window. The old wrapper ran the entire accessibility walk on main; WebKit accessibility IPC then waited for the same thread. Individual messages now use the element's serving process: same-process AppKit calls run on main, while WebKit/external calls remain on the blocking worker. Observation, cached-node actions, hit testing, text operations and menu discovery share this routing.

Preserve the control token across dispatch and recheck it on the executing thread before native actions or user attribute writes, so Stop rejects stale queued input. Add a real same-process AppKit/WKWebView regression covering reads, geometry, screenshot, exactly one activation per image/node click, exact Unicode text with independent DOM feedback, shortcuts and stopped-input rejection, with an external deadlock watchdog.

Cross-process AX proxies also advertise AXSelectedText as writable even when the setter is a no-op. Choose the existing directed-keyboard route before submitting text for these proxies, while native controls retain selection-preserving AX insertion. The new fixture reproduced the empty DOM value before this correction and verifies the actual input afterward.

Test-only commits align scripted mock-model HTTP cleanup with the existing streaming fixture: a client disconnect after the completed SSE payload must not panic the server and strand subsequent requests (observed Windows error 10053). Payload writes and test deadlines remain checked.

Type and Areas

Bug fix; macOS desktop ComputerUse adapter, native regression fixtures, and mock-model stream cleanup.

Motivation / Impact

Two reported runs stopped at get_app_state(OpenBitFun). The macOS hang report showed the main-thread AX call and WebKit's synchronous reply wait. Self-control remains supported without blocking the UI event loop.

Verification

  • PASS: final head d959e7835740ae2c72f45c9d71b01865f499edff CI run: 11 checks passed; 2 jobs skipped by impact selection.

  • PASS: pnpm run fmt:rs and git diff --check.

  • PASS: node scripts/test-macos-computer-use-self.mjs on macOS 15.7.3, including image/node click counts, exact Unicode DOM content and final stale-input rejection. AX-only read ~252 ms; screenshot observation ~411 ms.

  • PASS: cargo check --locked -p openbitfun-desktop --features devtools for the routing change; final head also covered by CI.

  • PASS: pnpm run check:core-boundaries.

  • Actual development-app logs also show two completed same-process observations after rebuilding: 46 and 70 nodes in approximately 79 ms and 74 ms. The previously hanging path returned in both cases.

  • PASS: pnpm --dir src/web-ui run test:run src/app/components/NavPanel/unifiedSessionCreation.test.ts (9 tests).

  • INCONCLUSIVE: existing node scripts/test-macos-control-roundtrip.mjs reached observation/click checks, but the foreground changed from its disposable observer to WeChat and its focus invariant failed. The user confirmed they were operating the computer during the run. This is not recorded as a passing cross-app run.

  • PASS: cargo test --locked -p openbitfun-cli --test terminal_process_contracts scheduled_jobs_ (real CLI process restart, persisted job restoration and unattended one-shot execution; 3.04 s on macOS). Windows execution is covered by CI.

  • Native runtime evidence is local macOS only. Remote workspace, remote control, Peer Device Mode and Detached Dispatch were not exercised; no wire or persisted schemas changed.

Reviewer Notes

AI-assisted; locally tested with a real native WebView fixture. AXUIElementGetPid can report the presenting app for WebKit proxies, so routing dynamically resolves _AXUIElementGetActualPid while authorization keeps the presenting PID. Missing routing SPI returns an explicit AX_DISPATCH_UNAVAILABLE state. Objective-C exceptions are caught on the executing thread. Enigo/HIToolbox input keeps its main-thread wrapper. WebKit's AX base object declares an empty selected-text setter; fallback is chosen before mutation and never retries an uncertain write.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@bobleer bobleer changed the title fix(desktop): prevent macOS self-control accessibility deadlocks fix(desktop): restore macOS WebView self-control Oct 29, 2026
@bobleer
bobleer merged commit 91eeba6 into openBitFun:main Oct 29, 2026
13 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.

1 participant