diff --git a/web-app/src/containers/ScrollToBottom.tsx b/web-app/src/containers/ScrollToBottom.tsx index b1259480f..c2ae8403f 100644 --- a/web-app/src/containers/ScrollToBottom.tsx +++ b/web-app/src/containers/ScrollToBottom.tsx @@ -8,6 +8,7 @@ import { cn } from '@/lib/utils' import { ArrowDown } from 'lucide-react' import { useTranslation } from '@/i18n/react-i18next-compat' import { useAppState } from '@/hooks/useAppState' +import { MessageStatus } from '@janhq/core' const ScrollToBottom = ({ threadId, @@ -18,8 +19,10 @@ const ScrollToBottom = ({ }) => { const { t } = useTranslation() const appMainViewBgColor = useAppearance((state) => state.appMainViewBgColor) - const { showScrollToBottomBtn, scrollToBottom } = - useThreadScrolling(threadId, scrollContainerRef) + const { showScrollToBottomBtn, scrollToBottom } = useThreadScrolling( + threadId, + scrollContainerRef + ) const { messages } = useMessages( useShallow((state) => ({ messages: state.messages[threadId], @@ -28,12 +31,9 @@ const ScrollToBottom = ({ const streamingContent = useAppState((state) => state.streamingContent) + const lastMsg = messages[messages.length - 1] const showGenerateAIResponseBtn = - (messages[messages.length - 1]?.role === 'user' || - (messages[messages.length - 1]?.metadata && - 'tool_calls' in (messages[messages.length - 1].metadata ?? {}))) && - !streamingContent - + !!lastMsg && lastMsg.status !== MessageStatus.Ready && !streamingContent return (