From 8a6d9fa4208dd059f6e563f1799172006fb9e5d6 Mon Sep 17 00:00:00 2001 From: Sergei Date: Wed, 28 Jan 2026 20:07:51 -0800 Subject: [PATCH] Add voice error handling - speak errors aloud and continue session Previously: API errors were silent, session stopped, user confused Now: Julia speaks error message, adds to transcript, keeps listening Changes: - Catch block now speaks error via TTS: "Sorry, I encountered an error: [msg]" - Error added to transcript (visible in chat history) - Session continues in listening state (doesn't stop on error) - User can try again immediately without restarting session UX improvement: graceful error recovery instead of silent failure contexts/VoiceContext.tsx:332-351 --- contexts/VoiceContext.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contexts/VoiceContext.tsx b/contexts/VoiceContext.tsx index b1a77bc..ddbce9f 100644 --- a/contexts/VoiceContext.tsx +++ b/contexts/VoiceContext.tsx @@ -335,10 +335,24 @@ export function VoiceProvider({ children }: { children: ReactNode }) { console.log('[VoiceContext] API request aborted'); return null; } + + // Handle API errors gracefully with voice feedback const errorMsg = err instanceof Error ? err.message : 'Unknown error'; console.warn('[VoiceContext] API error:', errorMsg); + + // Create user-friendly error message for TTS + const spokenError = `Sorry, I encountered an error: ${errorMsg}. Please try again.`; + + // Add error to transcript for chat display + addTranscriptEntry('assistant', spokenError); + + // Speak the error message + await speak(spokenError); + + // Don't set status to idle - return to listening after speaking error + // This keeps the voice session active + setError(errorMsg); - setStatus('idle'); return null; } },