From 6fa41d51bee15c7e80043cf56806d0309cbe8c34 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Fri, 14 Nov 2025 16:26:14 +0000 Subject: [PATCH] stabilize message auto scroll --- src/components/message-stream.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/message-stream.tsx b/src/components/message-stream.tsx index e3d3649b..08da3b8c 100644 --- a/src/components/message-stream.tsx +++ b/src/components/message-stream.tsx @@ -36,6 +36,7 @@ import { setActiveInstanceId } from "../stores/instances" const codeNomadLogo = new URL("../../images/CodeNomad-Icon.png", import.meta.url).href const SCROLL_OFFSET = 64 +const SCROLL_DIRECTION_THRESHOLD = 10 interface TaskSessionLocation { sessionId: string @@ -265,13 +266,13 @@ export default function MessageStream(props: MessageStreamProps) { if (!containerRef) return const currentScrollTop = containerRef.scrollTop - const movingUp = currentScrollTop < lastKnownScrollTop - 1 + const movingUp = currentScrollTop < lastKnownScrollTop - SCROLL_DIRECTION_THRESHOLD lastKnownScrollTop = currentScrollTop const atBottom = isNearBottom(containerRef) if (isUserScroll) { - if ((movingUp || !atBottom) && autoScroll()) { + if (movingUp && !atBottom && autoScroll()) { setAutoScroll(false) } else if (!movingUp && atBottom && !autoScroll()) { setAutoScroll(true)