diff --git a/src/components/ChatPanel.tsx b/src/components/ChatPanel.tsx index 01c7e91..6f24cc2 100644 --- a/src/components/ChatPanel.tsx +++ b/src/components/ChatPanel.tsx @@ -3,6 +3,7 @@ import { useAtomValue, useSetAtom } from "jotai"; import { chatMessagesByIdAtom, chatStreamCountByIdAtom, + isStreamingByIdAtom, } from "../atoms/chatAtoms"; import { IpcClient } from "@/ipc/ipc_client"; @@ -30,6 +31,7 @@ export function ChatPanel({ const [isVersionPaneOpen, setIsVersionPaneOpen] = useState(false); const [error, setError] = useState(null); const streamCountById = useAtomValue(chatStreamCountByIdAtom); + const isStreamingById = useAtomValue(isStreamingByIdAtom); // Reference to store the processed prompt so we don't submit it twice const messagesEndRef = useRef(null); @@ -131,10 +133,13 @@ export function ChatPanel({ }, [fetchChatMessages]); const messages = chatId ? (messagesById.get(chatId) ?? []) : []; - // Auto-scroll effect when messages change + const isStreaming = chatId ? (isStreamingById.get(chatId) ?? false) : false; + + // Auto-scroll effect when messages change during streaming useEffect(() => { if ( !isUserScrolling && + isStreaming && messagesContainerRef.current && messages.length > 0 ) { @@ -145,7 +150,7 @@ export function ChatPanel({ }); } } - }, [messages, isUserScrolling]); + }, [messages, isUserScrolling, isStreaming]); return (