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
feat(beta4): persist FI preparation and scope overlay choices by app
altic-deva1b7c30cb175
diff --git a/Fluid.xcodeproj/project.pbxproj b/Fluid.xcodeproj/project.pbxprojindex 7e409c96..fb27d4de 100644--- a/Fluid.xcodeproj/project.pbxproj+++ b/Fluid.xcodeproj/project.pbxproj@@ -505,7 +505,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 22;+ CURRENT_PROJECT_VERSION = 23;DEVELOPMENT_TEAM = V4J43B279J;ENABLE_APP_SANDBOX = NO;ENABLE_CODE_COVERAGE = NO;@@ -533,7 +533,7 @@"@executable_path/../Frameworks",);MACOSX_DEPLOYMENT_TARGET = 15.0;- MARKETING_VERSION = "1.6.10-beta.3";+ MARKETING_VERSION = "1.6.10-beta.4";PRODUCT_BUNDLE_IDENTIFIER = com.FluidApp.app.debug;PRODUCT_NAME = "FluidVoice Debug";PROVISIONING_PROFILE_SPECIFIER = "";@@ -560,7 +560,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 22;+ CURRENT_PROJECT_VERSION = 23;DEVELOPMENT_TEAM = V4J43B279J;ENABLE_APP_SANDBOX = NO;ENABLE_CODE_COVERAGE = NO;@@ -588,7 +588,7 @@"@executable_path/../Frameworks",);MACOSX_DEPLOYMENT_TARGET = 15.0;- MARKETING_VERSION = "1.6.10-beta.3";+ MARKETING_VERSION = "1.6.10-beta.4";PRODUCT_BUNDLE_IDENTIFIER = com.FluidApp.app;PRODUCT_NAME = FluidVoice;PROVISIONING_PROFILE_SPECIFIER = "";diff --git a/Info.plist b/Info.plistindex 40463e37..66f81c10 100644--- a/Info.plist+++ b/Info.plist@@ -13,9 +13,9 @@<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string><key>CFBundleVersion</key>- <string>22</string>+ <string>23</string><key>CFBundleShortVersionString</key>- <string>1.6.10-beta.3</string>+ <string>1.6.10-beta.4</string><key>LSMinimumSystemVersion</key><string>$(MACOSX_DEPLOYMENT_TARGET)</string><key>LSApplicationCategoryType</key>diff --git a/Sources/Fluid/AppDelegate.swift b/Sources/Fluid/AppDelegate.swiftindex e9eefc8c..de09c481 100644--- a/Sources/Fluid/AppDelegate.swift+++ b/Sources/Fluid/AppDelegate.swift@@ -12,6 +12,28 @@ import SwiftUIimport UserNotificationsclass AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {+ private static var restartPrepared = false+ private static var restartInProgress = false++ @MainActor+ static func restartAfterSaving() {+ guard !self.restartInProgress else { return }+ self.restartInProgress = true+ Task { @MainActor in+ await TranscriptionHistoryStore.shared.finishPendingWrites()+ guard TranscriptionHistoryStore.shared.persistenceError == nil else {+ self.restartInProgress = false+ DebugLogger.shared.error("Restart cancelled: history could not be saved", source: "AppDelegate")+ return+ }+ UserDefaults.standard.synchronize()+ await PrivateAIIntegrationService.shared.shutdownForTermination()+ await AppServices.shared.shutdownForTermination()+ self.restartPrepared = true+ NSApp.terminate(nil)+ }+ }+private var updateCheckTimer: Timer?private var didRevealMainWindowOnLaunch = falseprivate var didRequestMainWindowReopen = false@@ -42,6 +64,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele// Initialize app settings (dock visibility, etc.)SettingsStore.shared.initializeAppSettings()+ DictationAppSession.shared.start()+ OnboardingAISetupController.live.resumePendingDownload()LocalAPIServer.shared.start()// Record first-open synchronously before async analytics bootstrap so@@ -65,6 +89,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele}func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {+ if Self.restartPrepared { return .terminateNow }Task { @MainActor inawait TranscriptionHistoryStore.shared.finishPendingWrites()if let error = TranscriptionHistoryStore.shared.persistenceError {@@ -82,9 +107,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele}func applicationWillTerminate(_ notification: Notification) {+ if Self.restartPrepared {+ // Launch only after this process exits: never overlap two app instances.+ let helper = Process()+ helper.executableURL = URL(fileURLWithPath: "/bin/sh")+ let waitForExit = "i=0; while kill -0 \"$1\" 2>/dev/null; do i=$((i+1)); [ \"$i\" -lt 120 ] || exit 1; sleep 1; done; exec /usr/bin/open \"$2\""+ helper.arguments = ["-c", waitForExit, "fluidvoice-restart", String(ProcessInfo.processInfo.processIdentifier), Bundle.main.bundlePath]+ do { try helper.run() } catch {+ DebugLogger.shared.error("Could not schedule relaunch: \(error)", source: "AppDelegate")+ }+ }DebugLogger.shared.info("Application will terminate", source: "AppDelegate")- self.shutdownPrivateAIRuntimeForTermination()- self.shutdownASRRuntimeForTermination()+ if !Self.restartPrepared {+ self.shutdownPrivateAIRuntimeForTermination()+ self.shutdownASRRuntimeForTermination()+ }LocalAPIServer.shared.stop()// Clean up the update check timerself.updateCheckTimer?.invalidate()diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 02108e07..77d8c3d5 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -275,7 +275,7 @@ struct ContentView: View {@State private var promptModeHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.promptModeHotkeyShortcut@State private var commandModeHotkeyShortcut: HotkeyShortcut? = SettingsStore.shared.commandModeHotkeyShortcut@State private var rewriteModeHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.rewriteModeHotkeyShortcut- @State private var cancelRecordingHotkeyShortcut: HotkeyShortcut = SettingsStore.shared.cancelRecordingHotkeyShortcut+ @State private var cancelRecordingHotkeyShortcut: HotkeyShortcut? = SettingsStore.shared.cancelRecordingHotkeyShortcut@State private var pasteLastTranscriptionHotkeyShortcut: HotkeyShortcut? = SettingsStore.shared.pasteLastTranscriptionHotkeyShortcut@State private var isPasteLastTranscriptionShortcutEnabled: Bool = SettingsStore.shared.pasteLastTranscriptionShortcutEnabled@State private var isPromptModeShortcutEnabled: Bool = SettingsStore.shared.promptModeShortcutEnabled@@ -431,12 +431,15 @@ struct ContentView: View {if !self.settings.shouldShowOnboarding {ToolbarItemGroup(placement: .primaryAction) {self.todayStatsButton+ .buttonStyle(.automatic)self.themePreferenceButton+ .buttonStyle(.automatic)Button(action: self.openIssueReportingPage) {Image(systemName: "ladybug.fill")}+ .buttonStyle(.automatic).help("Report an issue").accessibilityLabel("Report an issue")}@@ -545,6 +548,9 @@ struct ContentView: View {.onChange(of: self.isRewriteModeShortcutEnabled) { newValue inself.handleRewriteShortcutEnabledChange(newValue)}+ .onChange(of: self.cancelRecordingHotkeyShortcut) { _, newValue in+ SettingsStore.shared.cancelRecordingHotkeyShortcut = newValue+ }.onChange(of: self.pasteLastTranscriptionHotkeyShortcut) { _, newValue inSettingsStore.shared.pasteLastTranscriptionHotkeyShortcut = newValueself.hotkeyManager?.refreshMouseShortcutTapIfNeeded()@@ -814,7 +820,7 @@ struct ContentView: View {recordingTarget: ShortcutRecordingTarget?) -> NSEvent? {guard isRecordingAnyShortcut else {- if self.cancelRecordingHotkeyShortcut.matches(keyCode: event.keyCode, modifiers: eventModifiers),+ if self.cancelRecordingHotkeyShortcut?.matches(keyCode: event.keyCode, modifiers: eventModifiers) == true,self.handleCancelShortcut(){return nil@@ -1128,14 +1134,15 @@ struct ContentView: View {}}- var configuredShortcuts: [(ShortcutRecordingTarget, HotkeyShortcut)] = [- (.edit, self.rewriteModeHotkeyShortcut),- (.cancel, self.cancelRecordingHotkeyShortcut),- ]+ var configuredShortcuts: [(ShortcutRecordingTarget, HotkeyShortcut)] = []+ if self.isRewriteModeShortcutEnabled {+ configuredShortcuts.append((.edit, self.rewriteModeHotkeyShortcut))+ }if self.isPromptModeShortcutEnabled {configuredShortcuts.append((.secondaryDictation, self.promptModeHotkeyShortcut))}let optionalConfiguredShortcuts: [(ShortcutRecordingTarget, HotkeyShortcut?)] = [+ (.cancel, self.cancelRecordingHotkeyShortcut),(.command, self.commandModeHotkeyShortcut),(.pasteLast, self.pasteLastTranscriptionHotkeyShortcut),]@@ -2384,8 +2391,7 @@ struct ContentView: View {// Resolve the effective prompt once so every provider path honors// transient overrides such as "Transcribe with Prompt".let promptText: String = {- let override = overrideSystemPrompt?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""- if !override.isEmpty { return override }+ if let overrideSystemPrompt { return overrideSystemPrompt }return self.buildSystemPrompt(appInfo: appInfo, dictationSlot: dictationSlot)}()@@ -2715,9 +2721,9 @@ struct ContentView: View {let sendsExistingDraft = spokenSendParse.shouldSend &&normalizedTranscribedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty- let shouldUseAI = !sendsExistingDraft && (activeDictationSlot.map {- DictationAIPostProcessingGate.isConfigured(for: $0, appBundleID: appInfo.bundleId)- } ?? DictationAIPostProcessingGate.isConfigured(for: .primary, appBundleID: appInfo.bundleId))+ let practiceModelID = route == .onboardingSandbox && self.settings.onboardingCurrentStep == 5+ ? PrivateAIProviderPromptFormat.verifiedModelID(settings: self.settings) : nil+ let shouldUseAI = !sendsExistingDraft && (practiceModelID != nil || DictationAIPostProcessingGate.isConfigured(for: activeDictationSlot ?? .primary, appBundleID: appInfo.bundleId))let transcriptionModelInfo = self.currentTranscriptionModelInfo()let postProcessingModelInfo = self.recordDictationUsage(shouldUseAI: shouldUseAI,@@ -2744,6 +2750,8 @@ struct ContentView: View {let result = try await self.processTextWithAIMetrics(normalizedTranscribedText,overrideSystemPrompt: promptOverride,+ overrideProviderID: practiceModelID == nil ? nil : PrivateAIProviderFeature.shared.providerID,+ overrideModel: practiceModelID,dictationSlot: activeDictationSlot,streamHandler: streamHandler,benchmarkID: pipelineID@@ -4119,7 +4127,7 @@ struct ContentView: View {}private func prewarmPrivateAIDictationIfNeeded(for slot: SettingsStore.DictationShortcutSlot) {- let appBundleID = self.recordingAppInfo?.bundleId+ let appBundleID = self.asr.isRunningOrStarting ? self.recordingAppInfo?.bundleId : DictationAppSession.shared.appIDlet settings = SettingsStore.sharedlet route = DictationProviderRoute.resolve(settings: settings,@@ -4286,8 +4294,9 @@ struct ContentView: View {NotchContentState.shared.onDictationPromptSelectionRequested = { selection inguard selection != .privateAI || PrivateAIProviderPromptFormat.isAvailable() else { return }let slot = self.activeDictationShortcutSlot ?? .primary- SettingsStore.shared.setDictationPromptSelection(selection, for: slot)+ DictationAppSession.shared.select(selection, slot: slot, appID: DictationAppSession.shared.appID)self.applyDictationShortcutSelectionContext(for: slot)+ self.prewarmPrivateAIDictationIfNeeded(for: slot)}guard self.hotkeyManager == nil else { return }@@ -4688,7 +4697,7 @@ extension ContentView {NotchContentState.shared.activeDictationShortcutSlot = slotNotchContentState.shared.isPromptModeActive = (slot == .secondary)- switch settings.dictationPromptSelection(for: slot) {+ switch settings.resolvedDictationPromptSelection(for: slot, appBundleID: DictationAppSession.shared.appID) {case .off, .default:self.promptModeOverrideText = nilNotchContentState.shared.promptModeOverrideProfileName = nil@@ -4698,10 +4707,9 @@ extension ContentView {NotchContentState.shared.promptModeOverrideProfileName = PrivateAIProviderFeature.displayNameNotchContentState.shared.promptModeOverrideProfileID = PrivateAIProviderPromptFormat.promptSelectionIDcase let .profile(profileID):- guard let profile = settings.selectedDictationPromptProfile(for: slot) ?? settings.dictationPromptProfiles.first(where: {+ guard let profile = settings.dictationPromptProfiles.first(where: {$0.id == profileID && $0.mode.normalized == .dictate}) else {- settings.setDictationPromptSelection(.default, for: slot)self.promptModeOverrideText = nilNotchContentState.shared.promptModeOverrideProfileName = nilNotchContentState.shared.promptModeOverrideProfileID = nil@@ -4845,7 +4853,7 @@ extension ContentView {}private var onboardingAIReady: Bool {- self.settings.onboardingAISkipped || DictationAIPostProcessingGate.isProviderConfigured()+ self.settings.onboardingAISkipped || DictationAIPostProcessingGate.isOnboardingChoiceConfigured()}private var onboardingPlaygroundReady: Bool {@@ -4931,9 +4939,20 @@ extension ContentView {@discardableResultprivate func refreshAccessibilityPermissionState() -> Bool {let trusted = self.checkAccessibilityPermissions()+ let newlyGranted = trusted && !self.accessibilityEnabledif trusted != self.accessibilityEnabled {self.accessibilityEnabled = trusted}+ if newlyGranted,+ UserDefaults.standard.bool(forKey: self.accessibilityRestartFlagKey),+ !UserDefaults.standard.bool(forKey: self.hasAutoRestartedForAccessibilityKey)+ {+ UserDefaults.standard.set(true, forKey: self.hasAutoRestartedForAccessibilityKey)+ DebugLogger.shared.info("Auto-restarting app after accessibility grant", source: "ContentView")+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {+ self.restartApp()+ }+ }return trusted}@@ -5201,17 +5220,10 @@ extension ContentView {}func restartApp() {- let appPath = Bundle.main.bundlePath- let process = Process()- process.launchPath = "/usr/bin/open"- process.arguments = ["-n", appPath]// Clear pending flag and hide prompt before restartingUserDefaults.standard.set(false, forKey: self.accessibilityRestartFlagKey)self.showRestartPrompt = false- try? process.run()- DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {- NSApp.terminate(nil)- }+ AppDelegate.restartAfterSaving()}func startAccessibilityPolling() {@@ -5234,18 +5246,6 @@ extension ContentView {DebugLogger.shared.info("Accessibility permission granted", source: "ContentView")self.refreshAccessibilityPermissionState()self.finishAccessibilityPermissionFlow()-- guard !UserDefaults.standard.bool(forKey: self.hasAutoRestartedForAccessibilityKey) else {- self.hotkeyManager?.reinitialize()- return- }-- // Mark that we've auto-restarted to prevent loops.- UserDefaults.standard.set(true, forKey: self.hasAutoRestartedForAccessibilityKey)- DebugLogger.shared.info("Auto-restarting app after accessibility grant", source: "ContentView")- DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {- self.restartApp()- }}break // Stop polling after triggering restart}diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swiftindex 6e703f32..cea0052a 100644--- a/Sources/Fluid/Persistence/BackupService.swift+++ b/Sources/Fluid/Persistence/BackupService.swift@@ -40,7 +40,7 @@ struct SettingsBackupPayload: Codable, Equatable {let rewriteModeSelectedModel: String?let rewriteModeSelectedProviderID: Stringlet rewriteModeLinkedToGlobal: Bool- let cancelRecordingHotkeyShortcut: HotkeyShortcut+ let cancelRecordingHotkeyShortcut: HotkeyShortcut?// Optional so older backup files (which predate this setting) still decode.let pasteLastTranscriptionHotkeyShortcut: HotkeyShortcut?let pasteLastTranscriptionShortcutEnabled: Bool?diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex c8aef45a..e90f1274 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -40,6 +40,7 @@ final class SettingsStore: ObservableObject {self.ensureDebugLoggingDefaults()self.migrateProviderAPIKeysIfNeeded()self.scrubSavedProviderAPIKeys()+ self.migrateExplicitDictationPromptsIfNeeded()self.migrateDictationPromptProfilesIfNeeded()self.migrateLegacyDictationAIPreferenceIfNeeded()self.migrateSecondaryPromptShortcutIfNeeded()@@ -244,6 +245,13 @@ final class SettingsStore: ObservableObject {}}+ /// Shared user-facing names; persisted selection IDs remain independent.+ enum DictationModeLabels {+ static let externalDefault = "Default"+ static let smart = "Smart"+ static let smartWithModel = "\(smart) — Fluid-1"+ }+enum DictationPromptSelection: Equatable {case off, `default`, privateAIcase profile(String)@@ -255,6 +263,9 @@ final class SettingsStore: ObservableObject {var prompt: Stringvar mode: PromptModevar includeContext: Bool+ var usesExplicitDictationPrompt = true+ var usesLegacyEmptyPromptFallback = false+ var legacyEmptyShortcutUsesBasePrompt = falsevar createdAt: Datevar updatedAt: Date@@ -264,6 +275,9 @@ final class SettingsStore: ObservableObject {case promptcase modecase includeContext+ case usesExplicitDictationPrompt+ case usesLegacyEmptyPromptFallback+ case legacyEmptyShortcutUsesBasePromptcase createdAtcase updatedAt}@@ -293,6 +307,9 @@ final class SettingsStore: ObservableObject {self.prompt = try container.decode(String.self, forKey: .prompt)self.mode = try (container.decodeIfPresent(PromptMode.self, forKey: .mode) ?? .dictate).normalizedself.includeContext = try container.decodeIfPresent(Bool.self, forKey: .includeContext) ?? false+ self.usesExplicitDictationPrompt = try container.decodeIfPresent(Bool.self, forKey: .usesExplicitDictationPrompt) ?? false+ self.usesLegacyEmptyPromptFallback = try container.decodeIfPresent(Bool.self, forKey: .usesLegacyEmptyPromptFallback) ?? false+ self.legacyEmptyShortcutUsesBasePrompt = try container.decodeIfPresent(Bool.self, forKey: .legacyEmptyShortcutUsesBasePrompt) ?? falseself.createdAt = try container.decode(Date.self, forKey: .createdAt)self.updatedAt = try container.decode(Date.self, forKey: .updatedAt)}@@ -399,7 +416,9 @@ final class SettingsStore: ObservableObject {}set {objectWillChange.send()- if let encoded = try? JSONEncoder().encode(newValue) {+ if let encoded = try? JSONEncoder().encode(newValue.map {+ Self.migrateExplicitDictationPrompt($0, legacySendOnly: self.defaults.bool(forKey: Keys.sendCustomPromptOnly))+ }) {self.defaults.set(encoded, forKey: Keys.dictationPromptProfiles)} else {// If encoding fails, avoid writing corrupt data.@@ -472,14 +491,6 @@ final class SettingsStore: ObservableObject {}}- var sendCustomPromptOnly: Bool {- get { self.defaults.bool(forKey: Keys.sendCustomPromptOnly) }- set {- objectWillChange.send()- self.defaults.set(newValue, forKey: Keys.sendCustomPromptOnly)- }- }-var isEditPromptOff: Bool {get { self.defaults.bool(forKey: Keys.editPromptOff) }set {@@ -721,13 +732,43 @@ final class SettingsStore: ObservableObject {return self.dictationPromptProfiles.first(where: { $0.id == id && $0.mode.normalized == .dictate })}+ func resolvedDictationPromptSelection(for slot: DictationShortcutSlot, appBundleID: String?) -> DictationPromptSelection {+ if let manual = DictationAppSession.shared.choice(for: slot, appID: appBundleID) { return manual }+ let selection = self.dictationPromptSelection(for: slot)+ guard selection != .off else { return .off }+ let appOnly = self.promptRoutingScope(for: .dictate) == .selectedAppsOnly+ guard appOnly || Self.dictationSelectionSupportsAppOverride(selection) else { return selection }+ guard let binding = self.appPromptBinding(for: .dictate, appBundleID: appBundleID) else {+ return appOnly ? .off : selection+ }+ guard let id = binding.promptID,+ self.dictationPromptProfiles.contains(where: { $0.id == id && $0.mode.normalized == .dictate })+ else { return .default }+ return .profile(id)+ }++ private func manualDictationPromptBody(_ selection: DictationPromptSelection, system: Bool) -> String {+ if selection == .off { return "" }+ if case let .profile(id) = selection,+ let profile = self.dictationPromptProfiles.first(where: { $0.id == id && $0.mode.normalized == .dictate })+ {+ let body = Self.customPromptBody(profile.prompt, mode: .dictate)+ if !body.isEmpty || !profile.usesLegacyEmptyPromptFallback {+ return system ? self.systemPrompt(forCustomProfileBody: body, mode: .dictate) : body+ }+ }+ let fallback = self.defaultPromptResolution(for: .dictate, source: .defaultOverride, appBinding: nil)+ return system ? fallback.systemPrompt : fallback.promptBody+ }+func resolvedDictationPromptProfile(for slot: DictationShortcutSlot, appBundleID: String?) -> DictationPromptProfile? {- switch self.dictationPromptSelection(for: slot) {+ switch self.resolvedDictationPromptSelection(for: slot, appBundleID: appBundleID) {case .off:return nilcase let .profile(promptID):return self.dictationPromptProfiles.first(where: { $0.id == promptID && $0.mode.normalized == .dictate })case .default, .privateAI:+ guard DictationAppSession.shared.choice(for: slot, appID: appBundleID) == nil else { return nil }guard let binding = self.appPromptBinding(for: .dictate, appBundleID: appBundleID) else { return nil }let promptID = binding.promptIDreturn self.dictationPromptProfiles.first {@@ -737,6 +778,7 @@ final class SettingsStore: ObservableObject {}func isAppDictationPromptBindingActive(for slot: DictationShortcutSlot, appBundleID: String?) -> Bool {+ guard DictationAppSession.shared.choice(for: slot, appID: appBundleID) == nil else { return false }let selection = self.dictationPromptSelection(for: slot)guard Self.dictationSelectionSupportsAppOverride(selection) else { return false }return self.hasAppPromptBinding(for: .dictate, appBundleID: appBundleID)@@ -746,8 +788,18 @@ final class SettingsStore: ObservableObject {selection == .default || selection == .privateAI}+ func dictationOverlayLabel(for slot: DictationShortcutSlot, appBundleID: String?) -> String {+ let selection = self.resolvedDictationPromptSelection(for: slot, appBundleID: appBundleID)+ guard selection != .off else { return "Basic" }+ let route = DictationProviderRoute.resolve(settings: self, dictationSlot: slot, appBundleID: appBundleID)+ let mode = self.dictationPromptDisplayName(for: slot, appBundleID: appBundleID)+ let modelName = PrivateAIModelRegistry.model(id: route.model)?.displayName ?? route.model+ let model = modelName.replacingOccurrences(of: "Fluid-1 ", with: "")+ return model.isEmpty ? "\(mode) · Unavailable" : "\(mode) · \(model)"+ }+func dictationPromptDisplayName(for slot: DictationShortcutSlot, appBundleID: String?) -> String {- switch self.dictationPromptSelection(for: slot) {+ switch self.resolvedDictationPromptSelection(for: slot, appBundleID: appBundleID) {case .off:return "Basic"case .default:@@ -764,7 +816,7 @@ final class SettingsStore: ObservableObject {}return "Default"}- return "Smart"+ return DictationModeLabels.smartcase let .profile(promptID):guard let profile = self.dictationPromptProfiles.first(where: { $0.id == promptID && $0.mode.normalized == .dictate }) else {return "Default"@@ -1178,8 +1230,8 @@ final class SettingsStore: ObservableObject {$0.mode.normalized == normalizedMode}){- let body = Self.stripBasePrompt(for: normalizedMode, from: profile.prompt)- if !body.isEmpty {+ let body = Self.customPromptBody(profile.prompt, mode: normalizedMode)+ if !body.isEmpty || (profile.mode.normalized == .dictate && !profile.usesLegacyEmptyPromptFallback) {return PromptResolution(source: .appBindingProfile,profile: profile,@@ -1207,8 +1259,8 @@ final class SettingsStore: ObservableObject {}if let profile = self.selectedPromptProfile(for: normalizedMode) {- let body = Self.stripBasePrompt(for: normalizedMode, from: profile.prompt)- if !body.isEmpty {+ let body = Self.customPromptBody(profile.prompt, mode: normalizedMode)+ if !body.isEmpty || (profile.mode.normalized == .dictate && !profile.usesLegacyEmptyPromptFallback) {return PromptResolution(source: .selectedProfile,profile: profile,@@ -1227,6 +1279,9 @@ final class SettingsStore: ObservableObject {}func effectiveDictationPromptBody(for slot: DictationShortcutSlot, appBundleID: String? = nil) -> String {+ if let manual = DictationAppSession.shared.choice(for: slot, appID: appBundleID) {+ return self.manualDictationPromptBody(manual, system: false)+ }if self.promptRoutingScope(for: .dictate) == .selectedAppsOnly {guard self.dictationPromptSelection(for: slot) != .off else { return "" }return self.effectivePromptBody(for: .dictate, appBundleID: appBundleID)@@ -1241,8 +1296,8 @@ final class SettingsStore: ObservableObject {guard let profile = self.dictationPromptProfiles.first(where: { $0.id == promptID && $0.mode.normalized == .dictate }) else {return self.effectivePromptBody(for: .dictate, appBundleID: appBundleID)}- let body = Self.stripBasePrompt(for: .dictate, from: profile.prompt)- if !body.isEmpty {+ let body = Self.customPromptBody(profile.prompt, mode: .dictate)+ if !body.isEmpty || (profile.mode.normalized == .dictate && !profile.usesLegacyEmptyPromptFallback) {return body}return self.effectivePromptBody(for: .dictate, appBundleID: appBundleID)@@ -1250,6 +1305,9 @@ final class SettingsStore: ObservableObject {}func effectiveDictationSystemPrompt(for slot: DictationShortcutSlot, appBundleID: String? = nil) -> String {+ if let manual = DictationAppSession.shared.choice(for: slot, appID: appBundleID) {+ return self.manualDictationPromptBody(manual, system: true)+ }if self.promptRoutingScope(for: .dictate) == .selectedAppsOnly {guard self.dictationPromptSelection(for: slot) != .off else { return "" }return self.effectiveSystemPrompt(for: .dictate, appBundleID: appBundleID)@@ -1262,8 +1320,8 @@ final class SettingsStore: ObservableObject {guard let profile = self.dictationPromptProfiles.first(where: { $0.id == promptID && $0.mode.normalized == .dictate }) else {return self.effectiveSystemPrompt(for: .dictate, appBundleID: appBundleID)}- let body = Self.stripBasePrompt(for: .dictate, from: profile.prompt)- if !body.isEmpty {+ let body = Self.customPromptBody(profile.prompt, mode: .dictate)+ if !body.isEmpty || (profile.mode.normalized == .dictate && !profile.usesLegacyEmptyPromptFallback) {return self.systemPrompt(forCustomProfileBody: body, mode: .dictate)}return self.effectiveSystemPrompt(for: .dictate, appBundleID: appBundleID)@@ -1342,17 +1400,19 @@ final class SettingsStore: ObservableObject {private func systemPrompt(forCustomProfileBody body: String, mode: PromptMode) -> String {let normalizedMode = mode.normalizedlet trimmedBody = body.trimmingCharacters(in: .whitespacesAndNewlines)- if normalizedMode == .dictate, self.sendCustomPromptOnly {- return trimmedBody+ if normalizedMode == .dictate {+ return body}return Self.combineBasePrompt(for: normalizedMode, with: trimmedBody)}- /// System prompt for a dictation-shortcut prompt override, honoring- /// "Send Custom Prompt Only" the same way the effective-prompt paths do.- func shortcutOverrideSystemPrompt(for profile: DictationPromptProfile, mode: PromptMode = .dictate) -> String {- self.systemPrompt(- forCustomProfileBody: Self.stripBasePrompt(for: mode, from: profile.prompt),+ /// Use the same explicit custom prompt for shortcut and app-based selection.+ func shortcutOverrideSystemPrompt(for profile: DictationPromptProfile, mode: PromptMode = .dictate) -> String? {+ if mode.normalized == .dictate, profile.usesLegacyEmptyPromptFallback {+ return profile.legacyEmptyShortcutUsesBasePrompt ? Self.baseDictationPromptText() : nil+ }+ return self.systemPrompt(+ forCustomProfileBody: Self.customPromptBody(profile.prompt, mode: mode),mode: mode)}@@ -1750,9 +1810,9 @@ final class SettingsStore: ObservableObject {}set {objectWillChange.send()- let shortcuts = Self.normalizedPrimaryDictationShortcuts([newValue], fallback: Self.defaultPrimaryDictationShortcut)+ let shortcuts = Self.normalizedPrimaryDictationShortcuts([newValue])self.storePrimaryDictationShortcuts(shortcuts)- self.storeLegacyHotkeyShortcut(shortcuts[0])+ if let first = shortcuts.first { self.storeLegacyHotkeyShortcut(first) }}}@@ -1761,7 +1821,7 @@ final class SettingsStore: ObservableObject {.map(\.displayString).map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.filter { !$0.isEmpty }- return displays.isEmpty ? Self.defaultPrimaryDictationShortcut.displayString : displays.joined(separator: " / ")+ return displays.isEmpty ? "Off" : displays.joined(separator: " / ")}var primaryDictationShortcuts: [HotkeyShortcut] {@@ -1770,15 +1830,15 @@ final class SettingsStore: ObservableObject {if let data = defaults.data(forKey: Keys.primaryDictationShortcutsKey),let shortcuts = try? JSONDecoder().decode([HotkeyShortcut].self, from: data){- return Self.normalizedPrimaryDictationShortcuts(shortcuts, fallback: fallback)+ return Self.normalizedPrimaryDictationShortcuts(shortcuts)}return [fallback]}set {objectWillChange.send()- let shortcuts = Self.normalizedPrimaryDictationShortcuts(newValue, fallback: self.legacyHotkeyShortcut)+ let shortcuts = Self.normalizedPrimaryDictationShortcuts(newValue)self.storePrimaryDictationShortcuts(shortcuts)- self.storeLegacyHotkeyShortcut(shortcuts[0])+ if let first = shortcuts.first { self.storeLegacyHotkeyShortcut(first) }}}@@ -1796,16 +1856,12 @@ final class SettingsStore: ObservableObject {}private static func normalizedPrimaryDictationShortcuts(- _ shortcuts: [HotkeyShortcut],- fallback: HotkeyShortcut+ _ shortcuts: [HotkeyShortcut]) -> [HotkeyShortcut] {var unique: [HotkeyShortcut] = []for shortcut in shortcuts where !unique.contains(shortcut) {unique.append(shortcut)}- if unique.isEmpty {- unique.append(fallback)- }return unique}@@ -2866,12 +2922,10 @@ final class SettingsStore: ObservableObject {}}- var cancelRecordingHotkeyShortcut: HotkeyShortcut {+ var cancelRecordingHotkeyShortcut: HotkeyShortcut? {get {- if let data = defaults.data(forKey: Keys.cancelRecordingHotkeyShortcut),- let shortcut = try? JSONDecoder().decode(HotkeyShortcut.self, from: data)- {- return shortcut+ if let data = defaults.data(forKey: Keys.cancelRecordingHotkeyShortcut) {+ do { return try JSONDecoder().decode(HotkeyShortcut?.self, from: data) } catch {}}return HotkeyShortcut(keyCode: 53, modifierFlags: [])}@@ -3618,6 +3672,30 @@ final class SettingsStore: ObservableObject {}}+ static func customPromptBody(_ text: String, mode: PromptMode) -> String {+ mode.normalized == .dictate ? text : self.stripBasePrompt(for: mode, from: text)+ }++ static func migrateExplicitDictationPrompt(+ _ profile: DictationPromptProfile, legacySendOnly: Bool+ ) -> DictationPromptProfile {+ guard profile.mode.normalized == .dictate, !profile.usesExplicitDictationPrompt else { return profile }+ var migrated = profile+ let body = self.stripBasePrompt(for: .dictate, from: profile.prompt)+ // Empty legacy styles used the default fallback; keep that behavior.+ migrated.prompt = legacySendOnly || body.isEmpty ? body : self.combineBasePrompt(for: .dictate, with: body)+ migrated.usesExplicitDictationPrompt = true+ migrated.usesLegacyEmptyPromptFallback = body.isEmpty+ migrated.legacyEmptyShortcutUsesBasePrompt = body.isEmpty && !legacySendOnly+ return migrated+ }++ private func migrateExplicitDictationPromptsIfNeeded() {+ let profiles = self.dictationPromptProfiles+ guard profiles.contains(where: { $0.mode.normalized == .dictate && !$0.usesExplicitDictationPrompt }) else { return }+ self.dictationPromptProfiles = profiles+ }+private func migrateDictationPromptProfilesIfNeeded() {// Migration path from legacy single prompt to multi-prompt profiles.// If user had a legacy custom dictation prompt, convert it to a profile and select it.@@ -3636,12 +3714,13 @@ final class SettingsStore: ObservableObject {return}- let profile = DictationPromptProfile(+ var profile = DictationPromptProfile(name: "My Custom Prompt",prompt: legacyPrompt,createdAt: Date(),updatedAt: Date())+ profile.usesExplicitDictationPrompt = falseself.dictationPromptProfiles = [profile]self.selectedDictationPromptID = profile.idself.customDictationPrompt = ""diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex b8f55972..d9832316 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -4847,6 +4847,12 @@ final class ASRService: ObservableObject {DebugLogger.shared.info("Total initialization time: \(String(format: "%.1f", totalDuration)) seconds", source: "ASRService")self.isAsrReady = true+ if !SettingsStore.shared.onboardingCompleted,+ SettingsStore.shared.analyticsOnboardingOrigin == .firstRun+ {+ DebugLogger.shared.info("Voice model ready; requesting FI prefetch", source: "OnboardingAI")+ OnboardingAISetupController.live.prefetch()+ }self.isCancellingModelPreparation = falseself.refreshWordBoostStatus()self.finishModelDownloadAnalytics(operationID: operationID, outcome: .succeeded)diff --git a/Sources/Fluid/Services/DictationAIPostProcessingGate.swift b/Sources/Fluid/Services/DictationAIPostProcessingGate.swiftindex 567cf509..43acce9a 100644--- a/Sources/Fluid/Services/DictationAIPostProcessingGate.swift+++ b/Sources/Fluid/Services/DictationAIPostProcessingGate.swift@@ -3,6 +3,15 @@ import Foundation/// Shared gating logic for whether dictation AI post-processing is usable/configured.enum DictationAIPostProcessingGate {+ /// Setup checks the explicit FI choice, not whether a foreground app has a rule.+ static func isOnboardingChoiceConfigured() -> Bool {+ let settings = SettingsStore.shared+ if settings.dictationPromptSelection(for: .primary) == .privateAI {+ return self.isPrivateProviderConfigured(settings: settings)+ }+ return self.isConfigured(for: .primary)+ }+/// Returns true if dictation AI post-processing should be allowed, given current settings./// - Requires dictation prompt selection to not be `Off`/// - Requires the selected provider connection to still be verified@@ -12,14 +21,8 @@ enum DictationAIPostProcessingGate {static func isConfigured(for slot: SettingsStore.DictationShortcutSlot, appBundleID: String? = nil) -> Bool {let settings = SettingsStore.shared- let promptSelection = settings.dictationPromptSelection(for: slot)+ let promptSelection = settings.resolvedDictationPromptSelection(for: slot, appBundleID: appBundleID)guard promptSelection != .off else { return false }- if let appBundleID,- settings.promptRoutingScope(for: .dictate) == .selectedAppsOnly,- !settings.hasAppPromptBinding(for: .dictate, appBundleID: appBundleID)- {- return false- }let route = DictationProviderRoute.resolve(settings: settings,diff --git a/Sources/Fluid/Services/DictationAppSession.swift b/Sources/Fluid/Services/DictationAppSession.swiftnew file mode 100644index 00000000..1ea0ac58--- /dev/null+++ b/Sources/Fluid/Services/DictationAppSession.swift@@ -0,0 +1,43 @@+import AppKit+import Combine+import Foundation++/// Event-driven and memory-only. Watching while the overlay is hidden catches A → B → A.+final class DictationAppSession: @unchecked Sendable {+ static let shared = DictationAppSession()+ private let lock = NSLock()+ private var state = ForegroundAppOverride<SettingsStore.DictationPromptSelection>()+ private var observer: NSObjectProtocol?+ var appID: String? { self.lock.withLock { self.state.appID } }++ @MainActor+ func start() {+ guard self.observer == nil else { return }+ self.activate(NSWorkspace.shared.frontmostApplication?.bundleIdentifier)+ self.observer = NSWorkspace.shared.notificationCenter.addObserver(+ forName: NSWorkspace.didActivateApplicationNotification, object: nil, queue: .main+ ) { [weak self] notification in+ let appID = (notification.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication)?.bundleIdentifier+ MainActor.assumeIsolated { self?.activate(appID) }+ }+ }++ @MainActor+ func activate(_ appID: String?) {+ // Our nonactivating overlay/popover must not end the target app's visit.+ guard appID != Bundle.main.bundleIdentifier else { return }+ let changed = self.lock.withLock { self.state.activate(appID) }+ if changed { SettingsStore.shared.objectWillChange.send() }+ }++ @MainActor+ func select(_ selection: SettingsStore.DictationPromptSelection, slot: SettingsStore.DictationShortcutSlot, appID: String?) {+ guard let appID else { return }+ self.lock.withLock { self.state.select(selection, slot: slot.rawValue, appID: appID) }+ SettingsStore.shared.objectWillChange.send()+ }++ func choice(for slot: SettingsStore.DictationShortcutSlot, appID: String?) -> SettingsStore.DictationPromptSelection? {+ self.lock.withLock { self.state.choice(slot: slot.rawValue, appID: appID) }+ }+}diff --git a/Sources/Fluid/Services/DictationPostProcessingService.swift b/Sources/Fluid/Services/DictationPostProcessingService.swiftindex c7666919..6afd87aa 100644--- a/Sources/Fluid/Services/DictationPostProcessingService.swift+++ b/Sources/Fluid/Services/DictationPostProcessingService.swift@@ -22,11 +22,7 @@ struct DictationProviderRoute: Equatable {let configuredModel: String?if let dictationSlot {- let selection = self.effectivePromptSelection(- settings: settings,- dictationSlot: dictationSlot,- appBundleID: appBundleID- )+ let selection = settings.resolvedDictationPromptSelection(for: dictationSlot, appBundleID: appBundleID)if selection == .off {return Self(providerID: "", providerKey: "", baseURL: "", model: "", apiKey: "")}@@ -160,30 +156,6 @@ struct DictationProviderRoute: Equatable {}return self.resolve(settings: settings, dictationSlot: dictationSlot)}-- private static func effectivePromptSelection(- settings: SettingsStore,- dictationSlot: SettingsStore.DictationShortcutSlot,- appBundleID: String?- ) -> SettingsStore.DictationPromptSelection {- let selection = settings.dictationPromptSelection(for: dictationSlot)- guard selection != .off else { return selection }-- let usesOnlyAppBindings = settings.promptRoutingScope(for: .dictate) == .selectedAppsOnly- let supportsAppOverride = SettingsStore.dictationSelectionSupportsAppOverride(selection)- guard usesOnlyAppBindings || supportsAppOverride else { return selection }- guard let binding = settings.appPromptBinding(for: .dictate, appBundleID: appBundleID) else {- return usesOnlyAppBindings ? .off : selection- }- guard let promptID = binding.promptID,- settings.dictationPromptProfiles.contains(where: {- $0.id == promptID && $0.mode.normalized == .dictate- })- else {- return .default- }- return .profile(promptID)- }}@MainActordiff --git a/Sources/Fluid/Services/ForegroundAppOverride.swift b/Sources/Fluid/Services/ForegroundAppOverride.swiftnew file mode 100644index 00000000..5442eba5--- /dev/null+++ b/Sources/Fluid/Services/ForegroundAppOverride.swift@@ -0,0 +1,25 @@+import Foundation++/// A manual choice belongs to one visit to an app, never to its saved rules.+struct ForegroundAppOverride<Value> {+ private(set) var appID: String?+ private var choices: [String: Value] = [:]++ @discardableResult+ mutating func activate(_ appID: String?) -> Bool {+ guard let appID, !appID.isEmpty, appID != self.appID else { return false }+ self.appID = appID+ self.choices.removeAll(keepingCapacity: true)+ return true+ }++ mutating func select(_ value: Value, slot: String, appID: String) {+ guard appID == self.appID else { return }+ self.choices[slot] = value+ }++ func choice(slot: String, appID: String?) -> Value? {+ guard let appID, appID == self.appID else { return nil }+ return self.choices[slot]+ }+}diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swiftindex 260f78e5..e5586c58 100644--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift@@ -826,7 +826,7 @@ final class GlobalHotkeyManager: NSObject {let commandEnabled: Boollet edit: HotkeyShortcutlet editEnabled: Bool- let cancel: HotkeyShortcut+ let cancel: HotkeyShortcut?let pasteLast: HotkeyShortcut?let pasteLastEnabled: Boollet mode: HotkeyActivationMode@@ -1248,7 +1248,7 @@ final class GlobalHotkeyManager: NSObject {self.markOtherInputDuringModifierOnly()// Check the configured cancel shortcut first.- if SettingsStore.shared.cancelRecordingHotkeyShortcut.matches(keyCode: keyCode, modifiers: eventModifiers) {+ if SettingsStore.shared.cancelRecordingHotkeyShortcut?.matches(keyCode: keyCode, modifiers: eventModifiers) == true {var handled = falseif self.asrService.isRunning || self.asrService.isStarting {diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swiftindex f5933c4d..4ee2cb73 100644--- a/Sources/Fluid/Services/NotchOverlayManager.swift+++ b/Sources/Fluid/Services/NotchOverlayManager.swift@@ -130,10 +130,10 @@ final class NotchOverlayManager {/// Setup cancel shortcut monitors - both global (other apps) and local (our app)private func setupEscapeKeyMonitors() {let escapeHandler: (NSEvent) -> NSEvent? = { [weak self] event in- guard SettingsStore.shared.cancelRecordingHotkeyShortcut.matches(+ guard SettingsStore.shared.cancelRecordingHotkeyShortcut?.matches(keyCode: event.keyCode,modifiers: event.modifierFlags- ) else { return event }+ ) == true else { return event }Task { @MainActor inguard self != nil else { return }diff --git a/Sources/Fluid/Services/OnboardingAISetupController+Live.swift b/Sources/Fluid/Services/OnboardingAISetupController+Live.swiftindex b68145ff..3d1018b9 100644--- a/Sources/Fluid/Services/OnboardingAISetupController+Live.swift+++ b/Sources/Fluid/Services/OnboardingAISetupController+Live.swift@@ -1,40 +1,51 @@import Foundationextension OnboardingAISetupController {- static var live: OnboardingAISetupController {- OnboardingAISetupController(dependencies: Dependencies(- recommend: {- guard PrivateFeatures.privateAIProvider else { throw PrivateAIUnavailableError() }- let recommendation = await PrivateAIHardwareRecommendation.current()- guard let model = PrivateAIModelRegistry.model(id: recommendation.model.rawValue), model.isEnabled else {- throw PrivateAIUnavailableError()- }- let installed = await Task.detached(priority: .utility) {- PrivateAIIntegrationService.isModelInstalled(model)- }.value- guard installed || model.canDownload else { throw PrivateAIUnavailableError() }- return Model(id: model.id, name: model.displayName, byteCount: model.artifact.byteCount, installed: installed)- },- prepare: { model, report in- guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }- _ = try await PrivateAIIntegrationService.prepareModel(registered) { progress in- let progress = progress.withFallbackExpectedBytes(model.byteCount)- await report(Progress(- fraction: progress.fractionCompleted,- status: PrivateAIModelDownloadProgressText.statusText(for: progress),- bytes: PrivateAIModelDownloadProgressText.byteText(for: progress)- ))- }- },- load: { model in- guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }- let status = try await PrivateAIIntegrationService.shared.loadModel(registered)- guard status.state == .ready else {- throw SetupError(message: status.message ?? "The model could not be prepared. Please try again.")- }+ static let live: OnboardingAISetupController = .init(dependencies: Dependencies(+ recommend: {+ guard PrivateFeatures.privateAIProvider else { throw PrivateAIUnavailableError() }+ let recommendation = await PrivateAIHardwareRecommendation.current()+ guard let model = PrivateAIModelRegistry.model(id: recommendation.model.rawValue), model.isEnabled else {+ throw PrivateAIUnavailableError()}- ))- }+ let installed = await Task.detached(priority: .utility) {+ PrivateAIIntegrationService.isModelInstalled(model)+ }.value+ guard installed || model.canDownload else { throw PrivateAIUnavailableError() }+ DebugLogger.shared.info("Recommended model=\(model.id) installed=\(installed)", source: "OnboardingAI")+ return Model(id: model.id, name: model.displayName, byteCount: model.artifact.byteCount, installed: installed)+ },+ prepare: { model, report in+ DebugLogger.shared.info("Transfer starting model=\(model.id)", source: "OnboardingAI")+ guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }+ _ = try await PrivateAIIntegrationService.prepareModel(registered) { progress in+ let progress = progress.withFallbackExpectedBytes(model.byteCount)+ await report(Progress(+ fraction: progress.fractionCompleted,+ status: PrivateAIModelDownloadProgressText.statusText(for: progress),+ bytes: PrivateAIModelDownloadProgressText.byteText(for: progress)+ ))+ }+ DebugLogger.shared.info("Transfer complete model=\(model.id)", source: "OnboardingAI")+ },+ load: { model in+ guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }+ let status = try await PrivateAIIntegrationService.shared.loadModel(registered)+ guard status.state == .ready else {+ throw SetupError(message: status.message ?? "The model could not be prepared. Please try again.")+ }+ },+ readPendingDownload: {+ let pending = UserDefaults.standard.bool(forKey: "OnboardingFIPendingDownload")+ DebugLogger.shared.info("Recovery check pending=\(pending)", source: "OnboardingAI")+ return pending+ },+ writePendingDownload: {+ UserDefaults.standard.set($0, forKey: "OnboardingFIPendingDownload")+ UserDefaults.standard.synchronize()+ DebugLogger.shared.info("Persisted pending=\($0)", source: "OnboardingAI")+ }+ ))private struct SetupError: LocalizedError {let message: Stringdiff --git a/Sources/Fluid/Services/OnboardingAISetupController.swift b/Sources/Fluid/Services/OnboardingAISetupController.swiftindex 23cd2abf..14f46b21 100644--- a/Sources/Fluid/Services/OnboardingAISetupController.swift+++ b/Sources/Fluid/Services/OnboardingAISetupController.swift@@ -25,6 +25,8 @@ final class OnboardingAISetupController: ObservableObject {var recommend: () async throws -> Modelvar prepare: (Model, @escaping @Sendable (Progress) async -> Void) async throws -> Voidvar load: (Model) async throws -> Void+ var readPendingDownload: () -> Bool = { false }+ var writePendingDownload: (Bool) -> Void = { _ in }}/// Retained by the onboarding flow across Back/Continue; Replay is the only reset.@@ -36,6 +38,42 @@ final class OnboardingAISetupController: ObservableObject {private let dependencies: Dependenciesprivate var task: Task<Void, Never>?private var operationID = UUID()+ @Published private(set) var activationRequested = false+ private var isPrefetching = false+ private var pendingActivation: ((Model) throws -> Void)?+ private var prefetchAfterRefresh = false+ private var retryTask: Task<Void, Never>?+ private var retryDelay: UInt64 = 30++ func resumePendingDownload() {+ guard self.dependencies.readPendingDownload() else { return }+ self.prefetch()+ }++ private func finishPendingDownload() {+ self.dependencies.writePendingDownload(false)+ self.retryTask?.cancel()+ self.retryTask = nil+ self.retryDelay = 30+ }++ private func schedulePendingRetry() {+ guard self.dependencies.readPendingDownload(), self.retryTask == nil else { return }+ let delay = self.retryDelay+ self.retryDelay = min(delay * 2, 300)+ self.retryTask = Task { @MainActor [weak self] in+ do { try await Task.sleep(nanoseconds: delay * 1_000_000_000) } catch { return }+ guard let self else { return }+ self.retryTask = nil+ self.resumePendingDownload()+ }+ }++ var canEnable: Bool {+ !self.activationRequested && (self.phase == .offered || (self.isPrefetching && self.phase != .cancelling))+ }++ var showsPreparationProgress: Bool { self.activationRequested && self.isBusy }var isBusy: Bool { [.downloading, .loading, .cancelling].contains(self.phase) }@@ -50,7 +88,15 @@ final class OnboardingAISetupController: ObservableObject {self.phase = .checkingself.errorMessage = nilself.task = Task { @MainActor in- defer { if self.operationID == operation { self.task = nil } }+ defer {+ if self.operationID == operation {+ self.task = nil+ if self.prefetchAfterRefresh {+ self.prefetchAfterRefresh = false+ self.prefetch()+ }+ }+ }do {let model = try await self.dependencies.recommend()try Task.checkCancellation()@@ -65,15 +111,107 @@ final class OnboardingAISetupController: ObservableObject {}}+ /// Downloads the recommended model early without loading it or changing the user's settings.+ func prefetch() {+ self.dependencies.writePendingDownload(true)+ self.retryTask?.cancel()+ self.retryTask = nil+ if self.phase == .ready {+ self.finishPendingDownload()+ return+ }+ if self.task != nil {+ if self.phase == .checking, !self.isPrefetching { self.prefetchAfterRefresh = true }+ return+ }+ guard self.task == nil, self.phase != .ready else { return }+ if let model, model.installed {+ self.finishPendingDownload()+ self.phase = .offered+ return+ }++ let operation = UUID()+ self.operationID = operation+ self.progress = nil+ self.errorMessage = nil+ self.phase = .checking+ self.isPrefetching = true+ self.task = Task { @MainActor in+ defer {+ if self.operationID == operation {+ self.task = nil+ self.isPrefetching = false+ self.schedulePendingRetry()+ let activation = self.pendingActivation+ self.pendingActivation = nil+ self.activationRequested = false+ if self.phase == .offered, self.errorMessage == nil, let activation {+ self.enable(onReady: activation)+ }+ }+ }+ do {+ let model = try await self.dependencies.recommend()+ try Task.checkCancellation()+ guard self.operationID == operation else { return }+ self.model = model+ guard !model.installed else {+ self.finishPendingDownload()+ self.phase = .offered+ return+ }++ self.phase = .downloading+ try await self.dependencies.prepare(model) { progress in+ await MainActor.run {+ guard self.operationID == operation, self.phase == .downloading else { return }+ self.progress = progress+ }+ }+ try Task.checkCancellation()+ guard self.operationID == operation else { return }+ self.model = Model(+ id: model.id,+ name: model.name,+ byteCount: model.byteCount,+ installed: true+ )+ self.progress = nil+ self.phase = .offered+ self.finishPendingDownload()+ } catch {+ guard self.operationID == operation else { return }+ self.progress = nil+ self.phase = self.model == nil ? .unavailable : .offered+ if !Task.isCancelled, !(error is CancellationError) {+ self.errorMessage = error.localizedDescription+ }+ }+ }+ }+func enable(onReady: @escaping (Model) throws -> Void) {+ if self.isPrefetching, self.canEnable {+ self.activationRequested = true+ self.pendingActivation = onReady+ return+ }guard self.task == nil, self.phase == .offered, let model else { return }+ self.activationRequested = true+ if !model.installed { self.dependencies.writePendingDownload(true) }let operation = UUID()self.operationID = operationself.progress = nilself.errorMessage = nilself.phase = model.installed ? .loading : .downloadingself.task = Task { @MainActor in- defer { if self.operationID == operation { self.task = nil } }+ defer {+ if self.operationID == operation {+ self.task = nil+ self.schedulePendingRetry()+ }+ }do {if !model.installed {try await self.dependencies.prepare(model) { progress in@@ -85,16 +223,28 @@ final class OnboardingAISetupController: ObservableObject {}try Task.checkCancellation()guard self.operationID == operation else { return }+ self.model = Model(id: model.id, name: model.name, byteCount: model.byteCount, installed: true)+ self.finishPendingDownload()+ guard self.activationRequested else {+ self.phase = .offered+ self.progress = nil+ return+ }self.phase = .loadingself.progress = niltry await self.dependencies.load(model)try Task.checkCancellation()guard self.operationID == operation else { return }+ guard self.activationRequested else {+ self.phase = .offered+ return+ }// Persistence is performed only here, after readiness and cancellation checks.try onReady(model)self.phase = .ready} catch {guard self.operationID == operation else { return }+ self.activationRequested = falseself.phase = .offeredself.progress = nilif !Task.isCancelled, !(error is CancellationError) {@@ -104,7 +254,26 @@ final class OnboardingAISetupController: ObservableObject {}}+ /// Navigation withdraws activation, but the retained task finishes saving the model.+ func leavePage() {+ self.pendingActivation = nil+ self.activationRequested = false+ }++ func setUpLater() {+ self.leavePage()+ if self.task == nil {+ self.prefetch()+ } else if self.phase == .checking, !self.isPrefetching {+ self.prefetchAfterRefresh = true+ }+ }+func cancel() {+ self.finishPendingDownload()+ self.prefetchAfterRefresh = false+ self.pendingActivation = nil+ self.activationRequested = falseguard self.task != nil else { return }self.task?.cancel()self.progress = nildiff --git a/Sources/Fluid/Theme/Components/FluidDropdown.swift b/Sources/Fluid/Theme/Components/FluidDropdown.swiftnew file mode 100644index 00000000..e5210060--- /dev/null+++ b/Sources/Fluid/Theme/Components/FluidDropdown.swift@@ -0,0 +1,85 @@+import SwiftUI++/// Shared dropdown surface. Native menus, pickers, and searchable popovers use+/// this appearance while retaining their own selection and presentation logic.+struct FluidDropdownSurface: ViewModifier {+ @Environment(\.theme) private var theme+ @Environment(\.isEnabled) private var isEnabled+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @State private var isHovered = false+ var cornerRadius: CGFloat = 10++ func body(content: Content) -> some View {+ let highlighted = self.isHovered && self.isEnabled+ content+ .background {+ RoundedRectangle(cornerRadius: self.cornerRadius, style: .continuous)+ .fill(self.theme.palette.elevatedCardBackground)+ .overlay {+ RoundedRectangle(cornerRadius: self.cornerRadius, style: .continuous)+ .fill(self.theme.palette.accent.opacity(highlighted ? 0.08 : 0))+ }+ }+ .overlay {+ RoundedRectangle(cornerRadius: self.cornerRadius, style: .continuous)+ .strokeBorder(highlighted ? self.theme.palette.accent.opacity(0.45) : self.theme.palette.cardBorder, lineWidth: 1)+ .allowsHitTesting(false)+ }+ .contentShape(RoundedRectangle(cornerRadius: self.cornerRadius, style: .continuous))+ .onHover { self.isHovered = $0 }+ .animation(self.reduceMotion ? nil : .easeOut(duration: 0.14), value: highlighted)+ }+}++struct FluidDropdownChevron: View {+ @Environment(\.theme) private var theme+ var body: some View {+ Image(systemName: "chevron.down")+ .font(.fluidSystem(size: 10, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ .accessibilityHidden(true)+ }+}++private struct FluidDropdownControlStyle: ViewModifier {+ @Environment(\.theme) private var theme+ func body(content: Content) -> some View {+ content+ .menuStyle(.borderlessButton)+ .buttonStyle(.plain)+ .menuIndicator(.hidden)+ .labelsHidden()+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.theme.palette.primaryText)+ .padding(.leading, 12)+ .padding(.trailing, 30)+ .padding(.vertical, 9)+ .fluidDropdownSurface()+ .overlay(alignment: .trailing) {+ FluidDropdownChevron().padding(.trailing, 12).allowsHitTesting(false)+ }+ }+}++extension View {+ /// Apply outside a native menu/picker, rather than inside its label:+ /// macOS may flatten label styling when building the native control.+ func fluidDropdownStyle() -> some View { modifier(FluidDropdownControlStyle()) }++ /// For custom searchable controls that provide their own label and chevron.+ func fluidDropdownSurface(cornerRadius: CGFloat = 10) -> some View {+ modifier(FluidDropdownSurface(cornerRadius: cornerRadius))+ }+}++struct FluidDropdown<Content: View>: View {+ let title: String+ var width: CGFloat = 192+ @ViewBuilder let content: () -> Content++ var body: some View {+ Menu(content: self.content) { Text(self.title) }+ .fluidDropdownStyle()+ .frame(width: self.width)+ }+}diff --git a/Sources/Fluid/Theme/Components/FluidOutlinedButtonStyle.swift b/Sources/Fluid/Theme/Components/FluidOutlinedButtonStyle.swiftnew file mode 100644index 00000000..372affe0--- /dev/null+++ b/Sources/Fluid/Theme/Components/FluidOutlinedButtonStyle.swift@@ -0,0 +1,76 @@+import SwiftUI++/// Neutral action button, matching the shared dropdown surface.+/// Prominent primary actions retain their accent-filled styles.+struct FluidOutlinedButtonStyle: ButtonStyle {+ var height: CGFloat? = nil+ var fillsWidth = false+ var foreground: Color? = nil+ var borderColor: Color? = nil++ func makeBody(configuration: Configuration) -> some View {+ Control(+ configuration: configuration,+ height: self.height,+ fillsWidth: self.fillsWidth,+ foreground: self.foreground,+ borderColor: self.borderColor+ )+ }++ private struct Control: View {+ let configuration: ButtonStyle.Configuration+ let height: CGFloat?+ let fillsWidth: Bool+ let foreground: Color?+ let borderColor: Color?+ @Environment(\.theme) private var theme+ @Environment(\.isEnabled) private var isEnabled+ @Environment(\.controlSize) private var controlSize+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @State private var isHovered = false++ private var controlHeight: CGFloat {+ if let height { return height }+ switch self.controlSize {+ case .mini: return 26+ case .small: return 30+ case .large, .extraLarge: return 40+ default: return 34+ }+ }++ var body: some View {+ let highlighted = self.isEnabled && self.isHovered+ let pressed = self.isEnabled && self.configuration.isPressed+ let destructive = self.configuration.role == .destructive+ let tone = destructive ? Color(nsColor: .systemRed) : self.theme.palette.accent+ let shape = RoundedRectangle(cornerRadius: 10, style: .continuous)+ self.configuration.label+ .font(self.theme.typography.bodySmall)+ .fontWeight(.medium)+ .foregroundStyle(self.foreground ?? (destructive ? tone : self.theme.palette.primaryText))+ .padding(.horizontal, 12)+ .frame(maxWidth: self.fillsWidth ? .infinity : nil)+ .frame(minHeight: self.controlHeight)+ .background {+ shape.fill(self.theme.palette.elevatedCardBackground)+ .overlay { shape.fill(tone.opacity(pressed ? 0.15 : (highlighted ? 0.08 : 0))) }+ }+ .overlay {+ shape.strokeBorder(highlighted || pressed ? tone.opacity(0.45) : (self.borderColor ?? self.theme.palette.cardBorder), lineWidth: 1)+ }+ .contentShape(shape)+ .opacity(self.isEnabled ? 1 : 0.45)+ .onHover { self.isHovered = $0 }+ .animation(self.reduceMotion ? nil : .easeOut(duration: 0.14), value: highlighted)+ .animation(self.reduceMotion ? nil : .easeOut(duration: 0.1), value: pressed)+ }+ }+}++extension View {+ func fluidOutlinedButton() -> some View {+ self.buttonStyle(FluidOutlinedButtonStyle())+ }+}diff --git a/Sources/Fluid/Theme/Components/OnboardingComponents.swift b/Sources/Fluid/Theme/Components/OnboardingComponents.swiftindex a656143a..dccae33c 100644--- a/Sources/Fluid/Theme/Components/OnboardingComponents.swift+++ b/Sources/Fluid/Theme/Components/OnboardingComponents.swift@@ -534,11 +534,11 @@ private struct OnboardingSecondaryButtonModifier: ViewModifier {func body(content: Content) -> some View {if let controlSize {content- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(controlSize)} else {content- .buttonStyle(.bordered)+ .fluidOutlinedButton()}}}diff --git a/Sources/Fluid/Theme/Components/README.md b/Sources/Fluid/Theme/Components/README.mdnew file mode 100644index 00000000..e401b395--- /dev/null+++ b/Sources/Fluid/Theme/Components/README.md@@ -0,0 +1,36 @@+# Dropdown controls++All dropdown selectors share `FluidDropdown.swift`. Keep their selection bindings,+search, menu entries, and enabled states in their existing owners.++- Use `FluidDropdown(title:width:content:)` for a text-labelled menu.+- Apply `.fluidDropdownStyle()` after `.pickerStyle(.menu)` for native pickers,+ or outside the label closure of a native `Menu`.+- Searchable buttons use `searchablePickerControlChrome(width:height:)`, which+ delegates its surface to `FluidDropdownSurface`, plus `FluidDropdownChevron`.+- Custom/compact overlay triggers use `.fluidDropdownSurface()` with their existing+ compact layout. Do not change overlay hover-open behavior to adopt the style.++Do not duplicate outlines, hover fills, chevrons, or animation timings in screens.+Update the shared component to change the design everywhere. macOS can flatten+native menu labels, so putting the surface inside a `Menu` label is insufficient.+Segmented controls, disclosure rows, and icon-only action/context menus are not+selection dropdowns and retain their own controls.++Hover changes are local, disabled controls do not highlight, and Reduce Motion+suppresses the short hover transition. No timers, polling, or rendering-time I/O.++## Standard action buttons++The app theme installs `FluidOutlinedButtonStyle` as the default, so unstyled+buttons inherit it automatically, including sheets. Use `.fluidOutlinedButton()`+for an explicit neutral action override. Existing `.fluidButton(.secondary)`+and `.fluidCompactButton()` delegate to `FluidOutlinedButtonStyle` as well.+Use `.controlSize(.small)` for compact contexts. Preserve accent-filled primary+and destructive actions, link controls, and icon-only toolbar controls when those+semantics are intentional. Do not copy a local outline or hover implementation.+The shared style has hover/press feedback, disabled appearance, and reduced-motion+support without scaling or changing layout on hover.++Native `ToolbarItemGroup` buttons must explicitly use `.buttonStyle(.automatic)`+to preserve macOS grouping instead of inheriting the outlined form-action style.diff --git a/Sources/Fluid/Theme/NativeButtonStyles.swift b/Sources/Fluid/Theme/NativeButtonStyles.swiftindex 56180b30..192e542d 100644--- a/Sources/Fluid/Theme/NativeButtonStyles.swift+++ b/Sources/Fluid/Theme/NativeButtonStyles.swift@@ -276,47 +276,7 @@ struct SecondaryButtonStyle: ButtonStyle {var height: CGFloat = 42func makeBody(configuration: Configuration) -> some View {- SecondaryButton(configuration: configuration, height: self.height)- }-- private struct SecondaryButton: View {- @Environment(\.theme) private var theme- @State private var isHovered = false- let configuration: ButtonStyle.Configuration- let height: CGFloat-- private var shape: RoundedRectangle {- RoundedRectangle(cornerRadius: self.theme.metrics.corners.lg, style: .continuous)- }-- var body: some View {- self.configuration.label- .fontWeight(.semibold)- .frame(maxWidth: .infinity)- .frame(height: self.height)- .foregroundStyle(self.theme.palette.primaryText)- .background(self.theme.materials.card, in: self.shape)- .background(- self.shape- .fill(self.theme.palette.cardBackground)- .overlay(- self.shape.stroke(- self.theme.palette.cardBorder.opacity(self.isHovered ? 0.45 : 0.25),- lineWidth: 1- )- )- )- .shadow(- color: self.theme.palette.cardBorder.opacity(self.isHovered ? 0.35 : 0.15),- radius: self.isHovered ? self.theme.metrics.cardShadow.radius : max(self.theme.metrics.cardShadow.radius - 4, 1),- x: 0,- y: self.isHovered ? self.theme.metrics.cardShadow.y : self.theme.metrics.cardShadow.y - 2- )- .scaleEffect(FluidInteractionVisuals.scale(isPressed: self.configuration.isPressed, isHovered: self.isHovered))- .animation(FluidInteractionVisuals.hoverAnimation, value: self.isHovered)- .animation(FluidInteractionVisuals.pressedAnimation, value: self.configuration.isPressed)- .onHover { self.isHovered = $0 }- }+ FluidOutlinedButtonStyle(height: self.height, fillsWidth: true).makeBody(configuration: configuration)}}@@ -326,65 +286,12 @@ struct CompactButtonStyle: ButtonStyle {var isReady: Bool = falsevar foreground: Color? = nilvar borderColor: Color? = nil+var height: CGFloat = 34func makeBody(configuration: Configuration) -> some View {- CompactButton(- configuration: configuration,- isReady: self.isReady,- foreground: self.foreground,- borderColor: self.borderColor,- height: self.height- )- }-- private struct CompactButton: View {- @Environment(\.theme) private var theme- @State private var isHovered = false- let configuration: ButtonStyle.Configuration- let isReady: Bool- let foreground: Color?- let borderColor: Color?- let height: CGFloat-- private var shape: RoundedRectangle {- RoundedRectangle(cornerRadius: self.theme.metrics.corners.sm, style: .continuous)- }-- var body: some View {- let border = self.borderColor ?? (self.isReady ? self.theme.palette.accent : self.theme.palette.cardBorder)- let foregroundColor = self.foreground ?? self.theme.palette.primaryText- let borderOpacity = self.borderColor == nil- ? (self.isHovered ? 0.56 : 0.38)- : (self.isHovered ? 0.64 : 0.48)-- self.configuration.label- .fontWeight(.medium)- .padding(.horizontal, self.theme.metrics.spacing.md)- .frame(height: self.height)- .foregroundStyle(foregroundColor)- .background(self.theme.materials.card, in: self.shape)- .background(- self.shape- .fill(self.theme.palette.cardBackground)- .overlay(- self.shape.stroke(- border.opacity(borderOpacity),- lineWidth: 1- )- )- )- .shadow(- color: border.opacity(self.isHovered ? 0.18 : 0.06),- radius: self.isHovered ? 4 : 1.5,- x: 0,- y: self.isHovered ? 1 : 0.5- )- .scaleEffect(FluidInteractionVisuals.scale(isPressed: self.configuration.isPressed, isHovered: self.isHovered))- .animation(FluidInteractionVisuals.hoverAnimation, value: self.isHovered)- .animation(FluidInteractionVisuals.pressedAnimation, value: self.configuration.isPressed)- .onHover { self.isHovered = $0 }- }+ FluidOutlinedButtonStyle(height: self.height, foreground: self.foreground, borderColor: self.borderColor)+ .makeBody(configuration: configuration)}}@@ -540,72 +447,20 @@ struct FormRowStyle: ViewModifier {// MARK: - Searchable Picker Chrome-struct FluidPickerDisclosureIcon: View {- @Environment(\.theme) private var theme- var backgroundOpacity: Double-- var body: some View {- let picker = self.theme.metrics.pickerControl-- Image(systemName: "chevron.down")- .font(.fluidSystem(.caption2))- .foregroundStyle(.secondary)- .frame(width: picker.disclosureSize, height: picker.disclosureSize)- .background(- Circle()- .fill(self.theme.palette.cardBackground.opacity(self.backgroundOpacity))- .overlay(- Circle()- .stroke(self.theme.palette.cardBorder.opacity(picker.disclosureBorderOpacity), lineWidth: 1)- )- )- }-}-struct SearchablePickerControlChrome: ViewModifier {+ static let horizontalPadding: CGFloat = 12@Environment(\.theme) private var themelet width: CGFloat?let height: CGFloat?- let usesMaterial: Bool- let showsShadow: Bool- @ViewBuilderfunc body(content: Content) -> some View {- let picker = self.theme.metrics.pickerControl- let shape = RoundedRectangle(cornerRadius: picker.cornerRadius, style: .continuous)- let control = content+ content.frame(width: self.width, alignment: .leading).frame(maxWidth: self.width == nil ? .infinity : nil, alignment: .leading)- .padding(.horizontal, picker.horizontalPadding)- .padding(.vertical, picker.verticalPadding)+ .padding(.horizontal, Self.horizontalPadding)+ .padding(.vertical, self.height == nil ? 9 : 0).frame(height: self.height)- .contentShape(Rectangle())-- if self.usesMaterial {- control- .background(self.theme.materials.card, in: shape)- .background(self.pickerSurface(shape, picker: picker))- .shadow(- color: self.theme.palette.cardBorder.opacity(self.showsShadow ? 0.18 : 0),- radius: self.showsShadow ? 3 : 0,- x: 0,- y: self.showsShadow ? 1 : 0- )- } else {- control- .background(self.pickerSurface(shape, picker: picker))- }- }-- private func pickerSurface(- _ shape: RoundedRectangle,- picker: AppTheme.Metrics.PickerControl- ) -> some View {- shape- .fill(self.theme.palette.cardBackground)- .overlay(- shape.stroke(self.theme.palette.cardBorder.opacity(picker.borderOpacity), lineWidth: 1)- )+ .fluidDropdownSurface()}}@@ -635,15 +490,11 @@ extension View {func searchablePickerControlChrome(width: CGFloat? = nil,- height: CGFloat? = nil,- usesMaterial: Bool = false,- showsShadow: Bool = false+ height: CGFloat? = nil) -> some View {modifier(SearchablePickerControlChrome(width: width,- height: height,- usesMaterial: usesMaterial,- showsShadow: showsShadow+ height: height))}diff --git a/Sources/Fluid/Theme/ThemeEnvironment.swift b/Sources/Fluid/Theme/ThemeEnvironment.swiftindex b19aa1ca..481d4857 100644--- a/Sources/Fluid/Theme/ThemeEnvironment.swift+++ b/Sources/Fluid/Theme/ThemeEnvironment.swift@@ -15,12 +15,15 @@ extension View {/// Applies an app theme to the view hierarchy.@ViewBuilderfunc appTheme(_ theme: AppTheme) -> some View {- if FluidTypography.overridesStandard {- self.environment(\.theme, theme)- .font(.fluidSystem(.body))- } else {- self.environment(\.theme, theme)+ Group {+ if FluidTypography.overridesStandard {+ self.font(.fluidSystem(.body))+ } else {+ self+ }}+ .environment(\.theme, theme)+ .buttonStyle(FluidOutlinedButtonStyle())}}diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swiftindex 0677caed..6e39d8eb 100644--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift@@ -47,6 +47,7 @@ struct AIEnhancementSettingsView: View {@State var hoveredPromptModeKey: String? = nil@State var hoveredPromptScopeKey: String? = nil@State var isPromptProfilesHelpPresented: Bool = false+ @State var showsAppSpecificStyles = false@State var promptEditorPrimarySelectionDraft: SettingsStore.DictationPromptSelection? = nil@State var promptEditorShortcutDraft: HotkeyShortcut? = nil@State var promptEditorProviderIDDraft: String = ""@@ -103,43 +104,4 @@ struct AIEnhancementSettingsView: View {Text(self.viewModel.appPromptBindingErrorMessage)}}-- var customPromptOnlyToggleRow: some View {- HStack(alignment: .center, spacing: 12) {- Image(systemName: "text.quote")- .font(.fluidSystem(size: 13, weight: .semibold))- .foregroundStyle(self.theme.palette.accent)- .frame(width: 24, height: 24)-- VStack(alignment: .leading, spacing: 3) {- Text("Send Custom Prompt Only")- .font(.fluidSystem(size: 13, weight: .semibold))- .foregroundStyle(self.theme.palette.primaryText)- Text("For custom Dictate prompts, send your prompt without prepending the built-in dictation prompt.")- .font(.fluidSystem(.caption2))- .foregroundStyle(self.theme.palette.secondaryText)- .fixedSize(horizontal: false, vertical: true)- }-- Spacer(minLength: 12)-- Toggle("", isOn: Binding(- get: { self.viewModel.sendCustomPromptOnly },- set: { self.viewModel.setSendCustomPromptOnly($0) }- ))- .toggleStyle(.switch)- .labelsHidden()- .help("Send custom Dictate prompts without prepending the built-in dictation prompt.")- }- .padding(.horizontal, 13)- .padding(.vertical, 10)- .background(- RoundedRectangle(cornerRadius: 10, style: .continuous)- .fill(self.theme.palette.cardBackground.opacity(0.72))- .overlay(- RoundedRectangle(cornerRadius: 10, style: .continuous)- .stroke(self.theme.palette.cardBorder.opacity(0.32), lineWidth: 1)- )- )- }}diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swiftindex bc8b451a..6d450156 100644--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift@@ -116,7 +116,6 @@ final class AIEnhancementSettingsViewModel: ObservableObject {@Published var appPromptBindingErrorMessage: String = ""@Published var selectedDictationPromptID: String? = nil@Published var selectedEditPromptID: String? = nil- @Published var sendCustomPromptOnly: Bool = false@Published var promptEditorMode: PromptEditorMode? = nil@Published var draftPromptName: String = ""@Published var draftPromptText: String = ""@@ -170,7 +169,6 @@ final class AIEnhancementSettingsViewModel: ObservableObject {self.appPromptBindings = self.settings.appPromptBindingsself.selectedDictationPromptID = self.settings.selectedDictationPromptIDself.selectedEditPromptID = self.settings.selectedEditPromptID- self.sendCustomPromptOnly = self.settings.sendCustomPromptOnlyself.isDictationPromptOff = self.settings.isDictationPromptOffself.isEditPromptOff = self.settings.isEditPromptOff@@ -1645,8 +1643,9 @@ final class AIEnhancementSettingsViewModel: ObservableObject {return singleLine.count > 120 ? String(singleLine.prefix(120)) + "…" : singleLine}- /// Combine a user-visible body with the hidden base prompt to ensure role/intent is always present.+ /// Preview uses the same prompt composition as the selected editor mode.func combinedDraftPrompt(_ text: String, mode: SettingsStore.PromptMode) -> String {+ if mode.normalized == .dictate, self.promptEditorMode?.isDefault != true { return text }let body = SettingsStore.stripBasePrompt(for: mode, from: text)return SettingsStore.combineBasePrompt(for: mode, with: body)}@@ -1737,7 +1736,7 @@ final class AIEnhancementSettingsViewModel: ObservableObject {self.draftPromptMode = profile.mode.normalizedself.draftIncludeContext = (self.draftPromptMode == .edit) ? true : profile.includeContextself.draftPromptName = profile.name- self.draftPromptText = SettingsStore.stripBasePrompt(for: self.draftPromptMode, from: profile.prompt)+ self.draftPromptText = SettingsStore.customPromptBody(profile.prompt, mode: self.draftPromptMode)self.promptEditorSessionID = UUID()self.promptEditorMode = .edit(promptID: profile.id)}@@ -1770,7 +1769,7 @@ final class AIEnhancementSettingsViewModel: ObservableObject {}let name = self.draftPromptName.trimmingCharacters(in: .whitespacesAndNewlines)- let promptBody = SettingsStore.stripBasePrompt(for: self.draftPromptMode, from: self.draftPromptText)+ let promptBody = SettingsStore.customPromptBody(self.draftPromptText, mode: self.draftPromptMode)let includeContext = (self.draftPromptMode.normalized == .edit) ? true : self.draftIncludeContextvar profiles = self.settings.dictationPromptProfiles@@ -1783,6 +1782,7 @@ final class AIEnhancementSettingsViewModel: ObservableObject {var updated = profiles[idx]updated.name = nameupdated.prompt = promptBody+ updated.usesLegacyEmptyPromptFallback = falseupdated.mode = self.draftPromptMode.normalizedupdated.includeContext = includeContextupdated.updatedAt = now@@ -1949,7 +1949,7 @@ final class AIEnhancementSettingsViewModel: ObservableObject {$0.mode.normalized == mode.normalized})else {- return mode.normalized == .dictate ? "Smart" : "Built-in Default"+ return mode.normalized == .dictate ? SettingsStore.DictationModeLabels.externalDefault : "Built-in Default"}let trimmed = profile.name.trimmingCharacters(in: .whitespacesAndNewlines)@@ -1968,11 +1968,6 @@ final class AIEnhancementSettingsViewModel: ObservableObject {self.isEditPromptOff = self.settings.isEditPromptOff}- func setSendCustomPromptOnly(_ sendOnly: Bool) {- self.settings.sendCustomPromptOnly = sendOnly- self.sendCustomPromptOnly = self.settings.sendCustomPromptOnly- }-func isPrimaryDictationPromptSelectionOff() -> Bool {return self.settings.isDictationPromptOff}@@ -2078,7 +2073,6 @@ final class AIEnhancementSettingsViewModel: ObservableObject {private func refreshPromptSelectionState() {self.selectedDictationPromptID = self.settings.selectedDictationPromptIDself.selectedEditPromptID = self.settings.selectedEditPromptID- self.sendCustomPromptOnly = self.settings.sendCustomPromptOnlyself.isDictationPromptOff = self.settings.isDictationPromptOffself.isEditPromptOff = self.settings.isEditPromptOff}diff --git a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swiftindex 2649405e..317a89d5 100644--- a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift+++ b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift@@ -899,6 +899,7 @@ extension AIEnhancementSettingsView {}}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().disabled(isBusy).help("Local Fluid-1 runtime. Default is MLX on Apple Silicon.")@@ -1887,36 +1888,7 @@ extension AIEnhancementSettingsView {}var promptsStepContent: some View {- VStack(alignment: .leading, spacing: 12) {- HStack(spacing: 8) {- Image(systemName: "text.bubble.fill")- .font(.fluidSystem(size: 12, weight: .medium))- .foregroundStyle(self.theme.palette.accent)- Text("Styles")- .font(.fluidSystem(size: 14, weight: .semibold))- .lineLimit(1)- .truncationMode(.tail)-- Button {- self.isPromptProfilesHelpPresented.toggle()- } label: {- Image(systemName: "info.circle")- .font(.fluidSystem(size: 12, weight: .semibold))- .foregroundStyle(self.theme.palette.secondaryText.opacity(0.78))- .frame(width: 22, height: 22)- .contentShape(Circle())- }- .buttonStyle(.plain)- .help("About prompt profiles")- .popover(isPresented: self.$isPromptProfilesHelpPresented, arrowEdge: .top) {- self.promptProfilesHelpPopover- }-- Spacer()- }-- self.advancedSettingsCard- }+ self.advancedSettingsCard}var builtInProvidersList: [(id: String, name: String)] {@@ -2485,6 +2457,7 @@ extension AIEnhancementSettingsView {Text("Custom...").tag("custom")}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().frame(width: 140)}@@ -2521,6 +2494,7 @@ extension AIEnhancementSettingsView {Text("high").tag("high")}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().frame(width: 100)} else if self.viewModel.editingReasoningParamName == "enable_thinking" {@@ -2529,6 +2503,7 @@ extension AIEnhancementSettingsView {Text("false").tag("false")}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().frame(width: 100)} else {diff --git a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swiftindex fc77e7ed..df7185ec 100644--- a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift+++ b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift@@ -25,6 +25,32 @@ private struct PromptCardModelPicker {let onOpenProviders: () -> Void}+private struct PromptAdvancedDisclosureStyle: DisclosureGroupStyle {+ func makeBody(configuration: Configuration) -> some View {+ VStack(alignment: .leading, spacing: 0) {+ Button {+ configuration.isExpanded.toggle()+ } label: {+ HStack(spacing: 10) {+ Image(systemName: configuration.isExpanded ? "chevron.down" : "chevron.right")+ .font(.system(size: 11, weight: .semibold))+ .frame(width: 14)+ .accessibilityHidden(true)+ configuration.label+ }+ .padding(.vertical, 8)+ .frame(maxWidth: .infinity, alignment: .leading)+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .accessibilityValue(configuration.isExpanded ? "Expanded" : "Collapsed")+ if configuration.isExpanded {+ configuration.content+ }+ }+ }+}+extension AIEnhancementSettingsView {// MARK: - Advanced Settings Card@@ -109,6 +135,7 @@ extension AIEnhancementSettingsView {assignments: PromptCardAssignments? = nil,notice: String? = nil,onManage: (() -> Void)? = nil,+ manageTitle: String? = nil,onDelete: (() -> Void)? = nil,isEnabled: Bool = true) -> some View {@@ -140,7 +167,11 @@ extension AIEnhancementSettingsView {Spacer(minLength: 10)HStack(spacing: 8) {- if let onManage {+ if let onManage, let manageTitle {+ Button(manageTitle, action: onManage)+ .fluidOutlinedButton()+ .disabled(!isEnabled)+ } else if let onManage {Button {onManage()} label: {@@ -164,26 +195,23 @@ extension AIEnhancementSettingsView {.buttonStyle(SquareIconButtonStyle(foreground: .red, borderColor: .red.opacity(0.5))).disabled(!isEnabled).help("Delete")- } else {- Color.clear- .frame(width: AISettingsLayout.providerRowControlHeight, height: AISettingsLayout.providerRowControlHeight)}}.fixedSize(horizontal: true, vertical: false)}- // Line 2: config metadata chips- if let assignments {- self.promptCardMetadataChips(- assignments: assignments,- tone: tone,- isEnabled: isEnabled- )+ if let shortcut = assignments?.shortcutDisplay {+ HStack {+ Label(shortcut, systemImage: "keyboard")+ .font(.fluidSystem(.caption2))+ .foregroundStyle(self.theme.palette.secondaryText)+ Spacer(minLength: 0)+ }+ .padding(.leading, 46)}}- .padding(.horizontal, 13)- .padding(.vertical, 9)- .frame(minHeight: 86)+ .padding(16)+ .frame(minHeight: 76).opacity(isEnabled ? 1 : 0.68).background(shape@@ -268,8 +296,7 @@ extension AIEnhancementSettingsView {Text(subtitle).font(.fluidSystem(.caption2)).foregroundStyle(.secondary)- .lineLimit(1)- .truncationMode(.tail)+ .fixedSize(horizontal: false, vertical: true).multilineTextAlignment(.leading)}}@@ -669,7 +696,7 @@ extension AIEnhancementSettingsView {}private func promptEditorConfigurationPanel(mode: PromptEditorMode) -> some View {- Grid(alignment: .leading, horizontalSpacing: 28, verticalSpacing: 14) {+ Grid(alignment: .leading, horizontalSpacing: 20, verticalSpacing: 12) {self.promptEditorShortcutRow(mode: mode)if mode.isPrivateAI {GridRow {@@ -687,15 +714,11 @@ extension AIEnhancementSettingsView {.font(self.theme.typography.caption)}}- Group {+ if !mode.isPrivateAI {self.promptEditorProviderRow- if !mode.isPrivateAI {- self.promptEditorProviderGuidance- }self.promptEditorModelRow+ self.promptEditorProviderGuidance}- .disabled(mode.isPrivateAI)- .opacity(mode.isPrivateAI ? 0.6 : 1)}.padding(14).frame(maxWidth: .infinity, alignment: .leading)@@ -755,9 +778,7 @@ extension AIEnhancementSettingsView {}.searchablePickerControlChrome(width: isRecording ? 192 : 114,- height: AISettingsLayout.controlHeight,- usesMaterial: true,- showsShadow: true+ height: AISettingsLayout.controlHeight)Button {@@ -823,24 +844,11 @@ extension AIEnhancementSettingsView {}}}- } label: {- HStack(spacing: 6) {- Text(self.viewModel.providerDisplayName(for: self.promptEditorProviderIDDraft))- .font(.fluidSystem(size: 12, weight: .semibold))- .foregroundStyle(self.theme.palette.primaryText)- .lineLimit(1)- .truncationMode(.tail)- Spacer(minLength: 4)- FluidPickerDisclosureIcon(backgroundOpacity: 0.6)- }- .searchablePickerControlChrome(- width: AISettingsLayout.promptEditorControlColumnWidth,- height: AISettingsLayout.controlHeight,- usesMaterial: true,- showsShadow: true- )- }- .buttonStyle(.plain)+ } label: { Text(self.viewModel.providerDisplayName(for: self.promptEditorProviderIDDraft)) }+ .frame(maxWidth: .infinity, alignment: .leading)+ .fluidDropdownStyle()+ .frame(width: AISettingsLayout.promptEditorControlColumnWidth)+ .buttonStyle(.plain)}}@@ -877,14 +885,17 @@ extension AIEnhancementSettingsView {}private var promptEditorModelRow: some View {- self.promptEditorConfigRow(title: "Model", description: "Used for this prompt.") {+ self.promptEditorConfigRow(title: "Model", description: "") {HStack(spacing: 8) {SearchableModelPicker(models: self.viewModel.models(for: self.promptEditorProviderIDDraft),selectedModel: self.promptEditorModelBinding,onRefresh: nil,selectionEnabled: !self.viewModel.models(for: self.promptEditorProviderIDDraft).isEmpty,- controlWidth: AISettingsLayout.promptEditorControlColumnWidth - AISettingsLayout.providerRowControlHeight - 8,+ // The searchable control adds its horizontal padding outside its content width.+ controlWidth: AISettingsLayout.promptEditorControlColumnWidth+ - AISettingsLayout.providerRowControlHeight - 8+ - 2 * SearchablePickerControlChrome.horizontalPadding,controlHeight: AISettingsLayout.controlHeight)@@ -1066,58 +1077,56 @@ extension AIEnhancementSettingsView {VStack(alignment: .leading, spacing: 10) {VStack(alignment: .leading, spacing: 10) {- self.promptRoutingScopeRow(mode: mode)-- if mode.normalized == .dictate {- self.customPromptOnlyToggleRow- }-- Text(- isSelectedAppsOnly- ? "Custom prompts only run in apps listed in App Overrides."- : "Custom prompts run based on your shortcut or the app you're in."- )- .font(.fluidSystem(.caption2))- .foregroundStyle(self.theme.palette.secondaryText)- .padding(.horizontal, 4)- .padding(.bottom, 2)-- if privateAIAvailable {- let privateAISelection = SettingsStore.DictationPromptSelection.privateAI- self.promptProfileCard(- cardKey: "\(mode.normalized.rawValue)-\(PrivateAIProviderFeature.shared.providerID)",- title: "Smart",- subtitle: PrivateAIProviderFeature.displayName,- mode: mode,- isSelected: self.viewModel.isPrivateAIPromptSelected(),- assignments: self.promptAssignments(selection: privateAISelection, isPrivateAI: true),- onManage: { self.viewModel.openPrivateAIPromptEditor() },- isEnabled: true- )+ FluidGlassControlGroup {+ LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 16), count: privateAIAvailable ? 2 : 1), spacing: 16) {+ if privateAIAvailable {+ let assignments = self.promptAssignments(selection: .privateAI, isPrivateAI: true)+ self.builtInStyleCard(+ title: SettingsStore.DictationModeLabels.smart,+ symbol: "sparkles",+ subtitle: "On-device · \(assignments.modelPicker.map { ModelDisplayName.forID($0.selectedModel) } ?? "Fluid Intelligence")",+ detail: "Built-in style",+ assignments: assignments,+ isEnabled: true,+ action: ("Edit shortcut", { self.viewModel.openPrivateAIPromptEditor() })+ )+ }+ let assignments = self.promptAssignments(selection: .default)+ self.builtInStyleCard(+ title: SettingsStore.DictationModeLabels.externalDefault,+ symbol: "textformat",+ subtitle: assignments.isReady ? self.styleConfigurationSummary(assignments) : "External AI provider",+ detail: assignments.isReady ? "Customizable cleanup" : "Setup required",+ assignments: assignments,+ isEnabled: true,+ action: (assignments.isReady ? "Edit style" : "Set up", { self.viewModel.openDefaultPromptViewer(for: mode) })+ )+ }}- Group {- let defaultSelection = SettingsStore.DictationPromptSelection.default- self.promptProfileCard(- cardKey: "\(mode.normalized.rawValue)-default",- title: mode.normalized == .dictate ? "Smart" : "Default \(self.friendlyModeName(mode))",- subtitle: "",- mode: mode,- isSelected: self.viewModel.selectedPromptID(for: mode) == nil,- assignments: mode.normalized == .dictate- ? self.promptAssignments(selection: defaultSelection)- : nil,- onManage: { self.viewModel.openDefaultPromptViewer(for: mode) },- isEnabled: !isSelectedAppsOnly- )+ VStack(alignment: .leading, spacing: 10) {+ HStack {+ Text("Custom instructions").font(self.theme.typography.bodyStrong)+ Spacer()+ Button {+ self.viewModel.openNewPromptEditor(prefillMode: mode)+ } label: {+ Label("Add instruction", systemImage: "plus")+ }+ .fluidOutlinedButton()+ }- if !customProfiles.isEmpty {+ if customProfiles.isEmpty {+ Text("Your own cleanup instructions.")+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.theme.palette.secondaryText)+ } else {ForEach(customProfiles) { profile inlet profileSelection = SettingsStore.DictationPromptSelection.profile(profile.id)self.promptProfileCard(cardKey: "\(profile.mode.normalized.rawValue)-\(profile.id)",title: profile.name.isEmpty ? "Untitled Prompt" : profile.name,- subtitle: "",+ subtitle: self.styleConfigurationSummary(self.promptAssignments(selection: profileSelection)),mode: profile.mode,isSelected: self.viewModel.selectedPromptID(for: profile.mode) == profile.id,assignments: profile.mode.normalized == .dictate@@ -1125,19 +1134,124 @@ extension AIEnhancementSettingsView {: nil,onManage: { self.viewModel.openEditor(for: profile) },onDelete: { self.viewModel.requestDeletePrompt(profile) },- isEnabled: !isSelectedAppsOnly+ isEnabled: true)}}- }- .opacity(isSelectedAppsOnly ? 0.5 : 1)- self.appPromptBindingsSection(mode: mode, isEmphasized: isSelectedAppsOnly, isEnabled: true)+ Divider().padding(.vertical, 4)+ DisclosureGroup(isExpanded: self.$showsAppSpecificStyles) {+ VStack(alignment: .leading, spacing: 12) {+ Text("Where custom styles apply")+ .font(self.theme.typography.bodyStrong)+ self.promptRoutingScopeRow(mode: mode)+ Text(isSelectedAppsOnly+ ? "Custom styles run only in the apps listed below. Other apps use the built-in prompt for the selected mode."+ : "Your chosen custom style can run in any app. Add an app rule below to use a different style there.")+ .font(.fluidSystem(.caption))+ .foregroundStyle(self.theme.palette.secondaryText)+ .fixedSize(horizontal: false, vertical: true)+ self.appPromptBindingsSection(mode: mode, isEmphasized: isSelectedAppsOnly, isEnabled: true)+ }+ .padding(.top, 12)+ } label: {+ HStack {+ Text("Advanced").font(self.theme.typography.bodyStrong)+ Spacer()+ if isSelectedAppsOnly {+ Text("Listed apps only")+ .font(.fluidSystem(.caption))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ let ruleCount = self.viewModel.appBindings(for: mode).count+ if ruleCount > 0 {+ Text("\(ruleCount) app \(ruleCount == 1 ? "rule" : "rules")")+ .font(.fluidSystem(.caption))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ }+ }+ .disclosureGroupStyle(PromptAdvancedDisclosureStyle())+ }+ .padding(16)+ .background(self.theme.palette.cardBackground, in: RoundedRectangle(cornerRadius: 16))+ .overlay {+ RoundedRectangle(cornerRadius: 16)+ .strokeBorder(self.theme.palette.cardBorder, lineWidth: 1)+ .allowsHitTesting(false)+ }}}.padding(.top, 2)}+ private func builtInStyleCard(+ title: String,+ symbol: String,+ subtitle: String,+ detail: String,+ assignments: PromptCardAssignments,+ isEnabled: Bool,+ action: (title: String, perform: () -> Void)+ ) -> some View {+ HStack(alignment: .center, spacing: 16) {+ HStack(alignment: .center, spacing: 12) {+ Image(systemName: symbol)+ .font(.fluidSystem(size: 20, weight: .medium))+ .foregroundStyle(symbol == "sparkles" ? self.theme.palette.accent : self.theme.palette.secondaryText)+ .frame(width: 24, height: 24)+ .accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 4) {+ Text(title)+ .font(.fluidSystem(size: 14, weight: .semibold))+ .foregroundStyle(self.theme.palette.primaryText)+ Text(subtitle)+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.theme.palette.secondaryText)+ Text(detail)+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(assignments.isReady ? self.theme.palette.secondaryText : self.theme.palette.warning)+ }+ .fixedSize(horizontal: false, vertical: true)+ }+ Spacer(minLength: 0)+ VStack(alignment: .trailing, spacing: 6) {+ Button(action.title, action: action.perform)+ .fluidOutlinedButton()+ .fixedSize()+ .disabled(!isEnabled)+ if let shortcut = assignments.shortcutDisplay {+ Label(shortcut, systemImage: "keyboard")+ .font(.fluidSystem(.caption2))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ }+ }+ .padding(16)+ .frame(maxWidth: .infinity, minHeight: 104, alignment: .leading)+ .background {+ RoundedRectangle(cornerRadius: 16)+ .fill(self.theme.palette.accent.opacity(assignments.isDefault ? 0.1 : 0))+ }+ .background {+ RoundedRectangle(cornerRadius: 16)+ .fill(self.theme.palette.cardBackground)+ }+ .overlay {+ RoundedRectangle(cornerRadius: 16)+ .strokeBorder(assignments.isDefault ? self.theme.palette.accent : self.theme.palette.cardBorder, lineWidth: 1)+ .allowsHitTesting(false)+ }+ }++ private func styleConfigurationSummary(_ assignments: PromptCardAssignments) -> String {+ guard let picker = assignments.modelPicker, !picker.providerName.isEmpty else {+ return "External provider required"+ }+ guard assignments.isReady else { return "\(picker.providerName) · Setup required" }+ return "\(picker.providerName) · \(ModelDisplayName.forID(picker.selectedModel))"+ }+private func promptModeHintRow(mode: SettingsStore.PromptMode) -> some View {HStack {if mode.normalized == .dictate {@@ -1154,41 +1268,15 @@ extension AIEnhancementSettingsView {private func promptRoutingScopeRow(mode: SettingsStore.PromptMode) -> some View {HStack(alignment: .center, spacing: 10) {- HStack(spacing: 4) {- self.promptRoutingScopeButton(- title: "All apps",- scope: .allApps,- mode: mode- )- self.promptRoutingScopeButton(- title: "Selected apps only",- scope: .selectedAppsOnly,- mode: mode- )+ VStack(alignment: .leading, spacing: 10) {+ self.promptRoutingScopeButton(title: "Everywhere", scope: .allApps, mode: mode)+ self.promptRoutingScopeButton(title: "Only in listed apps", scope: .selectedAppsOnly, mode: mode)}- .padding(3)- .background(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .fill(self.theme.palette.contentBackground)- .overlay(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .stroke(self.theme.palette.cardBorder, lineWidth: 1)- )- )Spacer(minLength: 12)if mode.normalized == .edit {self.editModeInlineModelControls- } else {- Button {- self.viewModel.openNewPromptEditor(prefillMode: .dictate)- } label: {- Label("Add Prompt", systemImage: "plus")- .font(.fluidSystem(size: 12, weight: .semibold))- .frame(minWidth: AISettingsLayout.actionMinWidth, minHeight: AISettingsLayout.controlHeight)- }- .fluidCompactButton(isReady: true, foreground: Color.fluidGreen, borderColor: Color.fluidGreen.opacity(0.5))}}.frame(minHeight: AISettingsLayout.controlHeight)@@ -1207,23 +1295,21 @@ extension AIEnhancementSettingsView {let isEnabled = truelet isHovering = isEnabled && self.hoveredPromptScopeKey == keylet tone = self.modeAccentColor(mode)- let cornerRadius: CGFloat = 9return Button {guard isEnabled else { return }self.viewModel.setPromptRoutingScope(scope, for: mode)} label: {- Text(title)- .font(.fluidSystem(size: 12, weight: .semibold))- .foregroundStyle(isSelected ? tone : (isHovering ? self.theme.palette.primaryText : self.theme.palette.secondaryText))- .frame(width: scope == .allApps ? 72 : 132, height: 26)- .contentShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))- .fluidControlSurface(- isSelected: isSelected,- isHovered: isHovering,- tone: tone,- cornerRadius: cornerRadius- )+ HStack(spacing: 9) {+ Image(systemName: isSelected ? "largecircle.fill.circle" : "circle")+ .font(.fluidSystem(size: 17))+ .foregroundStyle(isSelected ? tone : self.theme.palette.secondaryText)+ Text(title)+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(isHovering ? self.theme.palette.primaryText : self.theme.palette.secondaryText)+ }+ .padding(.vertical, 3)+ .contentShape(Rectangle())}.buttonStyle(.plain).disabled(!isEnabled)@@ -1308,6 +1394,7 @@ extension AIEnhancementSettingsView {}}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().frame(width: AISettingsLayout.promptInlinePickerWidth).disabled(self.settings.rewriteModeLinkedToGlobal)@@ -1359,7 +1446,7 @@ extension AIEnhancementSettingsView {Image(systemName: "app.dashed").font(.fluidSystem(size: 12, weight: .semibold)).foregroundStyle(self.theme.palette.secondaryText)- Text("App Overrides")+ Text("App-specific styles").font(.fluidSystem(size: 13, weight: .semibold)).foregroundStyle(self.theme.palette.secondaryText)@@ -1388,7 +1475,7 @@ extension AIEnhancementSettingsView {} label: {Text("+ Add App")}- .fluidCompactButton(isReady: true)+ .fluidDropdownStyle().frame(minHeight: AISettingsLayout.controlHeight).disabled(!isEnabled).opacity(isEnabled ? 1 : 0.48)@@ -1443,7 +1530,7 @@ extension AIEnhancementSettingsView {HStack(spacing: 8) {Menu {- Button("Default") {+ Button(SettingsStore.DictationModeLabels.externalDefault) {self.viewModel.setPromptID(nil, for: binding)}@@ -1461,25 +1548,11 @@ extension AIEnhancementSettingsView {}}}- } label: {- HStack(spacing: 6) {- Text(self.viewModel.promptName(for: mode, promptID: binding.promptID))- .font(.fluidSystem(size: 12, weight: .semibold))- .foregroundStyle(self.theme.palette.primaryText)- .lineLimit(1)- .truncationMode(.tail)- Spacer(minLength: 4)- FluidPickerDisclosureIcon(backgroundOpacity: 0.6)- }- .searchablePickerControlChrome(- width: 200,- height: AISettingsLayout.controlHeight,- usesMaterial: false,- showsShadow: false- )- }- .buttonStyle(.plain)- .disabled(!isEnabled)+ } label: { Text(self.viewModel.promptName(for: mode, promptID: binding.promptID)) }+ .fluidDropdownStyle()+ .frame(width: 224)+ .buttonStyle(.plain)+ .disabled(!isEnabled)Button {guard isEnabled else { return }@@ -1779,10 +1852,6 @@ extension AIEnhancementSettingsView {self.promptTest.updateDraftPromptText(combined)}}-- if self.viewModel.draftPromptMode == .dictate {- self.baseDictationPromptReference- }}if self.viewModel.draftPromptMode != .dictate {@@ -1814,15 +1883,6 @@ extension AIEnhancementSettingsView {if self.viewModel.draftPromptMode == .dictate && !mode.isPrivateAI {VStack(alignment: .leading, spacing: 8) {- HStack(spacing: 8) {- Image(systemName: "waveform")- .foregroundStyle(self.theme.palette.accent)- Text("Test")- .font(.fluidSystem(.subheadline))- .fontWeight(.semibold)- Spacer()- }-let hotkeyDisplay = self.settings.primaryDictationShortcutDisplayStringlet canTest = DictationAIPostProcessingGate.isProviderConfigured(providerID: self.promptEditorProviderIDDraft,@@ -1844,14 +1904,14 @@ extension AIEnhancementSettingsView {}})) {- Text("Enable Test Mode (Hotkey: \(hotkeyDisplay))")+ Text("Test prompt · \(hotkeyDisplay)").font(.fluidSystem(.caption))}.toggleStyle(.switch).disabled(!canTest)if !canTest {- Text("Testing is disabled because AI post-processing is not configured.")+ Text("Choose a provider and model to test your prompt.").font(.fluidSystem(.caption2)).foregroundStyle(.secondary)} else if self.promptTest.isActive {@@ -1920,10 +1980,11 @@ extension AIEnhancementSettingsView {}}}+ .frame(maxWidth: .infinity, alignment: .leading).padding(12).background(RoundedRectangle(cornerRadius: 12, style: .continuous)- .fill(self.theme.palette.accent.opacity(0.08))+ .fill(self.theme.palette.contentBackground).overlay(RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(self.theme.palette.cardBorder, lineWidth: 1)@@ -1973,7 +2034,13 @@ extension AIEnhancementSettingsView {}.padding()}- .frame(minWidth: 780, idealWidth: 820, minHeight: 420, idealHeight: 700, maxHeight: 720)+ .frame(+ minWidth: mode.isPrivateAI ? 620 : 780,+ idealWidth: mode.isPrivateAI ? 620 : 820,+ minHeight: mode.isPrivateAI ? 230 : 420,+ idealHeight: mode.isPrivateAI ? 230 : 700,+ maxHeight: mode.isPrivateAI ? 260 : 720+ ).onAppear {self.preparePromptEditorConfigurationDraft(mode: mode)}@@ -2018,32 +2085,6 @@ extension AIEnhancementSettingsView {}}- private var baseDictationPromptReference: some View {- VStack(alignment: .leading, spacing: 8) {- Text("Built-in Base Prompt")- .font(.fluidSystem(.caption))- .foregroundStyle(.secondary)- Text("Reference only. Copy any parts you want into a custom prompt.")- .font(.fluidSystem(.caption2))- .foregroundStyle(self.theme.palette.secondaryText)-- PromptTextView(- text: .constant(SettingsStore.baseDictationPromptText()),- isEditable: false,- font: NSFont.fluidMonospacedSystemFont(ofSize: NSFont.smallSystemFontSize, weight: .regular)- )- .frame(height: 110)- .background(- RoundedRectangle(cornerRadius: 8, style: .continuous)- .fill(self.theme.palette.contentBackground)- .overlay(- RoundedRectangle(cornerRadius: 8, style: .continuous)- .stroke(self.theme.palette.cardBorder, lineWidth: 1)- )- )- }- }-private func autoDisablePromptTestIfNeeded() {guard self.promptTest.isActive else { return }if !self.viewModel.isAIPostProcessingConfiguredForDictation() {diff --git a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swiftindex 4eae2443..f290291e 100644--- a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift+++ b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift@@ -62,24 +62,9 @@ extension VoiceEngineSettingsView {}}} label: {- HStack(spacing: 6) {- Image(systemName: "line.3.horizontal.decrease.circle")- .font(self.theme.typography.bodySmallStrong)- Text("Filter: \(self.viewModel.providerFilter.rawValue)")- .font(self.theme.typography.bodySmallStrong)- }- .foregroundStyle(self.voiceEngineTitleText)- .padding(.horizontal, 10)- .padding(.vertical, 6)- .background(- RoundedRectangle(cornerRadius: 9)- .fill(self.theme.palette.cardBackground.opacity(0.8))- .overlay(- RoundedRectangle(cornerRadius: 9)- .stroke(self.theme.palette.cardBorder.opacity(0.5), lineWidth: 1)- )- )+ Text("Filter: \(self.viewModel.providerFilter.rawValue)")}+ .fluidDropdownStyle()Menu {ForEach(ModelSortOption.allCases) { option inButton(option.rawValue) {@@ -87,22 +72,9 @@ extension VoiceEngineSettingsView {}}} label: {- HStack(spacing: 6) {- Text("Sort by: \(self.viewModel.modelSortOption.rawValue)")- .font(self.theme.typography.bodySmallStrong)- }- .foregroundStyle(self.voiceEngineTitleText)- .padding(.horizontal, 10)- .padding(.vertical, 6)- .background(- RoundedRectangle(cornerRadius: 9)- .fill(self.theme.palette.cardBackground.opacity(0.8))- .overlay(- RoundedRectangle(cornerRadius: 9)- .stroke(self.theme.palette.cardBorder.opacity(0.5), lineWidth: 1)- )- )+ Text("Sort by: \(self.viewModel.modelSortOption.rawValue)")}+ .fluidDropdownStyle()}// Active + Other models list@@ -164,7 +136,6 @@ extension VoiceEngineSettingsView {/// Stats panel showing speed/accuracy bars that animate when model changesvar modelStatsPanel: some View {let model = self.viewModel.previewSpeechModel- let supportsCustomWords = model.supportsCustomVocabularyreturn VStack(alignment: .leading, spacing: 12) {HStack(alignment: .center, spacing: 20) {@@ -269,38 +240,6 @@ extension VoiceEngineSettingsView {.frame(width: 140, alignment: .center).animation(.spring(response: 0.5, dampingFraction: 0.7), value: model.id)}-- if supportsCustomWords {- HStack(alignment: .center, spacing: 10) {- Image(systemName: "checkmark.seal.fill")- .font(self.theme.typography.bodySmall)- .foregroundStyle(Color.fluidGreen)-- Text("Custom Words supported on Parakeet. Teach names, product terms, and uncommon words for better accuracy.")- .font(self.theme.typography.bodySmall)- .foregroundStyle(self.voiceEngineSecondaryText)- .lineLimit(3)-- Spacer(minLength: 8)-- Button("Open Custom Dictionary") {- NotificationCenter.default.post(name: .openCustomDictionaryFromVoiceEngine, object: nil)- }- .buttonStyle(.borderedProminent)- .tint(Color.fluidGreen)- .controlSize(.small)- }- .padding(.horizontal, 10)- .padding(.vertical, 8)- .background(- RoundedRectangle(cornerRadius: 8)- .fill(Color.fluidGreen.opacity(0.10))- .overlay(- RoundedRectangle(cornerRadius: 8)- .stroke(Color.fluidGreen.opacity(0.30), lineWidth: 1)- )- )- }}.padding(.vertical, 6)}@@ -390,7 +329,7 @@ extension VoiceEngineSettingsView {Button(self.viewModel.isCancellingModelDownload ? "Cancelling…" : "Cancel") {self.viewModel.cancelSpeechModelDownload()}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small).disabled(self.viewModel.isCancellingModelDownload)}@@ -431,7 +370,7 @@ extension VoiceEngineSettingsView {Button(self.viewModel.asr.isCancellingModelPreparation ? "Cancelling…" : "Cancel") {self.viewModel.cancelActiveModelPreparation()}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small).disabled(self.viewModel.asr.isCancellingModelPreparation)}@@ -565,10 +504,9 @@ extension VoiceEngineSettingsView {}}}- } label: {- self.languageChipLabel(self.settings.selectedCohereLanguage.displayName)- }- .buttonStyle(.plain)+ } label: { Label(self.settings.selectedCohereLanguage.displayName, systemImage: "globe") }+ .fluidDropdownStyle()+ .buttonStyle(.plain)} else if model == .nemotronOffline || model == .nemotronStreaming || model == .nemotronStreaming320 {self.nemotronLanguagePickerButton}@@ -681,28 +619,15 @@ extension VoiceEngineSettingsView {}private func languageChipLabel(_ title: String) -> some View {- HStack(spacing: 5) {- Image(systemName: "globe")- .font(self.theme.typography.bodySmall)- .foregroundStyle(self.theme.palette.accent)- Text(title)- .lineLimit(1)- .fontWeight(.semibold)- Image(systemName: "chevron.down")- .font(.fluidSystem(size: 9, weight: .semibold))- .foregroundStyle(self.voiceEngineTertiaryText)+ HStack(spacing: 10) {+ Image(systemName: "globe").foregroundStyle(self.theme.palette.accent)+ Text(title).lineLimit(1)+ FluidDropdownChevron()}- .font(self.theme.typography.bodySmallStrong)- .frame(minHeight: 24)- .padding(.horizontal, 9)- .background(- Capsule()- .fill(self.theme.palette.accent.opacity(0.10))- .overlay(- Capsule()- .stroke(self.theme.palette.accent.opacity(0.28), lineWidth: 1)- )- )+ .font(self.theme.typography.bodySmall)+ .padding(.horizontal, 12)+ .padding(.vertical, 9)+ .fluidDropdownSurface()}private func speechModelSubtitle(for model: SettingsStore.SpeechModel) -> String {diff --git a/Sources/Fluid/UI/AISettingsView.swift b/Sources/Fluid/UI/AISettingsView.swiftindex a8268a35..20e85fd8 100644--- a/Sources/Fluid/UI/AISettingsView.swift+++ b/Sources/Fluid/UI/AISettingsView.swift@@ -92,8 +92,8 @@ enum AISettingsLayout {static let promptInlinePickerWidth: CGFloat = 145static let promptInlineModelWidth: CGFloat = 180static let promptScopeLabelWidth: CGFloat = 110- static let promptEditorLabelColumnWidth: CGFloat = 180- static let promptEditorControlColumnWidth: CGFloat = 270+ static let promptEditorLabelColumnWidth: CGFloat = 140+ static let promptEditorControlColumnWidth: CGFloat = 340static let rowLeadingIndent: CGFloat = labelWidth + 12}diff --git a/Sources/Fluid/UI/AnalyticsPrivacyView.swift b/Sources/Fluid/UI/AnalyticsPrivacyView.swiftindex 2e221fcd..dc3798a7 100644--- a/Sources/Fluid/UI/AnalyticsPrivacyView.swift+++ b/Sources/Fluid/UI/AnalyticsPrivacyView.swift@@ -18,7 +18,7 @@ struct AnalyticsPrivacyView: View {Spacer()Button("Done") { self.dismiss() }- .buttonStyle(.bordered)+ .fluidOutlinedButton()}Divider().opacity(0.4)diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swiftindex fd33d8a8..9538ad13 100644--- a/Sources/Fluid/UI/CustomDictionaryView.swift+++ b/Sources/Fluid/UI/CustomDictionaryView.swift@@ -3426,7 +3426,7 @@ struct AddDictionaryEntrySheet: View {.font(.fluidSystem(.headline))Spacer()Button("Cancel") { self.dismiss() }- .buttonStyle(.bordered)+ .fluidOutlinedButton()}Divider()@@ -3578,7 +3578,7 @@ struct EditDictionaryEntrySheet: View {.font(.fluidSystem(.headline))Spacer()Button("Cancel") { self.dismiss() }- .buttonStyle(.bordered)+ .fluidOutlinedButton()}Divider()diff --git a/Sources/Fluid/UI/DashboardView.swift b/Sources/Fluid/UI/DashboardView.swiftindex 08a5f951..15fd71a6 100644--- a/Sources/Fluid/UI/DashboardView.swift+++ b/Sources/Fluid/UI/DashboardView.swift@@ -244,7 +244,7 @@ struct DashboardView: View {@ViewBuilderprivate var shortcutKey: some View {let button = Button(action: self.openShortcutSettings) {- Text(self.settings.primaryDictationShortcuts.first?.displayString ?? self.shortcut)+ Text(self.settings.primaryDictationShortcuts.first?.displayString ?? "Off").font(.fluidSystem(size: 25, weight: .medium)).lineLimit(2).minimumScaleFactor(0.5).multilineTextAlignment(.center)diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swiftindex 3705fc3a..fdc3cdd6 100644--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift@@ -202,6 +202,7 @@ struct MeetingTranscriptionView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().labelsHidden().frame(width: 90)}diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swiftindex 252b2701..0f6484ad 100644--- a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift@@ -65,17 +65,6 @@ struct OnboardingAIEnhancementStepView: View {private var canNavigate: Bool { !self.isRunning && !self.isRecordingShortcut && !self.contentState.isProcessing && !self.isShowingIntroduction }private var isShowingIntroduction: Bool { self.isReady && !self.setup.introductionFinished && !self.reduceMotion }private var isReady: Bool { self.setup.phase == .ready }- private var sizeText: String? {- guard let count = self.setup.model?.byteCount, count > 0 else { return nil }- return ByteCountFormatter.string(fromByteCount: count, countStyle: .file)- }-- private var enableTitle: String {- guard let model = self.setup.model else { return "Download" }- if model.installed { return "Enable" }- return self.sizeText.map { "Download · \($0)" } ?? "Download"- }-var body: some View {GeometryReader { proxy inZStack {@@ -84,12 +73,17 @@ struct OnboardingAIEnhancementStepView: View {FluidOnboardingCompactProgress(value: self.progressValue).padding(.top, 28)self.mainContent+ if !self.isReady {+ self.offerStatus+ .padding(.horizontal, 30)+ .fixedSize(horizontal: false, vertical: true)+ }HStack(alignment: .center, spacing: 20) {self.action(id: "back", title: "Back", tone: .secondary, width: 132) {if self.isReady && self.showPractice {self.showPractice = false} else {- self.setup.cancel()+ self.setup.leavePage()self.onBack()}}@@ -143,7 +137,7 @@ struct OnboardingAIEnhancementStepView: View {}.task { self.setup.refresh() }.onDisappear {- self.setup.cancel()+ self.setup.leavePage()}}@@ -159,33 +153,32 @@ struct OnboardingAIEnhancementStepView: View {.padding(.bottom, 24)}} else {- // Keep example text at its designed size. Only the offer scrolls;- // Back, Skip and Enable remain in the fixed footer at every window height.- ScrollView {+ // Fit the showcase into the space left above the fixed status and footer.+ OnboardingFittedContent(width: 880) {VStack(spacing: 0) {- self.hero.padding(.bottom, 24)- self.offer+ self.hero.padding(.bottom, 16)+ OnboardingCleanupExampleCarousel(autoplay: self.carouselAutoplay)Text("You can choose a different model or turn off Fluid Intelligence anytime in Settings.").font(self.theme.typography.caption).foregroundStyle(.white.opacity(0.46)).multilineTextAlignment(.center)- .padding(.top, 28)+ .padding(.top, 12)}.frame(maxWidth: 880).padding(.horizontal, 32)- .padding(.top, 36)- .padding(.bottom, 24)+ .padding(.top, 16)+ .padding(.bottom, 12).frame(maxWidth: .infinity)}}}private var hero: some View {- VStack(spacing: 14) {- FluidOnboardingCompactAppIconMark(size: 52)- .padding(.bottom, 8)+ VStack(spacing: 10) {+ FluidOnboardingCompactAppIconMark(size: 40)+ .padding(.bottom, 4)Text("Meet Fluid Intelligence")- .font(.fluidSystem(size: 32, weight: .semibold))+ .font(.fluidSystem(size: 28, weight: .semibold)).foregroundStyle(.white).multilineTextAlignment(.center).lineLimit(2)@@ -204,14 +197,12 @@ struct OnboardingAIEnhancementStepView: View {}}- private var offer: some View {- VStack(spacing: 20) {- OnboardingCleanupExampleCarousel(autoplay: self.carouselAutoplay)- .padding(.bottom, 8)- if self.setup.phase == .checking {+ private var offerStatus: some View {+ VStack(spacing: 8) {+ if self.setup.phase == .checking, !self.setup.canEnable {ProgressView("Finding the right model for your Mac…").controlSize(.small)- } else if self.setup.isBusy {+ } else if self.setup.showsPreparationProgress || self.setup.phase == .cancelling {self.preparationProgress.transition(.opacity)}@@ -232,15 +223,14 @@ struct OnboardingAIEnhancementStepView: View {.foregroundStyle(FluidOnboardingLandingColors.blue)}}- .frame(minHeight: 180).animation(self.reduceMotion ? nil : .easeInOut(duration: 0.32), value: self.setup.isBusy)}private var offerNavigation: some View {HStack(spacing: 20) {- if !self.setup.isBusy {+ if !self.setup.showsPreparationProgress {Button("I’ll set it up later") {- self.setup.cancel()+ self.setup.setUpLater()self.onSkip()}.buttonStyle(.plain)@@ -249,8 +239,8 @@ struct OnboardingAIEnhancementStepView: View {.disabled(!self.canNavigate)}- if self.setup.phase == .offered {- self.action(id: "enable", title: self.enableTitle, tone: .primary, width: 210) {+ if self.setup.canEnable {+ self.action(id: "enable", title: "Enable", tone: .primary, width: 210) {self.setup.enable { model inguard self.canNavigate else {throw SetupError(message: "Stop dictation, then enable Smart mode again.")@@ -283,7 +273,7 @@ struct OnboardingAIEnhancementStepView: View {ProgressView().controlSize(.small)}if let bytes = self.setup.progress?.bytes {- Text(bytes)+ Text(bytes.replacingOccurrences(of: " downloaded", with: " ready").replacingOccurrences(of: " download", with: "")).font(self.theme.typography.caption).foregroundStyle(.white.opacity(0.62)).monospacedDigit()@@ -327,16 +317,16 @@ struct OnboardingAIEnhancementStepView: View {}private var downloadProgressTitle: String {- guard let fraction = self.setup.progress?.fraction, fraction.isFinite else { return "Downloading…" }+ guard let fraction = self.setup.progress?.fraction, fraction.isFinite else { return "Preparing…" }let percent = min(max(fraction, 0), 1).formatted(.percent.precision(.fractionLength(0)))- return "Downloading \(percent)"+ return "Preparing \(percent)"}private var preparationStatus: String {switch self.setup.phase {case .loading: "Preparing the model for your Mac. This can take a little while."case .cancelling: "Cancelling setup… You can go back or set this up later."- default: self.setup.progress?.status ?? "Starting download…"+ default: "Preparing Fluid Intelligence…"}}@@ -392,7 +382,7 @@ struct OnboardingAIEnhancementStepView: View {).frame(maxWidth: .infinity, alignment: .leading)self.modeSummary(- name: "Smart",+ name: SettingsStore.DictationModeLabels.smart,subtitle: "With Fluid Intelligence",detail: "Removes rambling, fixes mistakes, and formats your text.",smart: truediff --git a/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift b/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swiftindex 6a173dcd..3583498d 100644--- a/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift+++ b/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift@@ -37,7 +37,7 @@ struct OnboardingCleanupExampleCarousel: View {private var ids: [String] { Self.examples.map(\.id) }var body: some View {- VStack(spacing: 16) {+ VStack(spacing: 10) {GeometryReader { geometry inlet width = min(640, geometry.size.width * 0.76)let sideWidth = max(48, (geometry.size.width - width - 48) / 2)@@ -64,7 +64,7 @@ struct OnboardingCleanupExampleCarousel: View {self.advance(forward: value.translation.width < 0)})}- .frame(height: 440)+ .frame(height: 380)FluidGlassControlGroup {HStack(spacing: 24) {self.arrow(forward: false)@@ -90,19 +90,19 @@ struct OnboardingCleanupExampleCarousel: View {}private func card(_ example: Example, compact: Bool, contentWidth: CGFloat, visibleWidth: CGFloat) -> some View {- VStack(alignment: .leading, spacing: 14) {+ VStack(alignment: .leading, spacing: 10) {Group {Text(example.title)- .font(.fluidSystem(size: 28, weight: .regular, design: .serif))+ .font(.fluidSystem(size: 25, weight: .regular, design: .serif)).tracking(-0.5).foregroundStyle(Color(red: 0.96, green: 0.95, blue: 0.91)).multilineTextAlignment(.center).fixedSize(horizontal: false, vertical: true).frame(maxWidth: .infinity)- .frame(height: 68)+ .frame(height: 56).accessibilityAddTraits(.isHeader)self.mode(title: "Basic · Without Fluid Intelligence", text: example.spoken, enhanced: false)- .frame(minHeight: 88, alignment: .topLeading)+ .frame(minHeight: 76, alignment: .topLeading)Rectangle().fill(.white.opacity(0.12)).frame(height: 1)@@ -110,11 +110,11 @@ struct OnboardingCleanupExampleCarousel: View {}}// Keep text at its final reading width while the glass surface slides and narrows.- .frame(width: contentWidth - 64, alignment: .leading)+ .frame(width: contentWidth - 48, alignment: .leading).opacity(compact ? 0 : 1).animation(self.reduceMotion ? nil : .easeOut(duration: 0.18), value: compact)- .padding(32)- .frame(width: visibleWidth, height: 420, alignment: .top)+ .padding(24)+ .frame(width: visibleWidth, height: 360, alignment: .top).clipped().accessibilityHidden(compact).modifier(OnboardingGlassSurface(selected: !compact))@@ -130,7 +130,7 @@ struct OnboardingCleanupExampleCarousel: View {}private func mode(title: String, text: String, enhanced: Bool) -> some View {- VStack(alignment: .leading, spacing: 12) {+ VStack(alignment: .leading, spacing: 8) {Text(title).font(.fluidSystem(size: 18, weight: .regular, design: .serif)).tracking(-0.5)diff --git a/Sources/Fluid/UI/SearchableModelPicker.swift b/Sources/Fluid/UI/SearchableModelPicker.swiftindex b9346381..b6554051 100644--- a/Sources/Fluid/UI/SearchableModelPicker.swift+++ b/Sources/Fluid/UI/SearchableModelPicker.swift@@ -77,13 +77,11 @@ struct SearchableModelPicker: View {.truncationMode(.middle).foregroundStyle(self.selectedModel.isEmpty ? .secondary : self.theme.palette.primaryText)Spacer(minLength: 6)- FluidPickerDisclosureIcon(backgroundOpacity: 0.6)+ FluidDropdownChevron()}.searchablePickerControlChrome(width: self.pickerControlWidth,- height: self.controlHeight,- usesMaterial: true,- showsShadow: true+ height: self.controlHeight)}.buttonStyle(.plain)diff --git a/Sources/Fluid/UI/SearchableProviderPicker.swift b/Sources/Fluid/UI/SearchableProviderPicker.swiftindex 05cf1429..837dcf17 100644--- a/Sources/Fluid/UI/SearchableProviderPicker.swift+++ b/Sources/Fluid/UI/SearchableProviderPicker.swift@@ -73,7 +73,7 @@ struct SearchableProviderPicker: View {.lineLimit(1).truncationMode(.tail)Spacer(minLength: 6)- FluidPickerDisclosureIcon(backgroundOpacity: 0.7)+ FluidDropdownChevron()}.searchablePickerControlChrome(width: self.controlWidth, height: self.controlHeight)}diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex 17f052fa..c41fe77f 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -44,7 +44,7 @@ struct SettingsView: View {@Binding var shortcutRecordingMessage: String?@Binding var commandModeShortcut: HotkeyShortcut?@Binding var rewriteShortcut: HotkeyShortcut- @Binding var cancelRecordingShortcut: HotkeyShortcut+ @Binding var cancelRecordingShortcut: HotkeyShortcut?@Binding var pasteLastTranscriptionShortcut: HotkeyShortcut?@Binding var commandModeShortcutEnabled: Bool@Binding var rewriteShortcutEnabled: Bool@@ -174,30 +174,40 @@ struct SettingsView: View {private func dictationPromptPicker(for slot: SettingsStore.DictationShortcutSlot) -> some View {let profiles = self.settings.promptProfiles(for: .dictate)let privateAIAvailable = PrivateAIProviderPromptFormat.isAvailable(settings: self.settings)- HStack {+ let selection = self.dictationPromptSelectionBinding(for: slot)+ let title: String = switch self.settings.dictationPromptSelection(for: slot) {+ case .off: "Basic — No cleanup"+ case .default: SettingsStore.DictationModeLabels.externalDefault+ case .privateAI: SettingsStore.DictationModeLabels.smartWithModel+ case let .profile(id): profiles.first(where: { $0.id == id }).map { $0.name.isEmpty ? "Untitled" : $0.name } ?? "Default"+ }+ HStack(spacing: 10) {Text("Cleanup style").font(self.theme.typography.bodySmall).foregroundStyle(self.settingsSecondaryText).padding(.leading, 30)- Spacer()- Picker("", selection: self.dictationPromptSelectionBinding(for: slot)) {- Section("ON-DEVICE") {- Text("Basic — No cleanup").tag("__OFF__")- if PrivateFeatures.privateAIProvider {- Text("Smart — Fluid-1")- .tag(PrivateAIProviderPromptFormat.promptSelectionID)- .disabled(!privateAIAvailable)+ FluidDropdown(title: title) {+ Picker("Cleanup style", selection: selection) {+ Section("ON-DEVICE") {+ Text("Basic — No cleanup").tag("__OFF__")+ if PrivateFeatures.privateAIProvider {+ Text(SettingsStore.DictationModeLabels.smartWithModel)+ .tag(PrivateAIProviderPromptFormat.promptSelectionID)+ .disabled(!privateAIAvailable)+ }}- }- Section("EXTERNAL") {- Text("Smart").tag("__DEFAULT__")- ForEach(profiles) { profile in- Text(profile.name.isEmpty ? "Untitled" : profile.name)- .tag(profile.id)+ Section("CUSTOM STYLES") {+ Text(SettingsStore.DictationModeLabels.externalDefault).tag("__DEFAULT__")+ ForEach(profiles) { profile in+ Text(profile.name.isEmpty ? "Untitled" : profile.name)+ .tag(profile.id)+ }}}+ .pickerStyle(.inline)}- .frame(width: 220)+ .accessibilityLabel("Cleanup style")+ .accessibilityValue(title)}.padding(.bottom, 4)}@@ -338,6 +348,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing)}.settingsSearchTarget(.transcriptionSounds)@@ -489,7 +500,7 @@ struct SettingsView: View {NSWorkspace.shared.open(url)}}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular)Button(self.rollbackVersion.isEmpty ? "Rollback" : "Rollback to \(self.rollbackVersion)") {@@ -541,7 +552,7 @@ struct SettingsView: View {}}}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular).disabled(self.rollbackVersion.isEmpty || self.isRollingBack).opacity(self.isRollingBack ? 0.7 : 1.0)@@ -549,7 +560,7 @@ struct SettingsView: View {Button("Get Previous Builds") {self.openPreviousBuildPicker()}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular)}.padding(.top, 12)@@ -613,7 +624,7 @@ struct SettingsView: View {} label: {Label("Open Settings", systemImage: "gear")}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular)}}@@ -637,7 +648,7 @@ struct SettingsView: View {}// Shortcuts and dictation behavior- self.shortcutPageContainer {+ ThemedCard(style: .standard) {VStack(alignment: .leading, spacing: 14) {HStack(spacing: 8) {Label(self.selectedSection == .shortcuts ? "Shortcuts" : "Dictation behavior", systemImage: self.selectedSection == .shortcuts ? "keyboard" : "mic")@@ -651,16 +662,7 @@ struct SettingsView: View {Text("Recording…").font(.fluidSystem(.caption).weight(.semibold)).foregroundStyle(.orange)- } else if self.hotkeyManagerInitialized {- HStack(spacing: 6) {- Image(systemName: "checkmark.circle.fill")- .foregroundStyle(Color.fluidGreen)- .font(.fluidSystem(.caption))- Text("Active")- .font(.fluidSystem(.caption).weight(.semibold))- .foregroundStyle(self.settingsSecondaryText)- }- } else {+ } else if !self.hotkeyManagerInitialized {Text("Initializing…").font(.fluidSystem(.caption).weight(.semibold)).foregroundStyle(self.settingsSecondaryText)@@ -697,10 +699,10 @@ struct SettingsView: View {self.shortcutGroup {self.primaryDictationShortcutsList().settingsSearchTarget(.primaryDictationShortcuts)- self.dictationPromptPicker(for: .primary)self.shortcutGroupDividerself.smartDictationShortcutRow}+ self.shortcutGroupDividerself.shortcutGroup {self.shortcutRow(content: .init(@@ -714,7 +716,6 @@ struct SettingsView: View {isAnyRecordingActive: self.isRecordingAnyShortcut,recordingMessage: self.isRecording(.command) ? self.shortcutRecordingMessage : nil,isEnabled: self.$commandModeShortcutEnabled,- requiresShortcutToEnable: true,onChangePressed: {DebugLogger.shared.debug("Starting to record new command mode shortcut", source: "SettingsView")self.shortcutRecordingMessage = nil@@ -752,6 +753,7 @@ struct SettingsView: View {).settingsSearchTarget(.editModeShortcut)}+ self.shortcutGroupDividerself.shortcutGroup {self.shortcutRow(content: .init(@@ -768,7 +770,8 @@ struct SettingsView: View {DebugLogger.shared.debug("Starting to record new cancel shortcut", source: "SettingsView")self.shortcutRecordingMessage = nilself.activeShortcutRecordingTarget = .cancel- }+ },+ onRemovePressed: { self.cancelRecordingShortcut = nil }).settingsSearchTarget(.cancelRecordingShortcut)self.shortcutGroupDivider@@ -785,7 +788,6 @@ struct SettingsView: View {isAnyRecordingActive: self.isRecordingAnyShortcut,recordingMessage: self.isRecording(.pasteLast) ? self.shortcutRecordingMessage : nil,isEnabled: self.$pasteLastTranscriptionShortcutEnabled,- requiresShortcutToEnable: true,onChangePressed: {DebugLogger.shared.debug("Starting to record new paste last transcription shortcut", source: "SettingsView")self.shortcutRecordingMessage = nil@@ -826,6 +828,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing)}.onChange(of: self.hotkeyMode) { _, newValue in@@ -867,6 +870,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().fixedSize(horizontal: true, vertical: false).frame(minWidth: 170, alignment: .trailing)}@@ -1020,13 +1024,13 @@ struct SettingsView: View {Button("Reveal in Finder") {self.revealAppInFinder()}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small)Button("Open Applications") {self.openApplicationsFolder()}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small)}}@@ -1154,7 +1158,7 @@ struct SettingsView: View {} label: {Label("Refresh", systemImage: "arrow.clockwise")}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small)}@@ -1193,6 +1197,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 240).disabled(self.asr.isRunning) // Disable device changes during recording.onChange(of: self.selectedOutputUID) { oldUID, newUID in@@ -1261,7 +1266,7 @@ struct SettingsView: View {self.visualizerNoiseThreshold = 0.4SettingsStore.shared.visualizerNoiseThreshold = self.visualizerNoiseThreshold}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small)}.settingsSearchTarget(.overlaySensitivity)@@ -1307,6 +1312,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing)}.settingsSearchTarget(.overlayPosition)@@ -1380,6 +1386,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing)} else {Picker("", selection: self.$settings.notchPresentationMode) {@@ -1388,6 +1395,7 @@ struct SettingsView: View {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing)}}@@ -1496,7 +1504,7 @@ struct SettingsView: View {} label: {Label("Reveal Log File", systemImage: "doc.richtext")}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular)Text("The debug log contains detailed information about app operations and can help with troubleshooting.")@@ -1546,7 +1554,7 @@ struct SettingsView: View {.shownInSettingsSection(.experimental, selectedSection: self.selectedSection)}.padding(16)- .frame(maxWidth: self.selectedSection == .shortcuts ? 820 : .infinity)+ .frame(maxWidth: self.selectedSection == .shortcuts ? 960 : .infinity).frame(maxWidth: .infinity).environment(\.settingsSearchPresentation, self.settingsSearchPresentation)}@@ -1899,7 +1907,7 @@ struct SettingsView: View {Button(action: self.importBackup) {Label("Import", systemImage: "square.and.arrow.down")}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.regular)}}@@ -2048,122 +2056,133 @@ struct SettingsView: View {)}- @ViewBuilderprivate func primaryDictationShortcutsList() -> some View {let addTarget = ShortcutRecordingTarget.primaryDictation(.add)let isAdding = self.isRecording(addTarget)-- VStack(alignment: .leading, spacing: 6) {- HStack(spacing: 10) {- Image(systemName: "mic.fill")- .foregroundStyle(self.settingsSecondaryText)- .frame(width: 20)-- VStack(alignment: .leading, spacing: 1) {- Text("Primary dictation")- .font(self.theme.typography.bodyStrong)- .foregroundStyle(self.settingsTitleText)- Text("Keyboard shortcut or mouse button")- .font(self.theme.typography.bodySmall)- .foregroundStyle(self.settingsSecondaryText)- .lineLimit(1)+ return HStack(alignment: .top, spacing: 20) {+ VStack(alignment: .leading, spacing: 12) {+ self.shortcutLabel(+ icon: "mic.fill",+ color: self.settingsSecondaryText,+ title: "Primary dictation",+ description: "Keyboard shortcut or mouse button"+ )+ self.dictationPromptPicker(for: .primary)+ }+ Spacer(minLength: 12)+ VStack(alignment: .trailing, spacing: 10) {+ ForEach(Array(self.primaryDictationShortcuts.enumerated()), id: \.offset) { index, shortcut in+ self.primaryDictationShortcutRow(shortcut: shortcut, index: index)}-- Spacer()-- Button {- if isAdding {- self.shortcutRecordingMessage = nil- self.activeShortcutRecordingTarget = nil- } else {- DebugLogger.shared.debug("Starting to record new primary dictation shortcut", source: "SettingsView")+ if isAdding {+ self.shortcutControls(+ shortcut: nil,+ isRecording: true,+ title: "New dictation shortcut",+ onEdit: {},+ onRemove: nil+ )+ } else {+ Button {self.shortcutRecordingMessage = nilself.activeShortcutRecordingTarget = addTarget+ } label: {+ Label("Add shortcut", systemImage: "plus")}- } label: {- Label(isAdding ? "Cancel" : "Add shortcut", systemImage: isAdding ? "xmark" : "plus")+ .buttonStyle(ShortcutHoverButtonStyle())+ .disabled(self.isRecordingAnyShortcut)+ }+ if isAdding, let message = self.shortcutRecordingMessage {+ Text(message).font(self.theme.typography.bodySmall).foregroundStyle(self.theme.palette.warning)}- .buttonStyle(.bordered)- .controlSize(.small)- .disabled(!isAdding && self.isRecordingAnyShortcut)- }-- ForEach(Array(self.primaryDictationShortcuts.enumerated()), id: \.offset) { index, shortcut in- self.primaryDictationShortcutRow(shortcut: shortcut, index: index)- }-- if isAdding {- self.primaryDictationShortcutCaptureStatus(for: addTarget)}}}- @ViewBuilderprivate func primaryDictationShortcutRow(shortcut: HotkeyShortcut, index: Int) -> some View {let target = ShortcutRecordingTarget.primaryDictation(.replace(index))- let isRecording = self.isRecording(target)+ return VStack(alignment: .trailing, spacing: 4) {+ self.shortcutControls(+ shortcut: shortcut,+ isRecording: self.isRecording(target),+ title: "Dictation shortcut",+ onEdit: {+ self.shortcutRecordingMessage = nil+ self.activeShortcutRecordingTarget = target+ },+ onRemove: {+ guard self.primaryDictationShortcuts.indices.contains(index) else { return }+ self.primaryDictationShortcuts.remove(at: index)+ }+ )+ if self.isRecording(target), let message = self.shortcutRecordingMessage {+ Text(message).font(self.theme.typography.bodySmall).foregroundStyle(self.theme.palette.warning)+ }+ }+ }- HStack(spacing: 10) {- Color.clear- .frame(width: 20)+ private func shortcutLabel(icon: String, color: Color, title: String, description: String) -> some View {+ HStack(alignment: .top, spacing: 10) {+ Image(systemName: icon).foregroundStyle(color).frame(width: 20).padding(.top, 2)+ VStack(alignment: .leading, spacing: 3) {+ Text(title).font(self.theme.typography.bodyStrong).foregroundStyle(self.settingsTitleText)+ Text(description).font(self.theme.typography.bodySmall).foregroundStyle(self.settingsSecondaryText)+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ }+ private func shortcutControls(+ shortcut: HotkeyShortcut?,+ isRecording: Bool,+ title: String,+ onEdit: @escaping () -> Void,+ onRemove: (() -> Void)?+ ) -> some View {+ HStack(spacing: 12) {if isRecording {self.shortcutCapturePill()- } else {+ } else if let shortcut {self.shortcutDisplayPill(shortcut.displayString)+ } else {+ Text("Off").foregroundStyle(self.settingsSecondaryText)}-- Button(isRecording ? "Cancel" : "Change") {+ Button {if isRecording {self.shortcutRecordingMessage = nilself.activeShortcutRecordingTarget = nil} else {- DebugLogger.shared.debug("Starting to record replacement primary dictation shortcut", source: "SettingsView")- self.shortcutRecordingMessage = nil- self.activeShortcutRecordingTarget = target+ onEdit()+ }+ } label: {+ Group {+ if isRecording {+ Image(systemName: "xmark").font(.fluidSystem(size: 14, weight: .medium))+ } else {+ ShortcutPencilShape().stroke(style: StrokeStyle(lineWidth: 1.7, lineCap: .round, lineJoin: .round))+ .frame(width: 20, height: 20)+ }}+ .frame(width: 28, height: 28)}- .buttonStyle(.bordered)- .controlSize(.small)+ .buttonStyle(ShortcutHoverButtonStyle())+ .help(isRecording ? "Cancel recording" : "Set shortcut")+ .accessibilityLabel(isRecording ? "Cancel recording \(title)" : "Edit \(title)").disabled(!isRecording && self.isRecordingAnyShortcut)- Button("Remove") {- guard self.primaryDictationShortcuts.count > 1,- self.primaryDictationShortcuts.indices.contains(index)- else { return }- self.primaryDictationShortcuts.remove(at: index)- }- .buttonStyle(.bordered)- .controlSize(.small)- .disabled(self.primaryDictationShortcuts.count <= 1 || self.isRecordingAnyShortcut)-- if isRecording,- let recordingMessage = self.shortcutRecordingMessage,- !recordingMessage.isEmpty- {- Text(recordingMessage)- .font(.fluidSystem(.caption))- .foregroundStyle(self.theme.palette.warning)- }- }- }-- private func primaryDictationShortcutCaptureStatus(for target: ShortcutRecordingTarget) -> some View {- HStack(spacing: 10) {- Color.clear- .frame(width: 20)-- self.shortcutCapturePill()-- if self.isRecording(target),- let recordingMessage = self.shortcutRecordingMessage,- !recordingMessage.isEmpty- {- Text(recordingMessage)- .font(.fluidSystem(.caption))- .foregroundStyle(self.theme.palette.warning)+ Button {+ onRemove?()+ } label: {+ Image(systemName: "trash").frame(width: 28, height: 28)}+ .buttonStyle(ShortcutHoverButtonStyle())+ .help("Remove shortcut")+ .accessibilityLabel("Remove \(title)")+ .disabled(onRemove == nil || shortcut == nil || self.isRecordingAnyShortcut)+ .opacity(onRemove == nil || shortcut == nil || isRecording ? 0 : 1)+ .accessibilityHidden(onRemove == nil || shortcut == nil || isRecording)}+ .fixedSize(horizontal: true, vertical: false)}private func shortcutCapturePill() -> some View {@@ -2173,7 +2192,7 @@ struct SettingsView: View {.padding(.horizontal, 8).padding(.vertical, 4).background(- RoundedRectangle(cornerRadius: 5, style: .continuous)+ RoundedRectangle(cornerRadius: 12, style: .continuous).fill(.orange.opacity(0.2)))}@@ -2184,10 +2203,10 @@ struct SettingsView: View {.padding(.horizontal, 8).padding(.vertical, 4).background(- RoundedRectangle(cornerRadius: 5, style: .continuous)+ RoundedRectangle(cornerRadius: 12, style: .continuous).fill(.quaternary.opacity(0.5)).overlay(- RoundedRectangle(cornerRadius: 5, style: .continuous)+ RoundedRectangle(cornerRadius: 12, style: .continuous).stroke(.primary.opacity(0.15), lineWidth: 1)))@@ -2201,101 +2220,41 @@ struct SettingsView: View {isAnyRecordingActive: Bool,recordingMessage: String? = nil,isEnabled: Binding<Bool>? = nil,- requiresShortcutToEnable: Bool = false,onChangePressed: @escaping () -> Void,onRemovePressed: (() -> Void)? = nil) -> some View {let enabledValue = isEnabled?.wrappedValue ?? true- let hasShortcut = shortcut != nil- let enableToggleDisabled = isAnyRecordingActive || (requiresShortcutToEnable && !hasShortcut)-- VStack(alignment: .leading, spacing: 6) {- HStack(spacing: 10) {- Image(systemName: content.icon)- .foregroundStyle(content.iconColor)- .frame(width: 20)-- VStack(alignment: .leading, spacing: 1) {- Text(content.title)- .font(self.theme.typography.bodyStrong)- .foregroundStyle(self.settingsTitleText)- Text(content.description)- .font(self.theme.typography.bodySmall)- .foregroundStyle(self.settingsSecondaryText)- .lineLimit(1)- }-- Spacer()-- if let isEnabled {- Toggle("", isOn: isEnabled)- .toggleStyle(.switch)- .tint(self.theme.palette.accent)- .labelsHidden()- .disabled(enableToggleDisabled)- }- }-- HStack(spacing: 10) {- Color.clear- .frame(width: 20)-- if isRecording {- self.shortcutCapturePill()- } else {- self.shortcutDisplayPill(shortcut?.displayString ?? "Not set")- }-- Button(isRecording ? "Cancel" : "Change") {- if isRecording {- self.shortcutRecordingMessage = nil- self.activeShortcutRecordingTarget = nil- } else {- onChangePressed()- }- }- .buttonStyle(.bordered)- .controlSize(.small)- .disabled(!isRecording && (isAnyRecordingActive || (!enabledValue && hasShortcut)))-- if let onRemovePressed {- Button("Remove") {- onRemovePressed()- }- .buttonStyle(.bordered)- .controlSize(.small)- .disabled(!hasShortcut || isAnyRecordingActive)- }-+ let remove: (() -> Void)? = onRemovePressed ?? isEnabled.map { binding in+ { binding.wrappedValue = false }+ }+ HStack(alignment: .center, spacing: 20) {+ self.shortcutLabel(+ icon: content.icon,+ color: content.iconColor,+ title: content.title,+ description: content.description+ )+ Spacer(minLength: 12)+ VStack(alignment: .trailing, spacing: 4) {+ self.shortcutControls(+ shortcut: enabledValue ? shortcut : nil,+ isRecording: isRecording,+ title: content.title,+ onEdit: onChangePressed,+ onRemove: remove+ )if isRecording, let recordingMessage, !recordingMessage.isEmpty {- Text(recordingMessage)- .font(.fluidSystem(.caption))- .foregroundStyle(self.theme.palette.warning)+ Text(recordingMessage).font(self.theme.typography.bodySmall).foregroundStyle(self.theme.palette.warning)}}}- .opacity(enabledValue ? 1 : 0.7)+ .padding(.vertical, 6)}}private extension SettingsView {- @ViewBuilder- private func shortcutPageContainer<Content: View>(@ViewBuilder content: () -> Content) -> some View {- if self.selectedSection == .shortcuts {- content()- } else {- ThemedCard(style: .standard, content: content)- }- }-private func shortcutGroup<Content: View>(@ViewBuilder content: () -> Content) -> some View {VStack(alignment: .leading, spacing: 12, content: content)- .padding(16)- .background(self.theme.palette.elevatedCardBackground, in: RoundedRectangle(cornerRadius: 12))- .overlay {- RoundedRectangle(cornerRadius: 12)- .strokeBorder(self.theme.palette.cardBorder, lineWidth: 1)- }}private var shortcutGroupDivider: some View {@@ -2803,7 +2762,7 @@ struct FillerWordsEditor: View {.onSubmit { self.addWord() }Button("Add") { self.addWord() }- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small).disabled(self.newWord.trimmingCharacters(in: .whitespaces).isEmpty)@@ -2813,7 +2772,7 @@ struct FillerWordsEditor: View {self.fillerWords = SettingsStore.defaultFillerWordsSettingsStore.shared.fillerWords = self.fillerWords}- .buttonStyle(.bordered)+ .fluidOutlinedButton().controlSize(.small)}}@@ -2977,6 +2936,7 @@ private extension SettingsView {}}.pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 170, alignment: .trailing).accessibilityLabel("Spoken Send command")}@@ -3009,8 +2969,9 @@ private struct DictionarySuggestionsSettingsRow: View {Text(frequency.displayName).tag(frequency)}}- .labelsHidden()- .frame(width: 138)+ .pickerStyle(.menu)+ .fluidDropdownStyle()+ .frame(width: 180).disabled(!self.settings.automaticDictionaryLearningEnabled)Toggle("", isOn: Binding(@@ -3114,3 +3075,46 @@ private extension SettingsView {.settingsSearchTarget(.returnToStartingField)}}++private struct ShortcutPencilShape: Shape {+ func path(in rect: CGRect) -> Path {+ var path = Path()+ func point(_ x: CGFloat, _ y: CGFloat) -> CGPoint { CGPoint(x: rect.minX + x * rect.width, y: rect.minY + y * rect.height) }+ path.move(to: point(0.12, 0.88))+ path.addLine(to: point(0.19, 0.62))+ path.addLine(to: point(0.69, 0.12))+ path.addQuadCurve(to: point(0.82, 0.12), control: point(0.755, 0.055))+ path.addLine(to: point(0.88, 0.18))+ path.addQuadCurve(to: point(0.88, 0.31), control: point(0.945, 0.245))+ path.addLine(to: point(0.38, 0.81))+ path.closeSubpath()+ path.move(to: point(0.62, 0.19))+ path.addLine(to: point(0.81, 0.38))+ path.move(to: point(0.19, 0.62))+ path.addLine(to: point(0.38, 0.81))+ return path+ }+}++private struct ShortcutHoverButtonStyle: ButtonStyle {+ func makeBody(configuration: Configuration) -> some View {+ HoverContent(configuration: configuration)+ }++ private struct HoverContent: View {+ let configuration: ButtonStyle.Configuration+ @Environment(\.isEnabled) private var isEnabled+ @Environment(\.theme) private var theme+ @State private var isHovered = false++ var body: some View {+ self.configuration.label+ .foregroundStyle(self.isHovered && self.isEnabled ? self.theme.palette.accent : self.theme.palette.secondaryText)+ .padding(4)+ .background(RoundedRectangle(cornerRadius: 7).fill(self.theme.palette.accent.opacity(self.isEnabled && (self.isHovered || self.configuration.isPressed) ? 0.14 : 0)))+ .contentShape(Rectangle())+ .opacity(self.isEnabled ? 1 : 0.4)+ .onHover { self.isHovered = $0 }+ }+ }+}diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swiftindex 72004739..0afbe9af 100644--- a/Sources/Fluid/UI/WelcomeView.swift+++ b/Sources/Fluid/UI/WelcomeView.swift@@ -1,5 +1,6 @@import AppKitimport AVFoundation+import Combineimport SwiftUIstruct WelcomeView: View {@@ -296,7 +297,7 @@ struct OnboardingFlowView: View {}private var isAIReady: Bool {- self.settings.onboardingAISkipped || DictationAIPostProcessingGate.isProviderConfigured()+ self.settings.onboardingAISkipped || DictationAIPostProcessingGate.isOnboardingChoiceConfigured()}private var isPlaygroundReady: Bool {@@ -839,15 +840,8 @@ struct OnboardingFlowView: View {Button(language.displayName) { self.selectOnboardingLanguage(language) }}}- .frame(width: 530, height: 38)- .background(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .fill(Color.white.opacity(0.045))- .overlay(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .stroke(Color.white.opacity(0.08), lineWidth: 1)- )- )+ .fluidDropdownStyle()+ .frame(width: 530)}}@@ -2488,6 +2482,7 @@ private struct OnboardingMicrophoneSetupPanel: View {}.labelsHidden().pickerStyle(.menu)+ .fluidDropdownStyle().frame(width: 248).tint(.white).accessibilityHint("Moves the selected microphone to first in FluidVoice priority")diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftindex 8c66bc2b..95a12503 100644--- a/Sources/Fluid/Views/BottomOverlayView.swift+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -1585,7 +1585,7 @@ private struct BottomOverlayPromptMenuView: View {@ViewBuilderprivate func offRow() -> some View {let activeSlot = self.contentState.activeDictationShortcutSlot ?? .primary- let isSelected = self.settings.dictationPromptSelection(for: activeSlot) == .off+ let isSelected = self.settings.resolvedDictationPromptSelection(for: activeSlot, appBundleID: DictationAppSession.shared.appID) == .offButton(action: {if self.promptMode.normalized == .dictate {self.contentState.onDictationPromptSelectionRequested?(.off)@@ -1622,7 +1622,7 @@ private struct BottomOverlayPromptMenuView: View {let activeSlot = self.contentState.activeDictationShortcutSlot ?? .primarylet isSelected = (self.promptMode.normalized == .dictate- ? (self.settings.dictationPromptSelection(for: activeSlot) == .default)+ ? (self.settings.resolvedDictationPromptSelection(for: activeSlot, appBundleID: DictationAppSession.shared.appID) == .default): (selectedID == nil))Button(action: {@@ -1635,7 +1635,7 @@ private struct BottomOverlayPromptMenuView: View {self.onDismissRequested()}) {HStack {- Text("Default")+ Text(SettingsStore.DictationModeLabels.externalDefault)Spacer()if isSelected {Image(systemName: "checkmark")@@ -1657,7 +1657,7 @@ private struct BottomOverlayPromptMenuView: View {private func privateAIRow() -> some View {let activeSlot = self.contentState.activeDictationShortcutSlot ?? .primarylet isAvailable = PrivateAIProviderPromptFormat.isAvailable(settings: self.settings)- let isSelected = self.settings.dictationPromptSelection(for: activeSlot) == .privateAI+ let isSelected = self.settings.resolvedDictationPromptSelection(for: activeSlot, appBundleID: DictationAppSession.shared.appID) == .privateAIButton(action: {guard isAvailable else { return }self.contentState.onDictationPromptSelectionRequested?(.privateAI)@@ -1665,9 +1665,9 @@ private struct BottomOverlayPromptMenuView: View {self.onDismissRequested()}) {HStack(alignment: .firstTextBaseline, spacing: 8) {- Text("Smart")+ Text(SettingsStore.DictationModeLabels.smart)Spacer(minLength: 12)- Text("Fluid-1")+ Text(PrivateAIModelRegistry.model(id: PrivateAIIntegrationService.configuredModelID)?.displayName ?? "Fluid-1").font(.fluidSystem(size: 10, weight: .medium)).foregroundStyle(.white.opacity(0.45))if isSelected {@@ -1694,7 +1694,7 @@ private struct BottomOverlayPromptMenuView: View {let activeSlot = self.contentState.activeDictationShortcutSlot ?? .primarylet isSelected = (self.promptMode.normalized == .dictate- ? (self.settings.dictationPromptSelection(for: activeSlot) == .profile(profile.id))+ ? (self.settings.resolvedDictationPromptSelection(for: activeSlot, appBundleID: DictationAppSession.shared.appID) == .profile(profile.id)): (selectedID == profile.id))Button(action: {@@ -2384,7 +2384,7 @@ struct BottomOverlayView: View {}private var promptResolutionBundleID: String? {- self.activeAppMonitor.activeAppBundleID+ DictationAppSession.shared.appID}private var activeDictationShortcutSlot: SettingsStore.DictationShortcutSlot {@@ -2408,7 +2408,7 @@ struct BottomOverlayView: View {private var selectedPromptLabel: String {guard let activePromptMode else { return "N/A" }if activePromptMode.normalized == .dictate {- return self.settings.dictationPromptDisplayName(+ return self.settings.dictationOverlayLabel(for: self.activeDictationShortcutSlot,appBundleID: self.promptResolutionBundleID)@@ -2426,17 +2426,17 @@ struct BottomOverlayView: View {private var promptSelectorBuiltInLabel: String? {guard let activePromptMode else { return nil }if activePromptMode.normalized == .dictate {- switch self.settings.dictationPromptSelection(for: self.activeDictationShortcutSlot) {+ switch self.settings.resolvedDictationPromptSelection(for: self.activeDictationShortcutSlot, appBundleID: self.promptResolutionBundleID) {case .off:return "Basic"case .privateAI:- return self.isAppPromptOverrideActive ? nil : "Smart"+ return self.isAppPromptOverrideActive ? nil : SettingsStore.DictationModeLabels.smartcase .default:let hasAppOverride = self.settings.resolvedDictationPromptProfile(for: self.activeDictationShortcutSlot,appBundleID: self.promptResolutionBundleID) != nil- return hasAppOverride ? nil : "Default"+ return hasAppOverride ? nil : SettingsStore.DictationModeLabels.externalDefaultcase .profile:return nil}@@ -2449,6 +2449,7 @@ struct BottomOverlayView: View {}private var promptSelectorDisplayLabel: String {+ if self.activePromptMode?.normalized == .dictate { return self.selectedPromptLabel }let selectedLabel = self.selectedPromptLabel.trimmingCharacters(in: .whitespacesAndNewlines)let label = self.promptSelectorBuiltInLabel ?? selectedLabelguard !label.isEmpty else { return "Default" }@@ -2471,7 +2472,7 @@ struct BottomOverlayView: View {switch self.promptSelectorBuiltInLabel {case "Basic"?:return "bolt.fill"- case "Smart"?:+ case SettingsStore.DictationModeLabels.smart?:return "sparkles"default:return nil@@ -2813,9 +2814,7 @@ struct BottomOverlayView: View {.fixedSize(horizontal: true, vertical: false).padding(.horizontal, 8).padding(.vertical, self.promptSelectorVerticalPadding)- .background(- self.chipBackground(isHovered: self.isHoveringModeChip, disabled: self.contentState.isProcessing)- )+ .fluidDropdownSurface(cornerRadius: self.promptSelectorCornerRadius)}private var modeSelectorView: some View {@@ -2852,12 +2851,14 @@ struct BottomOverlayView: View {.foregroundStyle(.white.opacity(0.72))}Text(self.promptSelectorDisplayLabel)+ .help(self.selectedPromptLabel)+ .accessibilityLabel(self.selectedPromptLabel).font(.fluidSystem(size: self.promptSelectorFontSize, weight: .semibold)).foregroundStyle(.white.opacity(0.82)).lineLimit(1).truncationMode(.tail).frame(- maxWidth: self.promptSelectorBuiltInLabel == nil ? 72 : nil,+ maxWidth: self.activePromptMode?.normalized == .dictate ? nil : (self.promptSelectorBuiltInLabel == nil ? 72 : nil),alignment: .leading)if self.isAppPromptOverrideActive {diff --git a/Sources/Fluid/Views/CommandModeView.swift b/Sources/Fluid/Views/CommandModeView.swiftindex d8c4c72a..6d315a22 100644--- a/Sources/Fluid/Views/CommandModeView.swift+++ b/Sources/Fluid/Views/CommandModeView.swift@@ -124,7 +124,7 @@ struct CommandModeView: View {Button(action: { self.service.createNewChat() }) {Image(systemName: "plus")}- .buttonStyle(.bordered)+ .buttonStyle(FluidOutlinedButtonStyle(height: 24)).help("New chat").disabled(self.service.isProcessing)@@ -168,7 +168,7 @@ struct CommandModeView: View {Button(action: { self.showingClearConfirmation = true }) {Image(systemName: "trash")}- .buttonStyle(.bordered)+ .buttonStyle(FluidOutlinedButtonStyle(height: 24)).help("Delete chat").disabled(self.service.isProcessing)}@@ -456,7 +456,7 @@ struct CommandModeView: View {Button(action: { self.service.cancelPendingCommand() }) {Label("Cancel", systemImage: "xmark")}- .buttonStyle(.bordered)+ .fluidOutlinedButton().keyboardShortcut(.escape, modifiers: [])Button(action: {diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swiftindex 74a68bf2..4c524931 100644--- a/Sources/Fluid/Views/NotchContentViews.swift+++ b/Sources/Fluid/Views/NotchContentViews.swift@@ -610,7 +610,7 @@ struct NotchExpandedView: View {}private var promptResolutionBundleID: String? {- self.activeAppMonitor.activeAppBundleID+ DictationAppSession.shared.appID}private var activeDictationShortcutSlot: SettingsStore.DictationShortcutSlot {@@ -634,7 +634,7 @@ struct NotchExpandedView: View {private var selectedPromptLabel: String {guard let activePromptMode else { return "N/A" }if activePromptMode.normalized == .dictate {- return self.settings.dictationPromptDisplayName(+ return self.settings.dictationOverlayLabel(for: self.activeDictationShortcutSlot,appBundleID: self.promptResolutionBundleID)@@ -650,9 +650,7 @@ struct NotchExpandedView: View {}private var compactPromptLabel: String {- let label = self.selectedPromptLabel.trimmingCharacters(in: .whitespacesAndNewlines)- guard label.count > 7 else { return label }- return String(label.prefix(7))+ self.selectedPromptLabel}private var previewMaxHeight: CGFloat {@@ -664,7 +662,7 @@ struct NotchExpandedView: View {}private var promptSelectorFixedWidth: CGFloat {- 52+ self.showsSpokenSendIndicator ? 82 : 100}private var promptMenuWidth: CGFloat {@@ -817,14 +815,14 @@ struct NotchExpandedView: View {ScrollView(.vertical, showsIndicators: true) {VStack(alignment: .leading, spacing: 2) {let defaultSelected = promptMode.normalized == .dictate- ? (self.settings.dictationPromptSelection(for: activeDictationSlot) == .default)+ ? (self.settings.resolvedDictationPromptSelection(for: activeDictationSlot, appBundleID: self.promptResolutionBundleID) == .default): (self.settings.selectedPromptID(for: promptMode) == nil)if promptMode.normalized == .dictate {self.promptMenuRow("Basic",rowID: "off",- isSelected: self.settings.dictationPromptSelection(for: activeDictationSlot) == .off,+ isSelected: self.settings.resolvedDictationPromptSelection(for: activeDictationSlot, appBundleID: self.promptResolutionBundleID) == .off,isEnabled: true) {self.contentState.onDictationPromptSelectionRequested?(.off)@@ -833,7 +831,7 @@ struct NotchExpandedView: View {}}- self.promptMenuRow(promptMode.normalized == .dictate ? "Smart" : "Default", rowID: "default", isSelected: defaultSelected) {+ self.promptMenuRow(SettingsStore.DictationModeLabels.externalDefault, rowID: "default", isSelected: defaultSelected) {if promptMode.normalized == .dictate {self.contentState.onDictationPromptSelectionRequested?(.default)} else {@@ -846,9 +844,9 @@ struct NotchExpandedView: View {if promptMode.normalized == .dictate && PrivateFeatures.privateAIProvider {let privateAIAvailable = PrivateAIProviderPromptFormat.isAvailable(settings: self.settings)self.promptMenuRow(- "Smart — Fluid-1",+ SettingsStore.DictationModeLabels.smartWithModel,rowID: PrivateAIProviderFeature.shared.providerID,- isSelected: self.settings.dictationPromptSelection(for: activeDictationSlot) == .privateAI,+ isSelected: self.settings.resolvedDictationPromptSelection(for: activeDictationSlot, appBundleID: self.promptResolutionBundleID) == .privateAI,isEnabled: privateAIAvailable) {self.contentState.onDictationPromptSelectionRequested?(.privateAI)@@ -861,7 +859,7 @@ struct NotchExpandedView: View {if !profiles.isEmpty {ForEach(profiles) { profile inlet isSelected = promptMode.normalized == .dictate- ? (self.settings.dictationPromptSelection(for: activeDictationSlot) == .profile(profile.id))+ ? (self.settings.resolvedDictationPromptSelection(for: activeDictationSlot, appBundleID: self.promptResolutionBundleID) == .profile(profile.id)): (self.settings.selectedPromptID(for: promptMode) == profile.id)self.promptMenuRow(profile.name.isEmpty ? "Untitled" : profile.name,@@ -900,11 +898,13 @@ struct NotchExpandedView: View {if self.presentationPolicy.showsPromptSelector {HStack(spacing: 3) {Text(self.compactPromptLabel)+ .help(self.selectedPromptLabel)+ .accessibilityLabel(self.selectedPromptLabel).font(.fluidSystem(size: 9, weight: .medium)).foregroundStyle(self.isHoveringPromptChip ? .white.opacity(0.94) : .white.opacity(0.86)).lineLimit(1).truncationMode(.tail)- .fixedSize(horizontal: true, vertical: false)+ .fixedSize(horizontal: false, vertical: false)Image(systemName: "chevron.down").font(.fluidSystem(size: 8, weight: .bold)).foregroundStyle(self.isHoveringPromptChip ? .white.opacity(0.78) : .white.opacity(0.62))@@ -923,21 +923,7 @@ struct NotchExpandedView: View {.padding(.horizontal, 5).padding(.vertical, 3).frame(width: self.promptSelectorFixedWidth, alignment: .leading)- .background(- Capsule()- .fill(- LinearGradient(- colors: [- Color.black.opacity(self.isHoveringPromptChip ? 0.96 : 0.92),- Color(white: self.isHoveringPromptChip ? 0.10 : 0.06),- ],- startPoint: .top,- endPoint: .bottom- )- )- )- .shadow(color: .black.opacity(0.28), radius: 8, x: 0, y: 4)- .shadow(color: .white.opacity(self.isHoveringPromptChip ? 0.06 : 0.03), radius: 0, x: 0, y: 1)+ .fluidDropdownSurface().opacity(self.isPromptSelectableMode ? (self.contentState.isProcessing ? 0.7 : 1.0) : 0.6).allowsHitTesting(self.isPromptSelectableMode && !self.contentState.isProcessing).onHover { hovering indiff --git a/Sources/Fluid/Views/RewriteModeView.swift b/Sources/Fluid/Views/RewriteModeView.swiftindex 221576ac..1c3e3496 100644--- a/Sources/Fluid/Views/RewriteModeView.swift+++ b/Sources/Fluid/Views/RewriteModeView.swift@@ -131,7 +131,7 @@ struct RewriteModeView: View {Button("Try Again") {self.service.rewrittenText = ""}- .buttonStyle(.bordered)+ .fluidOutlinedButton()Spacer()diff --git a/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift b/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swiftindex 4d64920b..e5c64c3b 100644--- a/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift+++ b/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift@@ -639,7 +639,7 @@ final class DirectAudioReliabilityTests: XCTestCase {XCTAssertFalse(callbackSection.contains("Task {"))}- func testNormalOutputDismissesOverlayInPasteDispatchTurn() throws {+ func testNormalOutputHandlesOverlayAfterAwaitingPasteDispatch() throws {let repositoryRoot = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent()@@ -654,17 +654,13 @@ final class DirectAudioReliabilityTests: XCTestCase {.components(separatedBy: "if spokenSendRequested, !spokenSendAllowed").first)let pasteIndex = try XCTUnwrap(normalOutputSection.range(of: "typeOutputPlanToActiveField("))- let deliveryCompletionIndex = try XCTUnwrap(normalOutputSection.range(of: "completion: { outcome in"))+ let dispatchResultIndex = try XCTUnwrap(normalOutputSection.range(of: "didTypeExternally = deliveryResult.wasDispatched"))let deliveryHandlerIndex = try XCTUnwrap(normalOutputSection.range(of: "self.handleTypingDelivery("))- XCTAssertLessThan(pasteIndex.lowerBound, deliveryCompletionIndex.lowerBound)- XCTAssertLessThan(deliveryCompletionIndex.lowerBound, deliveryHandlerIndex.lowerBound)- let hideIndex = try XCTUnwrap(normalOutputSection.range(of: "self.hideOverlayForDispatchedPaste("))- XCTAssertLessThan(deliveryHandlerIndex.lowerBound, hideIndex.lowerBound)- let dispatchHideSection = try XCTUnwrap(source.components(separatedBy: "private func hideOverlayForDispatchedPaste(").last?.components(separatedBy: "private func handleTypingDelivery(").first)- XCTAssertTrue(dispatchHideSection.contains("reason=paste_dispatched"))- XCTAssertTrue(dispatchHideSection.contains("self.overlayLifecycleID == lifecycleID"))- XCTAssertFalse(dispatchHideSection.contains("Task {"))+ XCTAssertLessThan(pasteIndex.lowerBound, dispatchResultIndex.lowerBound)+ XCTAssertLessThan(dispatchResultIndex.lowerBound, deliveryHandlerIndex.lowerBound)+ XCTAssertTrue(normalOutputSection.contains("deliveryResult = await self.asr.typeOutputPlanToActiveField("))+ XCTAssertTrue(normalOutputSection.contains("deliveryResult.wasDispatched ? .inserted : .insertionFailed"))XCTAssertFalse(normalOutputSection.contains("Task { @MainActor in"))XCTAssertFalse(normalOutputSection[pasteIndex.lowerBound..<deliveryHandlerIndex.lowerBound]@@ -676,8 +672,7 @@ final class DirectAudioReliabilityTests: XCTestCase {.components(separatedBy: "private func hideOverlayAfterOutput()").first)XCTAssertTrue(deliveryHandlerSection.contains("self.overlayLifecycleID == expectedOverlayLifecycleID"))- XCTAssertTrue(normalOutputSection.contains("shouldHideOverlay: shouldHideOverlayAfterDelivery && spokenSendRequested"))- XCTAssertTrue(normalOutputSection.contains("shouldHide: shouldHideOverlayAfterDelivery && !spokenSendRequested"))+ XCTAssertTrue(normalOutputSection.contains("shouldHideOverlay: deliveryResult.wasDispatched && !shouldShowAIProcessingFailure && !stopOverlay.didRequestHide && !spokenSendRequested"))XCTAssertTrue(deliveryHandlerSection.contains("guard shouldHideOverlay else { return }"))XCTAssertFalse(deliveryHandlerSection.contains("await self.menuBarManager.beginProcessingCompletionAndHideOverlay"))@@ -783,16 +778,16 @@ final class DirectAudioReliabilityTests: XCTestCase {encoding: .utf8)let completionSection = try XCTUnwrap(- source.components(separatedBy: "let completedOutcome = outcome").last?- .components(separatedBy: "self.log(\"[TypingService] Starting async text insertion process\")").first+ source.components(separatedBy: "guard let postInsertionKey else {").last?+ .components(separatedBy: "guard let preferredTargetPID").first)- let callbackIndex = try XCTUnwrap(completionSection.range(of: "completion?(completedOutcome)"))+ let callbackIndex = try XCTUnwrap(completionSection.range(of: "completion?(outcome)"))let trackingIndex = try XCTUnwrap(completionSection.range(of: "AutomaticDictionaryCorrectionTracker.shared.beginObservingInsertion"))XCTAssertLessThan(callbackIndex.lowerBound, trackingIndex.lowerBound)- XCTAssertTrue(completionSection.contains("completedOutcome.didInsert"))+ XCTAssertTrue(completionSection.contains("tracksDictionaryCorrections, outcome.didInsert"))XCTAssertTrue(completionSection.contains("dictionary_tracking_scheduled afterDeliveryCallback=true"))}diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex 090d3276..cce7d2fa 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -6,6 +6,55 @@ import Foundationimport XCTestfinal class HotkeyShortcutTests: XCTestCase {+ func testExplicitCustomPromptMigrationPreservesRulesAndIdentity() throws {+ var legacy = SettingsStore.DictationPromptProfile(name: "Brief", prompt: "Keep it short.")+ legacy.usesExplicitDictationPrompt = false+ let migrated = SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: false)+ XCTAssertEqual(migrated.prompt, SettingsStore.combineBasePrompt(for: .dictate, with: legacy.prompt))+ XCTAssertEqual(migrated.id, legacy.id)+ XCTAssertEqual(migrated.updatedAt, legacy.updatedAt)+ XCTAssertTrue(migrated.usesExplicitDictationPrompt)+ XCTAssertEqual(SettingsStore.migrateExplicitDictationPrompt(migrated, legacySendOnly: false), migrated)+ let restored = try JSONDecoder().decode(SettingsStore.DictationPromptProfile.self, from: JSONEncoder().encode(migrated))+ XCTAssertEqual(SettingsStore.migrateExplicitDictationPrompt(restored, legacySendOnly: false), migrated)+ XCTAssertEqual(SettingsStore.shared.shortcutOverrideSystemPrompt(for: migrated), migrated.prompt)+ }++ func testExplicitCustomPromptMigrationHonorsLegacyToggleAndEditMode() {+ var legacy = SettingsStore.DictationPromptProfile(name: "Brief", prompt: "Keep it short.")+ legacy.usesExplicitDictationPrompt = false+ let standalone = SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: true)+ XCTAssertEqual(standalone.prompt, legacy.prompt)+ legacy.mode = .edit+ XCTAssertEqual(SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: false), legacy)+ legacy.mode = .dictate+ legacy.prompt = ""+ XCTAssertEqual(SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: false).prompt, "")+ }++ func testLegacyEmptyCustomShortcutPreservesBothFallbacks() throws {+ var legacy = SettingsStore.DictationPromptProfile(name: "Legacy empty", prompt: "")+ legacy.usesExplicitDictationPrompt = false+ let withBase = SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: false)+ let defaultFallback = SettingsStore.migrateExplicitDictationPrompt(legacy, legacySendOnly: true)+ XCTAssertEqual(SettingsStore.shared.shortcutOverrideSystemPrompt(for: withBase), SettingsStore.baseDictationPromptText())+ XCTAssertNil(SettingsStore.shared.shortcutOverrideSystemPrompt(for: defaultFallback))+ let restored = try JSONDecoder().decode(SettingsStore.DictationPromptProfile.self, from: JSONEncoder().encode(withBase))+ XCTAssertEqual(SettingsStore.shared.shortcutOverrideSystemPrompt(for: restored), SettingsStore.baseDictationPromptText())+ XCTAssertTrue(withBase.usesLegacyEmptyPromptFallback)+ XCTAssertTrue(defaultFallback.usesLegacyEmptyPromptFallback)+ }++ func testNewCustomPromptsUseWrittenTextWithoutStrippingOrAddingRules() {+ let written = SettingsStore.baseDictationPromptText() + "\n\nUse lowercase. "+ let profile = SettingsStore.DictationPromptProfile(name: "Custom", prompt: written)+ XCTAssertEqual(SettingsStore.migrateExplicitDictationPrompt(profile, legacySendOnly: false), profile)+ XCTAssertEqual(SettingsStore.customPromptBody(written, mode: .dictate), written)+ XCTAssertEqual(SettingsStore.shared.shortcutOverrideSystemPrompt(for: profile), written)+ XCTAssertEqual(SettingsStore.shared.shortcutOverrideSystemPrompt(for: .init(name: "Blank", prompt: "")), "")+ XCTAssertTrue(SettingsStore.defaultDictationPromptText().contains(SettingsStore.baseDictationPromptText()))+ }+func testInputDeliveryTimingKeepsClocksSeparate() {let input = HotkeyInputTiming(receivedAt: 100, eventTimestamp: 5_000_000_000, eventType: 12, receivedTimestamp: 5_050_000_000@@ -16,6 +65,29 @@ final class HotkeyShortcutTests: XCTestCase {XCTAssertEqual(input.eventType, 12)}+ func testRemovingAllPrimaryShortcutsPreservesExplicitEmptyState() throws {+ try self.withRestoredDefaults(keys: [self.legacyHotkeyShortcutKey, self.primaryDictationShortcutsKey]) {+ let existing = SettingsStore.shared.hotkeyShortcut+ SettingsStore.shared.primaryDictationShortcuts = []+ XCTAssertEqual(SettingsStore.shared.primaryDictationShortcuts, [])+ XCTAssertEqual(SettingsStore.shared.primaryDictationShortcutDisplayString, "Off")+ SettingsStore.shared.primaryDictationShortcuts = [existing]+ XCTAssertEqual(SettingsStore.shared.primaryDictationShortcuts, [existing])+ }+ }++ func testCancelShortcutRemovalDoesNotRestoreEscape() throws {+ try self.withRestoredDefaults(keys: ["CancelRecordingHotkeyShortcut"]) {+ UserDefaults.standard.removeObject(forKey: "CancelRecordingHotkeyShortcut")+ XCTAssertEqual(SettingsStore.shared.cancelRecordingHotkeyShortcut, HotkeyShortcut(keyCode: 53, modifierFlags: []))+ SettingsStore.shared.cancelRecordingHotkeyShortcut = nil+ XCTAssertNil(SettingsStore.shared.cancelRecordingHotkeyShortcut)+ let shortcut = HotkeyShortcut(keyCode: 53, modifierFlags: [.command])+ SettingsStore.shared.cancelRecordingHotkeyShortcut = shortcut+ XCTAssertEqual(SettingsStore.shared.cancelRecordingHotkeyShortcut, shortcut)+ }+ }+func testInputDeliveryTimingRejectsMissingAndFutureEventTimestamps() {let missing = HotkeyInputTiming(receivedAt: 100, eventTimestamp: 0, eventType: 12, receivedTimestamp: 5_000_000_000)XCTAssertNil(missing.deliveryAgeMs)diff --git a/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift b/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swiftindex 11495fa1..847ebe97 100644--- a/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift+++ b/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift@@ -95,7 +95,6 @@ final class LLMClientRequestBodyTests: XCTestCase {)settings.dictationPromptProfiles = [profile]settings.selectedDictationPromptID = profile.id- settings.sendCustomPromptOnly = truelet prompt = settings.effectiveDictationSystemPrompt(for: .primary)XCTAssertEqual(prompt, profile.prompt)@@ -112,7 +111,7 @@ final class LLMClientRequestBodyTests: XCTestCase {}}- func testCustomPromptOnly_defaultFalsePrependsBasePrompt() {+ func testCustomPromptOnly_newProfilesNeverPrependBasePrompt() {self.withPromptSettingsRestored {let settings = SettingsStore.sharedself.resetPromptSettings(settings)@@ -124,11 +123,10 @@ final class LLMClientRequestBodyTests: XCTestCase {)settings.dictationPromptProfiles = [profile]settings.selectedDictationPromptID = profile.id- settings.sendCustomPromptOnly = falseXCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary),- SettingsStore.combineBasePrompt(for: .dictate, with: profile.prompt)+ profile.prompt)}}@@ -138,8 +136,6 @@ final class LLMClientRequestBodyTests: XCTestCase {let settings = SettingsStore.sharedself.resetPromptSettings(settings)- settings.sendCustomPromptOnly = true-let prompt = settings.effectiveDictationSystemPrompt(for: .primary)XCTAssertFalse(prompt.isEmpty)XCTAssertEqual(prompt, SettingsStore.defaultSystemPromptText(for: .dictate))@@ -172,7 +168,6 @@ final class LLMClientRequestBodyTests: XCTestCase {promptID: mail.id),]- settings.sendCustomPromptOnly = trueXCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary, appBundleID: "com.apple.mail"),@@ -196,23 +191,71 @@ final class LLMClientRequestBodyTests: XCTestCase {mode: .dictate)settings.dictationPromptProfiles = [profile]- settings.sendCustomPromptOnly = trueXCTAssertEqual(settings.shortcutOverrideSystemPrompt(for: profile),profile.prompt)- settings.sendCustomPromptOnly = falseXCTAssertEqual(settings.shortcutOverrideSystemPrompt(for: profile),- SettingsStore.combineBasePrompt(for: .dictate, with: profile.prompt)+ profile.prompt)}}+ func testCustomPromptOnly_emptyExplicitProfileDoesNotFallBackToDefault() {+ self.withPromptSettingsRestored {+ let settings = SettingsStore.shared+ self.resetPromptSettings(settings)+ let profile = SettingsStore.DictationPromptProfile(name: "Blank", prompt: "")+ settings.dictationPromptProfiles = [profile]+ settings.selectedDictationPromptID = profile.id+ XCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary), "")+ XCTAssertEqual(SettingsStore.renderDictationUserMessage(promptText: "", transcript: "hello"), "hello")+ }+ }+private static let basePromptMarker = "You are a voice-to-text dictation cleaner"+ func testAppVisitOverrideUsesActualPromptAndDoesNotPersist() {+ self.withPromptSettingsRestored {+ let settings = SettingsStore.shared+ self.resetPromptSettings(settings)+ let session = DictationAppSession.shared+ let previousApp = session.appID+ defer { session.activate(previousApp ?? "test.finished") }+ let saved = SettingsStore.DictationPromptProfile(name: "App rule", prompt: "App rule body", mode: .dictate)+ let manual = SettingsStore.DictationPromptProfile(name: "Temporary", prompt: "Temporary body", mode: .dictate)+ settings.dictationPromptProfiles = [saved, manual]+ settings.appPromptBindings = [.init(mode: .dictate, appBundleID: "test.editor", appName: "Editor", promptID: saved.id)]+ let originalSelection = settings.dictationPromptSelection(for: .primary)+ session.activate("test.other")+ session.activate("test.editor")+ XCTAssertEqual(settings.resolvedDictationPromptSelection(for: .primary, appBundleID: "test.editor"), .profile(saved.id))+ session.select(.profile(manual.id), slot: .primary, appID: "test.editor")+ XCTAssertEqual(settings.resolvedDictationPromptSelection(for: .primary, appBundleID: "test.editor"), .profile(manual.id))+ XCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary, appBundleID: "test.editor"), "Temporary body")+ session.activate("test.editor")+ XCTAssertEqual(settings.dictationPromptDisplayName(for: .primary, appBundleID: "test.editor"), "Temporary")+ session.select(.off, slot: .primary, appID: "test.editor")+ XCTAssertEqual(settings.dictationOverlayLabel(for: .primary, appBundleID: "test.editor"), "Basic")+ XCTAssertFalse(DictationAIPostProcessingGate.isConfigured(for: .primary, appBundleID: "test.editor"))+ XCTAssertEqual(settings.dictationPromptSelection(for: .primary), originalSelection)+ XCTAssertEqual(settings.appPromptBindings.first?.promptID, saved.id)+ session.activate("test.other")+ session.activate("test.editor")+ XCTAssertEqual(settings.resolvedDictationPromptSelection(for: .primary, appBundleID: "test.editor"), .profile(saved.id))+ XCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary, appBundleID: "test.editor"), "App rule body")+ settings.dictationPromptRoutingScope = .selectedAppsOnly+ session.activate("test.unbound")+ XCTAssertEqual(settings.resolvedDictationPromptSelection(for: .primary, appBundleID: "test.unbound"), .off)+ session.select(.profile(manual.id), slot: .primary, appID: "test.unbound")+ XCTAssertEqual(settings.resolvedDictationPromptSelection(for: .primary, appBundleID: "test.unbound"), .profile(manual.id))+ XCTAssertEqual(settings.effectiveDictationSystemPrompt(for: .primary, appBundleID: "test.unbound"), "Temporary body")+ }+ }+private func resetPromptSettings(_ settings: SettingsStore) {settings.dictationPromptProfiles = []settings.appPromptBindings = []@@ -220,7 +263,6 @@ final class LLMClientRequestBodyTests: XCTestCase {settings.isDictationPromptOff = falsesettings.dictationPromptRoutingScope = .allAppssettings.defaultDictationPromptOverride = nil- settings.sendCustomPromptOnly = false}private func withPromptSettingsRestored(run: () -> Void) {@@ -231,7 +273,6 @@ final class LLMClientRequestBodyTests: XCTestCase {let isDictationPromptOff = settings.isDictationPromptOfflet dictationPromptRoutingScope = settings.dictationPromptRoutingScopelet defaultDictationPromptOverride = settings.defaultDictationPromptOverride- let sendCustomPromptOnly = settings.sendCustomPromptOnlydefer {settings.dictationPromptProfiles = profiles@@ -240,7 +281,6 @@ final class LLMClientRequestBodyTests: XCTestCase {settings.isDictationPromptOff = isDictationPromptOffsettings.dictationPromptRoutingScope = dictationPromptRoutingScopesettings.defaultDictationPromptOverride = defaultDictationPromptOverride- settings.sendCustomPromptOnly = sendCustomPromptOnly}run()@@ -256,7 +296,7 @@ final class LLMClientRequestBodyTests: XCTestCase {final class LLMClientStreamingTests: XCTestCase {// Regression test for https://github.com/altic-dev/FluidVoice/issues/445func testReasoningContentDeltaPreservesChunkedToolCall() async throws {- let client = makeClient()+ let client = self.makeClient()var config = LLMClient.Config(messages: [["role": "user", "content": "Show the working directory"]],model: "qwen3.5:9b",@@ -278,7 +318,7 @@ final class LLMClientStreamingTests: XCTestCase {}func testTagBasedReasoningStillPreservesChunkedToolCall() async throws {- let client = makeClient()+ let client = self.makeClient()var config = LLMClient.Config(messages: [["role": "user", "content": "Show the working directory"]],model: "qwen-thinking",diff --git a/Tests/ForegroundAppOverrideTests.swift b/Tests/ForegroundAppOverrideTests.swiftnew file mode 100644index 00000000..b799a706--- /dev/null+++ b/Tests/ForegroundAppOverrideTests.swift@@ -0,0 +1,33 @@+import Foundation++@main+enum ForegroundAppOverrideTests {+ static func main() {+ var state = ForegroundAppOverride<String>()+ precondition(state.activate("editor"))+ precondition(state.choice(slot: "primary", appID: "editor") == nil)+ state.select("smart-mini", slot: "primary", appID: "editor")+ precondition(!state.activate("editor"))+ precondition(!state.activate(nil))+ precondition(!state.activate(""))+ precondition(state.choice(slot: "primary", appID: "editor") == "smart-mini")+ precondition(state.choice(slot: "secondary", appID: "editor") == nil)+ state.select("basic", slot: "secondary", appID: "editor")+ precondition(state.choice(slot: "primary", appID: "editor") == "smart-mini")+ state.select("wrong-app", slot: "primary", appID: "browser")+ precondition(state.choice(slot: "primary", appID: "editor") == "smart-mini")+ precondition(state.choice(slot: "primary", appID: "browser") == nil)+ precondition(state.activate("browser"))+ precondition(state.choice(slot: "primary", appID: "editor") == nil)+ precondition(state.activate("editor"))+ precondition(state.choice(slot: "primary", appID: "editor") == nil)+ precondition(state.choice(slot: "secondary", appID: "editor") == nil)+ for _ in 0..<1000 {+ state.select("basic", slot: "primary", appID: "editor")+ state.activate("browser")+ state.activate("editor")+ precondition(state.choice(slot: "primary", appID: "editor") == nil)+ }+ print("PASS: same-app persistence, app re-entry reset, slot isolation, stale targets, nil events, 1000 rapid switches")+ }+}diff --git a/Tests/OnboardingAISetupControllerTests.swift b/Tests/OnboardingAISetupControllerTests.swiftindex 399e7f7e..89555d9a 100644--- a/Tests/OnboardingAISetupControllerTests.swift+++ b/Tests/OnboardingAISetupControllerTests.swift@@ -17,6 +17,7 @@ private final class Harness {var loadContinuation: CheckedContinuation<Void, Never>?var progressCallback: (@Sendable (Controller.Progress) async -> Void)?var lastID: String?+ var pendingDownload = falseenum Failure: Error { case simulated }func controller() -> Controller {@@ -43,7 +44,9 @@ private final class Harness {await withCheckedContinuation { self.loadContinuation = $0 }}if self.failLoad { throw Failure.simulated }- }+ },+ readPendingDownload: { self.pendingDownload },+ writePendingDownload: { self.pendingDownload = $0 }))}}@@ -61,6 +64,35 @@ struct OnboardingAISetupControllerTests {@MainActorstatic func main() async {+ // A newly created controller recovers a persisted request, never activation.+ let restarted = Harness()+ restarted.pendingDownload = true+ restarted.failDownload = true+ let firstProcess = restarted.controller()+ firstProcess.resumePendingDownload()+ await self.waitUntil { firstProcess.errorMessage != nil }+ precondition(restarted.pendingDownload && restarted.loads == 0 && restarted.commits == 0)+ restarted.failDownload = false+ let nextProcess = restarted.controller()+ nextProcess.resumePendingDownload()+ await self.waitUntil { !restarted.pendingDownload }+ precondition(restarted.downloads == 2 && restarted.loads == 0 && restarted.commits == 0)+ firstProcess.cancel()++ let cancelled = Harness()+ cancelled.pendingDownload = true+ cancelled.controller().cancel()+ cancelled.controller().resumePendingDownload()+ precondition(!cancelled.pendingDownload && cancelled.downloads == 0)++ let saved = Harness()+ saved.installed = true+ saved.pendingDownload = true+ let savedController = saved.controller()+ savedController.resumePendingDownload()+ await self.waitUntil { !saved.pendingDownload }+ precondition(saved.downloads == 0 && saved.loads == 0 && saved.commits == 0)+let fresh = Harness()let controller = fresh.controller()controller.refresh()@@ -81,7 +113,59 @@ struct OnboardingAISetupControllerTests {controller.introductionFinished = false // Explicit Replay changes only video progress.precondition(controller.phase == .ready && fresh.loads == 1 && fresh.commits == 1)+ let prefetched = Harness()+ prefetched.pauseDownload = true+ let prefetchedController = prefetched.controller()+ prefetchedController.prefetch()+ prefetchedController.prefetch()+ await self.waitUntil { prefetched.downloadContinuation != nil }+ precondition(prefetchedController.phase == .downloading)+ precondition(prefetchedController.canEnable && !prefetchedController.showsPreparationProgress)+ precondition(prefetched.readCount == 1 && prefetched.downloads == 1 && prefetched.loads == 0 && prefetched.commits == 0)+ prefetchedController.enable { _ in prefetched.commits += 1 }+ precondition(!prefetchedController.canEnable && prefetchedController.showsPreparationProgress)+ prefetchedController.enable { _ in preconditionFailure("Duplicate activation") }+ prefetched.downloadContinuation?.resume()+ await self.waitUntil { prefetchedController.phase == .ready }+ precondition(prefetched.downloads == 1 && prefetched.loads == 1 && prefetched.commits == 1)++ let prefetchedCached = Harness()+ prefetchedCached.installed = true+ let prefetchedCachedController = prefetchedCached.controller()+ prefetchedCachedController.prefetch()+ await self.waitUntil { prefetchedCachedController.phase == .offered }+ precondition(prefetchedCached.readCount == 1 && prefetchedCached.downloads == 0 && prefetchedCached.loads == 0)++ let cancelledPrefetch = Harness()+ cancelledPrefetch.pauseDownload = true+ let cancelledPrefetchController = cancelledPrefetch.controller()+ cancelledPrefetchController.prefetch()+ await self.waitUntil { cancelledPrefetch.downloadContinuation != nil }+ cancelledPrefetchController.enable { _ in preconditionFailure("Cancelled activation") }+ cancelledPrefetchController.cancel()+ precondition(cancelledPrefetchController.phase == .cancelling && cancelledPrefetchController.progress == nil)+ cancelledPrefetch.downloadContinuation?.resume()+ await self.waitUntil { cancelledPrefetchController.phase == .offered }+ cancelledPrefetch.pauseDownload = false+ cancelledPrefetchController.enable { _ in cancelledPrefetch.commits += 1 }+ await self.waitUntil { cancelledPrefetchController.phase == .ready }+ precondition(cancelledPrefetch.downloads == 2 && cancelledPrefetch.loads == 1 && cancelledPrefetch.commits == 1)+let cached = Harness()+ let deferred = Harness()+ deferred.pauseDownload = true+ var deferredController: OnboardingAISetupController? = deferred.controller()+ weak var retainedDownload = deferredController+ deferredController?.setUpLater()+ await self.waitUntil { deferred.downloadContinuation != nil }+ deferredController?.leavePage()+ deferredController = nil+ precondition(retainedDownload != nil, "Download survives onboarding dismissal")+ deferred.downloadContinuation?.resume()+ deferred.progressCallback = nil+ await self.waitUntil { retainedDownload == nil }+ precondition(deferred.downloads == 1 && deferred.loads == 0 && deferred.commits == 0)+cached.installed = truelet cachedController = cached.controller()cachedController.refresh()@@ -148,6 +232,6 @@ struct OnboardingAISetupControllerTests {missing.enable { _ in throw Harness.Failure.simulated }await self.waitUntil { missing.errorMessage != nil }precondition(missing.phase == .offered && unavailable.commits == 0)- print("PASS: read-only recommendation, fresh/cached activation, duplicate actions, cancellation during download/load, stale progress, failure/retry and commit rejection")+ print("PASS: recommendation prefetch, fresh/cached activation, prefetch cancellation/retry, duplicate actions, cancellation during download/load, stale progress, failure/retry and commit rejection")}}