From d4dc837d9fdb376db0c46963bded86125eb80786 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 18 Nov 2025 16:01:37 -0800 Subject: [PATCH] Fix various concurrency issues. --- Mac/AppDelegate.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index e74c0592d..36fbd2362 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -454,9 +454,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { - let userInfo = response.notification.request.content.userInfo + // Wrapper to safely transfer non-Sendable values to MainActor + struct UnsafeSendable: @unchecked Sendable { + let value: T + } + + let wrappedResponse = UnsafeSendable(value: response) + let wrappedCompletionHandler = UnsafeSendable(value: completionHandler) Task { @MainActor in + let response = wrappedResponse.value + let userInfo = response.notification.request.content.userInfo + switch response.actionIdentifier { case UserNotificationManager.ActionIdentifier.markAsRead: handleMarkAsRead(userInfo: userInfo) @@ -465,7 +474,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat default: mainWindowController?.handle(response) } - completionHandler() + wrappedCompletionHandler.value() } }