From f7fac831102cbe2d4bdc66afb45bf63879bd2d73 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 3 Oct 2024 02:03:47 -0400 Subject: [PATCH] Fix issue when retrying api req it would scroll up --- webview-ui/src/components/chat/ChatView.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 22568e6..e651287 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -504,6 +504,14 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie lastScrollTopRef.current = currentScrollTop }, []) + useEffect(() => { + const lastMessage = messages.at(-1) + if (lastMessage && lastMessage.say === "api_req_retried") { + // unique case where the api_req_started row will shrink in size when scrollview at bottom, causing didScrollUp to get set to true and followoutput to break. To mitigate this when an api request is retried, it's safe to assume they're already scrolled to the bottom + scrollToBottomAuto() + } + }, [messages, scrollToBottomAuto]) + const placeholderText = useMemo(() => { const text = task ? "Type a message (@ to add context)..." : "Type your task here (@ to add context)..." return text