From 6c9e6a3a5a9a1acb48b558cb8e448f2597298031 Mon Sep 17 00:00:00 2001 From: Wood Date: Sat, 4 Jan 2025 11:51:35 +0800 Subject: [PATCH] fix: fix issue with `chat-input-area` clearing during Responding state. (#12352) --- .../components/base/chat/chat/chat-input-area/index.tsx | 9 ++++++++- web/app/components/base/chat/chat/index.tsx | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/chat/chat/chat-input-area/index.tsx b/web/app/components/base/chat/chat/chat-input-area/index.tsx index eec636b478..f83ecbf4a1 100644 --- a/web/app/components/base/chat/chat/chat-input-area/index.tsx +++ b/web/app/components/base/chat/chat/chat-input-area/index.tsx @@ -39,6 +39,7 @@ type ChatInputAreaProps = { inputs?: Record inputsForm?: InputForm[] theme?: Theme | null + isResponding?: boolean } const ChatInputArea = ({ showFeatureBar, @@ -51,6 +52,7 @@ const ChatInputArea = ({ inputs = {}, inputsForm = [], theme, + isResponding, }: ChatInputAreaProps) => { const { t } = useTranslation() const { notify } = useToastContext() @@ -77,6 +79,11 @@ const ChatInputArea = ({ const historyRef = useRef(['']) const [currentIndex, setCurrentIndex] = useState(-1) const handleSend = () => { + if (isResponding) { + notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') }) + return + } + if (onSend) { const { files, setFiles } = filesStore.getState() if (files.find(item => item.transferMethod === TransferMethod.local_file && !item.uploadedId)) { @@ -116,7 +123,7 @@ const ChatInputArea = ({ setQuery(historyRef.current[currentIndex + 1]) } else if (currentIndex === historyRef.current.length - 1) { - // If it is the last element, clear the input box + // If it is the last element, clear the input box setCurrentIndex(historyRef.current.length) setQuery('') } diff --git a/web/app/components/base/chat/chat/index.tsx b/web/app/components/base/chat/chat/index.tsx index 22020066b4..e6de01252d 100644 --- a/web/app/components/base/chat/chat/index.tsx +++ b/web/app/components/base/chat/chat/index.tsx @@ -292,6 +292,7 @@ const Chat: FC = ({ inputs={inputs} inputsForm={inputsForm} theme={themeBuilder?.theme} + isResponding={isResponding} /> ) }