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 prompt test processing feedback

altic-dev44383192e20b
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 79700192..d1cd30a8 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -2643,7 +2643,7 @@ struct ContentView: View {
// Prompt Test Mode: reroute dictation hotkey output into the prompt editor (no typing/clipboard/history).
if promptTest.isActive {
- await self.processDictationPromptTest(transcribedText)
+ await self.processDictationPromptTest(transcribedText, lifecycleID: expectedOverlayLifecycleID)
return
}
@@ -2993,7 +2993,7 @@ struct ContentView: View {
}
}
- private func processDictationPromptTest(_ transcribedText: String) async {
+ private func processDictationPromptTest(_ transcribedText: String, lifecycleID: UInt64) async {
let promptTest = DictationPromptTestCoordinator.shared
promptTest.lastTranscriptionText = transcribedText
promptTest.lastOutputText = ""
@@ -3003,12 +3003,18 @@ struct ContentView: View {
model: promptTest.draftModel
) else {
promptTest.lastError = "AI post-processing is not configured. Configure a provider/model (and API key for non-local endpoints) to test prompts."
- self.menuBarManager.setProcessing(false)
+ if self.overlayLifecycleID == lifecycleID {
+ self.menuBarManager.setProcessing(false)
+ }
return
}
promptTest.isProcessing = true
+ let refiningStatusTask = self.makeAIProcessingFeedback(lifecycleID: lifecycleID).statusTask
defer {
- self.menuBarManager.setProcessing(false)
+ refiningStatusTask.cancel()
+ if self.overlayLifecycleID == lifecycleID {
+ self.menuBarManager.setProcessing(false)
+ }
promptTest.isProcessing = false
}
do {
diff --git a/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift b/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift
index 9e72c8fb..4d64920b 100644
--- a/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift
+++ b/Tests/FluidDictationIntegrationTests/DirectAudioReliabilityTests.swift
@@ -734,6 +734,44 @@ final class DirectAudioReliabilityTests: XCTestCase {
)
}
+ func testPromptTestReusesDelayedFeedbackAndScopesAllOverlayCleanup() throws {
+ let repositoryRoot = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ let source = try String(
+ contentsOf: repositoryRoot.appendingPathComponent("Sources/Fluid/ContentView.swift"),
+ encoding: .utf8
+ )
+ XCTAssertTrue(source.contains(
+ "await self.processDictationPromptTest(transcribedText, lifecycleID: expectedOverlayLifecycleID)"
+ ))
+ let promptTestSection = try XCTUnwrap(
+ source.components(separatedBy: "private func processDictationPromptTest(").last?
+ .components(separatedBy: "private func makeAIProcessingFeedback(").first
+ )
+ let feedbackIndex = try XCTUnwrap(promptTestSection.range(of:
+ "let refiningStatusTask = self.makeAIProcessingFeedback(lifecycleID: lifecycleID).statusTask"
+ ))
+ let providerIndex = try XCTUnwrap(promptTestSection.range(of: "try await self.processTextWithAI("))
+ XCTAssertLessThan(feedbackIndex.lowerBound, providerIndex.lowerBound)
+
+ let cleanup = try XCTUnwrap(
+ promptTestSection.components(separatedBy: "defer {").last?
+ .components(separatedBy: " do {").first
+ )
+ XCTAssertTrue(cleanup.contains("refiningStatusTask.cancel()"))
+ XCTAssertTrue(cleanup.contains("promptTest.isProcessing = false"))
+ // Both missing-provider and success/error cleanup must leave a newer overlay alone.
+ let scopedHide = "if self.overlayLifecycleID == lifecycleID {\n" +
+ " self.menuBarManager.setProcessing(false)\n }"
+ XCTAssertEqual(promptTestSection.components(separatedBy: scopedHide).count - 1, 2)
+ XCTAssertFalse(promptTestSection.contains("setProcessing(true)"), "Fast prompt tests must keep delayed feedback")
+ XCTAssertFalse(promptTestSection.contains("typeOutput"))
+ XCTAssertFalse(promptTestSection.contains("ClipboardService"))
+ XCTAssertFalse(promptTestSection.contains("TranscriptionHistoryStore"))
+ }
+
func testDictionaryTrackingStartsAfterDeliveryCallbackReturns() throws {
let repositoryRoot = URL(fileURLWithPath: #filePath)
.deletingLastPathComponent()