Hide voice mode while agents run

This commit is contained in:
Mohamed Boudra
2026-05-19 08:18:56 +07:00
parent 8aa8f7a0cc
commit 501dcf373b
2 changed files with 18 additions and 2 deletions
+2 -1
View File
@@ -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 (
+16 -1
View File
@@ -799,6 +799,7 @@ interface ToggleRealtimeVoiceContext {
voiceAgentId: string | undefined;
isConnected: boolean;
disabled: boolean;
isAgentRunning: boolean;
handleStopRealtimeVoice: () => Promise<unknown> | 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<MessageInputRef, MessageInputProps>(
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;