From b69da072d6e24955ed4bfd9e8a60a63a94f62721 Mon Sep 17 00:00:00 2001 From: sergiopesch Date: Tue, 21 Apr 2026 12:32:07 +0200 Subject: [PATCH] fix(voice): reset finalization gate on new turn, attach remote audio to DOM Two small but real issues in useVoiceInteraction.ts: 1. Dropped turn on fast re-speak. finalizeTurn() sets isFinalizingTurnRef.current = true, then awaits onFinalTranscript (a fetch to /api/chat). If the user starts a new turn before that fetch resolves, the server-emitted 'input_audio_buffer.speech_started' event clears the buffers but does NOT clear the gate. The next 'input_audio_transcription. completed' event then hits: if (isFinalizingTurnRef.current) return; and gets silently dropped. The user's second utterance is lost. Fix: reset isFinalizingTurnRef to false on speech_started. The previous turn's in-flight fetch still completes and updates state; it just no longer blocks the next turn from finalizing. 2. Remote