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
test split dictation budget coverage
altic-dev268fa8b9cc80
diff --git a/Fluid.xcodeproj/project.pbxproj b/Fluid.xcodeproj/project.pbxprojindex 214ba6aa..a3a68d7f 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 */; };+ B52000000000000000000002 /* PrivateAIDictationTokenBudgetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52000000000000000000001 /* PrivateAIDictationTokenBudgetTests.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 */; };@@ -71,6 +72,7 @@DA7100010000000000000001 /* DirectAudioReliabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectAudioReliabilityTests.swift; sourceTree = "<group>"; };B51800000000000000000001 /* SpokenSendTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpokenSendTests.swift; sourceTree = "<group>"; };B51900000000000000000001 /* PrivateAIProviderPromptFormatTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateAIProviderPromptFormatTests.swift; sourceTree = "<group>"; };+ B52000000000000000000001 /* PrivateAIDictationTokenBudgetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateAIDictationTokenBudgetTests.swift; sourceTree = "<group>"; };C0DE63700000000000000001 /* WhisperLanguageSelectionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhisperLanguageSelectionTests.swift; sourceTree = "<group>"; };7C078D8F2E3B339200FB7CAC /* FluidVoice Debug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "FluidVoice Debug.app"; sourceTree = BUILT_PRODUCTS_DIR; };7C91B0022F42AA0100C0DEF0 /* HotkeyShortcutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HotkeyShortcutTests.swift; sourceTree = "<group>"; };@@ -163,6 +165,7 @@803000000000000000000001 /* MediaPlaybackServiceTests.swift */,B51800000000000000000001 /* SpokenSendTests.swift */,B51900000000000000000001 /* PrivateAIProviderPromptFormatTests.swift */,+ B52000000000000000000001 /* PrivateAIDictationTokenBudgetTests.swift */,C0DE63700000000000000001 /* WhisperLanguageSelectionTests.swift */,);path = FluidDictationIntegrationTests;@@ -321,6 +324,7 @@files = (7CDB0A2E2F3C4D5600FB7CAD /* AudioFixtureLoader.swift in Sources */,7CDB0A2D2F3C4D5600FB7CAD /* DictationE2ETests.swift in Sources */,+ B52000000000000000000002 /* PrivateAIDictationTokenBudgetTests.swift in Sources */,CD1C7A0000000000000000B2 /* CustomDictionaryManualEntryTests.swift in Sources */,7C91B0012F42AA0100C0DEF0 /* HotkeyShortcutTests.swift in Sources */,86CAA2D4EF18433096185602 /* LLMClientRequestBodyTests.swift in Sources */,diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swiftindex 42127792..641ecca6 100644--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift@@ -1830,98 +1830,6 @@ final class DictationE2ETests: XCTestCase {}}- func testPrivateAIDictationTokenBudgetFallsBackBeforeLongInputCanTruncate() {- let shortTranscript = Array(repeating: "word", count: 600).joined(separator: " ")- let longTranscript = Array(repeating: "word", count: 3_385).joined(separator: " ")- let tokenDenseIdentifier = String(repeating: "a", count: 6_000)- let unspacedCJKTranscript = String(repeating: "漢", count: 2_500)-- XCTAssertTrue(SettingsStore.privateAIDictationTokenBudget(- forInputText: shortTranscript,- contextTokenLimit: 4096- ).hasSufficientHeadroom)- XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(- forInputText: longTranscript,- contextTokenLimit: 4096- ).hasSufficientHeadroom)- XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(- forInputText: tokenDenseIdentifier,- contextTokenLimit: 4096- ).hasSufficientHeadroom)- XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(- forInputText: unspacedCJKTranscript,- contextTokenLimit: 4096- ).hasSufficientHeadroom)- }-- func testPrivateAIDictationRejectsLongInputBeforeCallingProvider() async {- let longTranscript = Array(repeating: "word", count: 3_385).joined(separator: " ")- let runtime = PrivateAIIntegrationService.RuntimeConfiguration(- selectedProviderID: "private",- providerKey: "private",- baseURL: "",- model: "fluid-1",- apiKey: "",- localModelPath: nil,- usesStablePromptPrefixKVCache: true,- usesFluid1Boost: true,- contextTokenLimit: 4096- )- let context = PrivateAIIntegrationService.AppContext(- appName: "Notes",- bundleID: "com.apple.Notes",- windowTitle: "",- appVersion: nil- )-- do {- _ = try await PrivateAIIntegrationService.shared.enhanceDictation(- longTranscript,- runtime: runtime,- context: context- )- XCTFail("Expected long dictation to fall back before provider generation")- } catch AIProcessingError.dictationExceedsAIContextWindow {- // Expected: ContentView catches this and types the complete raw transcript.- } catch {- XCTFail("Unexpected error: \(error)")- }- }-- func testPrivateAIDictationRejectsTokenDenseInputBeforeCallingProvider() async {- let tokenDenseTranscript = String(repeating: "a", count: 6_000)- let runtime = PrivateAIIntegrationService.RuntimeConfiguration(- selectedProviderID: "private",- providerKey: "private",- baseURL: "",- model: "fluid-1",- apiKey: "",- localModelPath: nil,- usesStablePromptPrefixKVCache: true,- usesFluid1Boost: true,- contextTokenLimit: 4096- )- let context = PrivateAIIntegrationService.AppContext(- appName: "Notes",- bundleID: "com.apple.Notes",- windowTitle: "",- appVersion: nil- )-- do {- _ = try await PrivateAIIntegrationService.shared.enhanceDictation(- tokenDenseTranscript,- runtime: runtime,- context: context- )- XCTFail("Expected token-dense dictation to fall back before provider generation")- } catch AIProcessingError.dictationExceedsAIContextWindow {- // Expected: ContentView catches this and types the complete raw transcript.- } catch {- XCTFail("Unexpected error: \(error)")- }- }-func testPrivateAIProviderLocalRuntimeOnlyHandlesPrivateModels() {self.withRestoredDefaults(keys: [self.privateAILocalModelPathKey]) {let tempURL = FileManager.default.temporaryDirectorydiff --git a/Tests/FluidDictationIntegrationTests/PrivateAIDictationTokenBudgetTests.swift b/Tests/FluidDictationIntegrationTests/PrivateAIDictationTokenBudgetTests.swiftnew file mode 100644index 00000000..6a234ab1--- /dev/null+++ b/Tests/FluidDictationIntegrationTests/PrivateAIDictationTokenBudgetTests.swift@@ -0,0 +1,76 @@+@testable import FluidVoice_Debug+import XCTest++@MainActor+final class PrivateAIDictationTokenBudgetTests: XCTestCase {+ func testPrivateAIDictationTokenBudgetFallsBackBeforeLongInputCanTruncate() {+ let shortTranscript = Array(repeating: "word", count: 600).joined(separator: " ")+ let longTranscript = Array(repeating: "word", count: 3385).joined(separator: " ")+ let tokenDenseIdentifier = String(repeating: "a", count: 6000)+ let unspacedCJKTranscript = String(repeating: "漢", count: 2500)++ XCTAssertTrue(SettingsStore.privateAIDictationTokenBudget(+ forInputText: shortTranscript,+ contextTokenLimit: 4096+ ).hasSufficientHeadroom)+ XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(+ forInputText: longTranscript,+ contextTokenLimit: 4096+ ).hasSufficientHeadroom)+ XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(+ forInputText: tokenDenseIdentifier,+ contextTokenLimit: 4096+ ).hasSufficientHeadroom)+ XCTAssertFalse(SettingsStore.privateAIDictationTokenBudget(+ forInputText: unspacedCJKTranscript,+ contextTokenLimit: 4096+ ).hasSufficientHeadroom)+ }++ func testPrivateAIDictationRejectsLongInputBeforeCallingProvider() async {+ await self.assertRejectedBeforeProvider(+ Array(repeating: "word", count: 3385).joined(separator: " "),+ failureMessage: "Expected long dictation to fall back before provider generation"+ )+ }++ func testPrivateAIDictationRejectsTokenDenseInputBeforeCallingProvider() async {+ await self.assertRejectedBeforeProvider(+ String(repeating: "a", count: 6000),+ failureMessage: "Expected token-dense dictation to fall back before provider generation"+ )+ }++ private func assertRejectedBeforeProvider(_ transcript: String, failureMessage: String) async {+ let runtime = PrivateAIIntegrationService.RuntimeConfiguration(+ selectedProviderID: "private",+ providerKey: "private",+ baseURL: "",+ model: "fluid-1",+ apiKey: "",+ localModelPath: nil,+ usesStablePromptPrefixKVCache: true,+ usesFluid1Boost: true,+ contextTokenLimit: 4096+ )+ let context = PrivateAIIntegrationService.AppContext(+ appName: "Notes",+ bundleID: "com.apple.Notes",+ windowTitle: "",+ appVersion: nil+ )++ do {+ _ = try await PrivateAIIntegrationService.shared.enhanceDictation(+ transcript,+ runtime: runtime,+ context: context+ )+ XCTFail(failureMessage)+ } catch AIProcessingError.dictationExceedsAIContextWindow {+ // Expected: ContentView catches this and types the complete raw transcript.+ } catch {+ XCTFail("Unexpected error: \(error)")+ }+ }+}