From 27e3f21c2485e48babdbf1fa64a478ee4b70b327 Mon Sep 17 00:00:00 2001 From: JF-Cozy Date: Tue, 12 Nov 2024 15:34:16 +0100 Subject: [PATCH] fix(Assistant): We wasn't scrolling to the end of the instant message as we move from string to object as assistant message, the useEffect wasn't retrigger correctly --- src/assistant/Conversations/ChatConversation.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/assistant/Conversations/ChatConversation.jsx b/src/assistant/Conversations/ChatConversation.jsx index 6272e4a28..35c051777 100644 --- a/src/assistant/Conversations/ChatConversation.jsx +++ b/src/assistant/Conversations/ChatConversation.jsx @@ -12,6 +12,7 @@ import ChatRealtimeAnswer from './ChatRealtimeAnswer' const ChatConversation = ({ conversation, myself }) => { const { assistantState } = useAssistant() const listRef = useRef() + const instantMessageKeysCount = Object.keys(assistantState.message).length // test on role === user to be sure the last response is inside io.cozy.ai.chat.conversations const showRealtimeMessage = @@ -21,11 +22,11 @@ const ChatConversation = ({ conversation, myself }) => { useEffect(() => { // force scroll down if new message of change in AI instant response - listRef.current?.lastElementChild?.scrollIntoView({ block: 'end' }) + listRef.current?.lastElementChild?.scrollIntoView(false) }, [ conversation?.messages?.length, assistantState.status, - assistantState.message + instantMessageKeysCount ]) return (