fix: end voice call when brief generation completes
All checks were successful
Build & Push / build-and-push (push) Successful in 1m58s

The WebSocket, mic, and audio contexts were never torn down after
complete_brief succeeded, so the Gemini agent kept listening and
responding in the background. Now endConversation() fires as soon as
the brief arrives, and the Start button is hidden during the 1.5s
transition so it doesn't flash.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-31 20:35:48 -04:00
parent 600f1a5241
commit 3bf07674ad

View File

@@ -73,17 +73,18 @@ export default function VoiceAgent({ locale, onComplete }: VoiceAgentProps) {
} }
}, [transcript]); }, [transcript]);
// Handle completion // Handle completion — end the call, then transition
useEffect(() => { useEffect(() => {
if (completedBrief && completedFormData) { if (completedBrief && completedFormData) {
console.log('[VoiceAgent] Brief complete, transitioning in 1.5s...'); console.log('[VoiceAgent] Brief complete, ending conversation and transitioning in 1.5s...');
endConversation();
const timer = setTimeout(() => { const timer = setTimeout(() => {
console.log('[VoiceAgent] Calling onComplete'); console.log('[VoiceAgent] Calling onComplete');
onComplete(completedBrief, completedFormData); onComplete(completedBrief, completedFormData);
}, 1500); }, 1500);
return () => clearTimeout(timer); return () => clearTimeout(timer);
} }
}, [completedBrief, completedFormData, onComplete]); }, [completedBrief, completedFormData, onComplete, endConversation]);
// Orb animation driven by agent amplitude // Orb animation driven by agent amplitude
const amplitudeValue = useMotionValue(0); const amplitudeValue = useMotionValue(0);
@@ -255,7 +256,7 @@ export default function VoiceAgent({ locale, onComplete }: VoiceAgentProps) {
{/* Controls */} {/* Controls */}
<div className="flex items-center justify-center gap-3 pt-2"> <div className="flex items-center justify-center gap-3 pt-2">
{status === 'idle' && ( {status === 'idle' && !completedBrief && (
<button <button
type="button" type="button"
onClick={startConversation} onClick={startConversation}