Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix: notify on AI fallback
altic-dev8ea0deef7e29
diff --git a/Sources/Fluid/AppDelegate.swift b/Sources/Fluid/AppDelegate.swiftindex aaa0261f..d1f1e4cd 100644--- a/Sources/Fluid/AppDelegate.swift+++ b/Sources/Fluid/AppDelegate.swift@@ -8,14 +8,16 @@import AppKitimport PromiseKitimport SwiftUI+import UserNotifications-class AppDelegate: NSObject, NSApplicationDelegate {+class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {private var updateCheckTimer: Timer?func applicationDidFinishLaunching(_ notification: Notification) {// Bring up file logging + crash handlers immediately during launch._ = FileLogger.sharedDebugLogger.shared.info("Application launched", source: "AppDelegate")+ UNUserNotificationCenter.current().delegate = self// Initialize app settings (dock visibility, etc.)SettingsStore.shared.initializeAppSettings()@@ -76,6 +78,30 @@ class AppDelegate: NSObject, NSApplicationDelegate {return true}+ func userNotificationCenter(+ _ center: UNUserNotificationCenter,+ willPresent notification: UNNotification,+ withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void+ ) {+ completionHandler([.banner, .list])+ }++ func userNotificationCenter(+ _ center: UNUserNotificationCenter,+ didReceive response: UNNotificationResponse,+ withCompletionHandler completionHandler: @escaping () -> Void+ ) {+ let userInfo = response.notification.request.content.userInfo+ if userInfo[NotificationService.UserInfoKey.kind] as? String == NotificationService.Kind.aiProcessingFallback {+ DispatchQueue.main.async {+ AppNavigationRouter.shared.request(.history)+ self.bringMainWindowToFront()+ }+ }++ completionHandler()+ }+private func forceFrontOnLaunch() {// Login-item launches can take longer before SwiftUI's main window exists.// Keep retrying for a few seconds so the existing ContentView startup path runs.diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex ca9ac727..dbbbea9a 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -254,6 +254,7 @@ struct ContentView: View {let isOnboarded = self.asr.isAsrReady || self.asr.modelsExistOnDiskself.selectedSidebarItem = isOnboarded ? .preferences : .welcome}+ self.handlePendingAppNavigation()// Reset auto-restart flag if permission was revoked (allows re-triggering if user re-grants)if !self.accessibilityEnabled {@@ -605,6 +606,9 @@ struct ContentView: View {.onReceive(NotificationCenter.default.publisher(for: .openCustomDictionaryFromVoiceEngine)) { _ inself.selectedSidebarItem = .customDictionary}+ .onReceive(NotificationCenter.default.publisher(for: .appNavigationRequested)) { _ in+ self.handlePendingAppNavigation()+ }.onReceive(NotificationCenter.default.publisher(for: .settingsBackupDidRestore)) { _ inself.reloadSettingsStateAfterBackupRestore()}@@ -797,6 +801,15 @@ struct ContentView: View {}}+ private func handlePendingAppNavigation() {+ guard let destination = AppNavigationRouter.shared.consumePendingDestination() else { return }++ switch destination {+ case .history:+ self.selectedSidebarItem = .history+ }+ }+private func resetPendingShortcutState() {self.currentRecordingModifierKeyCodes = []self.pendingModifierKeyCodes = []@@ -1883,6 +1896,7 @@ struct ContentView: View {source: "ContentView")aiFallbackReason = error.localizedDescription+ NotificationService.showAIProcessingFallback(error: error.localizedDescription)finalText = transcribedText}let postProcessingLatencyMs = Int((Date().timeIntervalSince(postProcessingStart) * 1000).rounded())@@ -2170,6 +2184,7 @@ struct ContentView: View {source: "ContentView")aiFallbackReason = error.localizedDescription+ NotificationService.showAIProcessingFallback(error: error.localizedDescription)finalText = transcribedText}}diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex 5a963e97..2d3c1409 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -2157,6 +2157,18 @@ final class SettingsStore: ObservableObject {}}+ /// Whether to show a native notification when AI post-processing fails and raw text is used+ var notifyAIProcessingFailures: Bool {+ get {+ let value = self.defaults.object(forKey: Keys.notifyAIProcessingFailures)+ return value as? Bool ?? true+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.notifyAIProcessingFailures)+ }+ }+func makeBackupPayload() -> SettingsBackupPayload {SettingsBackupPayload(selectedProviderID: self.selectedProviderID,@@ -3585,6 +3597,7 @@ private extension SettingsStore {// Stats Keysstatic let userTypingWPM = "UserTypingWPM"static let saveTranscriptionHistory = "SaveTranscriptionHistory"+ static let notifyAIProcessingFailures = "NotifyAIProcessingFailures"// Filler Wordsstatic let fillerWords = "FillerWords"diff --git a/Sources/Fluid/Services/AppNavigationRouter.swift b/Sources/Fluid/Services/AppNavigationRouter.swiftnew file mode 100644index 00000000..7d49bce9--- /dev/null+++ b/Sources/Fluid/Services/AppNavigationRouter.swift@@ -0,0 +1,28 @@+import Foundation++enum AppNavigationDestination {+ case history+}++final class AppNavigationRouter {+ static let shared = AppNavigationRouter()++ private var pendingDestination: AppNavigationDestination?++ private init() {}++ func request(_ destination: AppNavigationDestination) {+ self.pendingDestination = destination+ NotificationCenter.default.post(name: .appNavigationRequested, object: nil)+ }++ func consumePendingDestination() -> AppNavigationDestination? {+ let destination = self.pendingDestination+ self.pendingDestination = nil+ return destination+ }+}++extension Notification.Name {+ static let appNavigationRequested = Notification.Name("AppNavigationRequested")+}diff --git a/Sources/Fluid/Services/NotificationService.swift b/Sources/Fluid/Services/NotificationService.swiftnew file mode 100644index 00000000..8beee2e9--- /dev/null+++ b/Sources/Fluid/Services/NotificationService.swift@@ -0,0 +1,66 @@+import Foundation+import UserNotifications++enum NotificationService {+ enum UserInfoKey {+ static let kind = "kind"+ }++ enum Kind {+ static let aiProcessingFallback = "aiProcessingFallback"+ }++ static func showAIProcessingFallback(error: String) {+ guard SettingsStore.shared.notifyAIProcessingFailures else { return }++ let center = UNUserNotificationCenter.current()+ center.getNotificationSettings { settings in+ switch settings.authorizationStatus {+ case .authorized, .provisional, .ephemeral:+ self.deliverAIProcessingFallback(error: error, using: center)+ case .notDetermined:+ center.requestAuthorization(options: [.alert, .sound]) { granted, requestError in+ if let requestError {+ DebugLogger.shared.warning(+ "Notification permission request failed: \(requestError.localizedDescription)",+ source: "NotificationService"+ )+ }+ guard granted else { return }+ self.deliverAIProcessingFallback(error: error, using: center)+ }+ case .denied:+ DebugLogger.shared.debug(+ "Skipping AI fallback notification because notification permission is denied",+ source: "NotificationService"+ )+ @unknown default:+ break+ }+ }+ }++ private static func deliverAIProcessingFallback(error: String, using center: UNUserNotificationCenter) {+ let content = UNMutableNotificationContent()+ content.title = "AI cleanup failed"+ content.body = "Typed raw transcription instead."+ content.subtitle = error+ content.sound = nil+ content.userInfo = [UserInfoKey.kind: Kind.aiProcessingFallback]++ let request = UNNotificationRequest(+ identifier: "ai-cleanup-fallback-\(UUID().uuidString)",+ content: content,+ trigger: nil+ )++ center.add(request) { addError in+ if let addError {+ DebugLogger.shared.warning(+ "Failed to show AI fallback notification: \(addError.localizedDescription)",+ source: "NotificationService"+ )+ }+ }+ }+}diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex 22d09f88..790bd987 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -816,6 +816,16 @@ struct SettingsView: View {)Divider().opacity(0.2)+ self.optionToggleRow(+ title: "Notify AI Cleanup Failures",+ description: "Show a macOS notification when AI cleanup fails and raw transcription is typed.",+ isOn: Binding(+ get: { SettingsStore.shared.notifyAIProcessingFailures },+ set: { SettingsStore.shared.notifyAIProcessingFailures = $0 }+ )+ )+ Divider().opacity(0.2)+self.optionToggleRow(title: "Weekends Don't Break Streak",description: "Skip Saturday and Sunday when calculating usage streaks. Perfect for weekday-only users.",