diff options
| author | Adam <[email protected]> | 2025-12-17 15:58:54 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-17 16:04:40 -0600 |
| commit | a168d854f46c68736aefcb321839684e71d240af (patch) | |
| tree | 3ef1e3e08df1140fd06ac520980ebcfd07e418de | |
| parent | 31645f5578d044f249258a26e1d298a3f31a7be4 (diff) | |
| download | opencode-a168d854f46c68736aefcb321839684e71d240af.tar.gz opencode-a168d854f46c68736aefcb321839684e71d240af.zip | |
fix: auto-scroll
| -rw-r--r-- | packages/ui/src/components/session-turn.tsx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/packages/ui/src/components/session-turn.tsx b/packages/ui/src/components/session-turn.tsx index 79b3b7d47..5be4a6bb4 100644 --- a/packages/ui/src/components/session-turn.tsx +++ b/packages/ui/src/components/session-turn.tsx @@ -56,6 +56,7 @@ export function SessionTurn( }) let scrollRef: HTMLDivElement | undefined + let lastScrollTop = 0 const [state, setState] = createStore({ contentRef: undefined as HTMLDivElement | undefined, stickyTitleRef: undefined as HTMLDivElement | undefined, @@ -84,11 +85,14 @@ export function SessionTurn( function handleScroll() { if (!scrollRef || state.autoScrolled) return - const { scrollTop, scrollHeight, clientHeight } = scrollRef - const atBottom = scrollHeight - scrollTop - clientHeight < 50 - if (!atBottom && working()) { + const { scrollTop } = scrollRef + // only mark as user scrolled if they actively scrolled upward + // content growth increases scrollHeight but never decreases scrollTop + const scrolledUp = scrollTop < lastScrollTop - 10 + if (scrolledUp && working()) { setState("userScrolled", true) } + lastScrollTop = scrollTop } function handleInteraction() { @@ -103,6 +107,7 @@ export function SessionTurn( requestAnimationFrame(() => { scrollRef?.scrollTo({ top: scrollRef.scrollHeight, behavior: "smooth" }) requestAnimationFrame(() => { + lastScrollTop = scrollRef?.scrollTop ?? 0 setState("autoScrolled", false) }) }) |
