diff --git a/packages/ui/src/components/chat/ChatContainer.tsx b/packages/ui/src/components/chat/ChatContainer.tsx index 54ee63d6..63869dc2 100644 --- a/packages/ui/src/components/chat/ChatContainer.tsx +++ b/packages/ui/src/components/chat/ChatContainer.tsx @@ -156,6 +156,7 @@ type ChatViewportProps = { handleMessageContentChange: (reason?: ContentChangeReason) => void; getAnimationHandlers: (messageId: string) => AnimationHandlers; handleLoadOlder: () => void; + handleHistoryScroll: () => void; scrollToBottom: () => void; sessionQuestions: QuestionRequest[]; sessionPermissions: PermissionRequest[]; @@ -181,6 +182,7 @@ const ChatViewport = React.memo(({ handleMessageContentChange, getAnimationHandlers, handleLoadOlder, + handleHistoryScroll, scrollToBottom, sessionQuestions, sessionPermissions, @@ -217,6 +219,7 @@ const ChatViewport = React.memo(({ hideTopShadow={isMobile && stickyUserHeader} tabIndex={0} onClick={focusScrollContainer} + onScroll={handleHistoryScroll} data-scroll-shadow="true" data-scrollbar="chat" > @@ -280,6 +283,7 @@ const ChatViewport = React.memo(({ && prev.handleMessageContentChange === next.handleMessageContentChange && prev.getAnimationHandlers === next.getAnimationHandlers && prev.handleLoadOlder === next.handleLoadOlder + && prev.handleHistoryScroll === next.handleHistoryScroll && prev.scrollToBottom === next.scrollToBottom && prev.sessionQuestions === next.sessionQuestions && prev.sessionPermissions === next.sessionPermissions @@ -655,7 +659,7 @@ export const ChatContainer: React.FC = ({ autoOpenDraft = tr }, [handleMessageContentChange, sessionPermissions, sessionQuestions]); const handleLoadOlder = React.useCallback(() => { - void loadEarlier(); + void loadEarlier({ userInitiated: true }); }, [loadEarlier]); const navigation = useChatTurnNavigation({ @@ -950,6 +954,7 @@ export const ChatContainer: React.FC = ({ autoOpenDraft = tr handleMessageContentChange={handleMessageContentChange} getAnimationHandlers={getAnimationHandlers} handleLoadOlder={handleLoadOlder} + handleHistoryScroll={timelineController.handleHistoryScroll} scrollToBottom={resumeToLatestInstant} sessionQuestions={sessionQuestions} sessionPermissions={sessionPermissions} diff --git a/packages/ui/src/components/chat/MessageList.tsx b/packages/ui/src/components/chat/MessageList.tsx index 95c2674b..121f6910 100644 --- a/packages/ui/src/components/chat/MessageList.tsx +++ b/packages/ui/src/components/chat/MessageList.tsx @@ -1005,15 +1005,9 @@ const StaticHistoryList = React.memo(({ entries, shouldVirtualize, virtualRows, } if (virtualRows.length === 0 && entries.length > 0) { - const fallbackStart = Math.max(0, entries.length - MESSAGE_LIST_OVERSCAN * 2); - const fallbackEntries = entries.slice(fallbackStart); - const fallbackHeight = fallbackEntries.reduce((total, entry) => total + estimateHistoryEntryHeight(entry), 0); - const fallbackPaddingTop = Math.max(0, totalSize - fallbackHeight); - return (
- {fallbackPaddingTop > 0 ?