fix(conversation): make realtime sessions cancellable and recoverable

This commit is contained in:
Yun Chan 2026-09-28 00:54:03 +09:00
parent a85b24d385
commit f4f9653361
6 changed files with 1248 additions and 279 deletions

View file

@ -124,8 +124,9 @@ export function VoiceConversationPage(): React.ReactElement {
isStartingSessionRef.current = true
try {
if (isRealtime) {
const ok = await realtime.start()
if (!ok) {
// 'cancelled'(시작 중 정지)는 fallback 대상이 아니다
const result = await realtime.start()
if (result === 'failed') {
setBackend('local')
setErrorBanner({ phase: 'llm', message: t('conversation.realtime.fallback') })
await window.electronAPI.voiceConversation.startSession()
@ -159,15 +160,21 @@ export function VoiceConversationPage(): React.ReactElement {
try {
if (isRealtime) {
if (!realtime.isActive) {
const ok = await realtime.start()
if (!ok) {
const result = await realtime.start()
if (result === 'failed') {
setBackend('local')
setErrorBanner({ phase: 'llm', message: t('conversation.realtime.fallback') })
await window.electronAPI.voiceConversation.startSession()
await window.electronAPI.voiceConversation.sendMessage({ text })
return
}
if (result === 'cancelled') {
// 시작 중 사용자가 멈췄다 — 보내지 못한 입력을 되돌려 준다
setTextInput((current) => current || text)
return
}
}
// start()는 이벤트 채널 open 후 resolve하고, 연결 중이면 컨트롤러가 큐에 쌓는다
realtime.sendText(text)
return
}