diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 62610197e..fd13be53b 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -207,10 +207,6 @@ export function ChatPage({ if (chatSessionIdRef.current !== null) { setHasPerformedInitialScroll(false); } - - if (isStreaming) { - setIsCancelled(true); - } } async function initialSessionFetch() { @@ -451,8 +447,6 @@ export function ChatPage({ const [sharingModalVisible, setSharingModalVisible] = useState(false); - // state for cancelling streaming - const [isCancelled, setIsCancelled] = useState(false); const [aboveHorizon, setAboveHorizon] = useState(false); const scrollableDivRef = useRef(null); @@ -517,11 +511,6 @@ export function ChatPage({ }, 50); }; - const isCancelledRef = useRef(isCancelled); // scroll is cancelled - useEffect(() => { - isCancelledRef.current = isCancelled; - }, [isCancelled]); - const distance = 500; // distance that should "engage" the scroll const debounce = 100; // time for debouncing @@ -599,11 +588,6 @@ export function ChatPage({ for (const packet of packetBunch) { stack.push(packet); } - - if (isCancelledRef.current) { - setIsCancelled(false); - break; - } } } catch (error) { stack.error = String(error); @@ -635,6 +619,15 @@ export function ChatPage({ isSeededChat?: boolean; alternativeAssistantOverride?: Persona | null; } = {}) => { + if (isStreaming) { + setPopup({ + message: "Please wait for the response to complete", + type: "error", + }); + + return; + } + setAlternativeGeneratingAssistant(alternativeAssistantOverride); clientScrollToBottom(); let currChatSessionId: number; @@ -873,10 +866,6 @@ export function ChatPage({ }, ]); } - if (isCancelledRef.current) { - setIsCancelled(false); - break; - } } } } catch (e: any) { @@ -1614,7 +1603,6 @@ export function ChatPage({ setMessage={setMessage} onSubmit={onSubmit} isStreaming={isStreaming} - setIsCancelled={setIsCancelled} filterManager={filterManager} llmOverrideManager={llmOverrideManager} files={currentMessageFiles} diff --git a/web/src/app/chat/input/ChatInputBar.tsx b/web/src/app/chat/input/ChatInputBar.tsx index 6b6059c21..5067d1ae6 100644 --- a/web/src/app/chat/input/ChatInputBar.tsx +++ b/web/src/app/chat/input/ChatInputBar.tsx @@ -40,7 +40,6 @@ export function ChatInputBar({ setMessage, onSubmit, isStreaming, - setIsCancelled, filterManager, llmOverrideManager, @@ -68,7 +67,6 @@ export function ChatInputBar({ setMessage: (message: string) => void; onSubmit: () => void; isStreaming: boolean; - setIsCancelled: (value: boolean) => void; filterManager: FilterManager; llmOverrideManager: LlmOverrideManager; selectedAssistant: Persona; @@ -328,7 +326,9 @@ export function ChatInputBar({ {filteredPrompts.map((currentPrompt, index) => (