Merge pull request #5290 from uinstinct/smooth-scroll-chat

add smooth scrolling to chat
This commit is contained in:
Patrick Erichsen 2025-04-28 15:42:06 -07:00 • committed by GitHub
commit ff63c8cb6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -400,6 +400,8 @@ describe("GUI Test", () => {
GUISelectors.getThreadMessageByText(view, llmResponse),
);
await new Promise(resolve=>setTimeout(resolve, 500));
const viewportHeight = await driver.executeScript(
"return window.innerHeight",
);

View file

@ -9,6 +9,17 @@ export const useAutoScroll = (
useEffect(() => {
if (history.length) {
setUserHasScrolled(false);
if (ref.current) {
// smooth scroll to the bottom of the chat
ref.current.style.scrollBehavior = "smooth";
ref.current.scrollTop = ref.current.scrollHeight;
// use 100 ms delay to scroll to restore the scroll and wait for the chat to be scrolled
const timer = setTimeout(() => {
ref.current!.style.scrollBehavior = "auto";
clearTimeout(timer);
}, 100);
}
}
}, [history.length]);