Compare commits

...

1 Commits

Author SHA1 Message Date
Weves
9b7f401618 Cleanup on ChatPage/MessagesDisply 2025-08-31 20:25:11 -07:00
2 changed files with 35 additions and 34 deletions

View File

@@ -362,39 +362,6 @@ export function ChatPage({
}
}, [setMessage, setCurrentMessageFiles]);
const clientScrollToBottom = useCallback((fast?: boolean) => {
waitForScrollRef.current = true;
setTimeout(() => {
if (!endDivRef.current || !scrollableDivRef.current) {
console.error("endDivRef or scrollableDivRef not found");
return;
}
const rect = endDivRef.current.getBoundingClientRect();
const isVisible = rect.top >= 0 && rect.bottom <= window.innerHeight;
if (isVisible) return;
// Check if all messages are currently rendered
// If all messages are already rendered, scroll immediately
endDivRef.current.scrollIntoView({
behavior: fast ? "auto" : "smooth",
});
if (chatSessionIdRef.current) {
useChatSessionStore
.getState()
.updateHasPerformedInitialScroll(chatSessionIdRef.current, true);
}
}, 50);
// Reset waitForScrollRef after 1.5 seconds
setTimeout(() => {
waitForScrollRef.current = false;
}, 1500);
}, []);
const debounceNumber = 100; // time for debouncing
// handle re-sizing of the text area
@@ -490,6 +457,40 @@ export function ChatPage({
(state) => state.updateCurrentChatSessionSharedStatus
);
const clientScrollToBottom = useCallback(
(fast?: boolean) => {
waitForScrollRef.current = true;
setTimeout(() => {
if (!endDivRef.current || !scrollableDivRef.current) {
console.error("endDivRef or scrollableDivRef not found");
return;
}
const rect = endDivRef.current.getBoundingClientRect();
const isVisible = rect.top >= 0 && rect.bottom <= window.innerHeight;
if (isVisible) return;
// Check if all messages are currently rendered
// If all messages are already rendered, scroll immediately
endDivRef.current.scrollIntoView({
behavior: fast ? "auto" : "smooth",
});
if (chatSessionIdRef.current) {
updateHasPerformedInitialScroll(chatSessionIdRef.current, true);
}
}, 50);
// Reset waitForScrollRef after 1.5 seconds
setTimeout(() => {
waitForScrollRef.current = false;
}, 1500);
},
[updateHasPerformedInitialScroll]
);
const { onSubmit, stopGenerating, handleMessageSpecificFileUpload } =
useChatController({
filterManager,

View File

@@ -1,5 +1,5 @@
import React, { RefObject, useCallback, useMemo } from "react";
import { CitationMap, Message } from "../interfaces";
import { Message } from "../interfaces";
import { OnyxDocument, MinimalOnyxDocument } from "@/lib/search/interfaces";
import { MemoizedHumanMessage } from "../message/MemoizedHumanMessage";
import { ErrorBanner } from "../message/Resubmit";