Keep saved transcripts when post-processing returns incomplete text

Merged
CO
2mo ago
+314-22

Reject severely shortened replacements and retain recovery audio. Compare the latest saved capture and notify completion only after validation and persistence; cover multilingual, resumed-capture, and read-failure cases.


[!NOTE]
Medium Risk
Changes core batch persistence and retention paths; incorrect truncation heuristics could block valid refinements, but failures are conservative (keep existing data).

Overview
Batch post-processing now refuses to replace saved transcripts when the new result is drastically shorter than what’s already stored, so users keep their live transcript and recovery audio instead of losing content to a bad provider run.

Before createTranscript, the flow loads the prior transcript(s) via getSessionTranscriptRecords (whole session) or getTranscriptRecord (current capture) and runs assertTranscriptNotTruncated using Unicode letter/digit counts with a 200-character loss floor and 50% retention threshold. Failures surface INCOMPLETE_BATCH_TRANSCRIPT_ERROR_MESSAGE as a terminal error—no persist, no audio cleanup, no completion notification.

Completion UX is reordered: startTranscription always gets notifyOnCompletion: false, and shared notifyBatchCompleted runs only after validation and successful persistence (extracted from general-batch for reuse in useRunBatch).

Reviewed by Cursor Bugbot for commit 220359d4e3ed69ba4011bdfbc6315dc409c3a9cd. Bugbot is set up for automated code reviews on this repo. Configure here.