@@ -3527,6 +3527,8 @@ function ChatViewContent(props: ChatViewProps) {
35273527 const activeTimelineAnchorIndexRef = useRef < number | null > ( null ) ;
35283528 const anchorUserScrollGenerationRef = useRef ( 0 ) ;
35293529 const liveFollowUserScrollGenerationRef = useRef < number | null > ( 0 ) ;
3530+ // Manual navigation stops live-follow without removing anchored end space.
3531+ // Collapsing that space during a gesture clamps the viewport back to the end.
35303532 const cancelTimelineLiveFollowForUserNavigation = useCallback ( ( ) => {
35313533 anchorUserScrollGenerationRef . current += 1 ;
35323534 timelineScrollModeRef . current = "free-scrolling" ;
@@ -3536,9 +3538,6 @@ function ChatViewContent(props: ChatViewProps) {
35363538 positionedTimelineAnchorRef . current = null ;
35373539 settledTimelineAnchorRef . current = null ;
35383540 activeTimelineAnchorIndexRef . current = null ;
3539- setTimelineAnchor ( ( current ) =>
3540- current . messageId === null ? current : { ...current , messageId : null } ,
3541- ) ;
35423541 } , [ ] ) ;
35433542 const cancelTimelineLiveFollowForUserNavigationRef = useRef (
35443543 cancelTimelineLiveFollowForUserNavigation ,
@@ -3565,6 +3564,35 @@ function ChatViewContent(props: ChatViewProps) {
35653564 } ,
35663565 [ composerOverlayHeight ] ,
35673566 ) ;
3567+ const timelineRealContentOverflowsViewport = useCallback (
3568+ ( list ?: LegendListRef | null ) => {
3569+ const resolvedList = list ?? legendListRef . current ;
3570+ const state = resolvedList ?. getState ( ) ;
3571+ if ( ! resolvedList || ! state || state . data . length === 0 ) {
3572+ return false ;
3573+ }
3574+
3575+ const lastRowIndex = state . data . length - 1 ;
3576+ const lastRowTop = state . positionAtIndex ( lastRowIndex ) ;
3577+ const lastRowHeight = state . sizeAtIndex ( lastRowIndex ) ;
3578+ if (
3579+ typeof lastRowTop !== "number" ||
3580+ typeof lastRowHeight !== "number" ||
3581+ ! Number . isFinite ( lastRowTop ) ||
3582+ ! Number . isFinite ( lastRowHeight )
3583+ ) {
3584+ return false ;
3585+ }
3586+
3587+ const realContentBottom = lastRowTop + Math . max ( 1 , lastRowHeight ) ;
3588+ const visibleScrollLength = Math . max (
3589+ 0 ,
3590+ ( state . scrollLength ?? 0 ) - composerOverlayHeight - CHAT_LIST_ANCHOR_OFFSET ,
3591+ ) ;
3592+ return realContentBottom > visibleScrollLength ;
3593+ } ,
3594+ [ composerOverlayHeight ] ,
3595+ ) ;
35683596 // Live-follow stays active after send/thread-open until an actual list scroll
35693597 // gesture opts out.
35703598 const scrollToEnd = useCallback ( ( animated = false ) => {
0 commit comments