diff --git a/frontend/components/ui/ui-input.tsx b/frontend/components/ui/ui-input.tsx index 16b2042..2d914d1 100644 --- a/frontend/components/ui/ui-input.tsx +++ b/frontend/components/ui/ui-input.tsx @@ -225,15 +225,16 @@ const UIInput = ({ const [isAtBottom, setIsAtBottom] = useState(true); const [showScrollToBottom, setShowScrollToBottom] = useState(false); + const [shouldAutoScroll, setShouldAutoScroll] = useState(true); const scrollToBottom = useCallback( (force = false) => { - if (force || isAtBottom) { + if (force || (isAtBottom && shouldAutoScroll)) { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); setShowScrollToBottom(false); } }, - [isAtBottom] + [isAtBottom, shouldAutoScroll] ); const handleScroll = useCallback(() => { @@ -243,6 +244,7 @@ const UIInput = ({ setIsAtBottom(scrolledToBottom); setShowScrollToBottom(!scrolledToBottom && messages.length > 0); + setShouldAutoScroll(scrolledToBottom); }, [messages.length]); useEffect(() => { @@ -431,6 +433,7 @@ const UIInput = ({ setQuery(""); setMessages((prev) => [...prev, userMessage]); setIsLoading(true); + setShouldAutoScroll(true); if (abortControllerRef.current) { abortControllerRef.current.abort();