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: unload private AI on quit
altic-deve48efdd7a7c9
diff --git a/Sources/Fluid/AppDelegate.swift b/Sources/Fluid/AppDelegate.swiftindex a7420393..c745f004 100644--- a/Sources/Fluid/AppDelegate.swift+++ b/Sources/Fluid/AppDelegate.swift@@ -64,12 +64,33 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelefunc applicationWillTerminate(_ notification: Notification) {DebugLogger.shared.info("Application will terminate", source: "AppDelegate")+ self.shutdownPrivateAIRuntimeForTermination()LocalAPIServer.shared.stop()// Clean up the update check timerself.updateCheckTimer?.invalidate()self.updateCheckTimer = nil}+ private func shutdownPrivateAIRuntimeForTermination() {+ var didFinishShutdown = false+ Task { @MainActor in+ await PrivateAIIntegrationService.shared.shutdownForTermination()+ didFinishShutdown = true+ }++ let deadline = Date().addingTimeInterval(8)+ while !didFinishShutdown, Date() < deadline {+ RunLoop.current.run(mode: .default, before: Date().addingTimeInterval(0.01))+ }++ if !didFinishShutdown {+ DebugLogger.shared.warning(+ "Timed out waiting for private AI runtime shutdown during termination",+ source: "AppDelegate"+ )+ }+ }+func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {if self.shouldSuppressNextReopenActivation {self.shouldSuppressNextReopenActivation = falsediff --git a/Sources/Fluid/Services/PrivateAIIntegrationService.swift b/Sources/Fluid/Services/PrivateAIIntegrationService.swiftindex 28c64764..3df09b23 100644--- a/Sources/Fluid/Services/PrivateAIIntegrationService.swift+++ b/Sources/Fluid/Services/PrivateAIIntegrationService.swift@@ -148,6 +148,10 @@ actor PrivateAIIntegrationService {await Self.provider.unloadCachedRuntime(reason: reason)}+ func shutdownForTermination() async {+ await Self.provider.shutdownForTermination()+ }+func enhanceDictation(_ inputText: String,runtime: RuntimeConfiguration,diff --git a/Sources/Fluid/Services/PrivateAIProvider.swift b/Sources/Fluid/Services/PrivateAIProvider.swiftindex 91c701fc..17d02eb6 100644--- a/Sources/Fluid/Services/PrivateAIProvider.swift+++ b/Sources/Fluid/Services/PrivateAIProvider.swift@@ -152,6 +152,7 @@ protocol PrivateAIIntegrationProviding: Sendable {func loadModel(_ model: PrivateAIRegisteredModel) async throws -> PrivateAIStatusfunc prewarmDictation() asyncfunc unloadCachedRuntime(reason: String) async+ func shutdownForTermination() asyncfunc enhanceDictation(_ inputText: String,runtime: PrivateAIIntegrationService.RuntimeConfiguration,@@ -168,6 +169,10 @@ extension PrivateAIIntegrationProviding {/// (the local FluidIntelligence bridge) override this to load and prime the/// dictation runtime ahead of the first request.func prewarmDictation() async {}++ func shutdownForTermination() async {+ await self.unloadCachedRuntime(reason: "termination")+ }}enum PrivateAIProviderRegistry {