fix(window): prevent hosts crashing when closing their own windows - #730
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:19 PM ET / 16:19 UTC (Revision 6). ClawSweeper reviewWhat this changesRuns host-owned window close, restore, maximize, and verification on MainActor, with a native regression fixture, CI completion checks, documentation, and updated CLI guidance tests. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main and v4.3.4 retain the crashing execution path. No actionable introduced defect was found, and the supplied native before/after evidence supports the repair. Priority: P2 Review scores
Verification
How this fits togetherPeekaboo’s shared window automation service receives exact-window requests from CLI and embedded hosts, validates the target, and invokes macOS Accessibility. It verifies the resulting window state before reporting completion. flowchart TD
A[Exact-window request] --> B[Validate window and process identity]
B --> C{Owned by this host?}
C -->|Yes| D[Main-thread Accessibility calls]
C -->|No| E[Detached calls with message deadlines]
D --> F[Verify exact window state]
E --> F
F --> G[Report action outcome]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep AppKit callbacks on the host’s main thread while preserving exact-window validation, remote AX deadlines, and native regression coverage. Do we have a high-confidence way to reproduce the issue? Yes: the native fixture invokes the public background-close service on a host-owned NSWindow with a MainActor-isolated delegate. Current main retains the detached dispatch, and the supplied before/after run reports the expected trap and recovery; this review did not execute it. Is this the best way to solve the issue? Yes: selecting the executor at the shared raw AX boundary is a narrow repair that preserves remote execution and existing target checks without adding a competing window-management path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6434b7852d16. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
PR SummaryMedium Risk Overview Adds an AppKit Docs and changelog describe the host vs remote routing split; doc tests accept Reviewed by Cursor Bugbot for commit b873bbc. Bugbot is set up for automated code reviews on this repo. Configure here. |
Fixes embedded macOS hosts crashing when background window automation closes one of their own windows. Same-process Accessibility calls synchronously invoke AppKit; running them from a detached task can trap an actor-isolated window delegate.
Host-owned AX lookup, close, restore, geometry, and close verification now run on MainActor. Other apps retain detached messaging, per-element deadlines, and exact-window/process-generation validation.
A dedicated AppKit child exercises the public close service, releases the target as a real window owner does, and checks main-actor delegate delivery, confirmed background completion, WindowServer disappearance, and sibling survival. The parent requires a successful exit plus an explicit completion marker; CI also requires suite and test-run completion, preventing early process exits from appearing green.
Direct macOS 27 proof: the same Developer ID-signed fixture ran under a sandbox protecting user configuration, preferences, Keychain services, and network access while participating in the normal Peekaboo coordination locks. Original dependency
44eff916exited with SIGTRAP and “Incorrect actor executor assumption”; the fixed source exited 0 withHOST_WINDOW_CLOSE_FIXTURE_COMPLETED. The fixture source was byte-identical in both builds.Production and test builds, SwiftLint, SwiftFormat, docs checks, and independent P0–P2 review pass. Final-head CI passed: macOS, full validation, and CodeQL. The full-safe lane completed 1,977 tests across 234 suites; the guarded native lane completed all 51 selected tests. OpenClaw integration is openclaw/openclaw#147114, pinned to the minimal runtime backport
13ffdea67297ba28adc53c2f83c394059322155e. The two modified production files match this repair exactly, and the backport source branch is retained while OpenClaw depends on it.The broader suite exposed stale guidance assertions from the already-merged skill update #729. The test-only repair recognizes the selected
"$PB"CLI alias, preserves exact-target and read-only requirements, and removes the obsolete requirement to list a clipboard example. All 12 guidance tests pass.