An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: Show scroll-to-bottom button during message generation
Yoshiki Miura558b6106c627
diff --git a/components/chat.tsx b/components/chat.tsxindex a5a25c02..5deb46ae 100644--- a/components/chat.tsx+++ b/components/chat.tsx@@ -233,6 +233,20 @@ export function Chat({return () => container.removeEventListener('scroll', handleScroll)}, [])+ // Check scroll position when messages change (during generation)+ useEffect(() => {+ const container = scrollContainerRef.current+ if (!container) return++ const { scrollTop, scrollHeight, clientHeight } = container+ const threshold = 50+ if (scrollHeight - scrollTop - clientHeight < threshold) {+ setIsAtBottom(true)+ } else {+ setIsAtBottom(false)+ }+ }, [messages])+// Scroll to the section when a new user message is sentuseEffect(() => {// Only scroll if this chat is currently visible in the URL