Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix(dictation): honor overlay prompt picks across apps
altic-dev1550fc68dd13
diff --git a/Sources/Fluid/Services/DictationStopSnapshot.swift b/Sources/Fluid/Services/DictationStopSnapshot.swiftindex 97e524e8..7b5700ee 100644--- a/Sources/Fluid/Services/DictationStopSnapshot.swift+++ b/Sources/Fluid/Services/DictationStopSnapshot.swift@@ -34,6 +34,18 @@ struct DictationStopSnapshot {returnToStartingField || ownOverlayFocused ? original : current}+ /// A prompt picked in the overlay during this dictation is stored under+ /// the app that was frontmost at the time. It must win even when the text+ /// is delivered to the field the recording started in.+ @MainActor+ static func promptResolutionAppID(slot: SettingsStore.DictationShortcutSlot, targetBundleID: String) -> String {+ let session = DictationAppSession.shared+ guard let visitedAppID = session.appID, session.choice(for: slot, appID: visitedAppID) != nil else {+ return targetBundleID+ }+ return visitedAppID+ }+@MainActorstatic func capture(target: TypingService.RecordingTargetContext?,@@ -43,14 +55,15 @@ struct DictationStopSnapshot {readsContextFromFocusedField: Bool = false) -> Self {let settings = SettingsStore.shared- let customPrompt = settings.resolvedDictationPromptProfile(for: slot, appBundleID: appInfo.bundleId)+ let promptAppID = Self.promptResolutionAppID(slot: slot, targetBundleID: appInfo.bundleId)+ let customPrompt = settings.resolvedDictationPromptProfile(for: slot, appBundleID: promptAppID).flatMap { settings.shortcutOverrideSystemPrompt(for: $0) }return Self(target: target,appInfo: appInfo,- route: DictationProviderRoute.resolve(settings: settings, dictationSlot: slot, appBundleID: appInfo.bundleId),- usesAI: target != nil && DictationAIPostProcessingGate.isConfigured(for: slot, appBundleID: appInfo.bundleId),- systemPrompt: customPrompt ?? settings.effectiveDictationSystemPrompt(for: slot, appBundleID: appInfo.bundleId),+ route: DictationProviderRoute.resolve(settings: settings, dictationSlot: slot, appBundleID: promptAppID),+ usesAI: target != nil && DictationAIPostProcessingGate.isConfigured(for: slot, appBundleID: promptAppID),+ systemPrompt: customPrompt ?? settings.effectiveDictationSystemPrompt(for: slot, appBundleID: promptAppID),hasCustomPrompt: customPrompt != nil,precedingText: precedingText,readsContextFromFocusedField: readsContextFromFocusedFielddiff --git a/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift b/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swiftindex f4d15230..d57c1098 100644--- a/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift+++ b/Tests/FluidDictationIntegrationTests/LLMClientRequestBodyTests.swift@@ -308,6 +308,32 @@ final class LLMClientRequestBodyTests: XCTestCase {}}+ func testOverlayPickMadeInAnotherAppStillAppliesToTheStartingField() {+ self.withPromptSettingsRestored {+ let settings = SettingsStore.shared+ self.resetPromptSettings(settings)+ let session = DictationAppSession.shared+ let previousApp = session.appID+ defer { session.activate(previousApp ?? "test.finished") }+ let profile = SettingsStore.DictationPromptProfile(name: "Casual", prompt: "Keep it casual.")+ settings.dictationPromptProfiles = [profile]+ // Recording started in Notes; the user switched to Slack and picked+ // Casual there. Return-to-starting-field delivers into Notes.+ session.activate("test.slack")+ session.select(.profile(profile.id), slot: .primary, appID: "test.slack")+ XCTAssertEqual(DictationStopSnapshot.promptResolutionAppID(slot: .primary, targetBundleID: "test.notes"), "test.slack")+ let target = TypingService.RecordingTargetContext(id: UUID(), pid: 7, bundleIdentifier: "test.notes", window: nil, element: nil)+ let info = (name: "Notes", bundleId: "test.notes", windowTitle: "")+ let snapshot = DictationStopSnapshot.capture(target: target, appInfo: info, slot: .primary, precedingText: "")+ XCTAssertEqual(snapshot.systemPrompt, "Keep it casual.")+ XCTAssertEqual(snapshot.appInfo.bundleId, "test.notes")+ // Without a pick, the delivery target's own rules apply.+ session.select(.off, slot: .primary, appID: "test.slack")+ session.activate("test.other")+ XCTAssertEqual(DictationStopSnapshot.promptResolutionAppID(slot: .primary, targetBundleID: "test.notes"), "test.notes")+ }+ }+func testStopSnapshotDefersWindowTitleAndPrecedingText() {let target = TypingService.RecordingTargetContext(id: UUID(), pid: 321, bundleIdentifier: "test.defer", window: nil, element: nil)let info = (name: "Defer app", bundleId: "test.defer", windowTitle: "")