From 171f31097d29b4c24b6be2ea2c45ff769a0d5914 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Tue, 18 Feb 2025 15:04:44 -0800 Subject: [PATCH 1/2] allow typing while streaming + refactor props --- .../WorkspaceChat/ChatContainer/PromptInput/index.jsx | 11 +++++------ .../components/WorkspaceChat/ChatContainer/index.jsx | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx index a0b5d7f828e..1ff21dcfad7 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx @@ -24,8 +24,7 @@ const MAX_EDIT_STACK_SIZE = 100; export default function PromptInput({ submit, onChange, - inputDisabled, - buttonDisabled, + isStreaming, sendCommand, attachments = [], }) { @@ -62,9 +61,9 @@ export default function PromptInput({ }, []); useEffect(() => { - if (!inputDisabled && textareaRef.current) textareaRef.current.focus(); + if (!isStreaming && textareaRef.current) textareaRef.current.focus(); resetTextAreaHeight(); - }, [inputDisabled]); + }, [isStreaming]); /** * Save the current state before changes @@ -115,6 +114,7 @@ export default function PromptInput({ // Is simple enter key press w/o shift key if (event.keyCode === 13 && !event.shiftKey) { event.preventDefault(); + if (isStreaming) return; return submit(event); } @@ -264,7 +264,6 @@ export default function PromptInput({ handlePasteEvent(e); }} required={true} - disabled={inputDisabled} onFocus={() => setFocused(true)} onBlur={(e) => { setFocused(false); @@ -274,7 +273,7 @@ export default function PromptInput({ className={`border-none cursor-text max-h-[50vh] md:max-h-[350px] md:min-h-[40px] mx-2 md:mx-0 pt-[12px] w-full leading-5 md:text-md text-white bg-transparent placeholder:text-white/60 light:placeholder:text-theme-text-primary resize-none active:outline-none focus:outline-none flex-grow ${textSizeClass}`} placeholder={"Send a message"} /> - {buttonDisabled ? ( + {isStreaming ? ( ) : ( <> diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx index 9fc640c4bee..3d2f374ea4b 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/index.jsx @@ -282,8 +282,7 @@ export default function ChatContainer({ workspace, knownHistory = [] }) { From 66a45280462cbc0ed1a39e0f95a7766f72499e46 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Tue, 18 Feb 2025 15:07:30 -0800 Subject: [PATCH 2/2] remove duplicate function --- .../WorkspaceChat/ChatContainer/PromptInput/index.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx index 1ff21dcfad7..8caa3dddf0c 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx @@ -48,11 +48,6 @@ export default function PromptInput({ setPromptInput(e?.detail ?? ""); } - function resetTextAreaHeight() { - if (!textareaRef.current) return; - textareaRef.current.style.height = "auto"; - } - useEffect(() => { if (!!window) window.addEventListener(PROMPT_INPUT_EVENT, handlePromptUpdate);