Skip to content

Mac tools never read or drive the agent's own app - #131

Merged
ayman3000 merged 3 commits into
mainfrom
mac-never-drive-own-app
Oct 7, 2026
Merged

ayman3000 merged 3 commits into
mainfrom
mac-never-drive-own-app

Conversation

@ayman3000

Copy link
Copy Markdown
Owner

Fixes a crash in Naseem 1.18.0. mac_ui snapshotted Naseem's own window from the AXClient actor. Accessibility answers an in-process call on the calling thread, so the app's SwiftUI views, including a SwiftData @Query, updated off the main thread, and dispatch_assert_queue trapped. The stack in the crash report was AXClient.snapshot → AXUIElementCopyAttributeValue → NSHostingView.accessibilityChildren → _SwiftData_SwiftUI → _dispatch_assert_queue_fail.

  • AppResolver.pid(forBundleId:) skips the own process. If another copy with the same bundle id is running, such as a Debug build beside the installed app, it is a separate process and is still used.
  • resolvePid throws own_app ("…can't be read or controlled from inside itself. Answer in the chat instead."), which covers every AXClient entry point.
  • runningApps() leaves out the own app, and launch no longer waits on its own windows.
  • Tests: testOwnProcessIsNeverTheTarget, testDrivingTheOwnAppIsRefusedWithAClearMessage. SwiftAgentKitMacTests: 77 tests, 0 failures.

🤖 Generated with Claude Code

ayman3000 and others added 3 commits October 8, 2026 00:24
Accessibility answers a call into the calling process on the calling
thread, so snapshotting the agent's own window from the AXClient actor
ran its SwiftUI views (and a SwiftData @query) off the main thread and
trapped — Naseem 1.18.0 crashed this way. The own process is now never a
target: another copy with the same bundle id is used if one runs,
otherwise an own_app error tells the model to answer in the chat. The
own app is also left out of the running-apps list.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The cancel-during-wait test raced a 50 ms timer against a 300 ms wait and
failed on slow CI runners (red on main since #129).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ayman3000
ayman3000 merged commit a4f7a55 into main Oct 7, 2026
1 check passed
@ayman3000
ayman3000 deleted the mac-never-drive-own-app branch October 7, 2026 21:49
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