Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 62ffeb3

Browse files
committed
fix(desktop): auto scroll
1 parent 4a8e8f5 commit 62ffeb3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/ui/src/components/session-turn.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ export function SessionTurn(
5555
userScrolled: false,
5656
stickyHeaderHeight: 0,
5757
scrollY: 0,
58+
autoScrolling: false,
5859
})
5960

6061
function handleScroll() {
6162
if (!scrollRef) return
6263
setState("scrollY", scrollRef.scrollTop)
64+
if (state.autoScrolling) return
6365
const { scrollTop, scrollHeight, clientHeight } = scrollRef
6466
const atBottom = scrollHeight - scrollTop - clientHeight < 50
6567
if (!atBottom && working()) {
@@ -74,9 +76,13 @@ export function SessionTurn(
7476
}
7577

7678
function scrollToBottom() {
77-
if (!scrollRef || state.userScrolled || !working()) return
79+
if (!scrollRef || state.userScrolled || !working() || state.autoScrolling) return
80+
setState("autoScrolling", true)
7881
requestAnimationFrame(() => {
7982
scrollRef?.scrollTo({ top: scrollRef.scrollHeight, behavior: "auto" })
83+
requestAnimationFrame(() => {
84+
setState("autoScrolling", false)
85+
})
8086
})
8187
}
8288

0 commit comments

Comments
 (0)