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:
parent
32cf826290
commit
cf37fd5281
2 changed files with 24 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -162,6 +162,24 @@ describe('앱 종료·중단 복구', () => {
|
|||
expect(meeting.getState()).toBe('idle')
|
||||
})
|
||||
|
||||
it('정지 처리(마지막 문장 대기) 중에 종료돼도 지금까지의 전사를 저장한다', async () => {
|
||||
const meeting = getMeetingModeService()
|
||||
const { sessionId } = await meeting.startRecording()
|
||||
caption.bus?.emit('segment', { id: 'seg-b', text: '정지 직전 문장', timestamp: Date.now(), isFinal: true } satisfies CaptionSegment)
|
||||
let release = (): void => undefined
|
||||
caption.gate = new Promise<void>((resolve) => { release = resolve })
|
||||
const stopping = meeting.stopRecording()
|
||||
|
||||
await meeting.shutdown()
|
||||
|
||||
const saved = row(sessionId)
|
||||
expect(saved?.status).toBe('completed')
|
||||
expect(saved?.rawTranscript).toContain('정지 직전 문장')
|
||||
release()
|
||||
caption.gate = null
|
||||
await stopping.catch(() => undefined)
|
||||
})
|
||||
|
||||
it('남은 recording/processing 행을 닫는다 — 전사가 있으면 completed, 없으면 error', () => {
|
||||
insertSession('stuck-with-text', { status: 'recording', rawTranscript: '[00:01] 저장된 부분' })
|
||||
// 전사가 없는 행은 이 기기에서 시작한 녹음(원장 표식)일 때만 닫는다 — redteam r3: 폰의 진행 중 회의 보호
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue