diff --git a/web/src/components/Chat/ChatContent.tsx b/web/src/components/Chat/ChatContent.tsx index 31b43064..c73d91f5 100644 --- a/web/src/components/Chat/ChatContent.tsx +++ b/web/src/components/Chat/ChatContent.tsx @@ -2,7 +2,7 @@ * @Author: ZhaoYing * @Date: 2025-12-10 16:46:17 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-19 10:35:21 + * @Last Modified time: 2026-03-19 10:37:01 */ import { type FC, useRef, useEffect, useState } from 'react' import clsx from 'clsx' @@ -59,8 +59,8 @@ const ChatContent: FC = ({ const handleScroll = () => { if (scrollContainerRef.current) { const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current; - // Consider user is at bottom if within 20px of the bottom - isScrolledToBottomRef.current = scrollHeight - scrollTop - clientHeight < 20; + // Consider user is at bottom if within 100px of the bottom + isScrolledToBottomRef.current = scrollHeight - scrollTop - clientHeight < 100; } }; @@ -88,6 +88,7 @@ const ChatContent: FC = ({ // Auto-scroll if data length changed OR user is currently at bottom if (data.length !== prevDataLengthRef.current || isScrolledToBottomRef.current) { scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight; + isScrolledToBottomRef.current = true; } prevDataLengthRef.current = data.length; } diff --git a/web/src/components/Markdown/index.tsx b/web/src/components/Markdown/index.tsx index 9d3c482b..3a0712ec 100644 --- a/web/src/components/Markdown/index.tsx +++ b/web/src/components/Markdown/index.tsx @@ -136,7 +136,7 @@ const RbMarkdown: FC = ({ /** Sync edit content when external content changes */ useEffect(() => { - setEditContent(content) + setEditContent(prev => prev !== content ? content : prev) }, [content]) /** Handle textarea content changes and trigger callback */