Compare commits

...

2 Commits

Author SHA1 Message Date
pablodanswer
4c974007d1 nit 2025-01-18 11:42:41 -08:00
pablodanswer
9a7aea3067 fix found 2025-01-17 17:37:13 -08:00

View File

@@ -432,7 +432,9 @@ export function ChatPage({
// if switching from one chat to another, then need to scroll again
// if we're creating a brand new chat, then don't need to scroll
if (chatSessionIdRef.current !== null) {
// we must always set this to true once we animate a new chat session. Thi sis
// handled
if (chatSessionIdRef.current !== null && chatSessionIdRef.current) {
setHasPerformedInitialScroll(false);
}
}
@@ -460,7 +462,8 @@ export function ChatPage({
}
const shouldScrollToBottom =
visibleRange.get(existingChatSessionId) === undefined ||
visibleRange.get(existingChatSessionId)?.end == 0;
visibleRange.get(existingChatSessionId)?.end == 0 ||
visibleRange.get(existingChatSessionId)?.end == BUFFER_COUNT;
clearSelectedDocuments();
setIsFetchingChatMessages(true);
@@ -507,6 +510,8 @@ export function ChatPage({
} else if (isChatSessionSwitch && autoScrollEnabled) {
clientScrollToBottom(true);
}
} else {
setHasPerformedInitialScroll(true);
}
setIsFetchingChatMessages(false);
@@ -918,14 +923,16 @@ export function ChatPage({
setTimeout(() => {
if (!endDivRef.current || !scrollableDivRef.current) {
console.error("endDivRef or scrollableDivRef not found");
console.log("endDivRef or scrollableDivRef not found");
return;
}
const rect = endDivRef.current.getBoundingClientRect();
const isVisible = rect.top >= 0 && rect.bottom <= window.innerHeight;
if (isVisible) return;
if (isVisible) {
return;
}
// Check if all messages are currently rendered
if (currentVisibleRange.end < messageHistory.length) {
@@ -945,15 +952,12 @@ export function ChatPage({
endDivRef.current?.scrollIntoView({
behavior: fast ? "auto" : "smooth",
});
setHasPerformedInitialScroll(true);
}, 100);
} else {
// If all messages are already rendered, scroll immediately
endDivRef.current.scrollIntoView({
behavior: fast ? "auto" : "smooth",
});
setHasPerformedInitialScroll(true);
}
}, 50);
@@ -2087,6 +2091,17 @@ export function ChatPage({
</Modal>
</div>
)}
<div className="fixed pointer-events-none z-[100000000] inset-0 flex items-center justify-center text-default">
<div className="h-[400px] w-full flex items-center justify-center">
<div className="w-full max-w-md">
<div className="bg-background-100 rounded-lg shadow-lg p-6 text-center">
<div className="w-full relative">
{hasPerformedInitialScroll ? "HAS" : "NOT"}
</div>
</div>
</div>
</div>
</div>
{presentingDocument && (
<TextView
@@ -2340,8 +2355,8 @@ export function ChatPage({
(settings?.enterpriseSettings
?.two_lines_for_chat_header
? "pt-20 "
: "pt-8") +
(hasPerformedInitialScroll ? "" : "invisible")
: "pt-8 ") +
(hasPerformedInitialScroll ? "" : " invisible")
}
>
{(messageHistory.length < BUFFER_COUNT