fix(meeting): save the recording when the app quits while a stop is still flushing

Quitting during the few seconds a stop waits for the last caption skipped
the shutdown save, so the in-memory audio and every sentence since the last
checkpoint were lost. Shutdown now saves unless post-processing already
wrote the final result.
This commit is contained in:
Yun Chan 2026-10-20 16:29:29 +09:00
parent 32cf826290
commit cf37fd5281
2 changed files with 24 additions and 1 deletions

View file

@ -142,6 +142,8 @@ class MeetingModeService extends EventEmitter {
private readonly _unsubscribeScope: () => void
/** 회의별 자막 인식 실패 수 — 전사가 비었을 때 'completed' 대신 'error' 로 닫는 근거 */
private readonly _captionFailures = new Map<string, number>()
/** 정지 후처리가 최종 저장을 마친 회의 — 종료(shutdown) 때 다시 쓰지 않는다. */
private _finalizedSessionId: string | null = null
private _unsubscribeCaptionFailure: (() => void) | null = null
private _lastCaptionFailureNoticeAt = 0
@ -457,7 +459,9 @@ class MeetingModeService extends EventEmitter {
this._stopTimers()
const session = this._current
if (!session) return
if (!session.isStopping) {
// 정지 중(마지막 문장 flush 대기)이어도 아직 최종 저장 전이면 지금까지를 저장한다 — 건너뛰면
// 메모리에만 있던 녹음과 마지막 주기 저장 이후 전사가 사라졌다.
if (this._finalizedSessionId !== session.id) {
try {
this._persistSnapshot(session.checkpoint({ includeAudio: true }), { interrupted: false })
logger.info(`종료 중 회의 저장: sessionId=${session.id}`)
@ -533,6 +537,7 @@ class MeetingModeService extends EventEmitter {
// Step 2: DB 저장 (rawTranscript + completed) + Step 2.5: 오디오 WAV 파일 저장 (화자 구분용)
this._sendProgress(sessionId, 'saving', 80)
this._persistSnapshot(snapshot, { interrupted: false })
this._finalizedSessionId = sessionId
// Step 3: 알림
this._sendProgress(sessionId, 'notifying', 95)