mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-07-03 11:11:45 +02:00
k (#2772)
This commit is contained in:
@ -777,7 +777,11 @@ export function ChatPage({
|
|||||||
|
|
||||||
const handleInputResize = () => {
|
const handleInputResize = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (inputRef.current && lastMessageRef.current) {
|
if (
|
||||||
|
inputRef.current &&
|
||||||
|
lastMessageRef.current &&
|
||||||
|
!waitForScrollRef.current
|
||||||
|
) {
|
||||||
const newHeight: number =
|
const newHeight: number =
|
||||||
inputRef.current?.getBoundingClientRect().height!;
|
inputRef.current?.getBoundingClientRect().height!;
|
||||||
const heightDifference = newHeight - previousHeight.current;
|
const heightDifference = newHeight - previousHeight.current;
|
||||||
@ -806,8 +810,11 @@ export function ChatPage({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const clientScrollToBottom = (fast?: boolean) => {
|
const clientScrollToBottom = (fast?: boolean) => {
|
||||||
|
waitForScrollRef.current = true;
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!endDivRef.current || !scrollableDivRef.current) {
|
if (!endDivRef.current || !scrollableDivRef.current) {
|
||||||
|
console.error("endDivRef or scrollableDivRef not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,6 +825,7 @@ export function ChatPage({
|
|||||||
|
|
||||||
// Check if all messages are currently rendered
|
// Check if all messages are currently rendered
|
||||||
if (currentVisibleRange.end < messageHistory.length) {
|
if (currentVisibleRange.end < messageHistory.length) {
|
||||||
|
console.log("Updating visible range");
|
||||||
// Update visible range to include the last messages
|
// Update visible range to include the last messages
|
||||||
updateCurrentVisibleRange({
|
updateCurrentVisibleRange({
|
||||||
start: Math.max(
|
start: Math.max(
|
||||||
@ -835,8 +843,9 @@ export function ChatPage({
|
|||||||
behavior: fast ? "auto" : "smooth",
|
behavior: fast ? "auto" : "smooth",
|
||||||
});
|
});
|
||||||
setHasPerformedInitialScroll(true);
|
setHasPerformedInitialScroll(true);
|
||||||
}, 0);
|
}, 100);
|
||||||
} else {
|
} else {
|
||||||
|
console.log("All messages are already rendered, scrolling immediately");
|
||||||
// If all messages are already rendered, scroll immediately
|
// If all messages are already rendered, scroll immediately
|
||||||
endDivRef.current.scrollIntoView({
|
endDivRef.current.scrollIntoView({
|
||||||
behavior: fast ? "auto" : "smooth",
|
behavior: fast ? "auto" : "smooth",
|
||||||
@ -844,6 +853,11 @@ export function ChatPage({
|
|||||||
setHasPerformedInitialScroll(true);
|
setHasPerformedInitialScroll(true);
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
|
// Reset waitForScrollRef after 1.5 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
waitForScrollRef.current = false;
|
||||||
|
}, 1500);
|
||||||
};
|
};
|
||||||
|
|
||||||
const distance = 500; // distance that should "engage" the scroll
|
const distance = 500; // distance that should "engage" the scroll
|
||||||
@ -1553,6 +1567,7 @@ export function ChatPage({
|
|||||||
toggle(false);
|
toggle(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const waitForScrollRef = useRef(false);
|
||||||
const sidebarElementRef = useRef<HTMLDivElement>(null);
|
const sidebarElementRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useSidebarVisibility({
|
useSidebarVisibility({
|
||||||
@ -1571,6 +1586,7 @@ export function ChatPage({
|
|||||||
endDivRef,
|
endDivRef,
|
||||||
distance,
|
distance,
|
||||||
debounceNumber,
|
debounceNumber,
|
||||||
|
waitForScrollRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Virtualization + Scrolling related effects and functions
|
// Virtualization + Scrolling related effects and functions
|
||||||
|
@ -641,9 +641,11 @@ export async function useScrollonStream({
|
|||||||
endDivRef,
|
endDivRef,
|
||||||
distance,
|
distance,
|
||||||
debounceNumber,
|
debounceNumber,
|
||||||
|
waitForScrollRef,
|
||||||
}: {
|
}: {
|
||||||
chatState: ChatState;
|
chatState: ChatState;
|
||||||
scrollableDivRef: RefObject<HTMLDivElement>;
|
scrollableDivRef: RefObject<HTMLDivElement>;
|
||||||
|
waitForScrollRef: RefObject<boolean>;
|
||||||
scrollDist: MutableRefObject<number>;
|
scrollDist: MutableRefObject<number>;
|
||||||
endDivRef: RefObject<HTMLDivElement>;
|
endDivRef: RefObject<HTMLDivElement>;
|
||||||
distance: number;
|
distance: number;
|
||||||
|
Reference in New Issue
Block a user