From 356390d29d3a829ec0433490b7cad2a4c9fee822 Mon Sep 17 00:00:00 2001 From: Jeff Green Date: Sun, 5 Apr 2026 15:15:19 -0400 Subject: [PATCH] fix: resolve voice 1007 disconnect by using sendRealtimeInput for greeting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace sendClientContent({ turnComplete: true }) with sendRealtimeInput({ text: " " }) to trigger the model's initial greeting. The Gemini Live API rejects mixing sendClientContent with sendRealtimeInput — they're different input modes, and audio was already flowing via sendRealtimeInput when the clientContent message arrived. --- CHANGELOG.md | 1 + lib/hooks/use-gemini-live.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7ddd6..91ef031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ All notable changes to this project will be documented in this file. ### Fixes +- Fix voice session immediately disconnecting with WebSocket 1007 by replacing `sendClientContent` with `sendRealtimeInput` to avoid mixing input modes - Fix workspace intent bar erroring on simple questions / read-only queries instead of showing response text - Fix bottom bar button/input height mismatch on desktop (Send and Mic buttons now match input height at sm+ breakpoint) - Fix missing voice and visual feedback after changeset execution via voice approval (PR `#29`) diff --git a/lib/hooks/use-gemini-live.ts b/lib/hooks/use-gemini-live.ts index 77103d2..c2f116d 100644 --- a/lib/hooks/use-gemini-live.ts +++ b/lib/hooks/use-gemini-live.ts @@ -600,11 +600,11 @@ export function useGeminiLive( }; // Trigger the model's initial greeting from the system instruction. - // Placed after audio pipeline is wired so mic audio is already flowing - // when the model starts responding. Wrapped in try-catch so a failure - // doesn't tear down the session (model will respond to audio instead). + // Uses sendRealtimeInput (same mode as audio) to avoid mixing with + // sendClientContent, which causes 1007 "invalid argument" when audio + // is also flowing via sendRealtimeInput. try { - primarySession.sendClientContent({ turnComplete: true }); + primarySession.sendRealtimeInput({ text: " " }); } catch { // Non-critical — model will respond once it receives audio input }