diff --git a/ee/tabby-ui/components/chat/chat.tsx b/ee/tabby-ui/components/chat/chat.tsx index edf172f2c58f..f3c8547276e1 100644 --- a/ee/tabby-ui/components/chat/chat.tsx +++ b/ee/tabby-ui/components/chat/chat.tsx @@ -228,6 +228,23 @@ function ChatRenderer( }) }, [answer, isLoading]) + React.useLayoutEffect(() => { + // scroll to bottom when a request is sent + if (isLoading) { + if (container) { + container.scrollTo({ + top: container.scrollHeight, + behavior: 'smooth' + }) + } else { + window.scrollTo({ + top: document.body.offsetHeight, + behavior: 'smooth' + }) + } + } + }, [isLoading]) + React.useEffect(() => { if (error && qaPairs?.length) { setQaPairs(prev => {