fix(inotes): probe Notes with a data event so the Automation prompt fires
`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 <noreply@anthropic.com>
This commit is contained in:
parent
90014f5dd3
commit
8597406898
2 changed files with 16 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue