fix: prevent sending messages while AI is streaming response (#674)

Co-authored-by: oasis <oasis42@qq.com>
This commit is contained in:
OasisCaterino
2026-07-24 16:04:36 +08:00
committed by GitHub
parent 20f5ac7acd
commit ebcac74b8f
2 changed files with 5 additions and 1 deletions

View File

@@ -619,6 +619,7 @@ export default memo(function ChatComposer({
ref={inputHandleRef}
textareaRef={textareaRef}
isVisualizeMode={isVisualizeMode}
isStreaming={isStreaming}
canSendEmpty={hasReferences}
onSend={doSend}
onInputChange={handleInputChange}

View File

@@ -24,6 +24,7 @@ import { useImeComposing } from "@/lib/use-ime-composing";
interface ComposerInputProps {
textareaRef: RefObject<HTMLTextAreaElement | null>;
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,