Skip to content

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: add Continuous Dictation Mode for chaining transcriptions

altic-dev6598842b4b40
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index d8bd62eb..242ae4da 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -112,7 +112,7 @@ enum ShortcutRecordingTarget: Hashable {
// NOTE: Streaming and AI response parsing is now handled by LLMClient
-// swiftlint:disable type_body_length
+// swiftlint:disable type_body_length file_length
struct ContentView: View {
private enum ActiveRecordingMode: String {
case none
@@ -178,6 +178,7 @@ struct ContentView: View {
@State private var previousSidebarItem: SidebarItem? = nil // Track previous for mode transitions
@State private var playgroundUsed: Bool = SettingsStore.shared.playgroundUsed
@State private var recordingAppInfo: (name: String, bundleId: String, windowTitle: String)? = nil
+ @State private var recordingPrecedingText: String = ""
// Command Mode State
// @State private var showCommandMode: Bool = false
@@ -1442,6 +1443,18 @@ struct ContentView: View {
"Captured recording app context: app=\(info.name), bundleId=\(info.bundleId), title=\(info.windowTitle)",
source: "ContentView"
)
+
+ // Capture text before the caret for Continuous Dictation Mode smart caps.
+ // Only read the field when the feature is enabled (low-resource: one AX round-trip).
+ if SettingsStore.shared.continuousDictationModeEnabled {
+ self.recordingPrecedingText = TypingService.textBeforeCursorInFocusedField()
+ DebugLogger.shared.debug(
+ "Captured preceding text for continuous dictation (chars=\(self.recordingPrecedingText.count))",
+ source: "ContentView"
+ )
+ } else {
+ self.recordingPrecedingText = ""
+ }
}
private func resolveTypingTargetPID() -> (pid: pid_t?, shouldRestoreOriginalFocus: Bool) {
@@ -2062,6 +2075,10 @@ struct ContentView: View {
// Apply GAAV formatting as the FINAL step (after AI post-processing)
// This ensures the user's preference for no capitalization/period is respected
finalText = ASRService.applyGAAVFormatting(finalText)
+ // Apply Continuous Dictation Mode after GAAV so smart caps use the field
+ // context captured at recording start, and the trailing space enables chaining.
+ finalText = ASRService.applyContinuousDictationFormatting(finalText, precedingText: self.recordingPrecedingText)
+ self.recordingPrecedingText = ""
self.asr.finalText = finalText
if route == .onboardingSandbox,
self.isOnboardingVoicePlaygroundStepActive,
@@ -2353,7 +2370,11 @@ struct ContentView: View {
self.cancelPrewarmDictationIfNeeded()
}
- let finalText = ASRService.applyGAAVFormatting(text)
+ let gaavText = ASRService.applyGAAVFormatting(text)
+ let precedingText = SettingsStore.shared.continuousDictationModeEnabled
+ ? TypingService.textBeforeCursorInFocusedField()
+ : ""
+ let finalText = ASRService.applyContinuousDictationFormatting(gaavText, precedingText: precedingText)
let appInfo = self.getCurrentAppInfo()
if saveToHistory, SettingsStore.shared.saveTranscriptionHistory {
@@ -2431,6 +2452,8 @@ struct ContentView: View {
self.menuBarManager.setProcessing(false)
finalText = ASRService.applyGAAVFormatting(finalText)
+ finalText = ASRService.applyContinuousDictationFormatting(finalText, precedingText: self.recordingPrecedingText)
+ self.recordingPrecedingText = ""
if SettingsStore.shared.saveTranscriptionHistory {
TranscriptionHistoryStore.shared.addEntry(
diff --git a/Sources/Fluid/Persistence/BackupService.swift b/Sources/Fluid/Persistence/BackupService.swift
index 5662adc5..1a3ea706 100644
--- a/Sources/Fluid/Persistence/BackupService.swift
+++ b/Sources/Fluid/Persistence/BackupService.swift
@@ -67,6 +67,7 @@ struct SettingsBackupPayload: Codable, Equatable {
let fillerWords: [String]
let removeFillerWordsEnabled: Bool
let gaavModeEnabled: Bool
+ let continuousDictationModeEnabled: Bool
let pauseMediaDuringTranscription: Bool
let vocabularyBoostingEnabled: Bool
let customDictionaryEntries: [SettingsStore.CustomDictionaryEntry]
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index 7c217d1b..d799b240 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -2688,6 +2688,7 @@ final class SettingsStore: ObservableObject {
fillerWords: self.fillerWords,
removeFillerWordsEnabled: self.removeFillerWordsEnabled,
gaavModeEnabled: self.gaavModeEnabled,
+ continuousDictationModeEnabled: self.continuousDictationModeEnabled,
pauseMediaDuringTranscription: self.pauseMediaDuringTranscription,
vocabularyBoostingEnabled: self.vocabularyBoostingEnabled,
customDictionaryEntries: self.customDictionaryEntries,
@@ -2779,6 +2780,7 @@ final class SettingsStore: ObservableObject {
self.fillerWords = payload.fillerWords
self.removeFillerWordsEnabled = payload.removeFillerWordsEnabled
self.gaavModeEnabled = payload.gaavModeEnabled
+ self.continuousDictationModeEnabled = payload.continuousDictationModeEnabled
self.pauseMediaDuringTranscription = payload.pauseMediaDuringTranscription
self.vocabularyBoostingEnabled = payload.vocabularyBoostingEnabled
self.customDictionaryEntries = payload.customDictionaryEntries
@@ -3372,6 +3374,20 @@ final class SettingsStore: ObservableObject {
}
}
+ // MARK: - Continuous Dictation Mode
+
+ /// Continuous Dictation Mode: Appends a trailing space to transcriptions and adjusts
+ /// capitalization based on the text already in the focused field, so multiple dictation
+ /// segments chain naturally without manual spacebar presses.
+ /// Implements the chaining behavior requested in GitHub issue #390.
+ var continuousDictationModeEnabled: Bool {
+ get { self.defaults.object(forKey: Keys.continuousDictationModeEnabled) as? Bool ?? false }
+ set {
+ objectWillChange.send()
+ self.defaults.set(newValue, forKey: Keys.continuousDictationModeEnabled)
+ }
+ }
+
// MARK: - Media Playback Control
/// When enabled, automatically pauses system media playback when transcription starts.
@@ -4204,6 +4220,9 @@ private extension SettingsStore {
/// GAAV Mode (removes capitalization and trailing punctuation)
static let gaavModeEnabled = "GAAVModeEnabled"
+ /// Continuous Dictation Mode (append trailing space + smart caps for chaining)
+ static let continuousDictationModeEnabled = "ContinuousDictationModeEnabled"
+
// Custom Dictionary
static let customDictionaryEntries = "CustomDictionaryEntries"
static let vocabularyBoostingEnabled = "VocabularyBoostingEnabled"
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index cec687d1..a625b4c8 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -2923,6 +2923,47 @@ final class ASRService: ObservableObject {
return result
}
+
+ // MARK: - Continuous Dictation Mode Formatting
+
+ /// Applies Continuous Dictation Mode formatting so transcribed segments chain naturally.
+ /// - Appends a trailing space so the next dictation continues without a manual spacebar press.
+ /// - Adjusts capitalization based on the text already in the field: if the preceding text
+ /// (after trimming trailing whitespace) ends with sentence-ending punctuation (.!?), the
+ /// first character is capitalized; otherwise it is lowercased so segments flow inline.
+ /// An empty field is treated as a sentence start (capitalized).
+ /// Only applied when `continuousDictationModeEnabled` is on.
+ ///
+ /// Implements the chaining behavior requested in GitHub issue #390.
+ static func applyContinuousDictationFormatting(_ text: String, precedingText: String) -> String {
+ guard SettingsStore.shared.continuousDictationModeEnabled else { return text }
+ guard !text.isEmpty else { return text }
+
+ var result = text
+
+ let precedingTrimmed = precedingText.trimmingCharacters(in: .whitespacesAndNewlines)
+ if precedingTrimmed.isEmpty {
+ // Empty field = sentence start: capitalize first alphabetic character.
+ if let first = result.first, first.isLetter, first.isLowercase {
+ result = first.uppercased() + result.dropFirst()
+ }
+ } else if let lastChar = precedingTrimmed.last, lastChar.isLetter || lastChar.isNumber {
+ // Last char before cursor is alphanumeric (no terminal punctuation): lowercase the
+ // first character so this segment flows inline with the existing text.
+ if let first = result.first, first.isUppercase {
+ result = first.lowercased() + result.dropFirst()
+ }
+ }
+ // If preceding text ends with .!? (or any other punctuation), leave the model's
+ // capitalization as-is (sentence start).
+
+ // Append a trailing space so the next dictation chains without a manual spacebar press.
+ if !result.hasSuffix(" ") {
+ result += " "
+ }
+
+ return result
+ }
}
// swiftlint:enable type_body_length
diff --git a/Sources/Fluid/Services/TypingService.swift b/Sources/Fluid/Services/TypingService.swift
index 26e5b9ee..cf9b4ba0 100644
--- a/Sources/Fluid/Services/TypingService.swift
+++ b/Sources/Fluid/Services/TypingService.swift
@@ -169,6 +169,47 @@ final class TypingService {
return pid
}
+ /// Best-effort: returns the text immediately before the caret in the currently focused
+ /// text field. Used by Continuous Dictation Mode to decide capitalization when chaining
+ /// transcribed segments. Returns "" when the focused field/context is unavailable.
+ /// Low-resource: single AX round-trip with a range fallback; no polling, no timers.
+ static func textBeforeCursorInFocusedField() -> String {
+ guard AXIsProcessTrusted() else { return "" }
+
+ let systemWideElement = AXUIElementCreateSystemWide()
+ var focusedElementRef: CFTypeRef?
+ let result = AXUIElementCopyAttributeValue(
+ systemWideElement,
+ kAXFocusedUIElementAttribute as CFString,
+ &focusedElementRef
+ )
+ guard result == .success, let focusedElementRef else { return "" }
+ guard CFGetTypeID(focusedElementRef) == AXUIElementGetTypeID() else { return "" }
+ let element = unsafeBitCast(focusedElementRef, to: AXUIElement.self)
+
+ var rangeRef: CFTypeRef?
+ let rangeResult = AXUIElementCopyAttributeValue(
+ element,
+ kAXSelectedTextRangeAttribute as CFString,
+ &rangeRef
+ )
+ guard rangeResult == .success, let rangeRef else { return "" }
+ guard CFGetTypeID(rangeRef) == AXValueGetTypeID() else { return "" }
+
+ var range = CFRange()
+ guard AXValueGetValue(unsafeBitCast(rangeRef, to: AXValue.self), .cfRange, &range) else { return "" }
+ guard range.location != kCFNotFound, range.location >= 0 else { return "" }
+
+ var valueRef: CFTypeRef?
+ let valueResult = AXUIElementCopyAttributeValue(element, kAXValueAttribute as CFString, &valueRef)
+ guard valueResult == .success, let fullText = valueRef as? String else { return "" }
+
+ let nsText = fullText as NSString
+ let location = min(range.location, nsText.length)
+ guard location > 0 else { return "" }
+ return nsText.substring(with: NSRange(location: 0, length: location))
+ }
+
@discardableResult
static func restoreCapturedFocus(in pid: pid_t) -> Bool {
guard AXIsProcessTrusted() else { return false }
diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swift
index 25515090..2acc0f94 100644
--- a/Sources/Fluid/UI/SettingsView.swift
+++ b/Sources/Fluid/UI/SettingsView.swift
@@ -877,6 +877,17 @@ struct SettingsView: View {
)
Divider().opacity(0.2)
+ self.optionToggleRow(
+ title: "Continuous Dictation Mode",
+ description: "Append a trailing space and adjust capitalization so consecutive dictations chain naturally. "
+ + "Smart caps: if the text in the field ends with a period, the next segment starts capitalized; otherwise it flows inline.",
+ isOn: Binding(
+ get: { SettingsStore.shared.continuousDictationModeEnabled },
+ set: { SettingsStore.shared.continuousDictationModeEnabled = $0 }
+ )
+ )
+ Divider().opacity(0.2)
+
self.optionToggleRow(
title: "Pause Media During Transcription",
description: "Automatically pause currently playing audio/video when transcription starts. Resumes only if FluidVoice paused it.",