From 8597406898f0a5dc95b9ca89f32518dcf647d8fc Mon Sep 17 00:00:00 2001 From: Natalie Date: Tue, 30 Jun 2026 03:41:59 -0400 Subject: [PATCH] fix(inotes): probe Notes with a data event so the Automation prompt fires MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tell application "Notes" to get name` resolves the app's bundle name WITHOUT sending an Apple event, so it never triggers the TCC Automation prompt — Notes stayed ungranted and unsynced while Messages (granted via a real data event) worked. Probe with `count notes`, a real automation event, in both the inotes authorization cycle (auto, no menu click) and the tray "Grant Automation" item (now data-reading per app: chats/accounts/notes). Co-Authored-By: Claude Opus 4.8 --- @packages/inotes/Sources/INoteSync/Reader.swift | 7 ++++++- src/client/MacSyncApp.swift | 13 ++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/@packages/inotes/Sources/INoteSync/Reader.swift b/@packages/inotes/Sources/INoteSync/Reader.swift index af7b29f..05c0cab 100644 --- a/@packages/inotes/Sources/INoteSync/Reader.swift +++ b/@packages/inotes/Sources/INoteSync/Reader.swift @@ -57,7 +57,12 @@ public final class NotesReader { /// System Settings → Privacy & Security → Automation. We prime the /// prompt with a trivial script; if it fails we mark unauthorized. public func requestAuthorization() async -> Bool { - let probe = "tell application \"Notes\" to get name" + // Probe with a command that actually reads Notes data. `get name` returns + // the app's bundle name WITHOUT sending an Apple event to Notes, so it never + // triggers the TCC Automation prompt — the bug that left Notes ungranted and + // unsynced. `count notes` sends a real automation event, surfacing the prompt + // and registering MacSync → Notes. + let probe = "tell application \"Notes\" to count notes" let (ok, _) = await runAppleScript(probe) isAuthorized = ok if !ok { diff --git a/src/client/MacSyncApp.swift b/src/client/MacSyncApp.swift index 700f512..03a40db 100644 --- a/src/client/MacSyncApp.swift +++ b/src/client/MacSyncApp.swift @@ -484,10 +484,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate { // pane — the bug that left Notes/Mail ungranted while Messages worked. Sending // one harmless event per app registers MacSync against each independently and // surfaces each first-time "Allow" prompt regardless of the others' outcome. - for app in ["Messages", "Mail", "Notes"] { + // Each probe must send a REAL Apple event (read data) to surface the + // Automation prompt. `get name` resolves from the app bundle without an + // event, so it never registers the app — use a data-reading command. + let probes = [ + ("Messages", "tell application \"Messages\" to count chats"), + ("Mail", "tell application \"Mail\" to count accounts"), + ("Notes", "tell application \"Notes\" to count notes"), + ] + for (app, source) in probes { var errorInfo: NSDictionary? - _ = NSAppleScript(source: "tell application \"\(app)\" to get name")? - .executeAndReturnError(&errorInfo) + _ = NSAppleScript(source: source)?.executeAndReturnError(&errorInfo) if let err = errorInfo { NSLog("MacSync: automation probe \(app) error=\(err)") } } NSWorkspace.shared.open(