diff --git a/docs/cli/settings.md b/docs/cli/settings.md index c5e8a3d51b..30285b1391 100644 --- a/docs/cli/settings.md +++ b/docs/cli/settings.md @@ -169,7 +169,7 @@ they appear in the UI. | Voice Activation Mode | `experimental.voice.activationMode` | How to trigger voice recording with the Space key. | `"push-to-talk"` | | Voice Transcription Backend | `experimental.voice.backend` | The backend to use for voice transcription. Note: When using the Gemini Live backend, voice recordings are sent to Google Cloud for transcription. | `"gemini-live"` | | Whisper Model | `experimental.voice.whisperModel` | The Whisper model to use for local transcription. | `"ggml-base.en.bin"` | -| Voice Stop Grace Period (ms) | `experimental.voice.stopGracePeriodMs` | How long to wait for final transcription after stopping recording. | `1000` | +| Voice Stop Grace Period (ms) | `experimental.voice.stopGracePeriodMs` | How long to wait for final transcription after stopping recording. | `4000` | | Enable Git Worktrees | `experimental.worktrees` | Enable automated Git worktree management for parallel work. | `false` | | Use OSC 52 Paste | `experimental.useOSC52Paste` | Use OSC 52 for pasting. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it). | `false` | | Use OSC 52 Copy | `experimental.useOSC52Copy` | Use OSC 52 for copying. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it). | `false` | diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 0897a69fa0..e216b6b27f 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -1795,7 +1795,7 @@ their corresponding top-level category object in your `settings.json` file. - **`experimental.voice.stopGracePeriodMs`** (number): - **Description:** How long to wait for final transcription after stopping recording. - - **Default:** `1000` + - **Default:** `4000` - **`experimental.adk.agentSessionNoninteractiveEnabled`** (boolean): - **Description:** Enable non-interactive agent sessions. diff --git a/packages/cli/src/config/settingsSchema.ts b/packages/cli/src/config/settingsSchema.ts index d27457bcd6..adb87bdfa2 100644 --- a/packages/cli/src/config/settingsSchema.ts +++ b/packages/cli/src/config/settingsSchema.ts @@ -2149,7 +2149,7 @@ const SETTINGS_SCHEMA = { label: 'Voice Stop Grace Period (ms)', category: 'Experimental', requiresRestart: false, - default: 1000, + default: 4000, description: 'How long to wait for final transcription after stopping recording.', showInDialog: true, diff --git a/packages/cli/src/ui/hooks/useVoiceMode.ts b/packages/cli/src/ui/hooks/useVoiceMode.ts index e2e61f76d2..54be78631a 100644 --- a/packages/cli/src/ui/hooks/useVoiceMode.ts +++ b/packages/cli/src/ui/hooks/useVoiceMode.ts @@ -75,13 +75,9 @@ export function useVoiceMode({ } const serviceToDisconnect = transcriptionServiceRef.current; - transcriptionServiceRef.current = null; if (serviceToDisconnect) { - const isLive = settings.experimental.voice?.backend === 'gemini-live'; - const gracePeriodMs = - settings.experimental.voice?.stopGracePeriodMs ?? - (isLive ? 2000 : 1000); + const gracePeriodMs = settings.experimental.voice.stopGracePeriodMs; debugLogger.debug( `[Voice] Draining transcription for ${gracePeriodMs}ms`, ); @@ -90,11 +86,16 @@ export function useVoiceMode({ disconnectTimerRef.current = setTimeout(() => { debugLogger.debug('[Voice] Grace period ended, disconnecting service'); serviceToDisconnect.disconnect(); + if (transcriptionServiceRef.current === serviceToDisconnect) { + transcriptionServiceRef.current = null; + } disconnectTimerRef.current = null; + liveTranscriptionRef.current = ''; }, gracePeriodMs); + } else { + liveTranscriptionRef.current = ''; } - liveTranscriptionRef.current = ''; pttStateRef.current = 'idle'; }, [settings.experimental.voice]); diff --git a/schemas/settings.schema.json b/schemas/settings.schema.json index 6e307f6966..50a58141f6 100644 --- a/schemas/settings.schema.json +++ b/schemas/settings.schema.json @@ -3107,8 +3107,8 @@ "stopGracePeriodMs": { "title": "Voice Stop Grace Period (ms)", "description": "How long to wait for final transcription after stopping recording.", - "markdownDescription": "How long to wait for final transcription after stopping recording.\n\n- Category: `Experimental`\n- Requires restart: `no`\n- Default: `1000`", - "default": 1000, + "markdownDescription": "How long to wait for final transcription after stopping recording.\n\n- Category: `Experimental`\n- Requires restart: `no`\n- Default: `4000`", + "default": 4000, "type": "number" } },