diff --git a/oAI/Services/AppleMailService.swift b/oAI/Services/AppleMailService.swift index 0db045b..af42420 100644 --- a/oAI/Services/AppleMailService.swift +++ b/oAI/Services/AppleMailService.swift @@ -61,7 +61,9 @@ final class AppleMailService { /// the Apple-Events equivalent of `EKEventStore.authorizationStatus(for:)`, reusing the same /// `PersonalDataAccessState` enum EventKitService/ContactsService/LocationMapsService use. var accessState: PersonalDataAccessState { - Self.mapAutomationPermissionStatus(Self.checkMailAutomationPermission(askUserIfNeeded: false)) + let status = Self.checkMailAutomationPermission(askUserIfNeeded: false) + Log.mail.debug("accessState: AEDeterminePermissionToAutomateTarget(askUserIfNeeded: false) returned \(status)") + return Self.mapAutomationPermissionStatus(status) } /// Pure mapping from an `AEDeterminePermissionToAutomateTarget` status code to the shared @@ -75,16 +77,18 @@ final class AppleMailService { } /// Triggers the real macOS "Confab wants to control Mail" Automation permission prompt if - /// the user hasn't been asked yet (a no-op if already granted or denied). Blocks until the - /// user responds, so this must run off the main thread. + /// the user hasn't been asked yet (a no-op if already granted or denied). Deliberately NOT + /// dispatched to the background `queue` used for AppleScript execution — the system consent + /// prompt needs to be raised from the main thread/run loop to actually display (same as this + /// codebase's existing blocking `NSAlert.runModal()` calls); calling it off-main appears to + /// silently fail (no dialog, no error, no state change — the exact symptom Rune hit live). + /// `AppleMailService` has no explicit actor annotation, so under this project's + /// `-default-isolation=MainActor` build setting this method already runs on the main actor. @discardableResult func requestAccess() async -> Bool { - await withCheckedContinuation { continuation in - queue.async { - let status = Self.checkMailAutomationPermission(askUserIfNeeded: true) - continuation.resume(returning: status == 0) - } - } + let status = Self.checkMailAutomationPermission(askUserIfNeeded: true) + Log.mail.info("requestAccess: AEDeterminePermissionToAutomateTarget(askUserIfNeeded: true) returned \(status)") + return status == 0 } private static func checkMailAutomationPermission(askUserIfNeeded: Bool) -> OSStatus {