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
Add speech models and improve dictation (#1240)
ALTIC6150956bef12
diff --git a/Fluid.xcodeproj/project.pbxproj b/Fluid.xcodeproj/project.pbxprojindex c4816754..6ca82216 100644--- a/Fluid.xcodeproj/project.pbxproj+++ b/Fluid.xcodeproj/project.pbxproj@@ -139,6 +139,7 @@C093F64545C6FDD2D79BF559 /* ParakeetArchiveInstallerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5F06B51CF3F45AF989D0CA7F /* ParakeetArchiveInstallerTests.swift */; };640AB09C7781553DF72D1156 /* CompactSpeechModelArchiveTransportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DEEE85A263FAED9ED5DEF8 /* CompactSpeechModelArchiveTransportTests.swift */; };F5E000000000000000000014 /* fv-serve in Embed Helpers */ = {isa = PBXBuildFile; fileRef = F5E000000000000000000005 /* fv-serve */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };+ C0DE123A0000000000000002 /* DictationContextCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DE123A0000000000000001 /* DictationContextCaptureTests.swift */; };/* End PBXBuildFile section *//* Begin PBXContainerItemProxy section */@@ -323,6 +324,7 @@5F06B51CF3F45AF989D0CA7F /* ParakeetArchiveInstallerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParakeetArchiveInstallerTests.swift; sourceTree = "<group>"; };01DEEE85A263FAED9ED5DEF8 /* CompactSpeechModelArchiveTransportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompactSpeechModelArchiveTransportTests.swift; sourceTree = "<group>"; };F5E000000000000000000005 /* fv-serve */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "fv-serve"; sourceTree = BUILT_PRODUCTS_DIR; };+ C0DE123A0000000000000001 /* DictationContextCaptureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DictationContextCaptureTests.swift; sourceTree = "<group>"; };/* End PBXFileReference section *//* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */@@ -544,6 +546,7 @@B51800000000000000000001 /* SpokenSendTests.swift */,B51900000000000000000001 /* PrivateAIProviderPromptFormatTests.swift */,B52000000000000000000001 /* PrivateAIDictationTokenBudgetTests.swift */,+ C0DE123A0000000000000001 /* DictationContextCaptureTests.swift */,C0DE63700000000000000001 /* WhisperLanguageSelectionTests.swift */,CACEC0010000000000000001 /* KeychainServiceCacheTests.swift */,0B05F11E000000000000A001 /* SupportedFileExtensionsTests.swift */,@@ -949,6 +952,7 @@803000000000000000000002 /* MediaPlaybackServiceTests.swift in Sources */,B51800000000000000000002 /* SpokenSendTests.swift in Sources */,B51900000000000000000002 /* PrivateAIProviderPromptFormatTests.swift in Sources */,+ C0DE123A0000000000000002 /* DictationContextCaptureTests.swift in Sources */,C0DE63700000000000000002 /* WhisperLanguageSelectionTests.swift in Sources */,CACEC0010000000000000002 /* KeychainServiceCacheTests.swift in Sources */,0B05F11E000000000000A002 /* SupportedFileExtensionsTests.swift in Sources */,@@ -1153,7 +1157,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 30;+ CURRENT_PROJECT_VERSION = 31;DEVELOPMENT_TEAM = V4J43B279J;ENABLE_APP_SANDBOX = NO;ENABLE_CODE_COVERAGE = NO;@@ -1181,7 +1185,7 @@"@executable_path/../Frameworks",);MACOSX_DEPLOYMENT_TARGET = 15.0;- MARKETING_VERSION = "1.6.12";+ MARKETING_VERSION = "1.6.13-beta.1";PRODUCT_BUNDLE_IDENTIFIER = com.FluidApp.app.debug;PRODUCT_NAME = "FluidVoice Debug";PROVISIONING_PROFILE_SPECIFIER = "";@@ -1208,7 +1212,7 @@"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";CODE_SIGN_STYLE = Automatic;COMBINE_HIDPI_IMAGES = YES;- CURRENT_PROJECT_VERSION = 30;+ CURRENT_PROJECT_VERSION = 31;DEVELOPMENT_TEAM = V4J43B279J;ENABLE_APP_SANDBOX = NO;ENABLE_CODE_COVERAGE = NO;@@ -1236,7 +1240,7 @@"@executable_path/../Frameworks",);MACOSX_DEPLOYMENT_TARGET = 15.0;- MARKETING_VERSION = "1.6.12";+ MARKETING_VERSION = "1.6.13-beta.1";PRODUCT_BUNDLE_IDENTIFIER = com.FluidApp.app;PRODUCT_NAME = FluidVoice;PROVISIONING_PROFILE_SPECIFIER = "";@@ -1542,7 +1546,7 @@repositoryURL = "https://github.com/altic-dev/FluidAudio.git";requirement = {kind = revision;- revision = eb1e6628998e47022799d305b52c2680d3576801;+ revision = 386f7195670b77f2954c7ee143ec63fcb50b6c3b;};};diff --git a/Fluid.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Fluid.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedindex ea0494b1..7f97a59f 100644--- a/Fluid.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved+++ b/Fluid.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved@@ -32,7 +32,7 @@"kind" : "remoteSourceControl","location" : "https://github.com/altic-dev/FluidAudio.git","state" : {- "revision" : "eb1e6628998e47022799d305b52c2680d3576801"+ "revision" : "386f7195670b77f2954c7ee143ec63fcb50b6c3b"}},{diff --git a/Info.plist b/Info.plistindex d2fcccfb..52ef77fd 100644--- a/Info.plist+++ b/Info.plist@@ -13,9 +13,9 @@<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string><key>CFBundleVersion</key>- <string>30</string>+ <string>31</string><key>CFBundleShortVersionString</key>- <string>1.6.12</string>+ <string>1.6.13-beta.1</string><key>LSMinimumSystemVersion</key><string>$(MACOSX_DEPLOYMENT_TARGET)</string><key>LSApplicationCategoryType</key>diff --git a/Package.resolved b/Package.resolvedindex 0894533a..39bfc337 100644--- a/Package.resolved+++ b/Package.resolved@@ -31,7 +31,7 @@"kind" : "remoteSourceControl","location" : "https://github.com/altic-dev/FluidAudio.git","state" : {- "revision" : "eb1e6628998e47022799d305b52c2680d3576801"+ "revision" : "386f7195670b77f2954c7ee143ec63fcb50b6c3b"}},{diff --git a/Package.swift b/Package.swiftindex f519e403..34851513 100644--- a/Package.swift+++ b/Package.swift@@ -11,7 +11,7 @@ let package = Package(dependencies: [.package(path: "Vendor/WebRTCAudioProcessing"),.package(url: "https://github.com/mxcl/AppUpdater.git", from: "1.0.0"),- .package(url: "https://github.com/altic-dev/FluidAudio.git", revision: "eb1e6628998e47022799d305b52c2680d3576801"),+ .package(url: "https://github.com/altic-dev/FluidAudio.git", revision: "386f7195670b77f2954c7ee143ec63fcb50b6c3b"),.package(url: "https://github.com/mxcl/PromiseKit", from: "6.0.0"),.package(url: "https://github.com/altic-dev/DynamicNotchKit.git", revision: "50dc8565469cc80bbbe3c0d5dd902585a2d67986"),.package(url: "https://github.com/altic-dev/transcribe-cpp-swift.git", exact: "0.1.2"),diff --git a/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/Contents.json b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/Contents.jsonnew file mode 100644index 00000000..88d31006--- /dev/null+++ b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/Contents.json@@ -0,0 +1,7 @@+{+ "images" : [+ { "filename" : "brand-icon.png", "idiom" : "universal", "scale" : "1x" },+ { "filename" : "[email protected]", "idiom" : "universal", "scale" : "2x" }+ ],+ "info" : { "author" : "xcode", "version" : 1 }+}diff --git a/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/brand-icon.png b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/brand-icon.pngnew file mode 100644index 00000000..c605500aBinary files /dev/null and b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/brand-icon.png differdiff --git a/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/[email protected] b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/[email protected]new file mode 100644index 00000000..f5dbc94aBinary files /dev/null and b/Sources/Fluid/Assets.xcassets/BrandIcon.imageset/[email protected] differdiff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 96837b80..18ab456b 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -337,6 +337,7 @@ struct ContentView: View {@State private var showsReleaseHighlights = false@State private var recordingAppInfo: (name: String, bundleId: String, windowTitle: String)? = nil@State private var recordingPrecedingText: String = ""+ @State private var dictationContextCapture: DictationContextCapture?@State private var recordingFocusTarget: TypingService.CapturedFocusTarget? = nil// Command Mode State@@ -510,6 +511,9 @@ struct ContentView: View {.onReceive(NotificationCenter.default.publisher(for: .openCustomDictionaryFromVoiceEngine)) { _ inself.navigateToApp(.customDictionary)}+ .onReceive(NotificationCenter.default.publisher(for: .openScreenContextSettings)) { _ in+ self.openSettings(.experimental)+ }.onReceive(NotificationCenter.default.publisher(for: .fluidMeetEnabledChanged)) { _ inif self.settings.fluidMeetEnabled, self.appServices.isUIReady {self.menuBarManager.configure(meetingCoordinator: self.appServices.meetingSessionCoordinator)@@ -583,9 +587,13 @@ struct ContentView: View {.onChange(of: self.audioObserver.inputAvailabilityTick) { _, _ inself.refreshInputDevices()}+ .onChange(of: self.settings.dictationScreenContextEnabled) { _, enabled in+ if !enabled { self.cancelDictationContextCapture() }+ }.onDisappear {Task { await self.asr.stopWithoutTranscription() }self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()// Note: Overlay lifecycle is now managed by MenuBarManager// Note: NotchContentState handlers capture self (a struct value copy) and are// intentionally kept alive so the overlay remains fully functional when the@@ -696,6 +704,7 @@ struct ContentView: View {Task { await self.asr.stopWithoutTranscription() }}self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()self.clearActiveRecordingMode()self.menuBarManager.setOverlayMode(.dictation)}@@ -716,6 +725,7 @@ struct ContentView: View {Task { await self.asr.stopWithoutTranscription() }}self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()self.clearActiveRecordingMode()self.menuBarManager.setOverlayMode(.dictation)}@@ -736,6 +746,7 @@ struct ContentView: View {Task { await self.asr.stopWithoutTranscription() }}self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()self.clearActiveRecordingMode()self.rewriteModeService.clearState()self.menuBarManager.setOverlayMode(.dictation)@@ -1257,6 +1268,9 @@ struct ContentView: View {}func shortcutConflictMessage(for shortcut: HotkeyShortcut, target: ShortcutRecordingTarget) -> String? {+ if target == .cancel, shortcut.isModifierOnlyShortcut {+ return "Modifier-only keys can't cancel recording. Use Esc or include a regular key."+ }if target == .meeting, !shortcut.isMeetingRecordingShortcut {return "Use a keyboard key with a modifier for meeting recording"}@@ -1717,7 +1731,8 @@ struct ContentView: View {accessibilityEnabled: self.accessibilityEnabled,savesTranscriptionHistory: SettingsStore.shared.saveTranscriptionHistory,savesAudioWithTranscriptionHistory: SettingsStore.shared.saveAudioWithTranscriptionHistory,- overlayAtBottom: self.settings.overlayPosition == .bottom+ overlayAtBottom: self.settings.overlayPosition == .bottom,+ privateAIAvailable: PrivateAIProviderFeature.shared.isAvailable))}@@ -2519,6 +2534,52 @@ struct ContentView: View {self.captureRecordingFormattingContextIfNeeded()}+ /// Starts reading the text around the cursor when the dictation model was+ /// trained to use it. Every other model skips this entirely.+ private func startDictationContextCaptureIfNeeded(for slot: SettingsStore.DictationShortcutSlot) {+ self.cancelDictationContextCapture()+ let route = DictationProviderRoute.resolve(+ settings: .shared,+ dictationSlot: slot,+ appBundleID: self.recordingAppInfo?.bundleId+ )+ guard self.settings.dictationScreenContextEnabled, route.usesPrivateAI,+ PrivateAIIntegrationService.readsDictationContext(model: route.model),+ let target = NotchContentState.shared.recordingTargetContext,+ target.pid != ProcessInfo.processInfo.processIdentifier+ else { return }+ self.dictationContextCapture = DictationContextCapture.start(+ target: target,+ textBeforeCursor: self.settings.needsDictationFormattingContext ? self.recordingPrecedingText : nil,+ settings: .shared+ )+ }++ private func cancelDictationContextCapture() {+ self.dictationContextCapture?.cancel()+ self.dictationContextCapture = nil+ }++ private func attachDictationContext(_ capture: DictationContextCapture, to stopSnapshot: inout DictationStopSnapshot?) async {+ // Context must belong to the exact destination field and a supported local model.+ guard self.settings.dictationScreenContextEnabled,+ let snapshot = stopSnapshot, snapshot.usesAI, snapshot.route.usesPrivateAI,+ PrivateAIIntegrationService.readsDictationContext(model: snapshot.route.model),+ let target = snapshot.target, capture.matches(target)+ else {+ capture.cancel()+ return+ }+ let startedAt = ProcessInfo.processInfo.systemUptime+ let context = await capture.result(timeout: .milliseconds(300))+ guard self.settings.dictationScreenContextEnabled else { return }+ stopSnapshot?.typingContext = context+ self.appBench(+ "dictation_context waitMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded())) "+ + "beforeCursorChars=\(context?.textBeforeCursor?.count ?? 0) screenLines=\(context?.screenText?.count ?? 0)"+ )+ }+private func captureDictationStopSnapshot(slot: SettingsStore.DictationShortcutSlot) -> DictationStopSnapshot {let current = TypingService.captureRecordingTargetContext()let ownPID = ProcessInfo.processInfo.processIdentifier@@ -2806,6 +2867,13 @@ struct ContentView: View {self.logDictationPromptTrace("Private AI Provider task", value: "dictationEnhancement")self.logDictationPromptTrace("Input transcription (Q)", value: inputText)self.logDictationPromptTrace("Selected context text", value: "<none (dictation mode)>")+ if let typingContext = stopSnapshot?.typingContext {+ // Sizes only: the typed and screen text are never logged.+ self.logDictationPromptTrace(+ "Dictation context",+ value: "beforeCursorChars=\(typingContext.textBeforeCursor?.count ?? 0) screenLines=\(typingContext.screenText?.count ?? 0)"+ )+ }}self.appBench("ai_private_call")@@ -2827,7 +2895,9 @@ struct ContentView: View {appName: appInfo.name,bundleID: appInfo.bundleId,windowTitle: appInfo.windowTitle,- appVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String+ appVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String,+ textBeforeCursor: stopSnapshot?.typingContext?.textBeforeCursor,+ screenText: stopSnapshot?.typingContext?.screenText),streamHandler: streamHandler)@@ -3042,6 +3112,11 @@ struct ContentView: View {// swiftlint:disable:next function_body_lengthprivate func processStoppedTranscription(route: DictationOutputRoute, pipelineID: String, toggleStopRequestedAt: TimeInterval?) async {+ let contextCapture = self.dictationContextCapture+ defer {+ contextCapture?.cancel()+ if self.dictationContextCapture === contextCapture { self.dictationContextCapture = nil }+ }guard let summaryActivity = MeetingSummaryActivityCoordinator.shared.beginProcessing() else {MeetingSummaryActivityCoordinator.presentBusyError()return@@ -3098,6 +3173,11 @@ struct ContentView: View {)self.appBench("asr_stop_return elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - asrStopStartedAt) * 1000).rounded()))")self.completeDictationStopSnapshot(&stopSnapshot)+ if let contextCapture, self.overlayLifecycleID == expectedOverlayLifecycleID,+ self.cancelledOutputLifecycleID != expectedOverlayLifecycleID, !Task.isCancelled+ {+ await self.attachDictationContext(contextCapture, to: &stopSnapshot)+ }let audioSnapshot = self.asr.consumeLastCompletedAudioSnapshot()let dictionaryLearningRecording = self.asr.consumeDictionaryLearningRecording()let transcriptionDurationMilliseconds = self.asr.consumeLastFinalTranscriptionDurationMs()@@ -3850,6 +3930,7 @@ struct ContentView: View {}private func advanceOverlayLifecycle() {+ self.cancelDictationContextCapture()self.spokenSendAutoStopTask?.cancel()self.spokenSendAutoStopTask = nilself.stopSpokenSendVoiceActivityMonitoring()@@ -4268,6 +4349,7 @@ struct ContentView: View {DebugLogger.shared.info("Actions: stopping active recording before history action output", source: "ContentView")await self.asr.stopWithoutTranscription()self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()}let appInfo = self.getCurrentAppInfo()@@ -4342,6 +4424,7 @@ struct ContentView: View {DebugLogger.shared.info("Actions: stopping active recording before reprocess", source: "ContentView")await self.asr.stopWithoutTranscription()self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()}self.setActiveRecordingMode(.dictate)@@ -4544,6 +4627,7 @@ struct ContentView: View {}private func setActiveRecordingMode(_ mode: ActiveRecordingMode) {+ if mode == .command || mode == .edit { self.cancelDictationContextCapture() }if mode != .dictate, mode != .promptMode {self.clearActiveDictationShortcutState()}@@ -4696,6 +4780,7 @@ struct ContentView: View {TranscriptionSoundPlayer.shared.playStartSound()}self.captureRecordingContext()+ self.startDictationContextCaptureIfNeeded(for: .primary)self.prewarmPrivateAIDictationIfNeeded(for: .primary)DebugLogger.shared.benchmark("APP_BENCH",@@ -4708,6 +4793,7 @@ struct ContentView: View {return}if startOutcome == .failed {+ self.cancelDictationContextCapture()self.menuBarManager.hideRecordingOverlayImmediately(reason: "asr_start_failed")}}@@ -4742,6 +4828,7 @@ struct ContentView: View {self.activeRecordingMode == mode || self.activeRecordingMode == .noneelse { return }self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()self.clearActiveRecordingMode()self.menuBarManager.hideRecordingOverlayImmediately(reason: "capture_start_cancelled")}@@ -5178,6 +5265,7 @@ struct ContentView: View {}if let lifecycleID = self.processingDictationLifecycleID {+ self.cancelDictationContextCapture()// A stop already owns the audio; suppress its pending output without stopping again.self.cancelledOutputLifecycleID = lifecycleIDhandled = true@@ -5213,9 +5301,11 @@ struct ContentView: View {self.clearActiveRecordingMode()}self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()handled = true} else if self.activeRecordingMode != .none {self.cancelPrewarmDictationIfNeeded()+ self.cancelDictationContextCapture()self.clearActiveRecordingMode()handled = true}@@ -5492,6 +5582,7 @@ extension ContentView {TranscriptionSoundPlayer.shared.playStartSound()}self.captureRecordingContext()+ self.startDictationContextCaptureIfNeeded(for: slot)self.prewarmPrivateAIDictationIfNeeded(for: slot)self.appBench("overlay_phase phase=recording trigger=first_pcm")})@@ -5500,6 +5591,7 @@ extension ContentView {return}if startOutcome == .failed {+ self.cancelDictationContextCapture()self.menuBarManager.hideRecordingOverlayImmediately(reason: "asr_start_failed")if isOnboardingTryout {AnalyticsService.shared.recordOnboardingTryoutAttemptResult(diff --git a/Sources/Fluid/Networking/CompactSpeechModelArchiveTransport.swift b/Sources/Fluid/Networking/CompactSpeechModelArchiveTransport.swiftindex ab2740d8..a3b215f2 100644--- a/Sources/Fluid/Networking/CompactSpeechModelArchiveTransport.swift+++ b/Sources/Fluid/Networking/CompactSpeechModelArchiveTransport.swift@@ -47,7 +47,7 @@ nonisolated enum CompactSpeechModelArchiveTransport {chunkBytes: Int64) async throws -> (URL, URLResponse) {try Task.checkCancellation()- guard descriptor.variant == .mini || descriptor.variant == .pico,+ guard descriptor.isHostedPack,descriptor.folderName == ParakeetSpeechModelCatalog.descriptor(for: descriptor.variant).folderName,modelsDirectory.isFileURL,let url = descriptor.archiveURL, url.scheme == "https", url.host == SpeechModelFeed.host,diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex ae090be2..1f324cfa 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -55,6 +55,7 @@ final class SettingsStore: ObservableObject {self.migrateDictationPromptProfilesIfNeeded()self.migrateLegacyDictationAIPreferenceIfNeeded()self.migrateSecondaryPromptShortcutIfNeeded()+ Self.migrateModifierOnlyCancelShortcutIfNeeded(defaults: self.defaults)self.retireLegacySecondaryPromptShortcutIfNeeded()self.normalizePromptSelectionsIfNeeded()self.purgeRetiredAppleIntelligenceState()@@ -3211,12 +3212,23 @@ final class SettingsStore: ObservableObject {}set {objectWillChange.send()- if let data = try? JSONEncoder().encode(newValue) {+ // Old backups can still contain a modifier-only Cancel binding.+ let shortcut = newValue?.isModifierOnlyShortcut == true ? HotkeyShortcut(keyCode: 53, modifierFlags: []) : newValue+ if let data = try? JSONEncoder().encode(shortcut) {self.defaults.set(data, forKey: Keys.cancelRecordingHotkeyShortcut)}}}+ static func migrateModifierOnlyCancelShortcutIfNeeded(defaults: UserDefaults) {+ guard let data = defaults.data(forKey: Keys.cancelRecordingHotkeyShortcut),+ let shortcut = try? JSONDecoder().decode(HotkeyShortcut.self, from: data),+ shortcut.isModifierOnlyShortcut,+ let replacement = try? JSONEncoder().encode(HotkeyShortcut(keyCode: 53, modifierFlags: []))+ else { return }+ defaults.set(replacement, forKey: Keys.cancelRecordingHotkeyShortcut)+ }+/// Unassigned by default. Meeting recording never claims a shortcut until explicitly configured.var meetingRecordingHotkeyShortcut: HotkeyShortcut? {get {@@ -5034,6 +5046,17 @@ final class SettingsStore: ObservableObject {self.continuousDictationSpacingEnabled || self.contextAwareCapitalizationEnabled}+ // MARK: - Dictation Screen Context++ /// One opt-in for cursor and window text, with local OCR when needed.+ var dictationScreenContextEnabled: Bool {+ get { self.defaults.bool(forKey: Keys.dictationScreenContextEnabled) }+ set {+ objectWillChange.send()+ self.defaults.set(newValue, forKey: Keys.dictationScreenContextEnabled)+ }+ }+// MARK: - Media Playback Control/// When enabled, automatically pauses system media playback when transcription starts.@@ -5165,6 +5188,7 @@ final class SettingsStore: ObservableObject {case parakeetTDTv2 = "parakeet-tdt-v2"case fluidParakeetMini = "fluid-parakeet-mini"case fluidParakeetPico = "fluid-parakeet-pico"+ case fluidParakeetPro = "fluid-parakeet-pro"case parakeetRealtime = "parakeet-realtime"case qwen3Asr = "qwen3-asr"case cohereTranscribeSixBit = "cohere-transcribe-6bit"@@ -5208,7 +5232,7 @@ final class SettingsStore: ObservableObject {var displayName: String {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.displayName ?? self.rawValue+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.displayName ?? self.rawValuecase .parakeetRealtime: return "Parakeet Flash (Beta)"case .qwen3Asr: return "Qwen3 ASR (Beta)"case .cohereTranscribeSixBit: return "Cohere Transcribe"@@ -5229,7 +5253,7 @@ final class SettingsStore: ObservableObject {var languageSupport: String {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.languageSupport ?? "English Only"+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.languageSupport ?? "English Only"case .parakeetRealtime: return "English Only (Live Streaming)"case .qwen3Asr, .qwen3Asr17B: return "30 Languages"case .cohereTranscribeSixBit: return "14 Languages (Select Manually)"@@ -5243,7 +5267,7 @@ final class SettingsStore: ObservableObject {var downloadSize: String {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.downloadSize ?? ""+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.downloadSize ?? ""case .parakeetRealtime: return "~428.4 MiB"case .qwen3Asr: return "~2.0 GiB"case .cohereTranscribeSixBit: return "~1.54 GiB"@@ -5264,7 +5288,7 @@ final class SettingsStore: ObservableObject {var expectedDownloadBytes: Int64 {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.expectedDownloadBytes ?? 0+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.expectedDownloadBytes ?? 0case .parakeetRealtime: return 449_190_189case .qwen3Asr: return 2000 * 1024 * 1024case .cohereTranscribeSixBit: return 1_650_748_785@@ -5283,14 +5307,14 @@ final class SettingsStore: ObservableObject {var requiresAppleSilicon: Bool {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime, .qwen3Asr, .qwen3Asr17B, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320: return true+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime, .qwen3Asr, .qwen3Asr17B, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320: return truedefault: return false}}var isWhisperModel: Bool {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime, .qwen3Asr, .qwen3Asr17B, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320, .appleSpeech,+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime, .qwen3Asr, .qwen3Asr17B, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320, .appleSpeech,.appleSpeechAnalyzer: return falsedefault: return true}@@ -5357,7 +5381,7 @@ final class SettingsStore: ObservableObject {/// Requires macOS 15 or later.var requiresMacOS15: Bool {switch self {- case .fluidParakeetMini, .fluidParakeetPico, .qwen3Asr, .cohereTranscribeSixBit: return true+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .qwen3Asr, .cohereTranscribeSixBit: return truedefault: return false}}@@ -5407,7 +5431,7 @@ final class SettingsStore: ObservableObject {/// Human-readable marketing name for the card UIvar humanReadableName: String {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.humanReadableName ?? self.rawValue+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.humanReadableName ?? self.rawValuecase .parakeetRealtime: return "Flash Dictation"case .qwen3Asr: return "Qwen3 - Multilingual"case .cohereTranscribeSixBit: return "Cohere - High Accuracy"@@ -5429,7 +5453,7 @@ final class SettingsStore: ObservableObject {/// One-line description for the card UIvar cardDescription: String {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return self.parakeetDescriptor?.cardDescription ?? ""case .parakeetRealtime:return "English-only streaming local dictation with low-latency partial text and end-of-utterance detection."@@ -5467,7 +5491,7 @@ final class SettingsStore: ObservableObject {/// Minimum recommended RAM in GB for this model to run safelyvar requiredMemoryGB: Double {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime:return 4.0case .qwen3Asr:return 8.0@@ -5513,7 +5537,7 @@ final class SettingsStore: ObservableObject {/// Speed rating (1-5, higher is faster)var speedRating: Int {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.performanceRatings?.speedRating ?? 0+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.performanceRatings?.speedRating ?? 0case .parakeetRealtime: return 5case .qwen3Asr: return 3case .cohereTranscribeSixBit: return 3@@ -5534,7 +5558,7 @@ final class SettingsStore: ObservableObject {/// Accuracy rating (1-5, higher is more accurate)var accuracyRating: Int {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.performanceRatings?.accuracyRating ?? 0+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.performanceRatings?.accuracyRating ?? 0case .parakeetRealtime: return 4case .qwen3Asr: return 4case .cohereTranscribeSixBit: return 5@@ -5555,7 +5579,7 @@ final class SettingsStore: ObservableObject {/// Exact speed percentage (0.0 - 1.0) for the liquid barsvar speedPercent: Double {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.performanceRatings?.speedPercent ?? 0+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.performanceRatings?.speedPercent ?? 0case .parakeetRealtime: return 1.0case .qwen3Asr: return 0.45case .cohereTranscribeSixBit: return 0.85@@ -5576,7 +5600,7 @@ final class SettingsStore: ObservableObject {/// Exact accuracy percentage (0.0 - 1.0) for the liquid barsvar accuracyPercent: Double {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico: return self.parakeetDescriptor?.performanceRatings?.accuracyPercent ?? 0+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return self.parakeetDescriptor?.performanceRatings?.accuracyPercent ?? 0case .parakeetRealtime: return 0.75case .qwen3Asr: return 0.90case .cohereTranscribeSixBit: return 0.98@@ -5599,7 +5623,7 @@ final class SettingsStore: ObservableObject {switch self {case .parakeetTDT: return "FluidVoice Pick"case .parakeetTDTv2: return "FluidVoice Pick"- case .fluidParakeetMini, .fluidParakeetPico: return "New"+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro: return "New"case .parakeetRealtime: return "Beta"case .qwen3Asr: return "Beta"case .qwen3Asr17B: return nil@@ -5613,7 +5637,7 @@ final class SettingsStore: ObservableObject {/// Optimization level for Apple Silicon (for display)var appleSiliconOptimized: Bool {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime, .qwen3Asr, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320, .appleSpeechAnalyzer:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime, .qwen3Asr, .cohereTranscribeSixBit, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320, .appleSpeechAnalyzer:return truedefault:return false@@ -5634,7 +5658,7 @@ final class SettingsStore: ObservableObject {var supportsPronunciationMatching: Bool {#if arch(arm64)switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return truedefault:return false@@ -5686,7 +5710,7 @@ final class SettingsStore: ObservableObject {/// Which provider this model belongs tovar provider: Provider {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320:return .nvidiacase .appleSpeech, .appleSpeechAnalyzer:return .apple@@ -5709,7 +5733,7 @@ final class SettingsStore: ObservableObject {switch self {case .appleSpeech, .appleSpeechAnalyzer:return true- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:#if canImport(FluidAudio)guard let descriptor = self.parakeetDescriptor else { return false }return Self.parakeetModelsExist(descriptor: descriptor)@@ -5798,7 +5822,7 @@ final class SettingsStore: ObservableObject {/// Brand/provider name for the model (NVIDIA, Apple, OpenAI)var brandName: String {switch self {- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return "FluidVoice"case .parakeetTDT, .parakeetTDTv2, .parakeetRealtime, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320:return "NVIDIA"@@ -5824,7 +5848,7 @@ final class SettingsStore: ObservableObject {/// Brand color for the provider badgevar brandColorHex: String {switch self {- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return "#1A75FF" // FluidBrandColors.bluecase .parakeetTDT, .parakeetTDTv2, .parakeetRealtime, .nemotronOffline, .nemotronStreaming, .nemotronStreaming320:return "#76B900"@@ -6047,6 +6071,7 @@ private extension SettingsStore {static let continuousDictationModeEnabled = "ContinuousDictationModeEnabled"static let continuousDictationSpacingEnabled = "ContinuousDictationSpacingEnabled"static let contextAwareCapitalizationEnabled = "ContextAwareCapitalizationEnabled"+ static let dictationScreenContextEnabled = "DictationScreenContextEnabled"// Custom Dictionarystatic let customDictionaryEntries = "CustomDictionaryEntries"@@ -6286,7 +6311,7 @@ extension SettingsStore.SpeechModel {switch self {case .parakeetTDT:return "BG, HR, CS, DA, NL, EN, ET, FI, FR, DE, EL, HU, IT, LV, LT, MT, PL, PT, RO, SK, SL, ES, SV, RU, UK"- case .fluidParakeetMini, .fluidParakeetPico, .parakeetRealtime:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro, .parakeetRealtime:return "EN"case .cohereTranscribeSixBit:return "AR, DE, EL, EN, ES, FR, IT, JA, KO, NL, PL, PT, VI, ZH"@@ -6308,7 +6333,7 @@ extension SettingsStore.SpeechModel {return """Bulgarian, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Greek, Hungarian, Italian, Latvian, Lithuanian, Maltese, Polish, Portuguese, Romanian, Slovak, Slovenian, Spanish, Swedish, Russian, and Ukrainian"""- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return "English"case .cohereTranscribeSixBit:return "Arabic, German, Greek, English, Spanish, French, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Vietnamese, and Mandarin Chinese"diff --git a/Sources/Fluid/Persistence/VoiceEngineLanguageCatalog.swift b/Sources/Fluid/Persistence/VoiceEngineLanguageCatalog.swiftindex 374e4d82..92b2d9f3 100644--- a/Sources/Fluid/Persistence/VoiceEngineLanguageCatalog.swift+++ b/Sources/Fluid/Persistence/VoiceEngineLanguageCatalog.swift@@ -48,7 +48,7 @@ struct VoiceEngineLanguageRoute: Identifiable, Equatable {var badgeText: String? {switch self.model {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return "Optimized for FluidVoice"default:return nil@@ -153,6 +153,7 @@ enum VoiceEngineLanguageCatalog {if language.id == "en" {routes.append(Self.route(language, .fluidParakeetMini, .automatic))routes.append(Self.route(language, .fluidParakeetPico, .automatic))+ routes.append(Self.route(language, .fluidParakeetPro, .automatic))}if let cohereLanguage = Self.cohereLanguage(for: language.id) {diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 5530b049..fa537ac7 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -1211,7 +1211,7 @@ final class ASRService: ObservableObject {}case .appleSpeech:return self.getAppleSpeechProvider()- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return self.getFluidAudioProvider()case .parakeetRealtime:return self.getParakeetRealtimeProvider()@@ -1343,7 +1343,7 @@ final class ASRService: ObservableObject {}case .appleSpeech:return AppleSpeechProvider()- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:// Create a new provider configured for the specific modelreturn FluidAudioProvider(modelOverride: model, configureWordBoosting: false, updateCompactWeights: updateWeights)case .parakeetRealtime:diff --git a/Sources/Fluid/Services/DictationContextCapture.swift b/Sources/Fluid/Services/DictationContextCapture.swiftnew file mode 100644index 00000000..56f36f5d--- /dev/null+++ b/Sources/Fluid/Services/DictationContextCapture.swift@@ -0,0 +1,508 @@+import AppKit+import ApplicationServices+import Carbon.HIToolbox+import ScreenCaptureKit+import Vision++/// Raw text around a dictation, for models trained to read it.+/// Fluid Intelligence picks the useful words and writes the prompt lines,+/// so nothing here formats them.+nonisolated struct DictationTypingContext: Sendable, Equatable {+ var textBeforeCursor: String?+ // One Accessibility element or OCR line per entry; nil means none was read.+ // swiftlint:disable:next discouraged_optional_collection+ var screenText: [String]?+}++/// Reads the dictation context when recording starts, off the main thread,+/// so it is ready when speech ends. What it reads is never logged or kept.+final nonisolated class DictationContextCapture: @unchecked Sendable {+ private let target: TypingService.RecordingTargetContext+ private let task: Task<DictationTypingContext?, Never>+ private let first = FirstResult()++ init(target: TypingService.RecordingTargetContext, task: Task<DictationTypingContext?, Never>) {+ self.target = target+ self.task = task+ }++ deinit { self.cancel() }++ @MainActor+ func matches(_ target: TypingService.RecordingTargetContext) -> Bool {+ guard self.target.pid == target.pid else { return false }+ if self.target.id == target.id { return true }+ guard let original = self.target.element, let current = target.element,+ CFEqual(original, current)+ else { return false }+ switch (self.target.window, target.window) {+ case let (original?, current?): return CFEqual(original, current)+ case (nil, nil): return true+ default: return false+ }+ }++ @MainActor+ static func start(+ target: TypingService.RecordingTargetContext,+ textBeforeCursor: String?,+ settings: SettingsStore+ ) -> DictationContextCapture? {+ guard settings.dictationScreenContextEnabled, AXIsProcessTrusted() else { return nil }+ let request = DictationContextReader.Request(+ pid: target.pid,+ bundleID: target.bundleIdentifier,+ window: target.window,+ element: target.element,+ textBeforeCursor: textBeforeCursor,+ isEnabled: settings.dictationScreenContextEnabled+ )+ let task = Task.detached(priority: .userInitiated) {+ await DictationContextReader.read(request)+ }+ return DictationContextCapture(target: target, task: task)+ }++ /// The context, or nil when it is not ready within `timeout`; a late+ /// result is dropped.+ func result(timeout: Duration) async -> DictationTypingContext? {+ let task = self.task+ let first = self.first+ return await withTaskCancellationHandler {+ await withCheckedContinuation { continuation in+ first.install(continuation)+ Task.detached {+ let value = await task.value+ first.resume(task.isCancelled ? nil : value)+ }+ first.setTimeout(Task.detached {+ do { try await Task.sleep(for: timeout) } catch { return }+ task.cancel()+ first.resume(nil)+ })+ }+ } onCancel: {+ self.cancel()+ }+ }++ func cancel() {+ self.task.cancel()+ self.first.resume(nil)+ }+}++private final nonisolated class FirstResult: @unchecked Sendable {+ private let lock = NSLock()+ private var continuation: CheckedContinuation<DictationTypingContext?, Never>?+ private var completed = false+ private var value: DictationTypingContext?+ private var timeout: Task<Void, Never>?++ func install(_ continuation: CheckedContinuation<DictationTypingContext?, Never>) {+ self.lock.lock()+ if self.completed {+ let value = self.value+ self.lock.unlock()+ continuation.resume(returning: value)+ } else {+ self.continuation = continuation+ self.lock.unlock()+ }+ }++ func setTimeout(_ timeout: Task<Void, Never>) {+ self.lock.lock()+ let completed = self.completed+ if !completed { self.timeout = timeout }+ self.lock.unlock()+ if completed { timeout.cancel() }+ }++ func resume(_ value: DictationTypingContext?) {+ self.lock.lock()+ guard !self.completed else {+ self.lock.unlock()+ return+ }+ self.completed = true+ self.value = value+ let continuation = self.continuation+ self.continuation = nil+ let timeout = self.timeout+ self.timeout = nil+ self.lock.unlock()+ timeout?.cancel()+ continuation?.resume(returning: value)+ }+}++nonisolated enum DictationContextReader {+ struct Request: @unchecked Sendable {+ let pid: pid_t+ let bundleID: String?+ let window: AXUIElement?+ let element: AXUIElement?+ /// Already read for dictation formatting; nil reads it here.+ let textBeforeCursor: String?+ let isEnabled: Bool+ }++ static let maxTextBeforeCursorCharacters = 2000+ static let maxScreenLines = 300+ static let maxLineCharacters = 400+ /// Fewer words than this means Accessibility could not read the window,+ /// so OCR is tried when it is allowed.+ static let minimumAccessibilityWords = 25++ private static let maxLinesPerElement = 150+ private static let maxVisitedElements = 4000+ private static let accessibilityBudgetSeconds = 0.5+ private static let messagingTimeoutSeconds: Float = 0.1+ /// Omit long text values when the app cannot report their visible range.+ private static let longValueCharacters = 4000++ private static let passwordManagerMarkers = [+ "password", "1password", "onepassword", "bitwarden", "lastpass", "dashlane",+ "keepass", "enpass", "keychain", "strongbox", "nordpass", "proton.pass", "keeper",+ ]+ private static let skippedRoles: Set<String> = [+ "AXSecureTextField", "AXScrollBar", "AXValueIndicator", "AXSplitter",+ "AXGrowArea", "AXIncrementor", "AXMenuBar", "AXMenu",+ ]+ /// Roles whose description is their visible label, such as icon buttons.+ private static let labelledRoles: Set<String> = [+ "AXButton", "AXLink", "AXImage", "AXMenuButton", "AXPopUpButton",+ "AXRadioButton", "AXCheckBox", "AXTab",+ ]+ private static let textEntryRoles: Set<String> = ["AXTextArea", "AXTextField", "AXComboBox"]++ static func read(+ _ request: Request,+ recognizeWindow: @Sendable (pid_t, AXUIElement?) async -> [String] = { await DictationContextReader.recognizedWindowText(pid: $0, window: $1) }+ ) async -> DictationTypingContext? {+ guard request.isEnabled, !Task.isCancelled else { return nil }+ if let element = request.element { AXUIElementSetMessagingTimeout(element, self.messagingTimeoutSeconds) }+ guard !self.isPrivate(request) else { return nil }++ let textBeforeCursor = (request.textBeforeCursor ?? request.element.flatMap(self.textBeforeCursor(in:)))+ .map { String($0.suffix(self.maxTextBeforeCursorCharacters)) }++ var lines = LineCollector()+ let windows = self.windows(for: request)+ for window in windows where !Task.isCancelled {+ self.collectAccessibilityText(in: window, into: &lines)+ }+ if let window = windows.first,+ lines.wordCount < self.minimumAccessibilityWords, !Task.isCancelled+ {+ for line in await recognizeWindow(request.pid, window) {+ lines.add(line)+ }+ }+ guard !Task.isCancelled else { return nil }++ let context = DictationTypingContext(+ textBeforeCursor: textBeforeCursor?.isEmpty == false ? textBeforeCursor : nil,+ screenText: lines.lines.isEmpty ? nil : lines.lines+ )+ return context.textBeforeCursor == nil && context.screenText == nil ? nil : context+ }++ private static func windows(for request: Request) -> [AXUIElement] {+ guard let window = request.window else { return [] }+ let app = AXUIElementCreateApplication(request.pid)+ self.exposeWebContent(of: app, pid: request.pid)+ return [window]+ }++ private static let webContentLock = NSLock()+ private nonisolated(unsafe) static var webContentPIDs: [pid_t] = []++ /// Chrome and Electron apps build their page's Accessibility tree only+ /// when asked; other apps ignore the attribute. The tree may still be+ /// building on the first dictation in such an app.+ private static func exposeWebContent(of app: AXUIElement, pid: pid_t) {+ self.webContentLock.lock()+ let isNew = !self.webContentPIDs.contains(pid)+ if isNew {+ if self.webContentPIDs.count == 64 { self.webContentPIDs.removeFirst() }+ self.webContentPIDs.append(pid)+ }+ self.webContentLock.unlock()+ guard isNew else { return }+ AXUIElementSetMessagingTimeout(app, self.messagingTimeoutSeconds)+ AXUIElementSetAttributeValue(app, "AXManualAccessibility" as CFString, kCFBooleanTrue)+ }++ // MARK: - Privacy++ private static func isPrivate(_ request: Request) -> Bool {+ if IsSecureEventInputEnabled() { return true }+ if let bundleID = request.bundleID?.lowercased(),+ self.passwordManagerMarkers.contains(where: { bundleID.contains($0) })+ {+ return true+ }+ return request.element.map(self.isSecure) ?? false+ }++ private static func isSecure(_ element: AXUIElement) -> Bool {+ let role = self.string(element, kAXRoleAttribute) ?? ""+ let subrole = self.string(element, kAXSubroleAttribute) ?? ""+ return role == "AXSecureTextField"+ || subrole == (kAXSecureTextFieldSubrole as String)+ || subrole.localizedCaseInsensitiveContains("secure")+ }++ // MARK: - Text before the cursor++ private static func textBeforeCursor(in element: AXUIElement) -> String? {+ guard let selection = self.range(element, kAXSelectedTextRangeAttribute) else { return nil }+ let end = selection.location+ guard end > 0 else { return nil }+ let start = max(0, end - self.maxTextBeforeCursorCharacters)+ if let text = self.string(element, in: CFRange(location: start, length: end - start)) {+ return text+ }+ guard let value = self.string(element, kAXValueAttribute) else { return nil }+ let nsValue = value as NSString+ let safeEnd = min(end, nsValue.length)+ let safeStart = max(0, safeEnd - self.maxTextBeforeCursorCharacters)+ return nsValue.substring(with: NSRange(location: safeStart, length: safeEnd - safeStart))+ }++ // MARK: - Accessibility text++ private struct ElementText {+ let role: String+ let isSecure: Bool+ let texts: [String]+ let frame: CGRect?+ let children: [AXUIElement]+ }++ private static let fetchedAttributes = [+ kAXRoleAttribute, kAXSubroleAttribute, kAXValueAttribute, kAXTitleAttribute,+ kAXDescriptionAttribute, kAXPositionAttribute, kAXSizeAttribute, kAXChildrenAttribute,+ kAXVisibleCharacterRangeAttribute,+ ] as CFArray++ private static func collectAccessibilityText(in window: AXUIElement, into lines: inout LineCollector) {+ let deadline = ProcessInfo.processInfo.systemUptime + self.accessibilityBudgetSeconds+ AXUIElementSetMessagingTimeout(window, self.messagingTimeoutSeconds)+ let windowFrame = self.frame(of: window)+ var stack = [window]+ var visited = 0+ while let element = stack.popLast(), visited < self.maxVisitedElements, !lines.isFull {+ visited += 1+ if Task.isCancelled || ProcessInfo.processInfo.systemUptime > deadline {+ break+ }+ AXUIElementSetMessagingTimeout(element, self.messagingTimeoutSeconds)+ guard let item = self.elementText(element),+ !item.isSecure, !self.skippedRoles.contains(item.role)+ else { continue }+ // Scrolled-out content lies outside the window; it is not on screen.+ if let windowFrame, let frame = item.frame, !frame.isEmpty, !frame.intersects(windowFrame) {+ continue+ }+ for text in item.texts {+ lines.add(text, limit: self.maxLinesPerElement)+ }+ stack.append(contentsOf: item.children.prefix(max(0, self.maxVisitedElements - visited - stack.count)).reversed())+ }+ }++ private static func elementText(_ element: AXUIElement) -> ElementText? {+ var valuesRef: CFArray?+ guard AXUIElementCopyMultipleAttributeValues(element, self.fetchedAttributes, AXCopyMultipleAttributeOptions(), &valuesRef) == .success,+ let values = valuesRef as? [AnyObject], values.count == 9+ else { return nil }++ let role = values[0] as? String ?? ""+ let subrole = values[1] as? String ?? ""+ var texts: [String] = []+ if var value = values[2] as? String {+ if self.textEntryRoles.contains(role) {+ value = self.textEntryValue(value, visibleRange: self.axValue(values[8], as: CFRange.self, type: .cfRange))+ }+ texts.append(value)+ }+ if let title = values[3] as? String { texts.append(title) }+ if self.labelledRoles.contains(role), let description = values[4] as? String { texts.append(description) }++ var frame: CGRect?+ if let origin = self.axValue(values[5], as: CGPoint.self, type: .cgPoint),+ let size = self.axValue(values[6], as: CGSize.self, type: .cgSize)+ {+ frame = CGRect(origin: origin, size: size)+ }+ return ElementText(+ role: role,+ isSecure: role == "AXSecureTextField" || subrole == (kAXSecureTextFieldSubrole as String),+ texts: texts,+ frame: frame,+ children: values[7] as? [AXUIElement] ?? []+ )+ }++ /// Use the app's visible range even for short fields that may be scrolled.+ /// Read both attributes together and slice the value without another AX call.+ static func textEntryValue(_ value: String, visibleRange: CFRange?) -> String {+ let text = value as NSString+ guard let visibleRange else { return text.length <= self.longValueCharacters ? value : "" }+ guard visibleRange.location >= 0, visibleRange.length > 0,+ visibleRange.location <= text.length,+ visibleRange.length <= text.length - visibleRange.location+ else { return "" }+ return text.substring(with: NSRange(location: visibleRange.location, length: visibleRange.length))+ }++ // MARK: - OCR fallback++ /// Screenshots only the dictated-into window, at native Retina pixels+ /// (Vision garbles small gray text at 1x), and reads it with Vision.+ /// Needs Screen Recording; FluidVoice never asks for it here.+ private static func recognizedWindowText(pid: pid_t, window: AXUIElement?) async -> [String] {+ guard !Task.isCancelled, CGPreflightScreenCaptureAccess(),+ let frame = window.flatMap(self.frame(of:)),+ let windowID = self.windowID(pid: pid, frame: frame)+ else { return [] }+ do {+ let content = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true)+ guard !Task.isCancelled,+ let scWindow = content.windows.first(where: { $0.windowID == windowID })+ else { return [] }+ let filter = SCContentFilter(desktopIndependentWindow: scWindow)+ let configuration = SCStreamConfiguration()+ let scale = CGFloat(filter.pointPixelScale)+ configuration.width = Int((filter.contentRect.width * scale).rounded())+ configuration.height = Int((filter.contentRect.height * scale).rounded())+ configuration.captureResolution = .best+ configuration.showsCursor = false+ configuration.ignoreShadowsSingleWindow = true+ let image = try await SCScreenshotManager.captureImage(contentFilter: filter, configuration: configuration)+ guard !Task.isCancelled else { return [] }+ return self.recognizedLines(in: image)+ } catch {+ return []+ }+ }++ private static func recognizedLines(in image: CGImage) -> [String] {+ let request = VNRecognizeTextRequest()+ request.recognitionLevel = .accurate+ request.usesLanguageCorrection = false+ request.recognitionLanguages = ["en-US"]+ do {+ try VNImageRequestHandler(cgImage: image).perform([request])+ } catch {+ return []+ }+ return (request.results ?? []).compactMap { $0.topCandidates(1).first?.string }+ }++ /// Only the captured window may be read; a stale window must never fall back to another one.+ private static func windowID(pid: pid_t, frame: CGRect?) -> CGWindowID? {+ let info = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID)+ as? [[String: Any]] ?? []+ return self.windowID(pid: pid, frame: frame, windows: info)+ }++ static func windowID(pid: pid_t, frame: CGRect?, windows: [[String: Any]]) -> CGWindowID? {+ guard let frame, !frame.isEmpty else { return nil }+ var matching: CGWindowID?+ for window in windows {+ guard (window[kCGWindowOwnerPID as String] as? pid_t) == pid,+ (window[kCGWindowLayer as String] as? Int) == 0,+ let bounds = window[kCGWindowBounds as String] as? NSDictionary,+ let rect = CGRect(dictionaryRepresentation: bounds as CFDictionary),+ abs(rect.minX - frame.minX) < 2, abs(rect.minY - frame.minY) < 2,+ abs(rect.width - frame.width) < 2, abs(rect.height - frame.height) < 2+ else { continue }+ // Same-sized windows cannot be distinguished by bounds. Never+ // guess from their stacking order, which can change during a read.+ guard matching == nil, let windowID = window[kCGWindowNumber as String] as? CGWindowID else { return nil }+ matching = windowID+ }+ return matching+ }++ // MARK: - Accessibility helpers++ private static func element(_ element: AXUIElement, _ attribute: String) -> AXUIElement? {+ var value: CFTypeRef?+ guard AXUIElementCopyAttributeValue(element, attribute as CFString, &value) == .success,+ let value, CFGetTypeID(value) == AXUIElementGetTypeID()+ else { return nil }+ return unsafeBitCast(value, to: AXUIElement.self)+ }++ private static func string(_ element: AXUIElement, _ attribute: String) -> String? {+ var value: CFTypeRef?+ guard AXUIElementCopyAttributeValue(element, attribute as CFString, &value) == .success else { return nil }+ return value as? String+ }++ private static func string(_ element: AXUIElement, in range: CFRange) -> String? {+ var range = range+ guard let rangeValue = AXValueCreate(.cfRange, &range) else { return nil }+ var value: CFTypeRef?+ guard AXUIElementCopyParameterizedAttributeValue(+ element,+ kAXStringForRangeParameterizedAttribute as CFString,+ rangeValue,+ &value+ ) == .success else { return nil }+ return value as? String+ }++ private static func range(_ element: AXUIElement, _ attribute: String) -> CFRange? {+ var value: CFTypeRef?+ guard AXUIElementCopyAttributeValue(element, attribute as CFString, &value) == .success else { return nil }+ return self.axValue(value, as: CFRange.self, type: .cfRange)+ }++ private static func frame(of element: AXUIElement) -> CGRect? {+ var position: CFTypeRef?+ var size: CFTypeRef?+ guard AXUIElementCopyAttributeValue(element, kAXPositionAttribute as CFString, &position) == .success,+ AXUIElementCopyAttributeValue(element, kAXSizeAttribute as CFString, &size) == .success,+ let origin = self.axValue(position, as: CGPoint.self, type: .cgPoint),+ let extent = self.axValue(size, as: CGSize.self, type: .cgSize)+ else { return nil }+ return CGRect(origin: origin, size: extent)+ }++ private static func axValue<T>(_ value: CFTypeRef?, as _: T.Type, type: AXValueType) -> T? {+ guard let value, CFGetTypeID(value) == AXValueGetTypeID() else { return nil }+ let axValue = unsafeBitCast(value, to: AXValue.self)+ guard AXValueGetType(axValue) == type else { return nil }+ let pointer = UnsafeMutablePointer<T>.allocate(capacity: 1)+ defer { pointer.deallocate() }+ guard AXValueGetValue(axValue, type, pointer) else { return nil }+ return pointer.pointee+ }+}++/// Screen lines in reading order, without repeats, within the size caps.+private nonisolated struct LineCollector {+ private(set) var lines: [String] = []+ private(set) var wordCount = 0+ private var seen: Set<String> = []++ var isFull: Bool { self.lines.count >= DictationContextReader.maxScreenLines }++ mutating func add(_ text: String, limit: Int = .max) {+ var added = 0+ for rawLine in text.split(whereSeparator: \.isNewline) {+ guard !self.isFull, added < limit else { return }+ let line = String(rawLine.trimmingCharacters(in: .whitespaces).prefix(DictationContextReader.maxLineCharacters))+ guard line.contains(where: \.isLetter), self.seen.insert(line).inserted else { continue }+ self.lines.append(line)+ self.wordCount += line.split(whereSeparator: \.isWhitespace).count+ added += 1+ }+ }+}diff --git a/Sources/Fluid/Services/DictationScreenPermissionController.swift b/Sources/Fluid/Services/DictationScreenPermissionController.swiftnew file mode 100644index 00000000..13cff96b--- /dev/null+++ b/Sources/Fluid/Services/DictationScreenPermissionController.swift@@ -0,0 +1,61 @@+import Combine+import CoreGraphics++/// Permission checks are read-only. Only the permission button may prompt.+@MainActor+final class DictationScreenPermissionController: ObservableObject {+ @Published private(set) var isAllowed = false+ @Published private(set) var hasChecked = false+ @Published private(set) var isRequesting = false+ @Published private(set) var requiresSettings = false++ private let check: @Sendable () -> Bool+ private let request: @MainActor () -> Bool+ private var refreshTask: Task<Bool, Never>?+ private var generation: UInt64 = 0++ init(+ check: @escaping @Sendable () -> Bool = { CGPreflightScreenCaptureAccess() },+ request: @escaping @MainActor () -> Bool = { CGRequestScreenCaptureAccess() }+ ) {+ self.check = check+ self.request = request+ }++ func refresh() async {+ let generation: UInt64+ let task: Task<Bool, Never>+ if let pending = self.refreshTask {+ task = pending+ generation = self.generation+ } else {+ self.generation &+= 1+ generation = self.generation+ let check = self.check+ task = Task.detached(priority: .utility) { check() }+ self.refreshTask = task+ }+ let allowed = await task.value+ guard generation == self.generation else { return }+ self.refreshTask = nil+ guard !Task.isCancelled else { return }+ if self.isAllowed, !allowed { self.requiresSettings = true }+ self.isAllowed = allowed+ if allowed { self.requiresSettings = false }+ self.hasChecked = true+ }++ func requestIfNeeded(shouldRequest: @MainActor () -> Bool) async {+ guard !self.isRequesting, shouldRequest() else { return }+ self.isRequesting = true+ defer { self.isRequesting = false }+ await self.refresh()+ guard shouldRequest(), !self.isAllowed, !Task.isCancelled else { return }+ self.generation &+= 1+ self.refreshTask?.cancel()+ self.refreshTask = nil+ self.isAllowed = self.request()+ self.requiresSettings = !self.isAllowed+ self.hasChecked = true+ }+}diff --git a/Sources/Fluid/Services/DictationStopSnapshot.swift b/Sources/Fluid/Services/DictationStopSnapshot.swiftindex c18f063a..1db0c5bf 100644--- a/Sources/Fluid/Services/DictationStopSnapshot.swift+++ b/Sources/Fluid/Services/DictationStopSnapshot.swift@@ -18,6 +18,8 @@ struct DictationStopSnapshot {/// True when the preceding text must be read from the field focused at/// stop rather than reused from recording start.let readsContextFromFocusedField: Bool+ /// Read at recording start for a context-trained model; nil otherwise.+ var typingContext: DictationTypingContext?/// Fills the fields that need WindowServer or Accessibility round-trips./// Called after the microphone has stopped so they never delay it.diff --git a/Sources/Fluid/Services/DictionaryMatchPlayground.swift b/Sources/Fluid/Services/DictionaryMatchPlayground.swiftindex ceb7cdca..cf656f7e 100644--- a/Sources/Fluid/Services/DictionaryMatchPlayground.swift+++ b/Sources/Fluid/Services/DictionaryMatchPlayground.swift@@ -70,6 +70,19 @@ actor DictionaryMatchPlayground {static let shared = DictionaryMatchPlayground()private var running = false+ /// Inspect hosted packs on this replay actor, including Pro and retained older installations.+ nonisolated static func installedModelKeys(+ cacheDirectory: (ParakeetSpeechModelCatalog.Descriptor) -> URL+ ) -> Set<String> {+ var keys: Set<String> = ["parakeet-v2", "parakeet-v3"]+ for descriptor in ParakeetSpeechModelCatalog.descriptors where descriptor.isHostedPack {+ if let hash = descriptor.installedArchiveSHA256(at: cacheDirectory(descriptor)) {+ keys.insert(descriptor.modelID + ":sha256:" + hash)+ }+ }+ return keys+ }+/// Resolve before loading a model: an older checkpoint's vectors remain saved/// but cannot be replayed through a different encoder with the same dimensions.nonisolated static func targetProfile(@@ -79,7 +92,9 @@ actor DictionaryMatchPlayground {) throws -> PronunciationDictionaryProfile {let matching = profiles.filter { $0.label.caseInsensitiveCompare(target) == .orderedSame }if let current = matching.first(where: {- compatibleModelKeys.contains($0.modelKey)+ (compatibleModelKeys.contains($0.modelKey)+ || ($0.modelKey == ParakeetSpeechModelCatalog.pro.modelID+ && compatibleModelKeys.contains(ParakeetSpeechModelCatalog.pro.pronunciationModelKey)))&& ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: $0.modelKey) != nil}) {return current@@ -119,12 +134,8 @@ actor DictionaryMatchPlayground {let duration = Double(samples.count) / 16_000#if arch(arm64)let allProfiles = await PronunciationDictionaryStore.shared.allProfiles()- var compatibleModelKeys: Set<String> = ["parakeet-v2", "parakeet-v3"]- for descriptor in [ParakeetSpeechModelCatalog.mini, ParakeetSpeechModelCatalog.pico] {- let directory = AsrModels.defaultCacheDirectory(for: descriptor.asrModelVersion)- if let hash = descriptor.installedArchiveSHA256(at: directory) {- compatibleModelKeys.insert(descriptor.modelID + ":sha256:" + hash)- }+ let compatibleModelKeys = Self.installedModelKeys { descriptor in+ AsrModels.defaultCacheDirectory(for: descriptor.asrModelVersion)}let targetProfile = try Self.targetProfile(from: allProfiles, target: target, compatibleModelKeys: compatibleModelKeys)let matching = allProfiles.filter { $0.modelKey == targetProfile.modelKey }.sorted {diff --git a/Sources/Fluid/Services/ExternalCoreMLModelRegistry.swift b/Sources/Fluid/Services/ExternalCoreMLModelRegistry.swiftindex 38e1c8f4..aa360fd4 100644--- a/Sources/Fluid/Services/ExternalCoreMLModelRegistry.swift+++ b/Sources/Fluid/Services/ExternalCoreMLModelRegistry.swift@@ -244,7 +244,7 @@ extension SettingsStore.SpeechModel {var supportsCustomVocabulary: Bool {switch self {- case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico:+ case .parakeetTDT, .parakeetTDTv2, .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return truedefault:return falsediff --git a/Sources/Fluid/Services/FluidAudioProvider.swift b/Sources/Fluid/Services/FluidAudioProvider.swiftindex 18294fac..1fd30569 100644--- a/Sources/Fluid/Services/FluidAudioProvider.swift+++ b/Sources/Fluid/Services/FluidAudioProvider.swift@@ -539,7 +539,7 @@ final class FluidAudioProvider: TranscriptionProvider {if installedHash == nil {let release = descriptorlet validator: ParakeetArchiveDownloader.StageValidator?- if release.variant == .mini || release.variant == .pico {+ if release.isHostedPack {validator = { directory inprogressRelay.report(.loading)try await CompactSpeechModelRuntimeCheck.validateStagedWeights(at: directory, descriptor: release)@@ -1842,7 +1842,7 @@ final class FluidAudioProvider: TranscriptionProvider {func modelsExistOnDisk() -> Bool {let selectedModel = self.resolvedSpeechModelswitch selectedModel {- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return SpeechModelInstallationSnapshot.shared.isInstalled(modelID: selectedModel.id)case .parakeetTDT, .parakeetTDTv2:return selectedModel.isInstalled@@ -1866,7 +1866,7 @@ final class FluidAudioProvider: TranscriptionProvider {}var preservesInstalledCompactWeights: Bool {- self.resolvedSpeechModel == .fluidParakeetMini || self.resolvedSpeechModel == .fluidParakeetPico+ [.fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro].contains(self.resolvedSpeechModel)}var shouldClearCacheAfterCancellation: Bool {diff --git a/Sources/Fluid/Services/ParakeetSpeechModelBackend.swift b/Sources/Fluid/Services/ParakeetSpeechModelBackend.swiftindex 8b7691b5..b673ebcd 100644--- a/Sources/Fluid/Services/ParakeetSpeechModelBackend.swift+++ b/Sources/Fluid/Services/ParakeetSpeechModelBackend.swift@@ -10,6 +10,7 @@ nonisolated extension ParakeetSpeechModelCatalog.Descriptor {case .v3: .v3case .mini: .fluidParakeetMinicase .pico: .fluidParakeetPico+ case .pro: .fluidParakeetPro}}}diff --git a/Sources/Fluid/Services/ParakeetSpeechModelCatalog.swift b/Sources/Fluid/Services/ParakeetSpeechModelCatalog.swiftindex f4898848..a53a71be 100644--- a/Sources/Fluid/Services/ParakeetSpeechModelCatalog.swift+++ b/Sources/Fluid/Services/ParakeetSpeechModelCatalog.swift@@ -5,7 +5,7 @@ import Foundation/// Resolving a descriptor performs no hardware, network or filesystem queries.nonisolated enum ParakeetSpeechModelCatalog {enum Variant: String, CaseIterable, Sendable {- case v2, v3, mini, pico+ case v2, v3, mini, pico, pro}struct PerformanceRatings: Equatable, Sendable {@@ -36,17 +36,20 @@ nonisolated enum ParakeetSpeechModelCatalog {var isEnglishOnly: Bool { self.supportedLanguageCodes == ["en"] }+ /// Downloaded as one tar from our own host, with an archive marker and manifest.+ var isHostedPack: Bool { self.variant == .mini || self.variant == .pico || self.variant == .pro }+var attribution: String {switch self.variant {case .v2, .v3: "NVIDIA Parakeet"- case .mini, .pico: "NVIDIA Parakeet · Moondream Parakeet Ultra"+ case .mini, .pico, .pro: "NVIDIA Parakeet · Moondream Parakeet Ultra"}}var creditLine: String {switch self.variant {case .v2, .v3: "Built on NVIDIA Parakeet."- case .mini, .pico: "Made by FluidVoice, built on NVIDIA Parakeet and Moondream’s Parakeet Ultra."+ case .mini, .pico, .pro: "Made by FluidVoice, built on NVIDIA Parakeet and Moondream’s Parakeet Ultra."}}@@ -56,7 +59,7 @@ nonisolated enum ParakeetSpeechModelCatalog {switch self.variant {case .v2: "parakeet-v2"case .v3: "parakeet-v3"- case .mini, .pico: "\(self.modelID):sha256:\(self.archiveSHA256 ?? "unavailable")"+ case .mini, .pico, .pro: "\(self.modelID):sha256:\(self.archiveSHA256 ?? "unavailable")"}}@@ -82,7 +85,7 @@ nonisolated enum ParakeetSpeechModelCatalog {/// Compact model folders are stable across releases; their exact installed/// archive revision must match before an existing cache may skip download.func installationRevisionMatches(at directory: URL) -> Bool {- guard self.variant == .mini || self.variant == .pico else { return true }+ guard self.isHostedPack else { return true }guard let hash = self.archiveSHA256, hash.count == 64,hash.utf8.allSatisfy({ (48...57).contains($0) || (97...102).contains($0) })else { return false }@@ -99,7 +102,7 @@ nonisolated enum ParakeetSpeechModelCatalog {/// Explicit background-only disk inspection. Older compact checkpoints remain/// usable, but must not be mistaken for the currently advertised download.func installedArchiveSHA256(at directory: URL) -> String? {- guard self.variant == .mini || self.variant == .pico,+ guard self.isHostedPack,let rootAttributes = try? FileManager.default.attributesOfItem(atPath: directory.path),rootAttributes[.type] as? FileAttributeType == .typeDirectoryelse { return nil }@@ -138,7 +141,7 @@ nonisolated enum ParakeetSpeechModelCatalog {/// Small bounded identity read for installation snapshots, never UI rendering./// Existing archive markers remain the pronunciation identity across migration.func installedManifestSHA256(at directory: URL) -> String? {- guard self.variant == .mini || self.variant == .pico,+ guard self.isHostedPack,(try? FileManager.default.attributesOfItem(atPath: directory.path))?[.type] as? FileAttributeType == .typeDirectoryelse { return nil }let file = directory.appendingPathComponent("manifest.json")@@ -156,7 +159,7 @@ nonisolated enum ParakeetSpeechModelCatalog {/// Only the downloader calls this on its validated, unpublished stage./// Exclusive creation rejects any marker supplied by the archive itself.func writeInstallationRevision(at directory: URL) throws {- guard self.variant == .mini || self.variant == .pico else { return }+ guard self.isHostedPack else { return }guard let hash = self.archiveSHA256, hash.count == 64,hash.utf8.allSatisfy({ (48...57).contains($0) || (97...102).contains($0) })else { throw InstallationRevisionError.invalidChecksum }@@ -251,7 +254,31 @@ nonisolated enum ParakeetSpeechModelCatalog {manifestSHA256: "a87ee649edc18aca6d30f251e75237f48c995448b865ffee35ab343ed3e66121")- static let descriptors = [ParakeetSpeechModelCatalog.v2, ParakeetSpeechModelCatalog.v3, ParakeetSpeechModelCatalog.mini, ParakeetSpeechModelCatalog.pico]+ /// One int8 encoder next to its own preprocessor, so the Mac pack is not split like Mini and Pico.+ static let proName = "Fluid Speech Pro"+ static let pro = Descriptor(+ modelID: "fluid-parakeet-pro",+ variant: .pro,+ folderName: "fluid-parakeet-pro-coreml",+ expectedDownloadBytes: 652_482_560,+ archiveURL: URL(string: "https://models.fluidvoice.app/parakeet/fluid-pro/1.0.0/fluid-parakeet-pro-coreml.tar"),+ archiveSHA256: "f7af24d8352757b088dd18d150dfbbd2adf37f1d5013ebb036674f507a794333",+ requiredModelNames: ParakeetSpeechModelCatalog.standardModelNames,+ vocabularyFile: "parakeet_vocab.json",+ displayName: ParakeetSpeechModelCatalog.proName,+ humanReadableName: ParakeetSpeechModelCatalog.proName,+ languageSupport: "English Only",+ supportedLanguageCodes: ["en"],+ downloadSize: "~622.3 MiB",+ cardDescription: "Our most accurate model, built for clear dictation in noisy places. Runs on your Mac.",+ performanceRatings: .init(speedRating: 5, accuracyRating: 5, speedPercent: 0.99, accuracyPercent: 0.98),+ manifestSHA256: "94651862cdad19f1ba0a2bed8ec205d664fd2ecd5c031098b347fff77fd79f1d"+ )++ static let descriptors = [+ ParakeetSpeechModelCatalog.v2, ParakeetSpeechModelCatalog.v3, ParakeetSpeechModelCatalog.mini,+ ParakeetSpeechModelCatalog.pico, ParakeetSpeechModelCatalog.pro,+ ]/// Dictionary sharing is separate from the exact identity used to load model files.static func sharesPronunciationFamily(_ source: String, with target: String) -> Bool {@@ -260,7 +287,7 @@ nonisolated enum ParakeetSpeechModelCatalog {private static func isParakeetPronunciationKey(_ key: String) -> Bool {if key == "parakeet-v2" || key == "parakeet-v3" { return true }- for descriptor in [self.mini, self.pico] {+ for descriptor in [self.mini, self.pico, self.pro] {if key == descriptor.modelID { return true }let prefix = descriptor.modelID + ":sha256:"guard key.hasPrefix(prefix) else { continue }@@ -285,7 +312,9 @@ nonisolated enum ParakeetSpeechModelCatalog {static func descriptor(forInstalledPronunciationModelKey modelKey: String) -> Descriptor? {if modelKey == self.v2.pronunciationModelKey { return self.v2 }if modelKey == self.v3.pronunciationModelKey { return self.v3 }- for source in [self.mini, self.pico] {+ // Pro's first-download session originally saved this unversioned key.+ if modelKey == self.pro.modelID { return self.pro }+ for source in [self.mini, self.pico, self.pro] {let prefix = source.modelID + ":sha256:"guard modelKey.hasPrefix(prefix) else { continue }let hash = String(modelKey.dropFirst(prefix.count))@@ -326,6 +355,7 @@ nonisolated enum ParakeetSpeechModelCatalog {case .v3: self.v3case .mini: self.minicase .pico: self.pico+ case .pro: self.pro}}}diff --git a/Sources/Fluid/Services/PrivateAIIntegrationService.swift b/Sources/Fluid/Services/PrivateAIIntegrationService.swiftindex 895e907f..11078d1d 100644--- a/Sources/Fluid/Services/PrivateAIIntegrationService.swift+++ b/Sources/Fluid/Services/PrivateAIIntegrationService.swift@@ -29,6 +29,11 @@ actor PrivateAIIntegrationService {let bundleID: Stringlet windowTitle: Stringlet appVersion: String?+ /// Raw text for models trained to read it; others ignore both.+ var textBeforeCursor: String? = nil+ // Absence means no screen context was read.+ // swiftlint:disable:next discouraged_optional_collection+ var screenText: [String]? = nil}struct EnhancementResult: Sendable, Equatable {@@ -279,6 +284,10 @@ actor PrivateAIIntegrationService {self.provider.shouldHandleDictation(model: model)}+ nonisolated static func readsDictationContext(model: String) -> Bool {+ self.provider.readsDictationContext(model: model)+ }+func status(for runtime: RuntimeConfiguration) async -> PrivateAIStatus {do { return try await Self.modelActivity { await Self.provider.status(for: runtime) } } catch { return PrivateAIStatus(state: .failed, message: error.localizedDescription) }}diff --git a/Sources/Fluid/Services/PrivateAIProvider.swift b/Sources/Fluid/Services/PrivateAIProvider.swiftindex 61d0e3c0..ea626372 100644--- a/Sources/Fluid/Services/PrivateAIProvider.swift+++ b/Sources/Fluid/Services/PrivateAIProvider.swift@@ -254,6 +254,9 @@ protocol PrivateAIIntegrationProviding: Sendable {func commitModelUpdate(_ token: PrivateAIModelUpdateToken) asyncfunc rollbackModelUpdate(_ token: PrivateAIModelUpdateToken) asyncfunc shouldHandleDictation(model: String) -> Bool+ /// True when the model was trained to read the text before the cursor+ /// and on screen, so dictation only captures them for that model.+ func readsDictationContext(model: String) -> Boolfunc status(for runtime: PrivateAIIntegrationService.RuntimeConfiguration) async -> PrivateAIStatusfunc loadedModelState() async -> PrivateAIIntegrationService.LoadedModelState?func residencySnapshot() async throws -> MeetingResidentModel?@@ -308,6 +311,8 @@ extension PrivateAIIntegrationProviding {func restoreResidency(_: MeetingResidentModel) async throws {}+ func readsDictationContext(model _: String) -> Bool { false }+func verifyModel(_ model: PrivateAIRegisteredModel) async throws -> PrivateAIStatus {try await self.loadModel(model)}diff --git a/Sources/Fluid/Services/SpeechModelInstallationSnapshot.swift b/Sources/Fluid/Services/SpeechModelInstallationSnapshot.swiftindex 9732abca..ddda7cb4 100644--- a/Sources/Fluid/Services/SpeechModelInstallationSnapshot.swift+++ b/Sources/Fluid/Services/SpeechModelInstallationSnapshot.swift@@ -207,7 +207,7 @@ final class SpeechModelInstallationSnapshot: ObservableObject {case .builtIn:exists = truecase let .parakeet(descriptor):- if descriptor.variant == .mini || descriptor.variant == .pico {+ if descriptor.isHostedPack {let hash = models.flatMap { descriptor.installedArchiveSHA256(at: descriptor.cacheDirectory(in: $0)) }exists = hash != nilif let hash {diff --git a/Sources/Fluid/Theme/Components/FluidVoiceBrandIcon.swift b/Sources/Fluid/Theme/Components/FluidVoiceBrandIcon.swiftindex 58a06e8f..d76d5998 100644--- a/Sources/Fluid/Theme/Components/FluidVoiceBrandIcon.swift+++ b/Sources/Fluid/Theme/Components/FluidVoiceBrandIcon.swift@@ -1,15 +1,13 @@-import AppKitimport SwiftUI-/// Reuse AppKit's cached app icon; no asset lookup or filesystem query in the view.+/// The current FluidVoice icon (Edge Shine) for in-app badges. The app icon+/// AppKit hands back can be the older artwork the icon set keeps for earlier+/// macOS, so badges use their own copy of the new one.struct FluidVoiceBrandIcon: View {- private static let appIconImage: NSImage = NSApplication.shared.applicationIconImage- ?? NSImage(size: NSSize(width: 32, height: 32))-let size: CGFloatvar body: some View {- Image(nsImage: Self.appIconImage)+ Image("BrandIcon").resizable().interpolation(.high).aspectRatio(contentMode: .fit)diff --git a/Sources/Fluid/UI/AISettings/DictationScreenContextSettings.swift b/Sources/Fluid/UI/AISettings/DictationScreenContextSettings.swiftnew file mode 100644index 00000000..0d71897a--- /dev/null+++ b/Sources/Fluid/UI/AISettings/DictationScreenContextSettings.swift@@ -0,0 +1,94 @@+import SwiftUI++/// One opt-in for local context. Unsupported models never read it.+struct DictationScreenContextSettings: View {+ @Environment(\.theme) private var theme+ @ObservedObject var settings: SettingsStore+ let isBusy: Bool++ @StateObject private var permission: DictationScreenPermissionController+ @State private var permissionRequestTask: Task<Void, Never>?++ init(settings: SettingsStore, isBusy: Bool, permission: DictationScreenPermissionController? = nil) {+ self.settings = settings+ self.isBusy = isBusy+ self._permission = StateObject(wrappedValue: permission ?? DictationScreenPermissionController())+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 12) {+ FluidManagementRow(+ title: "Use my active screen to improve dictation accuracy",+ detail: "Supported model: Fluid-1.1 Splash. Everything is processed on your device."+ ) {+ Toggle("Use my active screen to improve dictation accuracy", isOn: self.enabledBinding)+ .toggleStyle(.switch)+ .labelsHidden()+ .disabled(self.isBusy)+ }++ self.permissionStatus+ }+ .task { await self.permission.refresh() }+ .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in+ Task { await self.permission.refresh() }+ }+ .onChange(of: self.isBusy) { _, isBusy in+ if isBusy { self.permissionRequestTask?.cancel() }+ }+ .onDisappear {+ self.permissionRequestTask?.cancel()+ }+ }++ /// The feature switch never requests permission or opens System Settings.+ var enabledBinding: Binding<Bool> {+ Binding(+ get: { self.settings.dictationScreenContextEnabled },+ set: { self.settings.dictationScreenContextEnabled = $0 }+ )+ }++ @ViewBuilder private var permissionStatus: some View {+ if !self.permission.hasChecked {+ Text("Checking screen access…")+ .font(self.theme.typography.caption)+ .foregroundStyle(self.theme.palette.secondaryText)+ } else if self.permission.isAllowed {+ Label("Screen access allowed", systemImage: "checkmark.circle.fill")+ .font(self.theme.typography.caption)+ .foregroundStyle(self.theme.palette.success)+ } else {+ HStack(spacing: 12) {+ FluidGlassControlGroup {+ Button(self.permission.requiresSettings ? "Open System Settings" : "Allow screen access") {+ self.requestScreenAccess()+ }+ .fluidGlassAction()+ .disabled(self.isBusy || self.permission.isRequesting)+ }++ Text(self.permission.requiresSettings+ ? "Allow FluidVoice under Screen & System Audio Recording."+ : "macOS calls this Screen Recording access.")+ .font(self.theme.typography.caption)+ .foregroundStyle(self.theme.palette.secondaryText)+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ }++ private func requestScreenAccess() {+ guard !self.isBusy, self.permissionRequestTask == nil else { return }+ if self.permission.requiresSettings {+ if let url = URL(string: "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture") {+ NSWorkspace.shared.open(url)+ }+ return+ }+ self.permissionRequestTask = Task {+ defer { self.permissionRequestTask = nil }+ await self.permission.requestIfNeeded { !Task.isCancelled }+ }+ }+}diff --git a/Sources/Fluid/UI/AISettings/FluidIntelligenceModelCarousel.swift b/Sources/Fluid/UI/AISettings/FluidIntelligenceModelCarousel.swiftindex 8aebdc3a..070481b8 100644--- a/Sources/Fluid/UI/AISettings/FluidIntelligenceModelCarousel.swift+++ b/Sources/Fluid/UI/AISettings/FluidIntelligenceModelCarousel.swift@@ -42,7 +42,13 @@ struct FluidIntelligenceModelCarousel<Controls: View>: View {}.overlay(alignment: .bottom) {if position == 0, let model = self.models.first(where: { $0.id == id }) {- self.controls(model).padding(.horizontal, 16).padding(.bottom, 16)+ VStack(alignment: .leading, spacing: 8) {+ if PrivateAIIntegrationService.readsDictationContext(model: model.id) {+ ScreenContextChip(settings: SettingsStore.shared)+ }+ self.controls(model)+ }+ .padding(.horizontal, 16).padding(.bottom, 16)}}.frame(width: position == 0 ? cardWidth : sideWidth, height: AppTheme.Metrics.Showcase.cardHeight)@@ -131,7 +137,7 @@ struct FluidIntelligenceModelCarousel<Controls: View>: View {.font(compact ? self.theme.typography.sectionTitle : self.theme.typography.title).foregroundStyle(self.theme.palette.secondaryText).fixedSize(horizontal: false, vertical: true)- Text("Not available yet")+ Text(model.note).font(self.theme.typography.body).foregroundStyle(self.theme.palette.tertiaryText)Spacer(minLength: 0)diff --git a/Sources/Fluid/UI/AISettings/FluidModelShowcaseCard.swift b/Sources/Fluid/UI/AISettings/FluidModelShowcaseCard.swiftindex c472824b..79a34166 100644--- a/Sources/Fluid/UI/AISettings/FluidModelShowcaseCard.swift+++ b/Sources/Fluid/UI/AISettings/FluidModelShowcaseCard.swift@@ -26,7 +26,13 @@ struct FluidModelShowcaseCard: View {VStack(alignment: .leading, spacing: self.theme.metrics.spacing.md) {Color.clear.frame(height: 20).overlay(alignment: .leading) {- if self.isRecommended {+ if let badge = presentation.badge {+ Text(badge)+ .font(self.theme.typography.captionSmall)+ .foregroundStyle(self.theme.palette.secondaryText)+ .lineLimit(1)+ .padding(.trailing, 24)+ } else if self.isRecommended {Text(self.compact ? "Recommended" : "Recommended for your Mac").font(self.theme.typography.captionStrong).foregroundStyle(FluidBrandColors.blue)@@ -35,18 +41,10 @@ struct FluidModelShowcaseCard: View {.help("Based on your Mac’s RAM. You can choose either model.")}}- HStack(spacing: 8) {- Text(self.model.displayName.replacingOccurrences(of: "Fluid-1", with: "Fluid 1"))- .font(self.compact ? self.theme.typography.sectionTitle : self.theme.typography.title)- .foregroundStyle(self.theme.palette.primaryText)- .lineLimit(2).minimumScaleFactor(0.85)- if self.isSelected {- Image(systemName: "checkmark.circle.fill")- .font(.fluidSystem(size: 18, weight: .semibold))- .foregroundStyle(FluidBrandColors.blue)- .accessibilityLabel("Selected")- }- }+ Text(self.model.displayName.replacingOccurrences(of: "Fluid-1", with: "Fluid 1"))+ .font(self.compact ? self.theme.typography.sectionTitle : self.theme.typography.title)+ .foregroundStyle(self.theme.palette.primaryText)+ .lineLimit(self.compact ? 2 : 1).minimumScaleFactor(0.85)ZStack(alignment: .topLeading) {VStack(alignment: .leading, spacing: self.theme.metrics.spacing.md) {Text(presentation.summary)@@ -63,6 +61,9 @@ struct FluidModelShowcaseCard: View {.accessibilityHidden(self.showsInfo)VStack(alignment: .leading, spacing: self.theme.metrics.spacing.md) {self.infoRow("Languages", value: presentation.language)+ if let memory = self.model.recommendedMemoryGB {+ self.infoRow("Recommended", value: "Mac with \(memory) GB+ RAM")+ }if let bytes = self.model.artifact.byteCount, bytes > 0 {self.infoRow("Download size", value: "≈\(ByteCountFormatter.string(fromByteCount: bytes, countStyle: .file))")}@@ -75,6 +76,13 @@ struct FluidModelShowcaseCard: View {Spacer(minLength: self.theme.metrics.spacing.sm)// Separate sibling controls are overlaid by the carousel; never nest buttons.Color.clear.frame(height: 64)+ .overlay(alignment: .bottomLeading) {+ if self.compact, self.isSelected {+ Text("Active")+ .font(self.theme.typography.captionStrong)+ .foregroundStyle(FluidBrandColors.blue)+ }+ }}.padding(self.theme.metrics.spacing.xl).frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)@@ -102,7 +110,7 @@ struct FluidModelShowcaseCard: View {.onHover { self.hovered = $0 }.animation(self.reduceMotion ? nil : .easeOut(duration: 0.12), value: self.hovered).accessibilityLabel("Preview \(self.model.displayName.replacingOccurrences(of: "Fluid-1", with: "Fluid 1"))")- .accessibilityValue([self.isPreview ? "Previewed" : "", self.isRecommended ? "Recommended for your Mac" : ""].filter { !$0.isEmpty }.joined(separator: ", "))+ .accessibilityValue([self.isPreview ? "Previewed" : "", self.isSelected ? "Selected" : "", self.isRecommended ? "Recommended for your Mac" : ""].filter { !$0.isEmpty }.joined(separator: ", ")).accessibilityHint(self.showsInfo ? self.infoAccessibilityDescription : "\(presentation.summary). \(presentation.useCase) Browse without changing the selected model.").overlay(alignment: .topTrailing) {// Sibling to the browse button: opening details never selects or activates a model.@@ -134,8 +142,12 @@ struct FluidModelShowcaseCard: View {private var infoAccessibilityDescription: String {let language = PrivateAIModelPresentation.forModel(id: self.model.id).language- guard let bytes = self.model.artifact.byteCount, bytes > 0 else { return "Languages: \(language)" }- return "Languages: \(language). Download size: approximately \(ByteCountFormatter.string(fromByteCount: bytes, countStyle: .file))."+ var parts = ["Languages: \(language)."]+ if let memory = self.model.recommendedMemoryGB { parts.append("Recommended: Mac with \(memory) GB or more RAM.") }+ if let bytes = self.model.artifact.byteCount, bytes > 0 {+ parts.append("Download size: approximately \(ByteCountFormatter.string(fromByteCount: bytes, countStyle: .file)).")+ }+ return parts.joined(separator: " ")}}diff --git a/Sources/Fluid/UI/AISettings/PrivateAIModelPresentation.swift b/Sources/Fluid/UI/AISettings/PrivateAIModelPresentation.swiftindex a6747c7c..4bcb6810 100644--- a/Sources/Fluid/UI/AISettings/PrivateAIModelPresentation.swift+++ b/Sources/Fluid/UI/AISettings/PrivateAIModelPresentation.swift@@ -9,7 +9,14 @@ enum PrivateAIUpcomingModel: String, CaseIterable, Identifiable {var title: String {switch self {case .quad: "Fluid 1 Quad"- case .multilingual: "Fluid 1.1 Multilingual"+ case .multilingual: "Fluid 1.1 Wave"+ }+ }++ var note: String {+ switch self {+ case .quad: "Not available yet"+ case .multilingual: "Multilingual. Faster, smarter, smaller Fluid 1"}}}@@ -22,6 +29,8 @@ struct PrivateAIModelPresentation {// Illustrative design-preview values, not measured benchmark scores.var intelligence: Int?var speed: Int?+ /// A small label above the name, such as "Research preview".+ var badge: String?static func forModel(id: String) -> Self {switch id {@@ -29,8 +38,17 @@ struct PrivateAIModelPresentation {Self(summary: "Smallest & fastest", useCase: "Everyday dictation with basic cleanup and formatting.", language: "English only", intelligence: 2, speed: 5)case "fluid-1-mini-96k-dflash":Self(summary: "More capable", useCase: "Better structure, formatting and corrections.", language: "English only", intelligence: 4, speed: 4)+ case "fluid-1.1-splash":+ Self(+ summary: "Multilingual",+ useCase: "Our best cleanup model yet",+ language: "English, German, Spanish, French, Portuguese",+ intelligence: 5,+ speed: 4,+ badge: "Research preview"+ )case "fluid-1":- Self(summary: "The original Fluid model", useCase: "Cleanup and formatting across languages.", language: "Multilingual", intelligence: 4, speed: 2)+ Self(summary: "The original Fluid model", useCase: "Will be deprecated soon. Cleanup and formatting across languages.", language: "Multilingual", intelligence: 4, speed: 2)default:Self(summary: "On-device cleanup", useCase: "Polish your words privately on your Mac.")}diff --git a/Sources/Fluid/UI/AISettings/ScreenContextChip.swift b/Sources/Fluid/UI/AISettings/ScreenContextChip.swiftnew file mode 100644index 00000000..e1c68139--- /dev/null+++ b/Sources/Fluid/UI/AISettings/ScreenContextChip.swift@@ -0,0 +1,48 @@+import SwiftUI++extension Notification.Name {+ /// Opens Settings at Experimental, where the on-screen context switches live.+ static let openScreenContextSettings = Notification.Name("OpenScreenContextSettings")+}++/// Shows on the card of a model trained to read the screen whether on-screen+/// context is on. Clicking it opens the settings that turn it on or off.+struct ScreenContextChip: View {+ @Environment(\.theme) private var theme+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @ObservedObject var settings: SettingsStore++ private var isOn: Bool { self.settings.dictationScreenContextEnabled }++ var body: some View {+ Button {+ NotificationCenter.default.post(name: .openScreenContextSettings, object: nil)+ } label: {+ HStack(spacing: 6) {+ Image(systemName: self.isOn ? "checkmark.circle.fill" : "circle")+ .contentTransition(.symbolEffect(.replace))+ .foregroundStyle(self.isOn ? FluidBrandColors.blue : self.theme.palette.secondaryText)+ Text("On-screen context")+ .foregroundStyle(self.isOn ? self.theme.palette.primaryText : self.theme.palette.secondaryText)+ Image(systemName: "chevron.right")+ .font(.fluidSystem(size: 9, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ .font(self.theme.typography.captionStrong)+ .padding(.horizontal, 10)+ .padding(.vertical, 4)+ .background(+ Capsule().fill(self.isOn ? FluidBrandColors.blue.opacity(0.16) : self.theme.palette.secondaryText.opacity(0.08))+ )+ .overlay(+ Capsule().strokeBorder(self.isOn ? FluidBrandColors.blue.opacity(0.45) : self.theme.palette.cardBorder, lineWidth: 1)+ )+ .contentShape(Capsule())+ }+ .buttonStyle(.plain)+ .animation(self.reduceMotion ? nil : .spring(response: 0.3, dampingFraction: 0.7), value: self.isOn)+ .help(self.isOn ? "On. Click to change it in Settings." : "Off. Click to turn it on in Settings.")+ .accessibilityLabel("On-screen context, \(self.isOn ? "on" : "off")")+ .accessibilityHint("Opens the setting in Settings, Experimental.")+ }+}diff --git a/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift b/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swiftindex 14b19d95..05079950 100644--- a/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift+++ b/Sources/Fluid/UI/AISettings/VoiceEngineSettingsViewModel.swift@@ -212,7 +212,7 @@ final class VoiceEngineSettingsViewModel: ObservableObject {return "Parakeet TDT v3 uses CoreML and Neural Engine for fastest transcription (25 languages) on Apple Silicon."case .parakeetTDTv2:return "Parakeet TDT v2 is an English-only model optimized for accuracy and consistency on Apple Silicon."- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return "\(model.cardDescription) Requires Apple silicon."case .parakeetRealtime:return "Parakeet Flash uses FluidAudio's true streaming EOU pipeline for low-latency English dictation. Best when you want words to appear live as you speak."diff --git a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swiftindex bea69129..cb077623 100644--- a/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift+++ b/Sources/Fluid/UI/AISettingsView+SpeechRecognition.swift@@ -669,7 +669,7 @@ extension VoiceEngineSettingsView {}private func speechModelSubtitle(for model: SettingsStore.SpeechModel) -> String {- if model == .fluidParakeetMini || model == .fluidParakeetPico {+ if [.fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro].contains(model) {return model.languageSupport}switch model {diff --git a/Sources/Fluid/UI/ReleaseFeaturePreview.swift b/Sources/Fluid/UI/ReleaseFeaturePreview.swiftindex dbfe2e84..484033b3 100644--- a/Sources/Fluid/UI/ReleaseFeaturePreview.swift+++ b/Sources/Fluid/UI/ReleaseFeaturePreview.swift@@ -11,6 +11,7 @@ struct ReleaseFeaturePreview: View {case .meeting: self.meetingcase .dashboard: self.dashboardcase .models: self.models+ case .speech: self.speech}}.padding(16)@@ -91,9 +92,9 @@ struct ReleaseFeaturePreview: View {Label(PrivateAIProviderFeature.shared.isAvailable ? "Fluid Intelligence" : "AI Providers", systemImage: "sparkles").font(.system(size: 11, weight: .semibold))if PrivateAIProviderFeature.shared.isAvailable {- self.model("Fluid-1 Pico", detail: "Light & quick", symbol: "bolt")- self.model("Fluid-1 Mini", detail: "Everyday writing", symbol: "text.alignleft")- self.model("Fluid-1 Quad", detail: "More capable", symbol: "cpu")+ self.model("Fluid 1.1 Splash", detail: "Reads your screen", symbol: "text.viewfinder")+ self.model("Fluid 1 Mini", detail: "Everyday writing", symbol: "text.alignleft")+ self.model("Fluid 1 Pico", detail: "Light & quick", symbol: "bolt")} else {self.model("Your provider", detail: "Your choice", symbol: "sparkles")self.model("Your model", detail: "Your workflow", symbol: "cpu")@@ -101,6 +102,16 @@ struct ReleaseFeaturePreview: View {}}+ private var speech: some View {+ VStack(alignment: .leading, spacing: 10) {+ Label("Voice Engine", systemImage: "waveform")+ .font(.system(size: 11, weight: .semibold))+ self.model("Fluid Speech Pro", detail: "Most accurate", symbol: "star")+ self.model("Fluid Speech Mini", detail: "Half the size", symbol: "waveform")+ self.model("Fluid Speech Pico", detail: "Smallest", symbol: "bolt")+ }+ }+private func model(_ name: String, detail: String, symbol: String) -> some View {HStack(spacing: 8) {Image(systemName: symbol)diff --git a/Sources/Fluid/UI/ReleaseHighlightsContent.swift b/Sources/Fluid/UI/ReleaseHighlightsContent.swiftindex ff2bae85..a250ad0a 100644--- a/Sources/Fluid/UI/ReleaseHighlightsContent.swift+++ b/Sources/Fluid/UI/ReleaseHighlightsContent.swift@@ -2,8 +2,8 @@ import Foundation/// Edit this definition for each release. The renderer and acknowledgement logic stay unchanged.struct ReleaseHighlightsContent {- enum Destination { case meetings, dashboard, aiProviders }- enum Preview { case meeting, dashboard, models }+ enum Destination { case meetings, dashboard, aiProviders, voiceEngine }+ enum Preview { case meeting, dashboard, models, speech }struct Feature: Identifiable {let id: String@@ -22,33 +22,34 @@ struct ReleaseHighlightsContent {let features: [Feature]static func current(hasPrivateAI: Bool) -> Self {- Self(- release: "1.6.12",- title: "Meeting summaries and agent integrations",- subtitle: "Summarize meetings on your Mac or with your AI provider. Connect your coding agents from FluidMeet settings.",+ let splash = Feature(+ id: "splash",+ preview: .models,+ eyebrow: "RESEARCH PREVIEW",+ title: "Meet Fluid 1.1 Splash",+ detail: "Our best cleanup model yet. Multilingual, and it reads what's on screen so names and terms come out right.",+ action: "Try Splash",+ destination: .aiProviders+ )+ let speechPro = Feature(+ id: "speech-pro",+ preview: .speech,+ eyebrow: "NEW SPEECH MODEL",+ title: "Fluid Speech Pro",+ detail: "Our most accurate speech model, built for clear dictation in noisy places. Runs on your Mac.",+ action: "Open Voice Engine",+ destination: .voiceEngine+ )+ return Self(+ release: "1.6.13-beta.1",+ title: hasPrivateAI ? "Smarter cleanup, sharper speech" : "Sharper speech",+ subtitle: hasPrivateAI+ ? "Meet Fluid 1.1 Splash and Fluid Speech Pro. Plus Qwen dictation, smoother live captions and faster cleanup on M5 Macs."+ : "Meet Fluid Speech Pro. Plus Qwen dictation and smoother live captions.",officialSiteNotice: "**Help people find the real FluidVoice.** A site impersonating FluidVoice is appearing above us in search results, making it harder for people to find us. "+ "Our official websites are [fluidvoice.com](https://fluidvoice.com) and [altic.dev/fluid](https://altic.dev/fluid). "+ "If FluidVoice has helped you, please visit [fluidvoice.com](https://fluidvoice.com) and explore. Bookmark and share it to help others find the real app. Thank you for supporting us.",- features: [- Feature(- id: "summaries",- preview: .meeting,- eyebrow: "YOUR MEETINGS, SUMMARIZED",- title: "Meeting summaries are back",- detail: "Summarize on your Mac or with your own AI provider. Add a custom prompt and keep your summaries after restarting.",- action: "Open FluidMeet",- destination: .meetings- ),- Feature(- id: "integrations",- preview: .meeting,- eyebrow: "MEET YOUR CODING AGENTS",- title: "Connect your coding agents",- detail: "Let Claude Code, Codex and other coding agents read your meetings. Set them up in FluidMeet settings → Integrations.",- action: "Open FluidMeet",- destination: .meetings- ),- ]+ features: hasPrivateAI ? [splash, speechPro] : [speechPro])}}diff --git a/Sources/Fluid/UI/ReleaseHighlightsPresenter.swift b/Sources/Fluid/UI/ReleaseHighlightsPresenter.swiftindex b85dc5a4..c64056d9 100644--- a/Sources/Fluid/UI/ReleaseHighlightsPresenter.swift+++ b/Sources/Fluid/UI/ReleaseHighlightsPresenter.swift@@ -134,6 +134,7 @@ struct ReleaseHighlightsPresenter: ViewModifier {case .meetings: self.onExplore(.meetingTranscription)case .dashboard: self.onExplore(.welcome)case .aiProviders: self.onExplore(.aiEnhancements)+ case .voiceEngine: self.onExplore(.voiceEngine)}} else if result == false {self.presentIfNeeded()diff --git a/Sources/Fluid/UI/SettingsSearch.swift b/Sources/Fluid/UI/SettingsSearch.swiftindex b00edb51..1698bf1d 100644--- a/Sources/Fluid/UI/SettingsSearch.swift+++ b/Sources/Fluid/UI/SettingsSearch.swift@@ -73,6 +73,7 @@ enum SettingsSearchTarget: Hashable {case fasterLongDictationcase dictionaryMatcherExperimentscase historyPerformance+ case dictationScreenContextvar section: SettingsSection {switch self {@@ -132,7 +133,7 @@ enum SettingsSearchTarget: Hashable {case .dataAndDiagnostics, .backupAndRestore, .debugLogs:return .dataAndDiagnostics- case .experimental, .returnToStartingField, .fasterLongDictation, .dictionaryMatcherExperiments, .historyPerformance:+ case .experimental, .returnToStartingField, .fasterLongDictation, .dictionaryMatcherExperiments, .historyPerformance, .dictationScreenContext:return .experimental}}@@ -174,6 +175,7 @@ struct SettingsSearchAvailability {let savesTranscriptionHistory: Boollet savesAudioWithTranscriptionHistory: Boollet overlayAtBottom: Bool+ let privateAIAvailable: Boolstatic var current: Self {let settings = SettingsStore.shared@@ -182,7 +184,8 @@ struct SettingsSearchAvailability {accessibilityEnabled: AXIsProcessTrusted(),savesTranscriptionHistory: settings.saveTranscriptionHistory,savesAudioWithTranscriptionHistory: settings.saveAudioWithTranscriptionHistory,- overlayAtBottom: settings.overlayPosition == .bottom+ overlayAtBottom: settings.overlayPosition == .bottom,+ privateAIAvailable: PrivateAIProviderFeature.shared.isAvailable)}@@ -216,6 +219,8 @@ struct SettingsSearchAvailability {self.savesAudioWithTranscriptionHistorycase .bottomOffset:return self.overlayAtBottom+ case .dictationScreenContext:+ return self.privateAIAvailabledefault:return true}@@ -462,6 +467,11 @@ enum SettingsSearchIndex {title: "Show Performance in History",terms: ["timing speed tokens per second ASR cleanup Fluid Intelligence"]),+ .init(+ target: .dictationScreenContext,+ title: "Use my active screen to improve dictation accuracy",+ terms: ["experimental Fluid Intelligence context OCR screen words window capture recording permission accessibility cursor names spelling"]+ ),]static func results(for query: String) -> [SettingsSearchResult] {diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex ce922c29..c993d2ce 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -1500,6 +1500,19 @@ struct SettingsView: View {}.settingsSearchTarget(.fasterLongDictation).shownInSettingsSection(.experimental, selectedSection: self.selectedSection)++ if PrivateAIProviderFeature.shared.isAvailable {+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ Label("Fluid Intelligence", systemImage: "sparkles")+ .font(.fluidSystem(.headline))+ DictationScreenContextSettings(settings: self.settings, isBusy: self.asr.isRunningOrStarting)+ }+ .padding(16)+ }+ .settingsSearchTarget(.dictationScreenContext)+ .shownInSettingsSection(.experimental, selectedSection: self.selectedSection)+ }}.padding(.bottom, 28).fluidPageContent(width: .expanding)diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swiftindex 60808aa5..1db71b9b 100644--- a/Sources/Fluid/UI/WelcomeView.swift+++ b/Sources/Fluid/UI/WelcomeView.swift@@ -1520,7 +1520,7 @@ struct OnboardingFlowView: View {enablesHover: Bool = true) -> some View {let model = route.model- let isCompactModel = model == .fluidParakeetMini || model == .fluidParakeetPico+ let isCompactModel = [.fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro].contains(model)let isSelected = self.isOnboardingRouteSelected(route)let isHovered = enablesHover && self.hoveredModelRouteID == route.idlet isRouteActiveInSettings = self.isRouteSelectedInSettings(route)@@ -1999,7 +1999,7 @@ struct OnboardingFlowView: View {return "Parakeet v3"case .parakeetTDTv2:return "Parakeet v2"- case .fluidParakeetMini, .fluidParakeetPico:+ case .fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro:return model.displayNamecase .parakeetRealtime:return "Parakeet Flash"diff --git a/Tests/FluidDictationIntegrationTests/DictationContextCaptureTests.swift b/Tests/FluidDictationIntegrationTests/DictationContextCaptureTests.swiftnew file mode 100644index 00000000..4392e820--- /dev/null+++ b/Tests/FluidDictationIntegrationTests/DictationContextCaptureTests.swift@@ -0,0 +1,460 @@+import ApplicationServices+@testable import FluidVoice_Debug+import XCTest++@MainActor+final class DictationContextCaptureTests: XCTestCase {+ func testContextDefaultsOffAndDoesNotStartCaptureWhileDisabled() {+ let key = "DictationScreenContextEnabled"+ let defaults = UserDefaults.standard+ let saved = defaults.object(forKey: key)+ defer {+ if let saved { defaults.set(saved, forKey: key) } else { defaults.removeObject(forKey: key) }+ }+ defaults.removeObject(forKey: key)+ let settings = SettingsStore.shared+ XCTAssertFalse(settings.dictationScreenContextEnabled)+ settings.dictationScreenContextEnabled = true+ XCTAssertTrue(settings.dictationScreenContextEnabled)+ settings.dictationScreenContextEnabled = false+ XCTAssertNil(DictationContextCapture.start(target: self.target(), textBeforeCursor: "private", settings: settings))+ }++ func testDisabledContextReadsNeitherCursorNorScreen() async {+ let request = self.request(isEnabled: false)+ let context = await DictationContextReader.read(request) { _, _ in+ XCTFail("Screen context Off must prevent screenshots")+ return ["unexpected screen text"]+ }+ XCTAssertNil(context)+ }++ func testEnabledContextAutomaticallyUsesOCRWhenAppTextIsMissing() async {+ let request = DictationContextReader.Request(+ pid: 999_999,+ bundleID: "test.context",+ window: AXUIElementCreateApplication(999_999),+ element: nil,+ textBeforeCursor: "Known cursor text",+ isEnabled: true+ )+ let context = await DictationContextReader.read(request) { _, window in+ XCTAssertNotNil(window)+ return ["A name from the target window"]+ }+ XCTAssertEqual(context?.textBeforeCursor, "Known cursor text")+ XCTAssertEqual(context?.screenText, ["A name from the target window"])+ }++ func testMissingCapturedWindowNeverFallsBackToAnotherWindow() async {+ let context = await DictationContextReader.read(self.request(isEnabled: true)) { _, _ in+ XCTFail("A missing target window must not fall back to another window")+ return ["unexpected screen text"]+ }+ XCTAssertNil(context?.screenText)+ }++ func testPasswordManagerDropsCursorAndScreenContext() async {+ let context = await DictationContextReader.read(self.request(bundleID: "com.1password", isEnabled: true)) { _, _ in+ XCTFail("Private apps must not invoke OCR")+ return []+ }+ XCTAssertNil(context)+ }++ func testCursorContextIsBounded() async {+ let request = DictationContextReader.Request(+ pid: 999_999,+ bundleID: "test.context",+ window: nil,+ element: nil,+ textBeforeCursor: String(repeating: "a", count: 2100) + "end",+ isEnabled: true+ )+ let context = await DictationContextReader.read(request)+ XCTAssertEqual(context?.textBeforeCursor?.count, 2000)+ XCTAssertTrue(context?.textBeforeCursor?.hasSuffix("end") == true)+ }++ func testOCRSelectsOnlyTheMatchingAppWindow() {+ let frame = CGRect(x: 10, y: 20, width: 800, height: 600)+ let windows = [+ self.windowInfo(id: 1, pid: 999, frame: frame),+ self.windowInfo(id: 2, frame: frame.offsetBy(dx: 200, dy: 0)),+ self.windowInfo(id: 3, frame: frame, layer: 1),+ self.windowInfo(id: 4, frame: frame),+ ]+ XCTAssertEqual(DictationContextReader.windowID(pid: 101, frame: frame, windows: windows), 4)+ }++ func testOCRSkipsIdenticalWindowsRegardlessOfStackingOrder() {+ let frame = CGRect(x: 0, y: 0, width: 1440, height: 900)+ let first = self.windowInfo(id: 1, frame: frame)+ let second = self.windowInfo(id: 2, frame: frame)+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: [first, second]))+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: [second, first]))+ }++ func testOCRSkipsWindowsThatAreAmbiguousWithinBoundsTolerance() {+ let frame = CGRect(x: 0, y: 0, width: 1440, height: 900)+ let windows = [self.windowInfo(id: 1, frame: frame), self.windowInfo(id: 2, frame: frame.offsetBy(dx: 1, dy: 1))]+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: windows))+ }++ func testOCRDoesNotUseAnotherWindowAfterTargetDisappears() {+ let frame = CGRect(x: 10, y: 20, width: 800, height: 600)+ let remaining = [self.windowInfo(id: 2, frame: frame.offsetBy(dx: 200, dy: 0))]+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: remaining))+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: nil, windows: remaining))+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: .zero, windows: remaining))+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: []))+ }++ func testOCRSkipsIncompleteWindowMetadata() {+ let frame = CGRect(x: 10, y: 20, width: 800, height: 600)+ var missingID = self.windowInfo(id: 1, frame: frame)+ missingID.removeValue(forKey: kCGWindowNumber as String)+ var missingBounds = self.windowInfo(id: 2, frame: frame)+ missingBounds.removeValue(forKey: kCGWindowBounds as String)+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: [missingID]))+ XCTAssertNil(DictationContextReader.windowID(pid: 101, frame: frame, windows: [missingBounds]))+ }++ func testShortScrolledFieldIncludesOnlyVisibleWords() {+ let value = "hidden above\nVisible name\nhidden below"+ let range = (value as NSString).range(of: "Visible name")+ XCTAssertEqual(DictationContextReader.textEntryValue(value, visibleRange: CFRange(location: range.location, length: range.length)), "Visible name")+ }++ func testLongScrolledFieldIncludesOnlyVisibleWords() {+ let value = String(repeating: "hidden ", count: 1000) + "Visible name"+ let range = (value as NSString).range(of: "Visible name")+ XCTAssertEqual(DictationContextReader.textEntryValue(value, visibleRange: CFRange(location: range.location, length: range.length)), "Visible name")+ }++ func testVisibleRangeUsesUTF16Offsets() {+ let value = "👋 hidden\nZoë 🐈\nhidden"+ let range = (value as NSString).range(of: "Zoë 🐈")+ XCTAssertEqual(DictationContextReader.textEntryValue(value, visibleRange: CFRange(location: range.location, length: range.length)), "Zoë 🐈")+ }++ func testEmptyOrInvalidVisibleRangeNeverExposesTheFullValue() {+ for range in [+ CFRange(location: 0, length: 0), CFRange(location: -1, length: 1),+ CFRange(location: 0, length: -1), CFRange(location: 99, length: 1),+ CFRange(location: 5, length: Int.max), CFRange(location: Int.max, length: 1),+ ] {+ XCTAssertEqual(DictationContextReader.textEntryValue("hidden text", visibleRange: range), "")+ }+ }++ func testMissingVisibleRangeKeepsOnlyTheBoundedFallback() {+ XCTAssertEqual(DictationContextReader.textEntryValue("Short field", visibleRange: nil), "Short field")+ XCTAssertEqual(DictationContextReader.textEntryValue(String(repeating: "x", count: 4001), visibleRange: nil), "")+ }++ func testReadyContextReturnsAndCancelsItsTimeout() async throws {+ let expected = DictationTypingContext(textBeforeCursor: "ready", screenText: ["visible"])+ let task = Task<DictationTypingContext?, Never> { expected }+ _ = await task.value+ let capture = DictationContextCapture(target: self.target(), task: task)+ let result = await capture.result(timeout: .milliseconds(100))+ XCTAssertEqual(result, expected)+ try await Task.sleep(for: .milliseconds(150))+ XCTAssertFalse(task.isCancelled, "A finished read must not retain an active timeout")+ }++ func testCancellationBeforeWaitingDropsReadyContext() async {+ let task = Task<DictationTypingContext?, Never> { .init(textBeforeCursor: "stale", screenText: nil) }+ _ = await task.value+ let capture = DictationContextCapture(target: self.target(), task: task)+ capture.cancel()+ let result = await capture.result(timeout: .seconds(1))+ XCTAssertNil(result)+ XCTAssertTrue(task.isCancelled)+ }++ func testTimeoutDropsLateResultAndCancelsReader() async {+ let task = self.delayedRead()+ let capture = DictationContextCapture(target: self.target(), task: task)+ let result = await capture.result(timeout: .milliseconds(10))+ XCTAssertNil(result)+ XCTAssertTrue(task.isCancelled)+ _ = await task.value+ }++ func testCancellingWaiterCancelsReaderWithoutWaitingForTimeout() async {+ let task = self.delayedRead()+ let capture = DictationContextCapture(target: self.target(), task: task)+ let waiter = Task { await capture.result(timeout: .seconds(10)) }+ await Task.yield()+ waiter.cancel()+ let result = await waiter.value+ XCTAssertNil(result)+ XCTAssertTrue(task.isCancelled)+ }++ func testTargetMatchRequiresSameFieldAndWindow() {+ let field = AXUIElementCreateApplication(101)+ let window = AXUIElementCreateApplication(102)+ let original = self.target(window: window, element: field)+ let capture = DictationContextCapture(target: original, task: Task { nil })+ XCTAssertTrue(capture.matches(original))+ XCTAssertTrue(capture.matches(self.target(window: window, element: field)))+ XCTAssertFalse(capture.matches(self.target(window: window, element: AXUIElementCreateApplication(103))))+ XCTAssertFalse(capture.matches(self.target(window: AXUIElementCreateApplication(104), element: field)))+ XCTAssertFalse(capture.matches(self.target(pid: 2, window: window, element: field)))+ XCTAssertFalse(capture.matches(self.target()))+ }++ func testNewCaptureDoesNotReceiveCancelledResult() async {+ let stale = DictationContextCapture(target: self.target(), task: self.delayedRead())+ stale.cancel()+ let expected = DictationTypingContext(textBeforeCursor: "new recording", screenText: nil)+ let current = DictationContextCapture(target: self.target(), task: Task { expected })+ let result = await current.result(timeout: .seconds(1))+ let cancelledResult = await stale.result(timeout: .seconds(1))+ XCTAssertEqual(result, expected)+ XCTAssertNil(cancelledResult)+ }++ func testPermissionRefreshNeverPrompts() async {+ var requests = 0+ let permission = DictationScreenPermissionController(check: { false }, request: {+ requests += 1+ return false+ })+ await permission.refresh()+ XCTAssertTrue(permission.hasChecked)+ XCTAssertFalse(permission.isAllowed)+ XCTAssertEqual(requests, 0)+ }++ func testChangingContextToggleNeverRequestsPermission() async {+ let key = "DictationScreenContextEnabled"+ let defaults = UserDefaults.standard+ let saved = defaults.object(forKey: key)+ defer {+ if let saved { defaults.set(saved, forKey: key) } else { defaults.removeObject(forKey: key) }+ }+ let prompted = self.expectation(description: "The feature toggle must never prompt")+ prompted.isInverted = true+ let permission = DictationScreenPermissionController(check: { false }, request: {+ prompted.fulfill()+ return true+ })+ let settings = SettingsStore.shared+ let view = DictationScreenContextSettings(settings: settings, isBusy: false, permission: permission)+ view.enabledBinding.wrappedValue = true+ XCTAssertTrue(settings.dictationScreenContextEnabled)+ await self.fulfillment(of: [prompted], timeout: 0.2)+ XCTAssertFalse(permission.hasChecked)+ XCTAssertFalse(permission.isAllowed)+ view.enabledBinding.wrappedValue = false+ XCTAssertFalse(settings.dictationScreenContextEnabled)+ }++ func testExplicitPermissionActionRequestsMissingAccess() async {+ var requests = 0+ let permission = DictationScreenPermissionController(check: { false }, request: {+ requests += 1+ return true+ })+ await permission.requestIfNeeded { true }+ XCTAssertTrue(permission.isAllowed)+ XCTAssertFalse(permission.isRequesting)+ XCTAssertFalse(permission.requiresSettings)+ XCTAssertEqual(requests, 1)+ }++ func testDeniedPermissionReturnsToAnIdleState() async {+ let permission = DictationScreenPermissionController(check: { false }, request: { false })+ await permission.requestIfNeeded { true }+ XCTAssertTrue(permission.hasChecked)+ XCTAssertFalse(permission.isAllowed)+ XCTAssertFalse(permission.isRequesting)+ XCTAssertTrue(permission.requiresSettings)+ }++ func testGrantedPermissionDoesNotPromptAgain() async {+ let permission = DictationScreenPermissionController(check: { true }, request: {+ XCTFail("An existing grant must not prompt again")+ return false+ })+ await permission.requestIfNeeded { true }+ XCTAssertTrue(permission.isAllowed)+ XCTAssertFalse(permission.requiresSettings)+ }++ func testRequestEligibilityIsRecheckedBeforePrompt() async {+ let started = DispatchSemaphore(value: 0)+ let resume = DispatchSemaphore(value: 0)+ var enabled = true+ let permission = DictationScreenPermissionController(check: {+ started.signal()+ _ = resume.wait(timeout: .now() + 2)+ return false+ }, request: {+ XCTFail("An ineligible action must not show a pending permission request")+ return true+ })+ let request = Task { await permission.requestIfNeeded { enabled } }+ let didStart = await Task.detached { Self.waitForSignal(started) }.value+ XCTAssertTrue(didStart)+ enabled = false+ resume.signal()+ await request.value+ XCTAssertFalse(permission.isAllowed)+ XCTAssertFalse(permission.isRequesting)+ }++ func testReturningFromSystemSettingsUpdatesGrantedStatusWithoutPrompting() async {+ let state = ScreenPermissionCheck()+ var requests = 0+ let permission = DictationScreenPermissionController(check: { state.isAllowed }, request: {+ requests += 1+ return false+ })+ await permission.requestIfNeeded { true }+ XCTAssertTrue(permission.requiresSettings)+ state.isAllowed = true+ await permission.refresh()+ XCTAssertTrue(permission.isAllowed)+ XCTAssertFalse(permission.requiresSettings)+ XCTAssertEqual(requests, 1)+ }++ func testRevokedPermissionRemovesGrantedStatusWithoutPrompting() async {+ let state = ScreenPermissionCheck()+ state.isAllowed = true+ let permission = DictationScreenPermissionController(check: { state.isAllowed }, request: {+ XCTFail("Revoked permission must not trigger an automatic request")+ return true+ })+ await permission.refresh()+ XCTAssertTrue(permission.isAllowed)+ state.isAllowed = false+ await permission.refresh()+ XCTAssertFalse(permission.isAllowed)+ XCTAssertTrue(permission.requiresSettings)+ }++ func testLeavingSettingsCancelsPromptAndAllowsFreshPermissionCheck() async {+ let started = DispatchSemaphore(value: 0)+ let resume = DispatchSemaphore(value: 0)+ let state = ScreenPermissionCheck()+ let permission = DictationScreenPermissionController(check: {+ if state.isAllowed { return true }+ started.signal()+ _ = resume.wait(timeout: .now() + 2)+ return false+ }, request: {+ XCTFail("A cancelled action must not open the permission prompt")+ return true+ })+ let request = Task { await permission.requestIfNeeded { true } }+ let didStart = await Task.detached { Self.waitForSignal(started) }.value+ XCTAssertTrue(didStart)+ request.cancel()+ resume.signal()+ await request.value+ XCTAssertFalse(permission.isRequesting)+ XCTAssertFalse(permission.isAllowed)+ state.isAllowed = true+ await permission.refresh()+ XCTAssertTrue(permission.isAllowed)+ }++ func testRepeatedPermissionActionsProduceOnlyOneRequest() async {+ let started = DispatchSemaphore(value: 0)+ let resume = DispatchSemaphore(value: 0)+ var requests = 0+ let permission = DictationScreenPermissionController(check: {+ started.signal()+ _ = resume.wait(timeout: .now() + 2)+ return false+ }, request: {+ requests += 1+ return true+ })+ let first = Task { await permission.requestIfNeeded { true } }+ let didStart = await Task.detached { Self.waitForSignal(started) }.value+ XCTAssertTrue(didStart)+ await permission.requestIfNeeded { true }+ resume.signal()+ await first.value+ XCTAssertEqual(requests, 1)+ XCTAssertTrue(permission.isAllowed)+ XCTAssertFalse(permission.isRequesting)+ }++ func testSearchFindsOCRInExperimentalSettings() {+ let result = SettingsSearchIndex.results(for: "OCR", availability: self.searchAvailability(privateAIAvailable: true)).first+ XCTAssertEqual(result?.target, .dictationScreenContext)+ XCTAssertEqual(result?.section, .experimental)+ }++ func testPublicBuildSearchOmitsFluidIntelligenceContext() {+ let availability = self.searchAvailability(privateAIAvailable: false)+ for query in ["OCR", "screen words", "Fluid Intelligence"] {+ XCTAssertFalse(SettingsSearchIndex.results(for: query, availability: availability).contains { $0.target == .dictationScreenContext })+ }+ XCTAssertTrue(availability.includes(.experimental))+ }++ private func searchAvailability(privateAIAvailable: Bool) -> SettingsSearchAvailability {+ .init(+ microphoneAuthorized: true,+ accessibilityEnabled: true,+ savesTranscriptionHistory: true,+ savesAudioWithTranscriptionHistory: true,+ overlayAtBottom: false,+ privateAIAvailable: privateAIAvailable+ )+ }++ private nonisolated static func waitForSignal(_ semaphore: DispatchSemaphore) -> Bool {+ semaphore.wait(timeout: .now() + 2) == .success+ }++ private func target(pid: pid_t = 1, window: AXUIElement? = nil, element: AXUIElement? = nil) -> TypingService.RecordingTargetContext {+ .init(id: UUID(), pid: pid, bundleIdentifier: "test.context", window: window, element: element)+ }++ private func windowInfo(id: CGWindowID, pid: pid_t = 101, frame: CGRect, layer: Int = 0) -> [String: Any] {+ [+ kCGWindowNumber as String: id,+ kCGWindowOwnerPID as String: pid,+ kCGWindowLayer as String: layer,+ kCGWindowBounds as String: frame.dictionaryRepresentation,+ ]+ }++ private func delayedRead() -> Task<DictationTypingContext?, Never> {+ Task {+ try? await Task.sleep(for: .seconds(10))+ return .init(textBeforeCursor: "late result", screenText: nil)+ }+ }++ private func request(bundleID: String = "test.context", isEnabled: Bool) -> DictationContextReader.Request {+ .init(+ pid: 999_999,+ bundleID: bundleID,+ window: nil,+ element: nil,+ textBeforeCursor: "Known cursor text",+ isEnabled: isEnabled+ )+ }+}++private final nonisolated class ScreenPermissionCheck: @unchecked Sendable {+ private let lock = NSLock()+ private var allowed = false++ var isAllowed: Bool {+ get { self.lock.withLock { self.allowed } }+ set { self.lock.withLock { self.allowed = newValue } }+ }+}diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex 41950f7b..69e21179 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -137,6 +137,51 @@ final class HotkeyShortcutTests: XCTestCase {}}+ func testModifierOnlyCancelMigrationRestoresEscapeAndIsIdempotent() throws {+ let key = "CancelRecordingHotkeyShortcut"+ try self.withRestoredDefaults(keys: [key, self.primaryDictationShortcutsKey]) {+ let defaults = UserDefaults.standard+ let primary = try JSONEncoder().encode([HotkeyShortcut(keyCode: 61, modifierFlags: [])])+ defaults.set(primary, forKey: self.primaryDictationShortcutsKey)+ for keyCode: UInt16 in [54, 55, 56, 60, 58, 61, 59, 62, 63] {+ try defaults.set(JSONEncoder().encode(HotkeyShortcut(keyCode: keyCode, modifierFlags: [])), forKey: key)+ SettingsStore.migrateModifierOnlyCancelShortcutIfNeeded(defaults: defaults)+ let migrated = try XCTUnwrap(defaults.data(forKey: key))+ XCTAssertEqual(try JSONDecoder().decode(HotkeyShortcut.self, from: migrated), HotkeyShortcut(keyCode: 53, modifierFlags: []))+ SettingsStore.migrateModifierOnlyCancelShortcutIfNeeded(defaults: defaults)+ XCTAssertEqual(defaults.data(forKey: key), migrated)+ XCTAssertEqual(defaults.data(forKey: self.primaryDictationShortcutsKey), primary)+ }+ }+ }++ func testCancelMigrationPreservesValidDisabledMissingAndMalformedSettings() throws {+ let key = "CancelRecordingHotkeyShortcut"+ try self.withRestoredDefaults(keys: [key]) {+ let defaults = UserDefaults.standard+ let values: [Data?] = try [+ nil, Data("null".utf8), Data("invalid".utf8),+ JSONEncoder().encode(HotkeyShortcut(keyCode: 9, modifierFlags: [])),+ JSONEncoder().encode(HotkeyShortcut(keyCode: 9, modifierFlags: [.option])),+ ]+ for value in values {+ if let value { defaults.set(value, forKey: key) } else { defaults.removeObject(forKey: key) }+ SettingsStore.migrateModifierOnlyCancelShortcutIfNeeded(defaults: defaults)+ XCTAssertEqual(defaults.data(forKey: key), value)+ }+ }+ }++ func testRestoringModifierOnlyCancelShortcutFallsBackToEscape() throws {+ try self.withRestoredDefaults(keys: ["CancelRecordingHotkeyShortcut"]) {+ let settings = SettingsStore.shared+ settings.cancelRecordingHotkeyShortcut = HotkeyShortcut(keyCode: 58, modifierFlags: [.control, .option], modifierKeyCodes: [59, 58])+ XCTAssertEqual(settings.cancelRecordingHotkeyShortcut, HotkeyShortcut(keyCode: 53, modifierFlags: []))+ settings.cancelRecordingHotkeyShortcut = nil+ XCTAssertNil(settings.cancelRecordingHotkeyShortcut)+ }+ }+func testInputDeliveryTimingRejectsMissingAndFutureEventTimestamps() {let missing = HotkeyInputTiming(receivedAt: 100, eventTimestamp: 0, eventType: 12, receivedTimestamp: 5_000_000_000)XCTAssertNil(missing.deliveryAgeMs)@@ -1307,6 +1352,51 @@ final class HotkeyShortcutTests: XCTestCase {}}+ @MainActor+ func testCancelRejectsModifierOnlyShortcutsWithoutChangingSavedBindings() {+ self.withIsolatedShortcutConflicts { settings in+ let savedCancel = HotkeyShortcut(keyCode: 53, modifierFlags: [])+ settings.cancelRecordingHotkeyShortcut = savedCancel+ let modifierKeys: [UInt16] = [54, 55, 56, 60, 58, 61, 59, 62, 63]+ let shortcuts = modifierKeys.map { HotkeyShortcut(keyCode: $0, modifierFlags: []) } + [+ HotkeyShortcut(keyCode: 58, modifierFlags: [.control, .option], modifierKeyCodes: [59, 58]),+ HotkeyShortcut(keyCode: 61, modifierFlags: [.shift, .option], modifierKeyCodes: [60, 61]),+ ]+ let view = ContentView()+ for shortcut in shortcuts + shortcuts.reversed() {+ XCTAssertEqual(+ view.shortcutConflictMessage(for: shortcut, target: .cancel),+ "Modifier-only keys can't cancel recording. Use Esc or include a regular key.",+ shortcut.displayString+ )+ XCTAssertEqual(settings.cancelRecordingHotkeyShortcut, savedCancel)+ XCTAssertTrue(settings.primaryDictationShortcuts.isEmpty)+ }+ }+ }++ @MainActor+ func testCancelRestrictionPreservesRegularKeysAndOtherModifierOnlyActions() {+ self.withIsolatedShortcutConflicts { _ in+ let view = ContentView()+ for shortcut in [+ HotkeyShortcut(keyCode: 53, modifierFlags: []),+ HotkeyShortcut(keyCode: 9, modifierFlags: []),+ HotkeyShortcut(keyCode: 9, modifierFlags: [.option]),+ HotkeyShortcut(keyCode: 53, modifierFlags: [.control, .shift]),+ ] {+ XCTAssertNil(view.shortcutConflictMessage(for: shortcut, target: .cancel), shortcut.displayString)+ }+ let leftOption = HotkeyShortcut(keyCode: 58, modifierFlags: [])+ for target: ShortcutRecordingTarget in [+ .primaryDictation(.add), .secondaryDictation, .command, .edit,+ .pasteLast, .dictationPrompt("__default__"), .newPrompt,+ ] {+ XCTAssertNil(view.shortcutConflictMessage(for: leftOption, target: target), "\(target)")+ }+ }+ }+@MainActorfunc testCommandShortcutIsReservedOnlyWhileEnabled() {self.withIsolatedShortcutConflicts { settings indiff --git a/Tests/FluidDictationIntegrationTests/ParakeetCompactModelSmokeTests.swift b/Tests/FluidDictationIntegrationTests/ParakeetCompactModelSmokeTests.swiftindex 9ec81092..f1af0fea 100644--- a/Tests/FluidDictationIntegrationTests/ParakeetCompactModelSmokeTests.swift+++ b/Tests/FluidDictationIntegrationTests/ParakeetCompactModelSmokeTests.swift@@ -172,10 +172,14 @@ final class ParakeetCompactModelSmokeTests: XCTestCase {let root = FileManager.default.temporaryDirectory.appendingPathComponent("FluidVoiceCompactModels-\(UUID().uuidString)", isDirectory: true)defer { try? FileManager.default.removeItem(at: root) }let selection = SettingsStore.shared.selectedSpeechModel- for descriptor in [ParakeetSpeechModelCatalog.mini, ParakeetSpeechModelCatalog.pico] {+ let hosted: [(ParakeetSpeechModelCatalog.Descriptor, SettingsStore.SpeechModel)] = [+ (ParakeetSpeechModelCatalog.mini, .fluidParakeetMini),+ (ParakeetSpeechModelCatalog.pico, .fluidParakeetPico),+ (ParakeetSpeechModelCatalog.pro, .fluidParakeetPro),+ ]+ for (descriptor, model) in hosted {// Exercise first-download publication through the real provider's staged proof.do {- let model: SettingsStore.SpeechModel = descriptor.variant == .mini ? .fluidParakeetMini : .fluidParakeetPicolet provider = FluidAudioProvider(modelOverride: model, configureWordBoosting: false)provider.modelCacheRootForTesting = roottry await provider.prepare()@@ -186,7 +190,8 @@ final class ParakeetCompactModelSmokeTests: XCTestCase {XCTAssertTrue(descriptor.artifactsAreComplete(at: directory))let models = try await AsrModels.loadLocalOnly(from: directory, version: descriptor.asrModelVersion)XCTAssertEqual(models.version, descriptor.asrModelVersion)- XCTAssertNotNil(models.splitEncoder)+ // Pro's Mac pack keeps one encoder; Mini and Pico ship theirs in pieces.+ XCTAssertEqual(models.splitEncoder != nil, descriptor.variant != .pro)XCTAssertEqual(models.encoderOutputShape.count, 3)let hiddenDimension = try XCTUnwrap(models.encoderOutputShape.dropFirst().first)XCTAssertEqual(hiddenDimension, models.version.encoderHiddenSize)diff --git a/Tests/FluidDictationIntegrationTests/ParakeetSpeechModelCatalogTests.swift b/Tests/FluidDictationIntegrationTests/ParakeetSpeechModelCatalogTests.swiftindex 39dc6ae6..1c5b05ee 100644--- a/Tests/FluidDictationIntegrationTests/ParakeetSpeechModelCatalogTests.swift+++ b/Tests/FluidDictationIntegrationTests/ParakeetSpeechModelCatalogTests.swift@@ -77,9 +77,9 @@ final class ParakeetSpeechModelCatalogTests: XCTestCase {func testAllOfflineParakeetVariantsHaveIndependentStableCacheAndPronunciationKeys() throws {let descriptors = ParakeetSpeechModelCatalog.descriptorsXCTAssertEqual(Set(descriptors.map(\.variant)), Set(ParakeetSpeechModelCatalog.Variant.allCases))- XCTAssertEqual(Set(descriptors.map(\.modelID)).count, 4)- XCTAssertEqual(Set(descriptors.map(\.folderName)).count, 4)- XCTAssertEqual(Set(descriptors.map(\.pronunciationModelKey)).count, 4)+ XCTAssertEqual(Set(descriptors.map(\.modelID)).count, 5)+ XCTAssertEqual(Set(descriptors.map(\.folderName)).count, 5)+ XCTAssertEqual(Set(descriptors.map(\.pronunciationModelKey)).count, 5)let root = URL(fileURLWithPath: "/fixture/FluidAudio/Models", isDirectory: true)for descriptor in descriptors {let model = try XCTUnwrap(SettingsStore.SpeechModel(rawValue: descriptor.modelID))@@ -93,7 +93,7 @@ final class ParakeetSpeechModelCatalogTests: XCTestCase {XCTAssertFalse(model.isWhisperModel)XCTAssertEqual(model.provider, .nvidia)XCTAssertTrue(model.requiresAppleSilicon)- XCTAssertEqual(model.requiresMacOS15, model == .fluidParakeetMini || model == .fluidParakeetPico)+ XCTAssertEqual(model.requiresMacOS15, [.fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro].contains(model))XCTAssertFalse(model.requiresMacOS26)XCTAssertNil(model.whisperModelFile)XCTAssertNil(model.legacyWhisperModelFile)@@ -178,6 +178,54 @@ final class ParakeetSpeechModelCatalogTests: XCTestCase {XCTAssertEqual(SettingsStore.SpeechModel.fluidParakeetPico.humanReadableName, "Fluid Speech Pico")}+ func testProDownloadsItsHostedPackLikeMiniAndPico() throws {+ let descriptor = ParakeetSpeechModelCatalog.pro+ let model = SettingsStore.SpeechModel.fluidParakeetPro+ XCTAssertEqual(model.parakeetDescriptor, descriptor)+ XCTAssertEqual(descriptor.asrModelVersion, .fluidParakeetPro)+ XCTAssertEqual(descriptor.archiveURL?.absoluteString, "https://models.fluidvoice.app/parakeet/fluid-pro/1.0.0/fluid-parakeet-pro-coreml.tar")+ XCTAssertEqual(descriptor.archiveSHA256?.count, 64)+ XCTAssertEqual(descriptor.manifestSHA256?.count, 64)+ XCTAssertEqual(descriptor.expectedDownloadBytes, 652_482_560)+ XCTAssertTrue(descriptor.isHostedPack)+ XCTAssertFalse(ParakeetSpeechModelCatalog.v3.isHostedPack)+ XCTAssertNil(CompactSpeechModelReleaseCatalog.shared.descriptor(for: model), "The signed feed only updates Mini and Pico")+ XCTAssertEqual(descriptor.folderName, "fluid-parakeet-pro-coreml")+ XCTAssertEqual(descriptor.requiredModelNames, ParakeetSpeechModelCatalog.standardModelNames, "The Mac pack has one encoder")+ XCTAssertEqual(model.displayName, ParakeetSpeechModelCatalog.proName)+ XCTAssertEqual(model.humanReadableName, ParakeetSpeechModelCatalog.proName)+ XCTAssertTrue(descriptor.isEnglishOnly)+ XCTAssertEqual(model.brandName, "FluidVoice")+ XCTAssertEqual(model.provider, .nvidia)+ XCTAssertEqual(descriptor.creditLine, ParakeetSpeechModelCatalog.mini.creditLine)+ XCTAssertEqual(descriptor.pronunciationModelKey, try descriptor.modelID + ":sha256:" + XCTUnwrap(descriptor.archiveSHA256))+ XCTAssertTrue(ParakeetSpeechModelCatalog.sharesPronunciationFamily(descriptor.pronunciationModelKey, with: "parakeet-v3"))+ XCTAssertEqual(ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: descriptor.modelID), descriptor)+ XCTAssertFalse(ParakeetSpeechModelCatalog.isOutdatedCompactPronunciationModelKey(descriptor.modelID))+ XCTAssertTrue(+ FluidAudioProvider(modelOverride: model, configureWordBoosting: false).preservesInstalledCompactWeights,+ "Like Mini and Pico, a failed load must not delete verified hosted weights"+ )+ XCTAssertFalse(FluidAudioProvider(modelOverride: .parakeetTDT, configureWordBoosting: false).preservesInstalledCompactWeights)++ let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)+ defer { try? FileManager.default.removeItem(at: directory) }+ for name in descriptor.requiredModelNames {+ let root = directory.appendingPathComponent(name)+ try FileManager.default.createDirectory(at: root.appendingPathComponent("weights"), withIntermediateDirectories: true)+ for file in ["coremldata.bin", "metadata.json", "weights/weight.bin"] {+ try Data("fixture".utf8).write(to: root.appendingPathComponent(file))+ }+ }+ XCTAssertFalse(descriptor.artifactsAreComplete(at: directory))+ try Data("{}".utf8).write(to: directory.appendingPathComponent(descriptor.vocabularyFile))+ XCTAssertFalse(descriptor.artifactsAreComplete(at: directory), "Without the archive marker it is not the hosted release")+ XCTAssertNil(descriptor.installedArchiveSHA256(at: directory))+ try descriptor.writeInstallationRevision(at: directory)+ XCTAssertTrue(descriptor.artifactsAreComplete(at: directory))+ XCTAssertEqual(descriptor.installedArchiveSHA256(at: directory), descriptor.archiveSHA256)+ }+func testSmallVariantsAreOfferedOnlyForEnglishAndDoNotReplaceExistingFirstChoice() {let models: [SettingsStore.SpeechModel] = [.parakeetTDTv2, .parakeetRealtime, .parakeetTDT, .fluidParakeetMini, .fluidParakeetPico]let english = VoiceEngineLanguageCatalog.routes(forLanguageID: "en", availableModels: models)diff --git a/Tests/FluidDictationIntegrationTests/PronunciationModelRevisionTests.swift b/Tests/FluidDictationIntegrationTests/PronunciationModelRevisionTests.swiftindex 69e002a8..44448268 100644--- a/Tests/FluidDictationIntegrationTests/PronunciationModelRevisionTests.swift+++ b/Tests/FluidDictationIntegrationTests/PronunciationModelRevisionTests.swift@@ -23,6 +23,101 @@ final class PronunciationModelRevisionTests: XCTestCase {XCTAssertFalse(ParakeetSpeechModelCatalog.isOutdatedCompactPronunciationModelKey("parakeet-v3"))}+ func testProFirstDownloadAndInstalledKeysResolveToTheSameCheckpoint() throws {+ let descriptor = ParakeetSpeechModelCatalog.pro+ let installedKey = try descriptor.modelID + ":sha256:" + XCTUnwrap(descriptor.archiveSHA256)+ XCTAssertEqual(descriptor.pronunciationModelKey, installedKey)+ XCTAssertEqual(ParakeetSpeechModelCatalog.descriptor(forPronunciationModelKey: installedKey), descriptor)+ let installed = try XCTUnwrap(ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: installedKey))+ XCTAssertEqual(installed.pronunciationModelKey, installedKey)+ XCTAssertEqual(installed.archiveSHA256, descriptor.archiveSHA256)+ XCTAssertEqual(installed.requiredModelNames, descriptor.requiredModelNames)+ XCTAssertNil(installed.archiveURL, "Resolving stored evidence must never download replacement weights")++ let olderKey = descriptor.modelID + ":sha256:" + String(repeating: "a", count: 64)+ let older = try XCTUnwrap(ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: olderKey))+ XCTAssertEqual(older.pronunciationModelKey, olderKey)+ XCTAssertNil(older.archiveURL)+ for key in [installedKey, olderKey, descriptor.modelID] {+ for other in ParakeetSpeechModelCatalog.descriptors {+ XCTAssertTrue(ParakeetSpeechModelCatalog.sharesPronunciationFamily(key, with: other.pronunciationModelKey))+ XCTAssertTrue(ParakeetSpeechModelCatalog.sharesPronunciationFamily(other.pronunciationModelKey, with: key))+ }+ }+ for hash in ["", "bad", String(repeating: "G", count: 64), String(repeating: "a", count: 63), String(repeating: "a", count: 65)] {+ let key = descriptor.modelID + ":sha256:" + hash+ XCTAssertNil(ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: key))+ XCTAssertFalse(ParakeetSpeechModelCatalog.sharesPronunciationFamily(key, with: installedKey))+ }+ }++ func testReplayUsesEveryInstalledHostedPackIncludingProWithoutChangingItsFiles() throws {+ let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)+ defer { try? FileManager.default.removeItem(at: root) }+ let installedKeys = { DictionaryMatchPlayground.installedModelKeys { $0.cacheDirectory(in: root) } }+ XCTAssertEqual(installedKeys(), ["parakeet-v2", "parakeet-v3"])+ for descriptor in ParakeetSpeechModelCatalog.descriptors where descriptor.isHostedPack {+ let directory = descriptor.cacheDirectory(in: root)+ for model in descriptor.requiredModelNames {+ let modelRoot = directory.appendingPathComponent(model)+ try FileManager.default.createDirectory(at: modelRoot.appendingPathComponent("weights"), withIntermediateDirectories: true)+ for file in ["coremldata.bin", "metadata.json", "weights/weight.bin"] {+ try Data("fixture".utf8).write(to: modelRoot.appendingPathComponent(file))+ }+ }+ try Data("{}".utf8).write(to: directory.appendingPathComponent(descriptor.vocabularyFile))+ let marker = directory.appendingPathComponent(ParakeetSpeechModelCatalog.installationRevisionFileName)+ let hash = try XCTUnwrap(descriptor.archiveSHA256)+ try Data(hash.utf8).write(to: marker)+ let profile = Self.profile(entryID: UUID(), key: descriptor.pronunciationModelKey)+ XCTAssertEqual(try DictionaryMatchPlayground.targetProfile(from: [profile], target: profile.label, compatibleModelKeys: installedKeys()), profile)+ if descriptor.variant == .pro {+ let legacy = Self.profile(entryID: UUID(), key: descriptor.modelID)+ XCTAssertEqual(try DictionaryMatchPlayground.targetProfile(from: [legacy], target: legacy.label, compatibleModelKeys: installedKeys()), legacy)+ let oldHash = String(repeating: "a", count: 64)+ try Data(oldHash.utf8).write(to: marker)+ let older = Self.profile(entryID: UUID(), key: descriptor.modelID + ":sha256:" + oldHash)+ XCTAssertEqual(try DictionaryMatchPlayground.targetProfile(from: [older], target: older.label, compatibleModelKeys: installedKeys()), older)+ XCTAssertThrowsError(try DictionaryMatchPlayground.targetProfile(from: [legacy], target: legacy.label, compatibleModelKeys: installedKeys()))+ XCTAssertThrowsError(try DictionaryMatchPlayground.targetProfile(from: [profile], target: profile.label, compatibleModelKeys: installedKeys()))+ XCTAssertEqual(try String(contentsOf: marker, encoding: .utf8), oldHash)+ try Data("bad".utf8).write(to: marker)+ XCTAssertFalse(installedKeys().contains(older.modelKey))+ try Data(hash.utf8).write(to: marker)+ let model = try XCTUnwrap(descriptor.requiredModelNames.first)+ try FileManager.default.removeItem(at: directory.appendingPathComponent(model + "/weights/weight.bin"))+ XCTAssertFalse(installedKeys().contains(profile.modelKey))+ }+ XCTAssertEqual(try String(contentsOf: marker, encoding: .utf8), hash, "Replay discovery must never rewrite an installation")+ }+ XCTAssertTrue(installedKeys().contains(ParakeetSpeechModelCatalog.mini.pronunciationModelKey))+ XCTAssertTrue(installedKeys().contains(ParakeetSpeechModelCatalog.pico.pronunciationModelKey))+ }++ func testProReloadKeepsLegacyAndSharedProfilesWithoutRewritingStorage() async throws {+ let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)+ defer { try? FileManager.default.removeItem(at: directory) }+ let url = directory.appendingPathComponent("profiles.json")+ let store = PronunciationDictionaryStore(fileURL: url)+ let descriptor = ParakeetSpeechModelCatalog.pro+ let legacy = Self.profile(entryID: UUID(), key: descriptor.modelID)+ let current = Self.profile(entryID: UUID(), key: descriptor.pronunciationModelKey)+ let shared = Self.profile(entryID: UUID(), key: "parakeet-v3")+ for profile in [legacy, current, shared] {+ try await store.upsert(dictionaryEntryID: profile.dictionaryEntryID, label: profile.label, modelKey: profile.modelKey, enrollments: profile.enrollments)+ }+ let before = try Data(contentsOf: url)+ let reloaded = PronunciationDictionaryStore(fileURL: url)+ let profiles = await reloaded.sharedProfiles(modelKey: descriptor.pronunciationModelKey, hiddenSize: legacy.hiddenSize)+ XCTAssertEqual(Set(profiles.map(\.modelKey)), [legacy.modelKey, current.modelKey, shared.modelKey])+ XCTAssertEqual(try Data(contentsOf: url), before)+ XCTAssertEqual(try DictionaryMatchPlayground.targetProfile(from: [legacy], target: legacy.label), legacy)+ XCTAssertThrowsError(try DictionaryMatchPlayground.targetProfile(from: [legacy], target: legacy.label, compatibleModelKeys: ["parakeet-v3"]))+ #if arch(arm64)+ XCTAssertEqual(DictionaryPronunciationReferences.make(profiles: profiles, compatibleModelKey: descriptor.pronunciationModelKey).count, 9)+ #endif+ }+func testRetrainingKeepsOriginalStoredProfileAndTextEntryWithoutReusingOldVectors() async throws {let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)defer { try? FileManager.default.removeItem(at: directory) }@@ -191,7 +286,7 @@ final class PronunciationModelRevisionTests: XCTestCase {func testNormalProviderPreparationKeepsCompleteOldWeightsAndTheirActualPronunciationKey() async throws {let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)defer { try? FileManager.default.removeItem(at: root) }- for model: SettingsStore.SpeechModel in [.fluidParakeetMini, .fluidParakeetPico] {+ for model: SettingsStore.SpeechModel in [.fluidParakeetMini, .fluidParakeetPico, .fluidParakeetPro] {let descriptor = try XCTUnwrap(model.parakeetDescriptor)let installed = descriptor.cacheDirectory(in: root)try FileManager.default.createDirectory(at: installed, withIntermediateDirectories: true)@@ -213,6 +308,8 @@ final class PronunciationModelRevisionTests: XCTestCase {XCTFail("Dummy Core ML files must fail locally without deleting old weights for recovery")} catch {}XCTAssertEqual(provider.pronunciationModelKeyForTesting, descriptor.modelID + ":sha256:" + oldHash)+ XCTAssertNotNil(ParakeetSpeechModelCatalog.descriptor(forInstalledPronunciationModelKey: provider.pronunciationModelKeyForTesting))+ XCTAssertTrue(ParakeetSpeechModelCatalog.sharesPronunciationFamily(provider.pronunciationModelKeyForTesting, with: "parakeet-v3"))XCTAssertEqual(descriptor.installedArchiveSHA256(at: installed), oldHash, "Normal loading must never erase an older complete download")XCTAssertEqual(try Data(contentsOf: installed.appendingPathComponent(descriptor.vocabularyFile)), Data("{}".utf8))}diff --git a/Tests/FluidDictationIntegrationTests/SettingsNavigationStateTests.swift b/Tests/FluidDictationIntegrationTests/SettingsNavigationStateTests.swiftindex 3efeb37e..6d2b2c08 100644--- a/Tests/FluidDictationIntegrationTests/SettingsNavigationStateTests.swift+++ b/Tests/FluidDictationIntegrationTests/SettingsNavigationStateTests.swift@@ -235,7 +235,8 @@ final class SettingsNavigationStateTests: XCTestCase {accessibilityEnabled: true,savesTranscriptionHistory: false,savesAudioWithTranscriptionHistory: false,- overlayAtBottom: false+ overlayAtBottom: false,+ privateAIAvailable: false)let permissionTargets = SettingsSearchIndex.results(@@ -261,7 +262,8 @@ final class SettingsNavigationStateTests: XCTestCase {accessibilityEnabled: false,savesTranscriptionHistory: true,savesAudioWithTranscriptionHistory: true,- overlayAtBottom: true+ overlayAtBottom: true,+ privateAIAvailable: false)let gatedTargets: [(SettingsSearchTarget, String)] = [(.primaryDictationShortcuts, "primary dictation shortcuts"),