fix(templates): route dictation results into active template sessions

This commit is contained in:
Yun Chan 2026-09-28 02:16:19 +09:00
parent 11bf995409
commit 115e8488ac
7 changed files with 386 additions and 15 deletions

View file

@ -1,10 +1,12 @@
// VoiceMode session-completed → History 저장. bootstrap과 테스트가 같은 함수를 호출한다.
// VoiceMode session-completed → 결과 라우팅(템플릿 필드 등) + History 저장.
// bootstrap과 테스트가 같은 함수를 호출한다.
import { join } from 'path'
import { app } from 'electron'
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
import { getHistoryService } from './services/HistoryService'
import { getLogger } from './services/LoggerService'
import { routeCompletedVoiceText } from './voice-text-routing'
import type { HistoryEntry } from '@d3ro/core/types'
const logger = getLogger('voice-persist')
@ -37,11 +39,21 @@ export function persistCompletedVoiceSession(
})
}
/**
* 완료된 받아쓰기 결과를 소비자(진행 중인 받아쓰기 템플릿 세션의 현재 필드 등)에게 넘긴다.
* 소비되면 true — 일반 삽입 경로는 isVoiceSessionClaimed(session.id)로 이를 확인한다.
*/
export function routeCompletedVoiceSession(session: PersistableVoiceSession, finalText: string): boolean {
return routeCompletedVoiceText(session.id, finalText)
}
export function persistCompletedVoiceSessionSafe(
emitError: (error: D3ROError, session: PersistableVoiceSession) => void,
session: PersistableVoiceSession,
finalText: string,
): HistoryEntry | null {
// 히스토리 저장이 실패해도 결과는 소비자에게 전달돼야 하므로 먼저 라우팅한다
routeCompletedVoiceSession(session, finalText)
try {
return persistCompletedVoiceSession(session, finalText)
} catch (error) {