From c99ccf0bb0018348ec93d44e92d43f5016dc1339 Mon Sep 17 00:00:00 2001 From: Daniel <57051444+daniel-lxs@users.noreply.github.com> Date: Wed, 6 Aug 2025 19:24:18 -0500 Subject: [PATCH] fix: Replace scrollToIndex with scrollTo to fix scroll jitter (#6780) --- webview-ui/src/components/chat/ChatView.tsx | 35 ++++++--------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index e73ac67701..9b8c96dea1 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1334,23 +1334,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction - debounce( - () => { - const lastIndex = groupedMessages.length - 1 - if (lastIndex >= 0) { - virtuosoRef.current?.scrollToIndex({ - index: lastIndex, - behavior: "smooth", - align: "end", - }) - } - }, - 10, - { - immediate: true, - }, - ), - [groupedMessages.length], + debounce(() => virtuosoRef.current?.scrollTo({ top: Number.MAX_SAFE_INTEGER, behavior: "smooth" }), 10, { + immediate: true, + }), + [], ) useEffect(() => { @@ -1362,15 +1349,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction { - const lastIndex = groupedMessages.length - 1 - if (lastIndex >= 0) { - virtuosoRef.current?.scrollToIndex({ - index: lastIndex, - behavior: "auto", // Instant causes crash. - align: "end", - }) - } - }, [groupedMessages.length]) + virtuosoRef.current?.scrollTo({ + top: Number.MAX_SAFE_INTEGER, + behavior: "auto", // Instant causes crash. + }) + }, []) const handleSetExpandedRow = useCallback( (ts: number, expand?: boolean) => {