From 93d5dbd92aae2a156f8805dac81470fed2c34197 Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 14 Mar 2026 19:56:55 +0000 Subject: [PATCH] story-kit: fix chat auto-scroll to bottom on new messages (bug 248) Correct lastScrollTopRef assignment in scrollToBottom to read back the browser-capped scrollTop value instead of using scrollHeight, which was causing handleScroll to incorrectly detect upward scrolling and disable auto-scroll. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/Chat.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Chat.tsx b/frontend/src/components/Chat.tsx index 1368ec9..8b9e605 100644 --- a/frontend/src/components/Chat.tsx +++ b/frontend/src/components/Chat.tsx @@ -390,7 +390,11 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) { const element = scrollContainerRef.current; if (element) { element.scrollTop = element.scrollHeight; - lastScrollTopRef.current = element.scrollHeight; + // Read scrollTop back after assignment: the browser caps it at + // (scrollHeight - clientHeight), so storing scrollHeight would + // make handleScroll incorrectly interpret the next scroll event + // as an upward scroll and disable auto-scrolling. + lastScrollTopRef.current = element.scrollTop; } }, []);