Only scroll to bottom when user messages are added (#1788)

This commit is contained in:
Zero Liu 2025-09-05 12:09:07 -07:00 committed by GitHub
parent 9239dab78a
commit bb8bbcb5d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,10 +136,15 @@ export const useChatScrolling = ({
scrollToBottom("instant");
}, [scrollToBottom]);
// Scroll to bottom when new messages are added
// Scroll to bottom only when user messages are added (not AI messages)
useEffect(() => {
scrollToBottom();
}, [chatHistory.length, scrollToBottom]);
if (chatHistory.length > 0) {
const lastMessage = chatHistory[chatHistory.length - 1];
if (lastMessage && lastMessage.sender === USER_SENDER) {
scrollToBottom();
}
}
}, [chatHistory.length, chatHistory, scrollToBottom]);
return {
containerMinHeight,