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: prompt for 1.6.3 mlx upgrade
altic-dev39fc915d4f01
diff --git a/Sources/Fluid/AppDelegate.swift b/Sources/Fluid/AppDelegate.swiftindex d1b89205..82e9bf45 100644--- a/Sources/Fluid/AppDelegate.swift+++ b/Sources/Fluid/AppDelegate.swift@@ -17,6 +17,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDeleprivate var didRequestMainWindowReopen = falseprivate var shouldSuppressNextReopenActivation = falseprivate var wasLaunchedAsLoginItem = false+ private var hasDeferredMLXUpgradeOffer = falsefunc applicationDidFinishLaunching(_ notification: Notification) {// Bring up file logging + crash handlers immediately during launch.@@ -32,6 +33,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele// Initialize app settings (dock visibility, etc.)SettingsStore.shared.initializeAppSettings()+ let shouldOfferMLXUpgrade = PrivateAIMLXUpgradeCoordinator.prepareOfferIfNeeded()LocalAPIServer.shared.start()// Record first-open synchronously before async analytics bootstrap so@@ -58,6 +60,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele// Login Items can launch hidden; reveal the real SwiftUI window so ContentView startup runs.self.openMainWindowOnLaunch()+ if shouldOfferMLXUpgrade {+ if self.wasLaunchedAsLoginItem, !SettingsStore.shared.showMainWindowAtLoginLaunch {+ self.hasDeferredMLXUpgradeOffer = true+ } else {+ self.scheduleMLXUpgradeOffer()+ }+ }+// Note: App UI is designed with dark color scheme in mind// All gradients and effects are optimized for dark mode}@@ -124,6 +134,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelereturn !self.bringMainWindowToFrontIfPresent()}+ func applicationDidBecomeActive(_ notification: Notification) {+ guard self.hasDeferredMLXUpgradeOffer else { return }+ self.hasDeferredMLXUpgradeOffer = false+ self.scheduleMLXUpgradeOffer()+ }+func userNotificationCenter(_ center: UNUserNotificationCenter,willPresent notification: UNNotification,@@ -205,6 +221,30 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele}}+ private func scheduleMLXUpgradeOffer() {+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) { [weak self] in+ self?.showMLXUpgradeOffer()+ }+ }++ @MainActor+ private func showMLXUpgradeOffer() {+ let alert = NSAlert()+ alert.messageText = "Fluid-1 is now 2.2x faster"+ alert.informativeText = "A new 3.77 GB MLX model is available for Apple silicon. Continue to AI Enhancement to download and verify it. Your current slower model will keep working unless you choose to upgrade."+ alert.alertStyle = .informational+ alert.addButton(withTitle: "Continue to Download")+ alert.addButton(withTitle: "Keep Current Model")++ if alert.runModal() == .alertFirstButtonReturn {+ PrivateAIMLXUpgradeCoordinator.beginUpgrade()+ AppNavigationRouter.shared.request(.aiEnhancements)+ self.bringMainWindowToFront()+ } else {+ PrivateAIMLXUpgradeCoordinator.keepCurrentModel()+ }+ }+/// Realize the main window invisibly so ContentView's startup runs, then order it out./// Used for login-item launches when "Show window when launched at login" is off.@discardableResultdiff --git a/Sources/Fluid/Services/PrivateAIIntegrationService.swift b/Sources/Fluid/Services/PrivateAIIntegrationService.swiftindex 489046e6..ec4f6347 100644--- a/Sources/Fluid/Services/PrivateAIIntegrationService.swift+++ b/Sources/Fluid/Services/PrivateAIIntegrationService.swift@@ -1,5 +1,188 @@import Foundation+enum PrivateAIMLXUpgradeCoordinator {+ private static let offerVersion = "1.6.3"+ private static let offerHandledKey = "FluidIntelligenceMLXUpgrade163OfferHandled"+ private static let offerPreparedKey = "FluidIntelligenceMLXUpgrade163OfferPrepared"+ private static let upgradePendingKey = "FluidIntelligenceMLXUpgrade163Pending"+ private static let previousVerificationKey = "FluidIntelligenceMLXUpgrade163PreviousVerification"+ private static let legacyLlamaFilenames = ["fluid-1-q4_k_m.gguf", "Fluid-1-Q4_K_M.gguf"]++ static func prepareOfferIfNeeded(+ settings: SettingsStore = .shared,+ defaults: UserDefaults = .standard,+ modelDirectoryURL: URL = PrivateAIIntegrationService.modelDirectoryURL,+ isAppleSilicon: Bool = CPUArchitecture.isAppleSilicon,+ appVersion: String = Bundle.main.object(+ forInfoDictionaryKey: "CFBundleShortVersionString"+ ) as? String ?? ""+ ) -> Bool {+ if defaults.bool(forKey: self.upgradePendingKey) {+ self.restorePreviousLlama(settings: settings, defaults: defaults)+ return false+ }++ guard appVersion == self.offerVersion else {+ defaults.set(false, forKey: self.offerPreparedKey)+ return false+ }++ if defaults.bool(forKey: self.offerPreparedKey),+ !defaults.bool(forKey: self.offerHandledKey)+ {+ let rawBackend = defaults.string(forKey: SettingsStore.privateAIBackendPreferenceDefaultsKey)+ guard self.shouldResumePreparedOffer(+ hasPrivateProvider: PrivateFeatures.privateAIProvider,+ isAppleSilicon: isAppleSilicon,+ appVersion: appVersion,+ backendPreference: rawBackend.flatMap(SettingsStore.PrivateAIBackendPreference.init(rawValue:)),+ hasLegacyLlamaModel: self.hasLegacyLlamaModel(in: modelDirectoryURL),+ hasMLXModel: PrivateAIIntegrationService.hasInactiveInstalledModel(+ keeping: PrivateAIModelRegistry.defaultModel+ )+ ) else {+ defaults.set(false, forKey: self.offerPreparedKey)+ return false+ }++ settings.privateAIBackendPreference = .llama+ self.migrateLegacyVerificationToLlama(settings: settings)+ return true+ }++ guard self.shouldOffer(+ hasPrivateProvider: PrivateFeatures.privateAIProvider,+ isAppleSilicon: isAppleSilicon,+ appVersion: appVersion,+ backendPreferenceWasSet: defaults.object(+ forKey: SettingsStore.privateAIBackendPreferenceDefaultsKey+ ) != nil,+ hasLegacyLlamaModel: self.hasLegacyLlamaModel(in: modelDirectoryURL),+ hasMLXModel: PrivateAIIntegrationService.isModelInstalled(PrivateAIModelRegistry.defaultModel),+ offerWasHandled: defaults.bool(forKey: self.offerHandledKey)+ ) else {+ return false+ }++ settings.privateAIBackendPreference = .llama+ self.migrateLegacyVerificationToLlama(settings: settings)+ defaults.set(true, forKey: self.offerPreparedKey)+ return true+ }++ static func beginUpgrade(+ settings: SettingsStore = .shared,+ defaults: UserDefaults = .standard+ ) {+ let key = self.privateProviderKey+ if let verification = settings.verifiedProviderFingerprints[key] {+ defaults.set(verification, forKey: self.previousVerificationKey)+ } else {+ defaults.removeObject(forKey: self.previousVerificationKey)+ }++ defaults.set(true, forKey: self.offerHandledKey)+ defaults.set(false, forKey: self.offerPreparedKey)+ defaults.set(true, forKey: self.upgradePendingKey)+ settings.privateAIBackendPreference = .mlx+ settings.verifiedProviderFingerprints.removeValue(forKey: key)+ defaults.removeObject(forKey: PrivateAIIntegrationService.localModelPathDefaultsKey)+ }++ static func keepCurrentModel(defaults: UserDefaults = .standard) {+ defaults.set(true, forKey: self.offerHandledKey)+ defaults.set(false, forKey: self.offerPreparedKey)+ defaults.set(false, forKey: self.upgradePendingKey)+ defaults.removeObject(forKey: self.previousVerificationKey)+ }++ static func completeUpgrade(defaults: UserDefaults = .standard) {+ defaults.set(false, forKey: self.upgradePendingKey)+ defaults.removeObject(forKey: self.previousVerificationKey)+ }++ static func restorePreviousLlama(+ settings: SettingsStore = .shared,+ defaults: UserDefaults = .standard+ ) {+ settings.privateAIBackendPreference = .llama+ var fingerprints = settings.verifiedProviderFingerprints+ if let verification = defaults.string(forKey: self.previousVerificationKey), !verification.isEmpty {+ fingerprints[self.privateProviderKey] = verification+ } else {+ fingerprints.removeValue(forKey: self.privateProviderKey)+ }+ settings.verifiedProviderFingerprints = fingerprints+ defaults.set(false, forKey: self.upgradePendingKey)+ defaults.removeObject(forKey: self.previousVerificationKey)+ defaults.removeObject(forKey: PrivateAIIntegrationService.localModelPathDefaultsKey)+ }++ static func isUpgradePending(defaults: UserDefaults = .standard) -> Bool {+ defaults.bool(forKey: self.upgradePendingKey)+ }++ static func shouldOffer(+ hasPrivateProvider: Bool,+ isAppleSilicon: Bool,+ appVersion: String,+ backendPreferenceWasSet: Bool,+ hasLegacyLlamaModel: Bool,+ hasMLXModel: Bool,+ offerWasHandled: Bool+ ) -> Bool {+ hasPrivateProvider &&+ isAppleSilicon &&+ appVersion == self.offerVersion &&+ !backendPreferenceWasSet &&+ hasLegacyLlamaModel &&+ !hasMLXModel &&+ !offerWasHandled+ }++ static func shouldResumePreparedOffer(+ hasPrivateProvider: Bool,+ isAppleSilicon: Bool,+ appVersion: String,+ backendPreference: SettingsStore.PrivateAIBackendPreference?,+ hasLegacyLlamaModel: Bool,+ hasMLXModel: Bool+ ) -> Bool {+ hasPrivateProvider &&+ isAppleSilicon &&+ appVersion == self.offerVersion &&+ backendPreference == .llama &&+ hasLegacyLlamaModel &&+ !hasMLXModel+ }++ private static var privateProviderKey: String {+ let providerID = PrivateAIProviderFeature.shared.providerID+ if ModelRepository.shared.isBuiltIn(providerID) || providerID.hasPrefix("custom:") {+ return providerID+ }+ return "custom:\(providerID)"+ }++ private static func hasLegacyLlamaModel(in directoryURL: URL) -> Bool {+ self.legacyLlamaFilenames.contains {+ FileManager.default.fileExists(atPath: directoryURL.appendingPathComponent($0).path)+ }+ }++ private static func migrateLegacyVerificationToLlama(settings: SettingsStore) {+ let key = self.privateProviderKey+ let legacyFingerprint = "private-ai-provider|\(PrivateAIProviderFeature.shared.defaultModelID)"+ guard settings.verifiedProviderFingerprints[key] == legacyFingerprint else { return }++ var fingerprints = settings.verifiedProviderFingerprints+ fingerprints[key] = PrivateAIProviderFeature.verificationFingerprint(+ for: PrivateAIProviderFeature.shared.defaultModelID+ )+ settings.verifiedProviderFingerprints = fingerprints+ }+}+actor PrivateAIIntegrationService {static let shared = PrivateAIIntegrationService()@@ -85,6 +268,10 @@ actor PrivateAIIntegrationService {return !targetURLs.isEmpty}+ nonisolated static func hasInactiveInstalledModel(keeping model: PrivateAIRegisteredModel) -> Bool {+ !self.provider.inactiveInstalledModelURLs(keeping: model).isEmpty+ }+nonisolated static func removeInstalledModel(_ model: PrivateAIRegisteredModel) throws {let requestedURLs = self.provider.installedModelURLs(for: model)guard !requestedURLs.isEmpty else { return }@@ -160,6 +347,12 @@ actor PrivateAIIntegrationService {let status = try await Self.provider.loadModel(model)guard status.state == .ready else { return status }+ guard !PrivateAIMLXUpgradeCoordinator.isUpgradePending() else { return status }+ await self.removeInactiveInstalledModels(keeping: model)+ return status+ }++ func removeInactiveInstalledModels(keeping model: PrivateAIRegisteredModel) async {do {try Self.removeInactiveInstalledModels(keeping: model)} catch {@@ -170,7 +363,6 @@ actor PrivateAIIntegrationService {)}}- return status}private nonisolated static func errorMessage(for error: Error) -> String {diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swiftindex 524ff9f2..81f399aa 100644--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift@@ -101,6 +101,10 @@ struct AIEnhancementSettingsView: View {self.viewModel.onAppear()self.privateAISelectedModelID = PrivateAIIntegrationService.configuredModelIDself.refreshPrivateAILoadState()+ if PrivateAIMLXUpgradeCoordinator.isUpgradePending() {+ self.selectedConfigurationSection = .providers+ self.expandedProviderID = PrivateAIProviderFeature.shared.providerID+ }}.onChange(of: self.viewModel.connectionStatus) { oldValue, newValue inif oldValue == .success && newValue != .success {diff --git a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swiftindex 299cc5a8..72b45111 100644--- a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift+++ b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift@@ -1019,23 +1019,41 @@ extension AIEnhancementSettingsView {guard self.privateAISelectedModelID == model.id else { return }if verified {self.privateAILoadState = .loaded(modelID: model.id, latencyMilliseconds: latencyMilliseconds)+ if PrivateAIMLXUpgradeCoordinator.isUpgradePending() {+ PrivateAIMLXUpgradeCoordinator.completeUpgrade()+ await PrivateAIIntegrationService.shared.removeInactiveInstalledModels(keeping: model)+ }} else {let message = self.viewModel.connectionErrorMessage.isEmpty? "Model downloaded, but verification failed.": self.viewModel.connectionErrorMessage- self.privateAILoadState = .failed(modelID: model.id, message: message)+ self.restoreLlamaAfterFailedMLXUpgrade(message: message, modelID: model.id)}} catch {guard self.privateAISelectedModelID == model.id else { return }- self.privateAILoadState = .failed(- modelID: model.id,- message: Self.errorMessage(for: error)+ self.restoreLlamaAfterFailedMLXUpgrade(+ message: Self.errorMessage(for: error),+ modelID: model.id)}self.viewModel.refreshProviderItems()}}+ private func restoreLlamaAfterFailedMLXUpgrade(message: String, modelID: String) {+ guard PrivateAIMLXUpgradeCoordinator.isUpgradePending() else {+ self.privateAILoadState = .failed(modelID: modelID, message: message)+ return+ }++ PrivateAIMLXUpgradeCoordinator.restorePreviousLlama()+ self.viewModel.onAppear()+ self.privateAILoadState = .failed(+ modelID: modelID,+ message: "MLX upgrade failed. Your previous llama.cpp model is still active. \(message)"+ )+ }+private func verifyPrivateAIConnection(_ model: PrivateAIRegisteredModel) {self.privateAILoadState = .loading(modelID: model.id)Task { @MainActor in@@ -1906,7 +1924,7 @@ extension AIEnhancementSettingsView {return nil}- private func selectProvider(_ providerID: String) {+ func selectProvider(_ providerID: String) {self.viewModel.selectProvider(providerID)}diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex ae31a5d3..ba08bc0f 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -1880,6 +1880,106 @@ final class DictationE2ETests: XCTestCase {}}+ func testMLXUpgradeOfferOnlyTargetsLegacyAppleSiliconInstalls() {+ let eligible = PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: true,+ hasMLXModel: false,+ offerWasHandled: false+ )+ XCTAssertTrue(eligible)++ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: false,+ appVersion: "1.6.3",+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: true,+ hasMLXModel: false,+ offerWasHandled: false+ ))+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreferenceWasSet: true,+ hasLegacyLlamaModel: true,+ hasMLXModel: false,+ offerWasHandled: false+ ))+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: false,+ hasMLXModel: false,+ offerWasHandled: false+ ))+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: true,+ hasMLXModel: true,+ offerWasHandled: false+ ))+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: true,+ hasMLXModel: false,+ offerWasHandled: true+ ))+ for version in ["1.6.2", "1.6.4", "2.0.0", ""] {+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: version,+ backendPreferenceWasSet: false,+ hasLegacyLlamaModel: true,+ hasMLXModel: false,+ offerWasHandled: false+ ))+ }+ }++ func testMLXUpgradePreparedOfferIsRevalidatedBeforeResuming() {+ XCTAssertTrue(PrivateAIMLXUpgradeCoordinator.shouldResumePreparedOffer(+ hasPrivateProvider: true,+ isAppleSilicon: true,+ appVersion: "1.6.3",+ backendPreference: .llama,+ hasLegacyLlamaModel: true,+ hasMLXModel: false+ ))++ for state in [+ (true, true, "1.6.3", SettingsStore.PrivateAIBackendPreference.mlx, true, false),+ (true, true, "1.6.3", SettingsStore.PrivateAIBackendPreference.llama, false, false),+ (true, true, "1.6.3", SettingsStore.PrivateAIBackendPreference.llama, true, true),+ (true, true, "1.6.4", SettingsStore.PrivateAIBackendPreference.llama, true, false),+ (true, false, "1.6.3", SettingsStore.PrivateAIBackendPreference.llama, true, false),+ (false, true, "1.6.3", SettingsStore.PrivateAIBackendPreference.llama, true, false),+ (true, true, "1.6.3", nil, true, false),+ ] {+ XCTAssertFalse(PrivateAIMLXUpgradeCoordinator.shouldResumePreparedOffer(+ hasPrivateProvider: state.0,+ isAppleSilicon: state.1,+ appVersion: state.2,+ backendPreference: state.3,+ hasLegacyLlamaModel: state.4,+ hasMLXModel: state.5+ ))+ }+ }+func testPrivateAIProviderDoesNotConfigureCommandMode() {guard PrivateFeatures.privateAIProvider else { return }