fix(flow): improve tail capture and final chunk ASR recovery

- Add FlowUtteranceEndCoordinator with 350ms silence drain and 150ms post-roll
- Extend FinalChunkRecovery for short/empty final chunks in chunked pipeline
- Snapshot partial at mic stop and guard final transcript in FlowSessionManager
- Unify tail drain presets (iosFlow/macMLX) and expand diagnostics

Co-authored-by: Rocky <hkgood@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-07-26 10:13:40 +00:00
parent e6f99d2744
commit c7ee891a90
16 changed files with 485 additions and 42 deletions
@@ -0,0 +1,32 @@
// UtteranceTranscriptGuardTests.swift
// OSGKeyboardTests
import XCTest
@testable import OSGKeyboardShared
final class UtteranceTranscriptGuardTests: XCTestCase {
func testResolvePrefersPartialWhenClearlyLonger() {
let resolved = UtteranceTranscriptGuard.resolve(
stitchedFinal: "今天天气很好",
partialSnapshot: "今天天气很好,我们一起去公园吧"
)
XCTAssertEqual(resolved, "今天天气很好,我们一起去公园吧")
}
func testResolveKeepsFinalWhenPartialIsNotLonger() {
let resolved = UtteranceTranscriptGuard.resolve(
stitchedFinal: "今天天气很好,我们一起去公园吧",
partialSnapshot: "今天天气很好"
)
XCTAssertEqual(resolved, "今天天气很好,我们一起去公园吧")
}
func testResolveUsesPartialWhenFinalEmpty() {
let resolved = UtteranceTranscriptGuard.resolve(
stitchedFinal: "",
partialSnapshot: "最后一段 partial"
)
XCTAssertEqual(resolved, "最后一段 partial")
}
}