Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
feat(overlay): make closing animation an opt-in setting
altic-deva1b9adfafc09
diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swiftindex 42f09c2d..5e93484b 100644--- a/Sources/Fluid/Persistence/BackupService.swift+++ b/Sources/Fluid/Persistence/BackupService.swift@@ -90,6 +90,7 @@ struct SettingsBackupPayload: Codable, Equatable {let overlayGlassOpacity: Double?let overlayTint: SettingsStore.OverlayTint?let overlayHighlight: Double?+ let overlayClosingAnimationEnabled: Bool?let transcriptionPreviewCharLimit: Intlet userTypingWPM: Intlet saveTranscriptionHistory: Booldiff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex afff234e..f1ca9fc9 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -2196,6 +2196,16 @@ final class SettingsStore: ObservableObject {static let overlayGlassOpacityRange = 0.25...1.0static let defaultOverlayGlassOpacity = 0.8+ /// Keep cosmetic dismissal out of the stop path unless explicitly enabled.+ var overlayClosingAnimationEnabled: Bool {+ get { self.defaults.bool(forKey: "OverlayClosingAnimationEnabled") }+ set {+ guard newValue != self.overlayClosingAnimationEnabled else { return }+ objectWillChange.send()+ self.defaults.set(newValue, forKey: "OverlayClosingAnimationEnabled")+ }+ }+enum OverlayTint: String, CaseIterable, Codable {case ocean, violet, rose, mint, amber}@@ -3475,6 +3485,7 @@ final class SettingsStore: ObservableObject {overlayGlassOpacity: self.overlayGlassOpacity,overlayTint: self.overlayTint,overlayHighlight: self.overlayHighlight,+ overlayClosingAnimationEnabled: self.overlayClosingAnimationEnabled,transcriptionPreviewCharLimit: self.transcriptionPreviewCharLimit,userTypingWPM: self.userTypingWPM,saveTranscriptionHistory: self.saveTranscriptionHistory,@@ -3647,6 +3658,9 @@ final class SettingsStore: ObservableObject {if let overlayHighlight = payload.overlayHighlight {self.overlayHighlight = overlayHighlight}+ if let enabled = payload.overlayClosingAnimationEnabled {+ self.overlayClosingAnimationEnabled = enabled+ }self.transcriptionPreviewCharLimit = payload.transcriptionPreviewCharLimitself.userTypingWPM = payload.userTypingWPMself.saveTranscriptionHistory = payload.saveTranscriptionHistorydiff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swiftindex 1526cf27..20fbefa1 100644--- a/Sources/Fluid/Services/MenuBarManager.swift+++ b/Sources/Fluid/Services/MenuBarManager.swift@@ -444,29 +444,47 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {}}- /// Removes the successful recording overlay after insertion completes. There- /// is intentionally no separate exit animation on this latency-critical path.+ /// Removes the completed recording overlay immediately unless the optional+ /// closing transition is enabled.func beginProcessingCompletionAndHideOverlay() {let startedAt = ProcessInfo.processInfo.systemUptimeself.prepareForProcessingCompletion()- self.overlayBench("finish_hide_request mode=immediate")- NotchOverlayManager.shared.hideImmediately()+ self.overlayBench("finish_hide_request closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled)")+ NotchOverlayManager.shared.hide()+ let windowHideReturnedAt = ProcessInfo.processInfo.systemUptimeself.flushDeferredStoppedRecordingState()+ DebugLogger.shared.info(+ "HIDE_NOW windowHideUs=\(Int((windowHideReturnedAt - startedAt) * 1_000_000)) " ++ "menuRefreshUs=\(Int((ProcessInfo.processInfo.systemUptime - windowHideReturnedAt) * 1_000_000))",+ source: "StopTiming"+ )+ DebugLogger.shared.info("STOP_TRACE phase=hide_dispatched closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled) elapsedMs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1000))", source: "StopTiming")self.overlayBench(- "finish_hide_complete mode=immediate elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))"+ "finish_hide_dispatched elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))")}/// Ends processing and waits for the recording overlay's exit transition./// Use only when the caller must know the overlay has fully disappeared.func finishProcessingAndHideOverlay() async {+ guard SettingsStore.shared.overlayClosingAnimationEnabled else {+ self.beginProcessingCompletionAndHideOverlay()+ return+ }let startedAt = ProcessInfo.processInfo.systemUptimeself.prepareForProcessingCompletion()+ DebugLogger.shared.info("HIDE_TRACE phase=completion_prepared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")NotchOverlayManager.shared.setProcessing(false)+ DebugLogger.shared.info("HIDE_TRACE phase=processing_cleared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")self.overlayBench("finish_hide_request mode=awaited")let hideOutcome = await NotchOverlayManager.shared.hideAndWait()+ let hiddenAt = ProcessInfo.processInfo.systemUptimeself.flushDeferredStoppedRecordingState()+ DebugLogger.shared.info(+ "STOP_TRACE phase=overlay_hidden hideMs=\(Int((hiddenAt - startedAt) * 1000)) menuRefreshMs=\(Int((ProcessInfo.processInfo.systemUptime - hiddenAt) * 1000))",+ source: "StopTiming"+ )self.overlayBench("finish_hide_complete outcome=\(hideOutcome) elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))")diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swiftindex 4ee2cb73..afcbd31c 100644--- a/Sources/Fluid/Services/NotchOverlayManager.swift+++ b/Sources/Fluid/Services/NotchOverlayManager.swift@@ -310,6 +310,10 @@ final class NotchOverlayManager {}func hide() {+ guard SettingsStore.shared.overlayClosingAnimationEnabled else {+ self.hideImmediately()+ return+ }guard !self.isHideInProgress else { return }self.isHideInProgress = trueself.generation &+= 1@@ -328,6 +332,8 @@ final class NotchOverlayManager {/// Removes a successfully completed recording overlay synchronously so it/// cannot outlive the text insertion that follows.func hideImmediately() {+ var trace = OverlayCloseTrace("manager.hide")+ defer { trace.finish() }let startedAt = ProcessInfo.processInfo.systemUptimeself.generation &+= 1let currentGeneration = self.generation@@ -345,17 +351,26 @@ final class NotchOverlayManager {if self.notch != nil || self.state != .idle {self.retireCurrentNotchImmediately(reason: "completed_output")}+ trace.mark("bottomAndNotchRemoved")waiters.forEach { $0.resume(returning: .hidden) }Self.overlayBench("hide_immediate_complete elapsedMs=\(Self.elapsedMs(since: startedAt))")Task { @MainActor [weak self] in+ var cleanupTrace = OverlayCloseTrace("manager.deferredCleanup")+ cleanupTrace.mark("scheduledDelay", since: startedAt)+ defer { cleanupTrace.finish() }await Task.yield()+ cleanupTrace.mark("yield")guard let self, self.generation == currentGeneration else { return }ActiveAppMonitor.shared.stopMonitoring()+ cleanupTrace.mark("stopMonitoring")NotchContentState.shared.setProcessing(false)+ cleanupTrace.mark("processingFalse")NotchContentState.shared.updateTranscription("")+ cleanupTrace.mark("clearTranscription")NotchContentState.shared.setSpokenSendIndicatorState(.hidden)+ cleanupTrace.mark("clearIndicator")Self.overlayBench("hide_immediate_cleanup_complete")}}@@ -363,6 +378,10 @@ final class NotchOverlayManager {/// Reports whether the active overlay finished hiding or a newer/// presentation superseded this request.func hideAndWait() async -> RecordingOverlayHideOutcome {+ guard SettingsStore.shared.overlayClosingAnimationEnabled else {+ self.hideImmediately()+ return .hidden+ }if self.isHideInProgress {return await withCheckedContinuation { continuation inself.hideWaiters.append(continuation)@@ -388,10 +407,12 @@ final class NotchOverlayManager {// Stop monitoring active app changesActiveAppMonitor.shared.stopMonitoring()+ DebugLogger.shared.info("HIDE_TRACE phase=monitor_stopped elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")// Hide bottom overlay if visibleif self.isBottomOverlayVisible {let bottomOutcome = await BottomOverlayWindowController.shared.hideAndWait()+ DebugLogger.shared.info("HIDE_TRACE phase=bottom_returned elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")guard bottomOutcome == .hidden else {Self.overlayBench("hide_return reason=bottom_superseded")return .supersededdiff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex ca034bcc..d16846bd 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -1350,6 +1350,10 @@ struct SettingsView: View {.font(self.theme.typography.bodyStrong).padding(.bottom, 4)+ self.overlayClosingAnimationSetting++ Divider().padding(.vertical, 8)+// Overlay PositionHStack {VStack(alignment: .leading, spacing: 2) {@@ -2263,6 +2267,19 @@ struct SettingsView: View {}private extension SettingsView {+ var overlayClosingAnimationSetting: some View {+ Toggle(isOn: self.$settings.overlayClosingAnimationEnabled) {+ VStack(alignment: .leading, spacing: 2) {+ Text("Animate overlay closing")+ .font(self.theme.typography.bodyStrong)+ Text("Off closes immediately. Turn on to try the closing transition.")+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.settingsSecondaryText)+ }+ }+ .toggleStyle(.switch)+ }+var overlayMaterialSettings: some View {OverlayAppearanceEditor()}diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex d52b3523..a342f24b 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -261,6 +261,9 @@ final class HotkeyShortcutTests: XCTestCase {@MainActorfunc testBottomOverlayRapidStopStartStopDoesNotDropFinalHide() async {+ let previous = SettingsStore.shared.overlayClosingAnimationEnabled+ SettingsStore.shared.overlayClosingAnimationEnabled = true+ defer { SettingsStore.shared.overlayClosingAnimationEnabled = previous }let audioPublisher = Just(CGFloat.zero).eraseToAnyPublisher()let controller = BottomOverlayWindowController.shared@@ -282,6 +285,9 @@ final class HotkeyShortcutTests: XCTestCase {@MainActorfunc testBottomOverlayReportsWhenRapidRestartSupersedesHide() async {+ let previous = SettingsStore.shared.overlayClosingAnimationEnabled+ SettingsStore.shared.overlayClosingAnimationEnabled = true+ defer { SettingsStore.shared.overlayClosingAnimationEnabled = previous }let audioPublisher = Just(CGFloat.zero).eraseToAnyPublisher()let controller = BottomOverlayWindowController.shared@@ -300,6 +306,29 @@ final class HotkeyShortcutTests: XCTestCase {_ = await controller.hideAndWait()}+ @MainActor+ func testDisabledClosingAnimationHidesWithoutDismissalAndAllowsImmediateRestart() async {+ let previous = SettingsStore.shared.overlayClosingAnimationEnabled+ SettingsStore.shared.overlayClosingAnimationEnabled = false+ defer { SettingsStore.shared.overlayClosingAnimationEnabled = previous }+ let controller = BottomOverlayWindowController.shared+ let audioPublisher = Just(CGFloat.zero).eraseToAnyPublisher()+ controller.show(audioPublisher: audioPublisher, mode: .dictation)++ let outcome = await controller.hideAndWait()+ XCTAssertEqual(outcome, .hidden)+ XCTAssertTrue(controller.isVisuallyHiddenForTests)+ XCTAssertFalse(NotchContentState.shared.isBottomOverlayDismissing)+ XCTAssertFalse(NotchContentState.shared.isBottomOverlayReleaseTransitioning)++ controller.show(audioPublisher: audioPublisher, mode: .dictation)+ await Task.yield()+ XCTAssertFalse(controller.isVisuallyHiddenForTests, "Old deferred cleanup must not hide the new recording")+ controller.hide()+ XCTAssertTrue(controller.isVisuallyHiddenForTests)+ XCTAssertFalse(NotchContentState.shared.isBottomOverlayDismissing)+ }+@MainActorfunc testBottomOverlayImmediateHideCompletesBeforeReturningAndAllowsRestart() async {let audioPublisher = Just(CGFloat.zero).eraseToAnyPublisher()