fix(flow): drain trailing audio and harden chunked ASR pipeline

- P0/P1: tail-drain state machine in FlowContinuousCapture with converter
  flush; FlowSessionManager awaits drain before finalize
- P2: FlowCaptureTailDrain policy/tracker, pipeline diagnostics, unit tests
- P3: short final chunk merged re-transcription in ChunkedUtterancePipeline
- P4: UtteranceTranscriptStitcher composedSafely fallback; preview path parity
  in LiveDictationController

Co-authored-by: Rocky <hkgood@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-07-06 05:13:55 +00:00
parent 537a68552a
commit 8b105430e3
14 changed files with 690 additions and 47 deletions
@@ -20,4 +20,24 @@ final class UtteranceTranscriptStitcherTests: XCTestCase {
stitcher.append(index: 0, text: "第一段")
XCTAssertEqual(stitcher.composed(), "第一段 第二段")
}
func testComposedSafelyFallsBackWhenOverlapMergeShortensTooMuch() {
var stitcher = UtteranceTranscriptStitcher()
stitcher.append(index: 0, text: "今天天气很好我们")
stitcher.append(index: 1, text: "去公园")
let merged = stitcher.composed()
let safe = stitcher.composedSafely()
XCTAssertFalse(merged.isEmpty)
XCTAssertFalse(safe.isEmpty)
XCTAssertTrue(safe.contains("去公园"))
}
func testRemoveLastSegmentSupportsMergedTailRetranscription() {
var stitcher = UtteranceTranscriptStitcher()
stitcher.append(index: 0, text: "第一段")
stitcher.append(index: 1, text: "第二段")
stitcher.removeLastSegment()
stitcher.append(index: 1, text: "第二段合并")
XCTAssertEqual(stitcher.composed(), "第一段 第二段合并")
}
}