diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index e73ac677019..afc37c7e560 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -70,6 +70,11 @@ export interface ChatViewRef { export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images +// Viewport buffer constants +const VIEWPORT_BUFFER_AT_BOTTOM = 10_000 // Maintains scroll lock when at bottom +const VIEWPORT_BUFFER_SCROLLED_UP = 1_000 // Reduces memory usage when scrolled up +const VIEWPORT_BUFFER_TOP = 3_000 + const isMac = navigator.platform.toUpperCase().indexOf("MAC") >= 0 const ChatViewComponent: React.ForwardRefRenderFunction = ( @@ -174,6 +179,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction("") const [wasStreaming, setWasStreaming] = useState(false) const [showCheckpointWarning, setShowCheckpointWarning] = useState(false) @@ -1430,6 +1437,15 @@ const ChatViewComponent: React.ForwardRefRenderFunction { + const timer = setTimeout(() => { + setDebouncedIsAtBottom(isAtBottom) + }, 300) + + return () => clearTimeout(timer) + }, [isAtBottom]) + // Effect to handle showing the checkpoint warning after a delay useEffect(() => { // Only show the warning when there's a task but no visible messages yet @@ -1887,7 +1903,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction { @@ -1899,6 +1920,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction