Build and run agents you can see, understand and trust.
Python agentchatbotlarge-language-modelsllmllm-agentmcpmulti-agentmulti-modalreact-agentrealtime-agentvoice-agentvoice-assistant
fix(webui): scroll newly loaded sessions to bottom (#2100)
Cong Pendybdc65ace95ed
diff --git a/examples/web_ui/frontend/src/components/chat/ChatContent.tsx b/examples/web_ui/frontend/src/components/chat/ChatContent.tsxindex 16aa0b046..626391076 100644--- a/examples/web_ui/frontend/src/components/chat/ChatContent.tsx+++ b/examples/web_ui/frontend/src/components/chat/ChatContent.tsx@@ -65,21 +65,18 @@ const ChatContentComponent: React.FC<ChatContentProps> = ({const prevCount = prevMsgCountRef.current;const isActive = phase !== 'idle';- const shouldCheck =+ const isInitialLoad = prevCount === 0 && currentCount > 0;+ const hasRelevantUpdate =(currentCount > prevCount && prevCount > 0) || (isActive && prevCount > 0);+ const shouldScroll = isInitialLoad || (hasRelevantUpdate && wasNearBottomRef.current);- if (shouldCheck && scrollAreaRef.current) {+ if (shouldScroll && scrollAreaRef.current) {const { scrollHeight } = scrollAreaRef.current;- // Check if user was near bottom before content changed- const isNearBottom = wasNearBottomRef.current;-- if (isNearBottom) {- scrollAreaRef.current.scrollTo({- top: scrollHeight,- behavior: 'smooth',- });- }+ scrollAreaRef.current.scrollTo({+ top: scrollHeight,+ behavior: 'smooth',+ });}prevMsgCountRef.current = currentCount;