From 9422c3292611e71f93e57241c801728b60a7ea1e Mon Sep 17 00:00:00 2001 From: Sergei Date: Wed, 28 Jan 2026 20:05:38 -0800 Subject: [PATCH] Extend speaking indicator duration to cover STT restart delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User feedback: green speaker indicator was turning off too early, creating an awkward visual gap during the 300ms audio focus delay. Changes: - Added 300ms delay to setIsSpeaking(false) in TTS onDone callback - Keeps green "Speaking" indicator on until STT actually starts recording - onError and onStopped still turn off immediately (user interruption) - Smooth visual transition: TTS ends → 300ms delay → STT starts UX improvement: eliminates the brief "nothing is happening" moment between Julia finishing speech and microphone starting to listen. contexts/VoiceContext.tsx:393 --- contexts/VoiceContext.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contexts/VoiceContext.tsx b/contexts/VoiceContext.tsx index f8bc4d4..b1a77bc 100644 --- a/contexts/VoiceContext.tsx +++ b/contexts/VoiceContext.tsx @@ -386,7 +386,11 @@ export function VoiceProvider({ children }: { children: ReactNode }) { }, onDone: () => { console.log('[VoiceContext] TTS completed'); - setIsSpeaking(false); + // Delay turning off green indicator to match STT restart delay (300ms) + // This keeps the visual indicator on during the transition period + setTimeout(() => { + setIsSpeaking(false); + }, 300); // Return to listening state after speaking (if session wasn't stopped) if (!sessionStoppedRef.current) { setStatus('listening'); @@ -395,6 +399,7 @@ export function VoiceProvider({ children }: { children: ReactNode }) { }, onError: (error) => { console.warn('[VoiceContext] TTS error:', error); + // On error, turn off indicator immediately (no delay) setIsSpeaking(false); if (!sessionStoppedRef.current) { setStatus('listening'); @@ -403,6 +408,7 @@ export function VoiceProvider({ children }: { children: ReactNode }) { }, onStopped: () => { console.log('[VoiceContext] TTS stopped (interrupted)'); + // When interrupted by user, turn off indicator immediately setIsSpeaking(false); // Don't set status to listening if session was stopped by user if (!sessionStoppedRef.current) {