@@ -70,10 +70,10 @@ export interface ChatViewRef {
7070
7171export const MAX_IMAGES_PER_MESSAGE = 20 // Anthropic limits to 20 images
7272
73- // Viewport buffer constants for memory-efficient scroll behavior
74- const VIEWPORT_BUFFER_AT_BOTTOM = 10_000 // Larger buffer when at bottom to maintain scroll lock
75- const VIEWPORT_BUFFER_SCROLLED_UP = 1_000 // Smaller buffer when scrolled up to preserve memory efficiency
76- const VIEWPORT_BUFFER_TOP = 3_000 // Top buffer for smooth scrolling
73+ // Viewport buffer constants
74+ const VIEWPORT_BUFFER_AT_BOTTOM = 10_000 // Maintains scroll lock when at bottom
75+ const VIEWPORT_BUFFER_SCROLLED_UP = 1_000 // Reduces memory usage when scrolled up
76+ const VIEWPORT_BUFFER_TOP = 3_000
7777
7878const isMac = navigator . platform . toUpperCase ( ) . indexOf ( "MAC" ) >= 0
7979
@@ -1437,12 +1437,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
14371437
14381438 useEvent ( "wheel" , handleWheel , window , { passive : true } ) // passive improves scrolling performance
14391439
1440- // Debounce the isAtBottom state to prevent rapid viewport buffer changes
1441- // This adds hysteresis to avoid performance issues when users quickly scroll between top and bottom
1440+ // Debounce isAtBottom to prevent rapid viewport buffer changes
14421441 useEffect ( ( ) => {
14431442 const timer = setTimeout ( ( ) => {
14441443 setDebouncedIsAtBottom ( isAtBottom )
1445- } , 300 ) // 300ms delay provides good balance between responsiveness and stability
1444+ } , 300 )
14461445
14471446 return ( ) => clearTimeout ( timer )
14481447 } , [ isAtBottom ] )
@@ -1906,11 +1905,8 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
19061905 className = "scrollable grow overflow-y-scroll mb-1"
19071906 increaseViewportBy = { {
19081907 top : VIEWPORT_BUFFER_TOP ,
1909- // Dynamic bottom buffer based on scroll position:
1910- // - When at bottom: Use larger buffer to maintain scroll lock behavior
1911- // - When scrolled up: Use smaller buffer to preserve memory efficiency
1912- // This balances the memory leak fix from PR #6697 with proper scroll lock functionality
1913- // Using debounced state to prevent rapid toggling during quick scrolling
1908+ // Dynamic bottom buffer: larger when at bottom for scroll lock,
1909+ // smaller when scrolled up for memory efficiency
19141910 bottom : debouncedIsAtBottom ? VIEWPORT_BUFFER_AT_BOTTOM : VIEWPORT_BUFFER_SCROLLED_UP ,
19151911 } }
19161912 data = { groupedMessages }
@@ -1924,9 +1920,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
19241920 } }
19251921 atBottomThreshold = { 10 }
19261922 initialTopMostItemIndex = { groupedMessages . length - 1 }
1927- // followOutput='smooth' ensures smooth scrolling animation when new content arrives,
1928- // working in conjunction with the dynamic viewport buffer to maintain scroll lock
1929- // when the user is at the bottom of the chat
1923+ // Smooth scrolling when new content arrives
19301924 followOutput = "smooth"
19311925 />
19321926 </ div >
0 commit comments