From c6a9ce2046f61f011455a8de65d2dbbc94bf6401 Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 22:30:54 -0600 Subject: [PATCH] fix: auto-scroll in GlobalChatPane embedded mode The scroll effects were checking `isOpen` which is false in embedded mode. Now checks for either `isOpen` or `embedded` to enable auto-scrolling. --- src/components/GlobalChatPane.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/GlobalChatPane.tsx b/src/components/GlobalChatPane.tsx index c06828c9..3f7631ac 100644 --- a/src/components/GlobalChatPane.tsx +++ b/src/components/GlobalChatPane.tsx @@ -123,9 +123,10 @@ export function GlobalChatPane({ embedded = false, mobileChatMode, onMobileChatM } }, [providerModel, settings.recentlyUsedModels, setProviderModel]); - // Scroll to bottom and focus textarea when chat opens + // Scroll to bottom and focus textarea when chat opens (or when embedded mode becomes active) useEffect(() => { - if (isOpen && scrollAreaRef.current) { + const shouldScroll = isOpen || embedded; + if (shouldScroll && scrollAreaRef.current) { // Small delay to ensure content is rendered requestAnimationFrame(() => { if (scrollAreaRef.current) { @@ -137,17 +138,18 @@ export function GlobalChatPane({ embedded = false, mobileChatMode, onMobileChatM // Reset scroll tracking when opening userScrolledUp.current = false; } - }, [isOpen]); + }, [isOpen, embedded]); // Auto-scroll to bottom when messages change or streaming content updates useEffect(() => { - if (!scrollAreaRef.current || !isOpen) return; + const isActive = isOpen || embedded; + if (!scrollAreaRef.current || !isActive) return; // Only auto-scroll if user hasn't manually scrolled up if (!userScrolledUp.current) { scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight; } - }, [messages, lastMessageContent, isLoading, isOpen]); + }, [messages, lastMessageContent, isLoading, isOpen, embedded]); // Handle scroll to detect user scrolling and show/hide scroll-to-bottom button const handleScroll = useCallback(() => {