diff --git a/packages/app/src/components/composer.tsx b/packages/app/src/components/composer.tsx index 1914bae49..dc29e28fd 100644 --- a/packages/app/src/components/composer.tsx +++ b/packages/app/src/components/composer.tsx @@ -756,7 +756,8 @@ function ComposerRightControlsSlot({ ...voiceProps }: ComposerRightControlsSlotProps) { const hideVoiceForCompactInput = isCompact && hasSendableContent; - const showVoiceModeButton = !isVoiceModeForAgent && hasAgent && !hideVoiceForCompactInput; + const showVoiceModeButton = + !isVoiceModeForAgent && hasAgent && !isAgentRunning && !hideVoiceForCompactInput; const shouldShowCancelButton = isAgentRunning && !hasSendableContent && !isProcessing; if (!showVoiceModeButton && !shouldShowCancelButton) return null; return ( diff --git a/packages/app/src/components/message-input.tsx b/packages/app/src/components/message-input.tsx index 3fc41f11d..ed4409b2a 100644 --- a/packages/app/src/components/message-input.tsx +++ b/packages/app/src/components/message-input.tsx @@ -799,6 +799,7 @@ interface ToggleRealtimeVoiceContext { voiceAgentId: string | undefined; isConnected: boolean; disabled: boolean; + isAgentRunning: boolean; handleStopRealtimeVoice: () => Promise | void; toast: { error: (msg: string) => void }; } @@ -812,6 +813,10 @@ function toggleRealtimeVoiceImpl(ctx: ToggleRealtimeVoiceContext): void { void ctx.handleStopRealtimeVoice(); return; } + if (ctx.isAgentRunning) { + ctx.toast.error("Interrupt the agent before starting voice mode"); + return; + } void ctx.voice.startVoice(ctx.voiceServerId, ctx.voiceAgentId).catch((error) => { console.error("[MessageInput] Failed to start realtime voice", error); const message = extractErrorMessage(error); @@ -1450,10 +1455,20 @@ export const MessageInput = forwardRef( voiceAgentId, isConnected, disabled, + isAgentRunning, handleStopRealtimeVoice, toast, }); - }, [disabled, handleStopRealtimeVoice, isConnected, toast, voice, voiceAgentId, voiceServerId]); + }, [ + disabled, + handleStopRealtimeVoice, + isAgentRunning, + isConnected, + toast, + voice, + voiceAgentId, + voiceServerId, + ]); const minimizeInputHeight = useCallback(() => { inputHeightRef.current = MIN_INPUT_HEIGHT;