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 onboarding final polish
altic-dev7bf77b9a7dec
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 8d4f86f9..e2adb19e 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -33,6 +33,16 @@ enum AIProcessingError: LocalizedError {return "AI returned an empty response"}}++ /// Configuration errors the user can fix in AI Enhancement settings.+ var isConfigurationError: Bool {+ switch self {+ case .noVerifiedProvider, .missingAPIKey, .missingModel:+ return true+ case .emptyResponse:+ return false+ }+ }}// MARK: - Sidebar Item Enum@@ -190,6 +200,7 @@ struct ContentView: View {@State private var accessibilityGuidePanel: NSPanel?@State private var accessibilityGuideMonitorTask: Task<Void, Never>?@State private var accessibilityGuideRequestID: UUID?+ @State private var prewarmDictationTask: Task<Void, Never>?private var isRecordingAnyShortcutCapture: Bool {self.activeShortcutRecordingTarget != nil@@ -578,6 +589,7 @@ struct ContentView: View {if self.asr.isRunning {Task { await self.asr.stopWithoutTranscription() }}+ self.cancelPrewarmDictationIfNeeded()self.clearActiveRecordingMode()self.menuBarManager.setOverlayMode(.dictation)}@@ -596,6 +608,7 @@ struct ContentView: View {if self.asr.isRunning {Task { await self.asr.stopWithoutTranscription() }}+ self.cancelPrewarmDictationIfNeeded()self.clearActiveRecordingMode()self.menuBarManager.setOverlayMode(.dictation)}@@ -614,6 +627,7 @@ struct ContentView: View {if self.asr.isRunning {Task { await self.asr.stopWithoutTranscription() }}+ self.cancelPrewarmDictationIfNeeded()self.clearActiveRecordingMode()self.rewriteModeService.clearState()self.menuBarManager.setOverlayMode(.dictation)@@ -700,6 +714,7 @@ struct ContentView: View {}.onDisappear {Task { await self.asr.stopWithoutTranscription() }+ self.cancelPrewarmDictationIfNeeded()// 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@@ -1825,10 +1840,14 @@ struct ContentView: View {// The processing indicator will stay visible during this phaselet asrStopStartedAt = ProcessInfo.processInfo.systemUptimeself.appBench("asr_stop_call")- let transcribedText = await asr.stop()+ // Play the stop cue as soon as the audio engine has stopped, before the+ // (potentially slow) final transcription pass. Scoped to dictation only —+ // Command/Edit modes call asr.stop() without this callback.+ let transcribedText = await asr.stop(onCaptureStopped: {+ TranscriptionSoundPlayer.shared.playStopSound()+ })self.appBench("asr_stop_return elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - asrStopStartedAt) * 1000).rounded()))")let audioSnapshot = self.asr.consumeLastCompletedAudioSnapshot()- TranscriptionSoundPlayer.shared.playStopSound()DebugLogger.shared.info("Stop transcription result | chars=\(transcribedText.count) | empty=\(transcribedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)",source: "ContentView"@@ -1947,7 +1966,17 @@ struct ContentView: View {source: "ContentView")aiFallbackReason = error.localizedDescription- NotificationService.showAIProcessingFallback(error: error.localizedDescription)+ // Configuration errors are actionable — point the user at settings+ // rather than just echoing the technical error string.+ if let aiError = error as? AIProcessingError,+ aiError.isConfigurationError+ {+ NotificationService.showAIProcessingFallback(+ error: "\(aiError.localizedDescription). Open AI Enhancement settings to configure a provider."+ )+ } else {+ NotificationService.showAIProcessingFallback(error: error.localizedDescription)+ }finalText = transcribedText}let postProcessingLatencyMs = Int((Date().timeIntervalSince(postProcessingStart) * 1000).rounded())@@ -2260,6 +2289,7 @@ struct ContentView: View {if self.asr.isRunning {DebugLogger.shared.info("Actions: stopping active recording before history action output", source: "ContentView")await self.asr.stopWithoutTranscription()+ self.cancelPrewarmDictationIfNeeded()}let finalText = ASRService.applyGAAVFormatting(text)@@ -2305,6 +2335,7 @@ struct ContentView: View {if self.asr.isRunning {DebugLogger.shared.info("Actions: stopping active recording before reprocess", source: "ContentView")await self.asr.stopWithoutTranscription()+ self.cancelPrewarmDictationIfNeeded()}self.setActiveRecordingMode(.dictate)@@ -2473,6 +2504,14 @@ struct ContentView: View {self.setActiveRecordingMode(.none)}+ /// Cancel an in-flight prewarm. Called on abort / new recording start — NOT on+ /// a normal stop, because AI post-processing runs after stop and benefits from+ /// the warm prefix cache the prewarm prime.+ private func cancelPrewarmDictationIfNeeded() {+ self.prewarmDictationTask?.cancel()+ self.prewarmDictationTask = nil+ }+private func handleLivePromptModeSwitch(_ mode: SettingsStore.PromptMode) {guard !NotchContentState.shared.isProcessing else { return }switch mode.normalized {@@ -2588,7 +2627,10 @@ struct ContentView: View {DictationAIPostProcessingGate.isConfigured(for: slot, appBundleID: appBundleID)else { return }- Task {+ // Cancel any prior prewarm so rapid start/stop doesn't queue duplicate+ // actor work on PrivateAIIntegrationService.+ self.prewarmDictationTask?.cancel()+ self.prewarmDictationTask = Task {DebugLogger.shared.debug("ContentView: AI dictation prewarm started slot=\(slot.rawValue)",source: "ContentView"@@ -2598,6 +2640,9 @@ struct ContentView: View {"AI dictation prewarm complete slot=\(slot.rawValue)",source: "ContentView")+ if !Task.isCancelled {+ self.prewarmDictationTask = nil+ }}}@@ -2868,6 +2913,7 @@ struct ContentView: View {// Reset recording mode flagsif self.activeRecordingMode != .none {+ self.cancelPrewarmDictationIfNeeded()self.clearActiveRecordingMode()handled = true}@@ -2922,6 +2968,7 @@ struct ContentView: View {if self.asr.isRunning {DebugLogger.shared.debug("Cancel shortcut: cancelling ASR recording", source: "ContentView")Task { await self.asr.stopWithoutTranscription() }+ self.cancelPrewarmDictationIfNeeded()handled = true}diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex 0922376c..563bacf2 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -1699,10 +1699,6 @@ final class SettingsStore: ObservableObject {}}- var soundFileName: String? {- self.startSoundFileName- }-var stopSoundFileName: String? {switch self {case .fluidSfx0: return "FV_end_0"diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex c8ee89f5..cec687d1 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -930,7 +930,12 @@ final class ASRService: ObservableObject {/// - ASR models are not available/// - Transcription process fails/// Check debug logs for detailed error information.- func stop() async -> String {+ /// - Parameter onCaptureStopped: Optional callback fired on the main actor+ /// after the audio engine has stopped but before the (potentially slow)+ /// final transcription pass. Use this for immediate stop cues that+ /// shouldn't wait on finalization. Only invoked when capture was actually+ /// running (i.e. not when `stop()` early-returns because `isRunning` is false).+ func stop(onCaptureStopped: (@MainActor () -> Void)? = nil) async -> String {DebugLogger.shared.info("🛑 STOP() called - beginning shutdown sequence", source: "ASRService")self.lastCompletedAudioSnapshot = nillet stopStartedAt = Date().timeIntervalSince1970@@ -977,6 +982,11 @@ final class ASRService: ObservableObject {self.engine.stop()DebugLogger.shared.debug("✅ Engine stopped", source: "ASRService")+ // Capture has fully ended — invoke the callback so callers can play a+ // stop cue or release capture-dependent UI without waiting on the+ // (potentially slow) final transcription pass.+ await MainActor.run { onCaptureStopped?() }+// Recreate the engine instance instead of calling reset() to prevent format corruption// VoiceInk approach: tearing down and rebuilding ensures fresh, valid audio format on restartDebugLogger.shared.debug("🗑️ Deallocating old engine and creating fresh instance...", source: "ASRService")diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swiftindex 928550ab..65fb7fa0 100644--- a/Sources/Fluid/Services/MenuBarManager.swift+++ b/Sources/Fluid/Services/MenuBarManager.swift@@ -45,8 +45,12 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {private var pendingShowOperation: DispatchWorkItem?private var pendingHideOperation: DispatchWorkItem?private var pendingProcessingShowOperation: DispatchWorkItem?+ // Show immediately so users see the processing state right away.private let processingVisualDelay: DispatchTimeInterval = .milliseconds(0)- private let processingHideDelay: DispatchTimeInterval = .milliseconds(0)+ // Debounce the hide so a fast transcription doesn't flash the processing+ // overlay for a single frame. 80ms is under the perception threshold but+ // long enough to coalesce a quick show->hide cycle.+ private let processingHideDelay: DispatchTimeInterval = .milliseconds(80)// Subscription for forwarding audio levels to expanded command notchprivate var expandedModeAudioSubscription: AnyCancellable?@@ -307,7 +311,7 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {return}- self.overlayBench("processing_hide_workitem_execute delayMs=0")+ self.overlayBench("processing_hide_workitem_execute delayMs=80")NotchOverlayManager.shared.hide()self.overlayBench("processing_hide_workitem_return")self.pendingHideOperation = nil@@ -315,7 +319,7 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {self.pendingHideOperation = hideItemDispatchQueue.main.asyncAfter(deadline: .now() + self.processingHideDelay, execute: hideItem)NotchOverlayManager.shared.setProcessing(false)- self.overlayBench("processing_forwarded processing=false hideDelayMs=0")+ self.overlayBench("processing_forwarded processing=false hideDelayMs=80")return}}diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swiftindex feb99e20..3676c6f2 100644--- a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift@@ -31,7 +31,6 @@ struct OnboardingAIEnhancementStepView: View {@State private var privateAIActionTask: Task<Void, Never>?@State private var privateAIActionID = UUID()@State private var shouldShowTryout = false- @State private var hasPreparedExistingPrivateAI = false@State private var selectedExampleID = Self.examples[0].id@State private var activeRecordingExampleID: String?@State private var playgroundOutputs: [String: String] = [:]@@ -200,10 +199,6 @@ struct OnboardingAIEnhancementStepView: View {PrivateAIModelDownloadProgressText.byteText(for: self.privateAISetupProgress)}- private var trimmedFinalText: String {- self.finalText.trimmingCharacters(in: .whitespacesAndNewlines)- }-private var sectionTransition: AnyTransition {if self.reduceMotion {return .opacity@@ -238,9 +233,6 @@ struct OnboardingAIEnhancementStepView: View {self.footer}.frame(width: proxy.size.width, height: proxy.size.height)- .onAppear {- self.prepareExistingPrivateAIStateIfNeeded()- }.onDisappear {self.cancelPrivateAIAction()}@@ -513,6 +505,11 @@ struct OnboardingAIEnhancementStepView: View {let outputText = self.playgroundOutputs[example.id] ?? ""let hasOutput = !outputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmptylet isListening = self.activeRecordingExampleID == example.id && self.isRunning+ let allowsDecorativeShadow = !self.reduceMotion+ let rawShadowRadius: CGFloat = allowsDecorativeShadow && isSelected ? 13 : 0+ let arrowShadowRadius: CGFloat = allowsDecorativeShadow && isListening ? 12 : 0+ let outputShadowRadius: CGFloat = allowsDecorativeShadow && (isSelected || isListening) ? (isSelected ? 14 : 8) : 0+ let outputShadowOpacity: Double = allowsDecorativeShadow ? (isListening ? 0.24 : (isSelected ? 0.16 : 0)) : 0let rawShape = RoundedRectangle(cornerRadius: 14, style: .continuous)let outputShape = RoundedRectangle(cornerRadius: 14, style: .continuous)@@ -559,7 +556,7 @@ struct OnboardingAIEnhancementStepView: View {rawShape.stroke(isSelected ? FluidOnboardingLandingColors.blue.opacity(0.48) : Color.white.opacity(0.070), lineWidth: isSelected ? 1.2 : 1))- .shadow(color: FluidOnboardingLandingColors.blue.opacity(isSelected ? 0.13 : 0), radius: 13, x: 0, y: 4)+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(allowsDecorativeShadow && isSelected ? 0.13 : 0), radius: rawShadowRadius, x: 0, y: 4)).contentShape(rawShape)}@@ -585,7 +582,7 @@ struct OnboardingAIEnhancementStepView: View {Circle().stroke(isSelected ? FluidOnboardingLandingColors.blue.opacity(0.28) : Color.white.opacity(0.10), lineWidth: 1))- .shadow(color: FluidOnboardingLandingColors.blue.opacity(isListening ? 0.30 : 0), radius: 12, x: 0, y: 0)+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(allowsDecorativeShadow && isListening ? 0.30 : 0), radius: arrowShadowRadius, x: 0, y: 0)).matchedGeometryEffect(id: "example-arrow-\(example.id)",@@ -660,7 +657,7 @@ struct OnboardingAIEnhancementStepView: View {outputShape.stroke(FluidOnboardingLandingColors.blue.opacity(isListening ? 0.72 : (isSelected ? 0.54 : 0.22)), lineWidth: isSelected ? 1.3 : 1))- .shadow(color: FluidOnboardingLandingColors.blue.opacity(isListening ? 0.24 : (isSelected ? 0.16 : 0.04)), radius: isSelected ? 14 : 8, x: 0, y: 5)+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(outputShadowOpacity), radius: outputShadowRadius, x: 0, y: 5)).contentShape(outputShape).onTapGesture {@@ -1029,8 +1026,6 @@ struct OnboardingAIEnhancementStepView: View {self.playgroundOutputs[targetExampleID] = textself.selectedExampleID = targetExampleIDself.activeRecordingExampleID = nil- self.settings.onboardingPlaygroundValidated = true- self.settings.playgroundUsed = true}private func clearExampleOutput(_ example: EnhancementExample) {@@ -1039,17 +1034,6 @@ struct OnboardingAIEnhancementStepView: View {if self.selectedExampleID == example.id {self.finalText = ""}-- if !self.hasAnyPlaygroundOutput {- self.settings.onboardingPlaygroundValidated = false- self.settings.playgroundUsed = false- }- }-- private var hasAnyPlaygroundOutput: Bool {- self.playgroundOutputs.values.contains { output in- !output.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty- }}private func handlePrivateAIPrimaryAction(scrollProxy: ScrollViewProxy) {@@ -1069,17 +1053,6 @@ struct OnboardingAIEnhancementStepView: View {}}- private func prepareExistingPrivateAIStateIfNeeded() {- guard self.isPrivateAIAvailable else {- self.shouldShowTryout = false- return- }-- guard !self.hasPreparedExistingPrivateAI else { return }- self.hasPreparedExistingPrivateAI = true- self.shouldShowTryout = false- }-private func downloadPrivateAIModel() {guard self.canNavigateOrMutate else { return }guard self.privateAIModel.canDownload else {diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftindex cbf29d55..3c78202c 100644--- a/Sources/Fluid/Views/BottomOverlayView.swift+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -1747,12 +1747,22 @@ private struct PromptSelectorAnchorReader: NSViewRepresentable {}}-private final class BottomOverlayHostingView: NSHostingView<BottomOverlayView> {- private let pillShadowPadding: CGFloat = 26+private enum PillShadowMetrics {+ // Keep in sync with the pill shadow in BottomOverlayView.body.+ static let radius: CGFloat = 10+ static let yOffset: CGFloat = 4+ // Hit-test inset must cover the visible shadow extent (radius + |offset|)+ // plus a small margin so the shadow region doesn't intercept clicks.+ static let hitTestInset: CGFloat = radius + abs(yOffset) + 12+}+private final class BottomOverlayHostingView: NSHostingView<BottomOverlayView> {override func hitTest(_ point: NSPoint) -> NSView? {if SettingsStore.shared.overlaySize == .pill {- let visibleOverlayBounds = self.bounds.insetBy(dx: self.pillShadowPadding, dy: self.pillShadowPadding)+ let visibleOverlayBounds = self.bounds.insetBy(+ dx: PillShadowMetrics.hitTestInset,+ dy: PillShadowMetrics.hitTestInset+ )guard visibleOverlayBounds.contains(point) else { return nil }}return super.hitTest(point)@@ -1779,6 +1789,7 @@ struct BottomOverlayView: View {@ObservedObject private var historyStore = TranscriptionHistoryStore.shared@ObservedObject private var settings = SettingsStore.shared@Environment(\.theme) private var theme+ @Environment(\.accessibilityReduceMotion) private var reduceMotion@State private var isHoveringModeChip = false@State private var isHoveringPromptChip = false@State private var isHoveringActionsChip = false@@ -2795,16 +2806,15 @@ struct BottomOverlayView: View {.fill(Color.black).shadow(color: Color.black.opacity(self.isPillSize ? 0.32 : 0),- radius: self.isPillSize ? 10 : 0,+ radius: self.isPillSize ? PillShadowMetrics.radius : 0,x: 0,- y: self.isPillSize ? 4 : 0+ y: self.isPillSize ? PillShadowMetrics.yOffset : 0)if self.isPillSize {// Glossy border: a bright highlight that slowly rotates around the edge.- TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { timeline in- let seconds = timeline.date.timeIntervalSinceReferenceDate- let angle = (seconds.truncatingRemainder(dividingBy: 6.0) / 6.0) * 360.0+ // Paused under reduce-motion to avoid continuous redraws on low-resource Macs.+ if self.reduceMotion {RoundedRectangle(cornerRadius: self.layout.cornerRadius).strokeBorder(AngularGradient(@@ -2817,10 +2827,31 @@ struct BottomOverlayView: View {.init(color: .white.opacity(0.06), location: 1.00),]),center: .center,- angle: .degrees(angle)+ angle: .degrees(0)),lineWidth: 1.2)+ } else {+ TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { timeline in+ let seconds = timeline.date.timeIntervalSinceReferenceDate+ let angle = (seconds.truncatingRemainder(dividingBy: 6.0) / 6.0) * 360.0+ RoundedRectangle(cornerRadius: self.layout.cornerRadius)+ .strokeBorder(+ AngularGradient(+ gradient: Gradient(stops: [+ .init(color: .white.opacity(0.06), location: 0.00),+ .init(color: .white.opacity(0.55), location: 0.13),+ .init(color: .white.opacity(0.10), location: 0.30),+ .init(color: .white.opacity(0.03), location: 0.55),+ .init(color: .white.opacity(0.22), location: 0.80),+ .init(color: .white.opacity(0.06), location: 1.00),+ ]),+ center: .center,+ angle: .degrees(angle)+ ),+ lineWidth: 1.2+ )+ }}} else {// Inner borderdiff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex a7b695ab..9d441a7f 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -29,7 +29,7 @@ final class DictationE2ETests: XCTestCase {func testTranscriptionStartSound_noneOptionHasNoFile() {XCTAssertEqual(SettingsStore.TranscriptionStartSound.none.displayName, "None")- XCTAssertNil(SettingsStore.TranscriptionStartSound.none.soundFileName)+ XCTAssertNil(SettingsStore.TranscriptionStartSound.none.startSoundFileName)}func testTranscriptionStartSound_legacyDisabledToggleMigratesToNone() {