From ebcac74b8f12bef4c2f072b791c66d3de90304ef Mon Sep 17 00:00:00 2001 From: OasisCaterino <149987042+OasisCaterino@users.noreply.github.com> Date: Fri, 24 Jul 2026 16:04:36 +0800 Subject: [PATCH] fix: prevent sending messages while AI is streaming response (#674) Co-authored-by: oasis --- web/components/chat/home/ChatComposer.tsx | 1 + web/components/chat/home/ComposerInput.tsx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/web/components/chat/home/ChatComposer.tsx b/web/components/chat/home/ChatComposer.tsx index d9a1019f1..0913f5d45 100644 --- a/web/components/chat/home/ChatComposer.tsx +++ b/web/components/chat/home/ChatComposer.tsx @@ -619,6 +619,7 @@ export default memo(function ChatComposer({ ref={inputHandleRef} textareaRef={textareaRef} isVisualizeMode={isVisualizeMode} + isStreaming={isStreaming} canSendEmpty={hasReferences} onSend={doSend} onInputChange={handleInputChange} diff --git a/web/components/chat/home/ComposerInput.tsx b/web/components/chat/home/ComposerInput.tsx index ae1b61a27..697317a4d 100644 --- a/web/components/chat/home/ComposerInput.tsx +++ b/web/components/chat/home/ComposerInput.tsx @@ -24,6 +24,7 @@ import { useImeComposing } from "@/lib/use-ime-composing"; interface ComposerInputProps { textareaRef: RefObject; isVisualizeMode: boolean; + isStreaming?: boolean; // When true, parent has attachments/references queued and will accept a // send even if the text body is empty. Without this, Enter would silently // do nothing for an attachment-only message. @@ -128,6 +129,7 @@ export const ComposerInput = memo( { textareaRef, isVisualizeMode, + isStreaming = false, canSendEmpty, onSend, onInputChange, @@ -309,7 +311,7 @@ export const ComposerInput = memo( } if (shouldSubmitOnEnter(e, isComposingRef.current)) { e.preventDefault(); - doSend(); + if (!isStreaming) doSend(); } else if (e.key === "Escape") { setShowAtPopup(false); setShowSlashPopup(false); @@ -317,6 +319,7 @@ export const ComposerInput = memo( }, [ doSend, + isStreaming, showSlashPopup, handleSelectSlashPersona, showAtPopup,