Skip to content

Commit

Permalink
fix(Assistant): We wasn't scrolling to the end of the instant message
Browse files Browse the repository at this point in the history
as we move from string to object as assistant message, the useEffect wasn't retrigger correctly
  • Loading branch information
JF-Cozy committed Nov 12, 2024
1 parent a352589 commit 27e3f21
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/assistant/Conversations/ChatConversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 (
Expand Down

0 comments on commit 27e3f21

Please sign in to comment.