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 rendering bugs on extended transcription lengths
grohith3277d9eec2b15ba
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex e4db850a..0f51d999 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -10,6 +10,9 @@ import FluidAudiofinal class SettingsStore: ObservableObject {static let shared = SettingsStore()+ static let transcriptionPreviewCharLimitRange: ClosedRange<Int> = 50...800+ static let transcriptionPreviewCharLimitStep = 50+ static let defaultTranscriptionPreviewCharLimit = 150private let defaults = UserDefaults.standardprivate let keychain = KeychainService.shared@@ -680,20 +683,35 @@ final class SettingsStore: ObservableObject {}}- /// How many recent transcription characters show in overlays (default: 140)+ /// How many recent transcription characters show in overlays (default: 150)var transcriptionPreviewCharLimit: Int {get {let stored = self.defaults.object(forKey: Keys.transcriptionPreviewCharLimit) as? NSNumber- let value = stored?.intValue ?? 140- return max(40, min(2000, value))+ let value = stored?.intValue ?? Self.defaultTranscriptionPreviewCharLimit+ return Self.normalizedTranscriptionPreviewCharLimit(value)}set {+ let clamped = Self.normalizedTranscriptionPreviewCharLimit(newValue)+ guard clamped != self.transcriptionPreviewCharLimit else { return }+objectWillChange.send()- let clamped = max(40, min(2000, newValue))self.defaults.set(clamped, forKey: Keys.transcriptionPreviewCharLimit)+ NotificationCenter.default.post(+ name: NSNotification.Name("TranscriptionPreviewCharLimitChanged"),+ object: nil+ )}}+ private static func normalizedTranscriptionPreviewCharLimit(_ value: Int) -> Int {+ let range = Self.transcriptionPreviewCharLimitRange+ let clamped = max(range.lowerBound, min(range.upperBound, value))+ let offset = clamped - range.lowerBound+ let snappedOffset = Int((Double(offset) / Double(Self.transcriptionPreviewCharLimitStep)).rounded())+ * Self.transcriptionPreviewCharLimitStep+ return max(range.lowerBound, min(range.upperBound, range.lowerBound + snappedOffset))+ }+// MARK: - Preferences Settingsenum AccentColorOption: String, CaseIterable, Identifiable {diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex 1766f484..a44092c0 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -856,35 +856,44 @@ struct SettingsView: View {Divider().padding(.vertical, 8)- HStack {- VStack(alignment: .leading, spacing: 2) {- Text("Transcription Preview Length")- .font(.body)- Text("How many recent characters appear in the notch/pill preview")- .font(.subheadline)+ VStack(alignment: .leading, spacing: 10) {+ HStack(alignment: .top) {+ VStack(alignment: .leading, spacing: 2) {+ Text("Transcription Preview Length")+ .font(.body)+ Text("How many recent characters appear in the notch/pill preview")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Text("\(self.settings.transcriptionPreviewCharLimit) chars")+ .font(.caption.monospaced()).foregroundStyle(.secondary)}- Spacer()+ HStack(spacing: 10) {+ Text("Less")+ .font(.caption)+ .foregroundStyle(.secondary)+ .frame(width: 36, alignment: .trailing)- HStack(spacing: 6) {Slider(value: Binding(get: { Double(self.settings.transcriptionPreviewCharLimit) },set: { self.settings.transcriptionPreviewCharLimit = Int($0.rounded()) }),- in: 40...2000,- step: 10+ in: Double(SettingsStore.transcriptionPreviewCharLimitRange.lowerBound)...Double(SettingsStore.transcriptionPreviewCharLimitRange.upperBound),+ step: Double(SettingsStore.transcriptionPreviewCharLimitStep))- .frame(width: 110)- .controlSize(.small)+ .controlSize(.regular)- Text("\(self.settings.transcriptionPreviewCharLimit) chars")- .font(.caption.monospaced())+ Text("More")+ .font(.caption).foregroundStyle(.secondary)- .frame(width: 90, alignment: .trailing)+ .frame(width: 36, alignment: .leading)}- .frame(width: 200, alignment: .trailing)}// Bottom overlay specific settings (only show when bottom is selected)diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftindex 3258ace9..53a79ac4 100644--- a/Sources/Fluid/Views/BottomOverlayView.swift+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -17,6 +17,7 @@ final class BottomOverlayWindowController {private var window: NSPanel?private var audioSubscription: AnyCancellable?+ private var pendingResizeWorkItem: DispatchWorkItem?private init() {NotificationCenter.default.addObserver(forName: NSNotification.Name("OverlayOffsetChanged"), object: nil, queue: .main) { [weak self] _ in@@ -32,6 +33,9 @@ final class BottomOverlayWindowController {}func show(audioPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {+ self.pendingResizeWorkItem?.cancel()+ self.pendingResizeWorkItem = nil+// Update mode in content stateNotchContentState.shared.mode = modeNotchContentState.shared.updateTranscription("")@@ -68,6 +72,8 @@ final class BottomOverlayWindowController {// Cancel audio subscriptionself.audioSubscription?.cancel()self.audioSubscription = nil+ self.pendingResizeWorkItem?.cancel()+ self.pendingResizeWorkItem = nil// Reset stateNotchContentState.shared.setProcessing(false)@@ -90,7 +96,14 @@ final class BottomOverlayWindowController {}func refreshSizeForContent() {- self.updateSizeAndPosition()+ self.pendingResizeWorkItem?.cancel()++ // Debounce rapid streaming updates to avoid resize thrash.+ let resizeWorkItem = DispatchWorkItem { [weak self] in+ self?.updateSizeAndPosition()+ }+ self.pendingResizeWorkItem = resizeWorkItem+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.03, execute: resizeWorkItem)}/// Update window size based on current SwiftUI content and re-position@@ -305,6 +318,10 @@ struct BottomOverlayView: View {self.layout.transFontSize * 4.2}+ private var previewMaxWidth: CGFloat {+ self.layout.waveformWidth * 2.2+ }+private var transcriptionVerticalPadding: CGFloat {max(4, self.layout.vPadding / 2)}@@ -397,10 +414,13 @@ struct BottomOverlayView: View {.font(.system(size: self.layout.transFontSize, weight: .medium)).foregroundStyle(.white.opacity(0.9)).multilineTextAlignment(.leading)+ .lineLimit(nil)+ .fixedSize(horizontal: false, vertical: true).frame(maxWidth: .infinity, alignment: .leading)Color.clear.frame(height: 1).id("bottom")}- .frame(maxWidth: self.layout.waveformWidth * 2.2, maxHeight: self.previewMaxHeight)+ .frame(width: self.previewMaxWidth)+ .frame(maxHeight: self.previewMaxHeight).clipped().onAppear {DispatchQueue.main.async {@@ -422,7 +442,7 @@ struct BottomOverlayView: View {}}.frame(- maxWidth: self.layout.waveformWidth * 2.2,+ maxWidth: self.previewMaxWidth,minHeight: self.hasTranscription || self.contentState.isProcessing ? self.layout.transFontSize * 1.5 : 0)diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swiftindex b209bced..6da3ec10 100644--- a/Sources/Fluid/Views/NotchContentViews.swift+++ b/Sources/Fluid/Views/NotchContentViews.swift@@ -13,6 +13,8 @@ import SwiftUI@MainActorclass NotchContentState: ObservableObject {static let shared = NotchContentState()+ // Keep overlay state bounded even during very long recordings.+ private static let maxStoredTranscriptionCharacters = SettingsStore.transcriptionPreviewCharLimitRange.upperBound@Published var transcriptionText: String = ""@Published var mode: OverlayMode = .dictation@@ -63,7 +65,12 @@ class NotchContentState: ObservableObject {private init() {- NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)+ let previewLimitChanged = NotificationCenter.default.publisher(+ for: NSNotification.Name("TranscriptionPreviewCharLimitChanged")+ )+ let defaultsChanged = NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)++ Publishers.Merge(previewLimitChanged, defaultsChanged).receive(on: DispatchQueue.main).sink { [weak self] _ inself?.recomputeTranscriptionLines()@@ -78,8 +85,10 @@ class NotchContentState: ObservableObject {/// Update transcription and recompute cached linesfunc updateTranscription(_ text: String) {- guard text != self.transcriptionText else { return }- self.transcriptionText = text+ let boundedText = Self.tailCharacters(in: text, maxCharacters: Self.maxStoredTranscriptionCharacters)+ guard boundedText != self.transcriptionText else { return }++ self.transcriptionText = boundedTextself.recomputeTranscriptionLines()}@@ -88,12 +97,23 @@ class NotchContentState: ObservableObject {let text = self.transcriptionTextguard !text.isEmpty else {- self.cachedPreviewText = ""+ if !self.cachedPreviewText.isEmpty {+ self.cachedPreviewText = ""+ }return}let maxChars = SettingsStore.shared.transcriptionPreviewCharLimit- self.cachedPreviewText = text.count > maxChars ? String(text.suffix(maxChars)) : text+ let previewText = Self.tailCharacters(in: text, maxCharacters: maxChars)+ guard previewText != self.cachedPreviewText else { return }+ self.cachedPreviewText = previewText+ }++ private static func tailCharacters(in text: String, maxCharacters: Int) -> String {+ guard maxCharacters > 0, !text.isEmpty else { return "" }++ let start = text.index(text.endIndex, offsetBy: -maxCharacters, limitedBy: text.startIndex) ?? text.startIndex+ return String(text[start..<text.endIndex])}// MARK: - Recording State for Expanded View@@ -278,6 +298,10 @@ struct NotchExpandedView: View {60}+ private var previewMaxWidth: CGFloat {+ 180+ }+private func handlePromptHover(_ hovering: Bool) {self.promptHoverWorkItem?.cancel()let task = DispatchWorkItem {@@ -423,10 +447,13 @@ struct NotchExpandedView: View {.font(.system(size: 10, weight: .medium)).foregroundStyle(.white.opacity(0.75)).multilineTextAlignment(.leading)+ .lineLimit(nil)+ .fixedSize(horizontal: false, vertical: true).frame(maxWidth: .infinity, alignment: .leading)Color.clear.frame(height: 1).id("bottom")}- .frame(maxWidth: 180, maxHeight: self.previewMaxHeight, alignment: .leading)+ .frame(width: self.previewMaxWidth, alignment: .leading)+ .frame(maxHeight: self.previewMaxHeight, alignment: .leading).clipped().onAppear {DispatchQueue.main.async {@@ -869,6 +896,8 @@ struct NotchCommandOutputExpandedView: View {.font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.75)).multilineTextAlignment(.leading)+ .lineLimit(nil)+ .fixedSize(horizontal: false, vertical: true).frame(maxWidth: .infinity, alignment: .leading)Color.clear.frame(height: 1).id("bottom")}