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(