Skip to content

Commit 93db129

Browse files
committed
fix: improve scroll lock behavior while maintaining memory efficiency
- Use dynamic increaseViewportBy bottom value based on scroll position - When at bottom, use larger value (10,000px) to maintain scroll lock - When scrolled up, use smaller value (1,000px) for memory efficiency - Add followOutput='smooth' for better scroll behavior - Fixes scroll lock issues introduced in PR #6697
1 parent 2b647ed commit 93db129

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18871887
ref={virtuosoRef}
18881888
key={task.ts}
18891889
className="scrollable grow overflow-y-scroll mb-1"
1890-
increaseViewportBy={{ top: 3_000, bottom: 1000 }}
1890+
increaseViewportBy={{
1891+
top: 3_000,
1892+
// Use a dynamic bottom value: larger when at bottom to maintain scroll lock,
1893+
// smaller when scrolled up to preserve memory efficiency
1894+
bottom: isAtBottom ? 10_000 : 1000,
1895+
}}
18911896
data={groupedMessages}
18921897
itemContent={itemContent}
18931898
atBottomStateChange={(isAtBottom: boolean) => {
@@ -1899,6 +1904,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
18991904
}}
19001905
atBottomThreshold={10}
19011906
initialTopMostItemIndex={groupedMessages.length - 1}
1907+
followOutput="smooth"
19021908
/>
19031909
</div>
19041910
<div className={`flex-initial min-h-0 ${!areButtonsVisible ? "mb-1" : ""}`}>

0 commit comments

Comments
 (0)