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

Record the chosen language before saving a meeting retry. Fixes #1033

ParamKataria7e4b0fa5413e
diff --git a/Sources/Fluid/Services/Meeting/MeetingModels.swift b/Sources/Fluid/Services/Meeting/MeetingModels.swift
index 11187d4b..a7ec6ecb 100644
--- a/Sources/Fluid/Services/Meeting/MeetingModels.swift
+++ b/Sources/Fluid/Services/Meeting/MeetingModels.swift
@@ -1156,7 +1156,8 @@ nonisolated struct MeetingSession: Codable, Identifiable, Equatable, Sendable {
}
}
// Earlier attempts may record a language used before the user transcribed the saved
- // audio again. The latest recorded attempt is the transcript currently stored.
+ // audio again. The latest attempt that has a language is the one in progress or just
+ // finished, so that attempt must already carry the session language before it is saved.
if let latestLanguage = self.processingAttempts.compactMap(\.languageCode).last,
latestLanguage != self.languageCode
{
diff --git a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift
index 46b5f3ac..f3834687 100644
--- a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift
+++ b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift
@@ -765,7 +765,11 @@ final class MeetingSessionCoordinator: ObservableObject {
for index in session.processingAttempts.indices where session.processingAttempts[index].completedAt == nil {
session.processingAttempts[index].completedAt = closedAt
}
- session.processingAttempts.append(Self.pendingProcessingAttempt())
+ // Record the language on the new attempt before the first save. A language change
+ // otherwise leaves only the previous attempt's language, and persistence rejects the session.
+ var attempt = Self.pendingProcessingAttempt()
+ attempt.languageCode = session.languageCode
+ session.processingAttempts.append(attempt)
session.updatedAt = Date()
self.activeSession = session
try? await self.store.save(session)
diff --git a/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift b/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift
index 5de212ec..e4f94d6a 100644
--- a/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift
+++ b/Tests/FluidDictationIntegrationTests/MeetingRecoveryTests.swift
@@ -2538,6 +2538,54 @@ final class MeetingRecoveryTests: XCTestCase {
XCTAssertFalse(FileManager.default.fileExists(atPath: checkpointURL.path))
}
+ func testFailedLanguageChangeRetryKeepsChosenLanguage() async throws {
+ let dir = self.makeTempDirectory()
+ defer { try? FileManager.default.removeItem(at: dir) }
+ let store = MeetingSessionStore(rootDirectory: dir)
+ let started = Date(timeIntervalSinceNow: -120)
+ var session = self.makeSession(
+ state: .completed,
+ startedAt: started,
+ endedAt: Date(),
+ audioTracks: [self.makeMicrophoneTrack(chunks: [self.makeFinalizedChunk()])],
+ processingAttempts: [MeetingProcessingAttempt(
+ id: UUID(),
+ startedAt: started,
+ completedAt: started.addingTimeInterval(10),
+ stage: .completed,
+ pipelineVersion: MeetingProcessingPipeline.pipelineVersion,
+ asrProvider: "fixture",
+ asrModel: "parakeet-tdt-v2",
+ languageCode: "en",
+ diarizationModel: nil,
+ lastCompletedTrackID: nil,
+ errorCode: nil
+ )]
+ )
+ session.languageCode = "en"
+ try await store.create(session)
+
+ let coordinator = MeetingSessionCoordinator(
+ store: store,
+ capture: StubCaptureController(),
+ processing: DiagnosticFailingProcessingController(error: ProcessingFailure()),
+ audioArbiter: StubArbiter()
+ )
+ await coordinator.ensureRestored()
+ do {
+ _ = try await coordinator.retryProcessing(sessionID: session.id, languageCode: "nl")
+ XCTFail("Expected the language-changing retry to fail during transcription")
+ } catch {
+ XCTAssertTrue(error is ProcessingFailure)
+ }
+
+ let saved = try await store.load(id: session.id)
+ let persisted = try XCTUnwrap(saved)
+ XCTAssertEqual(persisted.languageCode, "nl")
+ XCTAssertEqual(persisted.state, .failed)
+ XCTAssertEqual(persisted.processingAttempts.map(\.languageCode), ["en", "nl"])
+ }
+
func testProcessingDiagnosticsPreserveFailureAndTranscriptAcrossRetries() async throws {
let dir = self.makeTempDirectory()
defer { try? FileManager.default.removeItem(at: dir) }
diff --git a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
index 5eaf95b2..fc925242 100644
--- a/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
+++ b/Tests/FluidDictationIntegrationTests/SpeakerTurnMergingTests.swift
@@ -1670,6 +1670,18 @@ final class MeetingSessionModelTests: XCTestCase {
}
}
+ func testLanguageChangeWithoutPendingAttemptLanguageIsRejected() {
+ self.assertSessionValidationError(.unsupportedLanguage) {
+ $0.languageCode = "nl"
+ var pending = $0.processingAttempts[0]
+ pending.id = UUID()
+ pending.completedAt = nil
+ pending.stage = .pending
+ pending.languageCode = nil
+ $0.processingAttempts.append(pending)
+ }
+ }
+
func testEarlierProcessingAttemptMayRecordPreviousRetranscriptionLanguage() throws {
var session = MeetingModelFixture.makeSession()
session.languageCode = "nl"