Skip to content

Commit c99ccf0

Browse files
authored
fix: Replace scrollToIndex with scrollTo to fix scroll jitter (RooCodeInc#6780)
1 parent c52fdc4 commit c99ccf0

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,23 +1334,10 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
13341334

13351335
const scrollToBottomSmooth = useMemo(
13361336
() =>
1337-
debounce(
1338-
() => {
1339-
const lastIndex = groupedMessages.length - 1
1340-
if (lastIndex >= 0) {
1341-
virtuosoRef.current?.scrollToIndex({
1342-
index: lastIndex,
1343-
behavior: "smooth",
1344-
align: "end",
1345-
})
1346-
}
1347-
},
1348-
10,
1349-
{
1350-
immediate: true,
1351-
},
1352-
),
1353-
[groupedMessages.length],
1337+
debounce(() => virtuosoRef.current?.scrollTo({ top: Number.MAX_SAFE_INTEGER, behavior: "smooth" }), 10, {
1338+
immediate: true,
1339+
}),
1340+
[],
13541341
)
13551342

13561343
useEffect(() => {
@@ -1362,15 +1349,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
13621349
}, [scrollToBottomSmooth])
13631350

13641351
const scrollToBottomAuto = useCallback(() => {
1365-
const lastIndex = groupedMessages.length - 1
1366-
if (lastIndex >= 0) {
1367-
virtuosoRef.current?.scrollToIndex({
1368-
index: lastIndex,
1369-
behavior: "auto", // Instant causes crash.
1370-
align: "end",
1371-
})
1372-
}
1373-
}, [groupedMessages.length])
1352+
virtuosoRef.current?.scrollTo({
1353+
top: Number.MAX_SAFE_INTEGER,
1354+
behavior: "auto", // Instant causes crash.
1355+
})
1356+
}, [])
13741357

13751358
const handleSetExpandedRow = useCallback(
13761359
(ts: number, expand?: boolean) => {

0 commit comments

Comments
 (0)