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

fix: address 1.6.3 review findings

altic-dev45a31c823049
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index a9d51ad8..b5aaeeef 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -21,6 +21,7 @@ final class SettingsStore: ObservableObject {
static let privateAIDictationSystemOverheadTokens = 1280
static let privateAIDictationMinimumOutputTokens = 256
static let privateAIDictationRoundTripTokenCost = 2.75
+ static let privateAIBackendPreferenceDefaultsKey = "FluidIntelligenceBackendPreference"
private static let forcedOnboardingResetIntroducedAt = Date(timeIntervalSince1970: 1_782_091_732)
private let defaults = UserDefaults.standard
private let keychain = KeychainService.shared
@@ -4723,7 +4724,7 @@ private extension SettingsStore {
static let selectedProviderID = "SelectedProviderID"
static let privateAIPrefixKVCacheEnabled = "PrivateAIProviderPrefixKVCacheEnabled"
static let privateAIBoostEnabled = "PrivateAIProviderBoostEnabled"
- static let privateAIBackendPreference = "FluidIntelligenceBackendPreference"
+ static let privateAIBackendPreference = SettingsStore.privateAIBackendPreferenceDefaultsKey
static let privateAIContextTokenLimit = "PrivateAIProviderContextTokenLimit"
static let privateAIContextDefaultMigratedTo4K = "PrivateAIProviderContextDefaultMigratedTo4K"
static let providerAPIKeys = "ProviderAPIKeys"
diff --git a/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift
index 486d97ca..37640bea 100644
--- a/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift
+++ b/Sources/Fluid/Services/ASRService+SpokenPunctuationFormatting.swift
@@ -103,17 +103,6 @@ private enum SpokenPunctuationFormatter {
}
}
- private static let rulesByFirstWord: [String: [PhraseRule]] = {
- let rules = Self.makeRules()
- let grouped = Dictionary(grouping: rules) { $0.words.first ?? "" }
- return grouped.mapValues {
- $0.sorted {
- if $0.words.count != $1.words.count { return $0.words.count > $1.words.count }
- return $0.words.joined(separator: " ").count > $1.words.joined(separator: " ").count
- }
- }
- }()
-
static func apply(
_ text: String,
prefix: String,
@@ -582,7 +571,12 @@ private enum SpokenPunctuationFormatter {
}
if matched,
!rule.requiresSymbolContext ||
- self.hasSymbolContext(in: tokens, startIndex: index, endIndex: cursor),
+ self.hasSymbolContext(
+ in: tokens,
+ startIndex: index,
+ endIndex: cursor,
+ rulesByFirstWord: rulesByFirstWord
+ ),
!rule.requiresDotContext ||
self.hasDotContext(in: tokens, startIndex: index, endIndex: cursor),
!rule.requiresSlashPathContext ||
@@ -596,21 +590,27 @@ private enum SpokenPunctuationFormatter {
return nil
}
- private static func hasSymbolContext(in tokens: [Token], startIndex: Int, endIndex: Int) -> Bool {
+ private static func hasSymbolContext(
+ in tokens: [Token],
+ startIndex: Int,
+ endIndex: Int,
+ rulesByFirstWord: [String: [PhraseRule]]
+ ) -> Bool {
let previous = self.significantToken(before: startIndex, in: tokens)
let next = self.significantToken(atOrAfter: endIndex, in: tokens)
if let previous, let next {
- return self.isSymbolContextToken(previous) || self.isSymbolContextToken(next) ||
+ return self.isSymbolContextToken(previous, rulesByFirstWord: rulesByFirstWord) ||
+ self.isSymbolContextToken(next, rulesByFirstWord: rulesByFirstWord) ||
(self.isShortSymbolOperand(previous) && self.isShortSymbolOperand(next))
}
if let previous {
- return self.isSymbolContextToken(previous)
+ return self.isSymbolContextToken(previous, rulesByFirstWord: rulesByFirstWord)
}
if let next {
- return self.isSymbolContextToken(next)
+ return self.isSymbolContextToken(next, rulesByFirstWord: rulesByFirstWord)
}
return false
@@ -716,10 +716,13 @@ private enum SpokenPunctuationFormatter {
return nil
}
- private static func isSymbolContextToken(_ token: Token) -> Bool {
+ private static func isSymbolContextToken(
+ _ token: Token,
+ rulesByFirstWord: [String: [PhraseRule]]
+ ) -> Bool {
switch token {
case let .word(_, normalized):
- return self.rulesByFirstWord[normalized]?.contains { $0.symbol != "," && $0.symbol != "." } == true
+ return rulesByFirstWord[normalized]?.contains { $0.symbol != "," && $0.symbol != "." } == true
case let .text(text):
return text.contains { self.symbolCommaCleanupCharacters.contains($0) }
}
diff --git a/Sources/Fluid/Services/PrivateAIProvider.swift b/Sources/Fluid/Services/PrivateAIProvider.swift
index 19ec4d36..18558b67 100644
--- a/Sources/Fluid/Services/PrivateAIProvider.swift
+++ b/Sources/Fluid/Services/PrivateAIProvider.swift
@@ -292,7 +292,7 @@ enum PrivateAIProviderFeature {
}
nonisolated static func verificationFingerprint(for modelID: String) -> String {
- let backendPreference = UserDefaults.standard.string(forKey: "FluidIntelligenceBackendPreference")?
+ let backendPreference = UserDefaults.standard.string(forKey: SettingsStore.privateAIBackendPreferenceDefaultsKey)?
.trimmingCharacters(in: .whitespacesAndNewlines)
.lowercased()
let normalizedBackendPreference: String
diff --git a/Sources/Fluid/Services/WhisperProvider.swift b/Sources/Fluid/Services/WhisperProvider.swift
index 586043ea..7a2c1547 100644
--- a/Sources/Fluid/Services/WhisperProvider.swift
+++ b/Sources/Fluid/Services/WhisperProvider.swift
@@ -318,7 +318,6 @@ final class WhisperProvider: TranscriptionProvider {
}
func modelsExistOnDisk() -> Bool {
- try? FileManager.default.createDirectory(at: self.modelDirectory, withIntermediateDirectories: true)
return self.isModelFileValid(at: self.modelURL, for: self.selectedModel)
}
diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
index 9e16ffa5..2d5864b9 100644
--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
@@ -887,6 +887,15 @@ final class DictationE2ETests: XCTestCase {
XCTAssertTrue(FileManager.default.fileExists(atPath: legacyURL.path))
}
+ func testWhisperProvider_readinessCheckDoesNotCreateMissingDirectory() {
+ let modelDirectory = Self.modelDirectoryForRun()
+ let provider = WhisperProvider(modelDirectory: modelDirectory, modelOverride: .whisperTiny)
+
+ XCTAssertFalse(FileManager.default.fileExists(atPath: modelDirectory.path))
+ XCTAssertFalse(provider.modelsExistOnDisk())
+ XCTAssertFalse(FileManager.default.fileExists(atPath: modelDirectory.path))
+ }
+
func testWhisperProvider_ggufCacheReadinessDoesNotDeleteLegacyUntilExplicitClear() async throws {
let modelDirectory = Self.modelDirectoryForRun()
try FileManager.default.createDirectory(at: modelDirectory, withIntermediateDirectories: true)