Skip to content

Commit ff63c8c

Browse files
Merge pull request #5290 from uinstinct/smooth-scroll-chat
add smooth scrolling to chat
2 parents 5d9128e + 2361b03 commit ff63c8c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

extensions/vscode/e2e/tests/GUI.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ describe("GUI Test", () => {
400400
GUISelectors.getThreadMessageByText(view, llmResponse),
401401
);
402402

403+
await new Promise(resolve=>setTimeout(resolve, 500));
404+
403405
const viewportHeight = await driver.executeScript(
404406
"return window.innerHeight",
405407
);

gui/src/pages/gui/useAutoScroll.ts

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ export const useAutoScroll = (
99
useEffect(() => {
1010
if (history.length) {
1111
setUserHasScrolled(false);
12+
if (ref.current) {
13+
// smooth scroll to the bottom of the chat
14+
ref.current.style.scrollBehavior = "smooth";
15+
ref.current.scrollTop = ref.current.scrollHeight;
16+
17+
// use 100 ms delay to scroll to restore the scroll and wait for the chat to be scrolled
18+
const timer = setTimeout(() => {
19+
ref.current!.style.scrollBehavior = "auto";
20+
clearTimeout(timer);
21+
}, 100);
22+
}
1223
}
1324
}, [history.length]);
1425

0 commit comments

Comments
 (0)