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(dictionary): allow whitespace-only replacements (e.g. a pasted newline)
Nick Sutcliffe1bb3ff32f60a
diff --git a/Fluid.xcodeproj/project.pbxproj b/Fluid.xcodeproj/project.pbxprojindex f281dd4c..88cacacf 100644--- a/Fluid.xcodeproj/project.pbxproj+++ b/Fluid.xcodeproj/project.pbxproj@@ -14,6 +14,7 @@7C9A71022F58B00000FB7CAF /* TranscribeCpp in Frameworks */ = {isa = PBXBuildFile; productRef = 7C9A71012F58B00000FB7CAF /* TranscribeCpp */; };7C91B0012F42AA0100C0DEF0 /* HotkeyShortcutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C91B0022F42AA0100C0DEF0 /* HotkeyShortcutTests.swift */; };7CDB0A2D2F3C4D5600FB7CAD /* DictationE2ETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CDB0A292F3C4D5600FB7CAD /* DictationE2ETests.swift */; };+ CD1C7A0000000000000000B2 /* CustomDictionaryManualEntryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1C7A0000000000000000B1 /* CustomDictionaryManualEntryTests.swift */; };7CDB0A2E2F3C4D5600FB7CAD /* AudioFixtureLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CDB0A2A2F3C4D5600FB7CAD /* AudioFixtureLoader.swift */; };86CAA2D4EF18433096185602 /* LLMClientRequestBodyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 343B29013F4441D6A797D12D /* LLMClientRequestBodyTests.swift */; };272BFB5CB271489892CAE50C /* TemperatureSupportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 980330F3CE464336ADCE3E23 /* TemperatureSupportTests.swift */; };@@ -63,6 +64,7 @@7C91B0022F42AA0100C0DEF0 /* HotkeyShortcutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotkeyShortcutTests.swift; sourceTree = "<group>"; };7CDB0A202F3C4D5600FB7CAD /* FluidDictationIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FluidDictationIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };7CDB0A292F3C4D5600FB7CAD /* DictationE2ETests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DictationE2ETests.swift; sourceTree = "<group>"; };+ CD1C7A0000000000000000B1 /* CustomDictionaryManualEntryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDictionaryManualEntryTests.swift; sourceTree = "<group>"; };7CFA1D0B2F500000C0DEF002 /* TypingServiceTransientPasteboardTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypingServiceTransientPasteboardTests.swift; sourceTree = "<group>"; };7CDB0A2A2F3C4D5600FB7CAD /* AudioFixtureLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioFixtureLoader.swift; sourceTree = "<group>"; };7CDB0A2B2F3C4D5600FB7CAD /* dictation_fixture.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = dictation_fixture.wav; sourceTree = "<group>"; };@@ -133,6 +135,7 @@7CDB0A262F3C4D5600FB7CAD /* Helpers */,7CDB0A272F3C4D5600FB7CAD /* Resources */,7CDB0A292F3C4D5600FB7CAD /* DictationE2ETests.swift */,+ CD1C7A0000000000000000B1 /* CustomDictionaryManualEntryTests.swift */,7C91B0022F42AA0100C0DEF0 /* HotkeyShortcutTests.swift */,343B29013F4441D6A797D12D /* LLMClientRequestBodyTests.swift */,980330F3CE464336ADCE3E23 /* TemperatureSupportTests.swift */,@@ -295,6 +298,7 @@files = (7CDB0A2E2F3C4D5600FB7CAD /* AudioFixtureLoader.swift in Sources */,7CDB0A2D2F3C4D5600FB7CAD /* DictationE2ETests.swift in Sources */,+ CD1C7A0000000000000000B2 /* CustomDictionaryManualEntryTests.swift in Sources */,7C91B0012F42AA0100C0DEF0 /* HotkeyShortcutTests.swift in Sources */,86CAA2D4EF18433096185602 /* LLMClientRequestBodyTests.swift in Sources */,272BFB5CB271489892CAE50C /* TemperatureSupportTests.swift in Sources */,diff --git a/Sources/Fluid/UI/CustomDictionaryView.swift b/Sources/Fluid/UI/CustomDictionaryView.swiftindex d03d4957..cea4ec2a 100644--- a/Sources/Fluid/UI/CustomDictionaryView.swift+++ b/Sources/Fluid/UI/CustomDictionaryView.swift@@ -189,9 +189,13 @@ struct CustomDictionaryView: View {self.manualTriggers.filter { self.allExistingTriggers().contains($0) }}+ private var sanitizedManualReplacement: String {+ CustomDictionaryManualEntry.sanitizedReplacement(self.manualReplacement)+ }+private var canAddManualReplacement: Bool {!self.manualTriggers.isEmpty &&- !self.manualReplacement.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&+ !self.sanitizedManualReplacement.isEmpty &&self.manualDuplicateTriggers.isEmpty}@@ -580,7 +584,7 @@ struct CustomDictionaryView: View {.font(self.theme.typography.caption).foregroundStyle(self.theme.palette.tertiaryText)- Text(self.manualReplacement.trimmingCharacters(in: .whitespacesAndNewlines))+ Text(CustomDictionaryManualEntry.replacementDisplayText(self.sanitizedManualReplacement)).font(self.theme.typography.captionStrong).foregroundStyle(self.theme.palette.accent)}@@ -1603,7 +1607,7 @@ struct CustomDictionaryView: View {guard self.canAddManualReplacement else { return }let entry = SettingsStore.CustomDictionaryEntry(triggers: self.manualTriggers,- replacement: self.manualReplacement.trimmingCharacters(in: .whitespacesAndNewlines)+ replacement: self.sanitizedManualReplacement)self.addReplacementEntry(entry)self.manualTriggerDraft = ""@@ -2667,6 +2671,28 @@ enum CustomDictionaryManualEntry {return self.normalizedTriggers(trimmed.split(separator: ",").map(String.init))}++ /// A replacement that is entirely whitespace (e.g. a pasted newline or space)+ /// is a deliberate payload — keep it verbatim instead of trimming it to empty.+ static func sanitizedReplacement(_ text: String) -> String {+ let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)+ return trimmed.isEmpty ? text : trimmed+ }++ /// Whitespace-only replacements render as invisible/blank text, so show+ /// them as symbols (⏎ ␣ ⇥) in previews and entry rows.+ static func replacementDisplayText(_ replacement: String) -> String {+ guard !replacement.isEmpty, replacement.allSatisfy(\.isWhitespace) else { return replacement }+ return replacement.map { character -> String in+ if character.isNewline {+ return "⏎"+ }+ if character == "\t" {+ return "⇥"+ }+ return "␣"+ }.joined()+ }}enum PronunciationProfileEditPolicy {@@ -3081,7 +3107,7 @@ struct DictionaryEntryRow: View {.font(self.theme.typography.caption).foregroundStyle(self.theme.palette.tertiaryText)- Text(self.entry.replacement)+ Text(CustomDictionaryManualEntry.replacementDisplayText(self.entry.replacement)).font(self.theme.typography.bodySmallStrong).foregroundStyle(self.theme.palette.accent).frame(maxWidth: .infinity, alignment: .leading)@@ -3352,7 +3378,7 @@ struct EditDictionaryEntrySheet: View {private var canSave: Bool {!self.parseTriggers().isEmpty &&- !self.replacement.trimmingCharacters(in: .whitespaces).isEmpty &&+ !CustomDictionaryManualEntry.sanitizedReplacement(self.replacement).isEmpty &&self.duplicateTriggers.isEmpty}@@ -3434,9 +3460,11 @@ struct EditDictionaryEntrySheet: View {.font(.caption).foregroundStyle(.tertiary)- Text(self.replacement)- .font(.caption.weight(.medium))- .foregroundStyle(self.theme.palette.accent)+ Text(CustomDictionaryManualEntry.replacementDisplayText(+ CustomDictionaryManualEntry.sanitizedReplacement(self.replacement)+ ))+ .font(.caption.weight(.medium))+ .foregroundStyle(self.theme.palette.accent)}}.padding(10)@@ -3483,7 +3511,7 @@ struct EditDictionaryEntrySheet: View {let updatedEntry = SettingsStore.CustomDictionaryEntry(id: self.entry.id,triggers: self.parseTriggers(),- replacement: self.replacement.trimmingCharacters(in: .whitespaces)+ replacement: CustomDictionaryManualEntry.sanitizedReplacement(self.replacement))self.onSave(updatedEntry)self.dismiss()diff --git a/Tests/FluidDictationIntegrationTests/CustomDictionaryManualEntryTests.swift b/Tests/FluidDictationIntegrationTests/CustomDictionaryManualEntryTests.swiftnew file mode 100644index 00000000..736e1446--- /dev/null+++ b/Tests/FluidDictationIntegrationTests/CustomDictionaryManualEntryTests.swift@@ -0,0 +1,21 @@+@testable import FluidVoice_Debug+import XCTest++final class CustomDictionaryManualEntryTests: XCTestCase {+ func testKeepsWhitespaceOnlyReplacements() {+ XCTAssertEqual(CustomDictionaryManualEntry.sanitizedReplacement("\n"), "\n")+ XCTAssertEqual(CustomDictionaryManualEntry.sanitizedReplacement(" "), " ")+ XCTAssertEqual(CustomDictionaryManualEntry.sanitizedReplacement("\t"), "\t")+ XCTAssertEqual(CustomDictionaryManualEntry.sanitizedReplacement(""), "")+ XCTAssertEqual(CustomDictionaryManualEntry.sanitizedReplacement(" FluidVoice \n"), "FluidVoice")+ }++ func testRendersWhitespaceReplacementsVisibly() {+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText("\n"), "⏎")+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText(" "), "␣")+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText("\t"), "⇥")+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText(" \n"), "␣⏎")+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText("FluidVoice"), "FluidVoice")+ XCTAssertEqual(CustomDictionaryManualEntry.replacementDisplayText(""), "")+ }+}