diff --git a/web/components/chat/chat-container.tsx b/web/components/chat/chat-container.tsx
index c6eb65ac1..793dbaf23 100644
--- a/web/components/chat/chat-container.tsx
+++ b/web/components/chat/chat-container.tsx
@@ -219,14 +219,17 @@ const ChatContainer = () => {
)}
{/* Wrap the Completion component in a container with a specific height */}
-
diff --git a/web/components/chat/completion.tsx b/web/components/chat/completion.tsx
index 7611b75eb..d84dee18a 100644
--- a/web/components/chat/completion.tsx
+++ b/web/components/chat/completion.tsx
@@ -178,15 +178,44 @@ const Completion = ({ messages, onSubmit, onFormatContent }: Props) => {
}, []);
useEffect(() => {
- setTimeout(() => {
- scrollableRef.current?.scrollTo(0, scrollableRef.current.scrollHeight);
- }, 50);
- }, [messages]);
+ // Scroll to bottom when messages change
+ const scrollToBottom = () => {
+ if (scrollableRef.current) {
+ const element = scrollableRef.current;
+ // Force scroll to bottom using multiple methods
+ element.scrollTop = element.scrollHeight;
+ element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
+
+ // Additional force scroll for chat_dashboard
+ if (scene === 'chat_dashboard') {
+ requestAnimationFrame(() => {
+ element.scrollTop = element.scrollHeight;
+ });
+ }
+ }
+ };
+
+ // Use multiple timeouts to ensure scrolling works even with dynamic content
+ setTimeout(scrollToBottom, 50);
+ setTimeout(scrollToBottom, 200);
+ setTimeout(scrollToBottom, 500);
+
+ // Additional timeout for chat_dashboard
+ if (scene === 'chat_dashboard') {
+ setTimeout(scrollToBottom, 1000);
+ }
+
+ // Also try immediate scroll
+ scrollToBottom();
+ }, [messages, showMessages, scene]);
return (
<>
{contextHolder}
-
+
{showMessages.length ? (
showMessages.map((content, index) => {