Squash misc UX bugs (#2356)

This commit is contained in:
pablodanswer
2024-09-07 14:26:14 -07:00
committed by GitHub
parent fb3d7330fa
commit 350482e53e

View File

@@ -128,7 +128,7 @@ export function ChatPage({
userInputPrompts, userInputPrompts,
} = useChatContext(); } = useChatContext();
const { user, refreshUser } = useUser(); const { user, refreshUser, isLoadingUser } = useUser();
// chat session // chat session
const existingChatIdRaw = searchParams.get("chatId"); const existingChatIdRaw = searchParams.get("chatId");
@@ -137,6 +137,7 @@ export function ChatPage({
const existingChatSessionId = existingChatIdRaw const existingChatSessionId = existingChatIdRaw
? parseInt(existingChatIdRaw) ? parseInt(existingChatIdRaw)
: null; : null;
const selectedChatSession = chatSessions.find( const selectedChatSession = chatSessions.find(
(chatSession) => chatSession.id === existingChatSessionId (chatSession) => chatSession.id === existingChatSessionId
); );
@@ -205,6 +206,7 @@ export function ChatPage({
selectedAssistant || selectedAssistant ||
filteredAssistants[0] || filteredAssistants[0] ||
availableAssistants[0]; availableAssistants[0];
useEffect(() => { useEffect(() => {
if (!loadedIdSessionRef.current && !currentPersonaId) { if (!loadedIdSessionRef.current && !currentPersonaId) {
return; return;
@@ -278,6 +280,7 @@ export function ChatPage({
); );
const [isReady, setIsReady] = useState(false); const [isReady, setIsReady] = useState(false);
useEffect(() => { useEffect(() => {
Prism.highlightAll(); Prism.highlightAll();
setIsReady(true); setIsReady(true);
@@ -775,11 +778,16 @@ export function ChatPage({
const clientScrollToBottom = (fast?: boolean) => { const clientScrollToBottom = (fast?: boolean) => {
setTimeout(() => { setTimeout(() => {
if (fast) { if (!endDivRef.current) {
endDivRef.current?.scrollIntoView(); return;
} else {
endDivRef.current?.scrollIntoView({ behavior: "smooth" });
} }
const rect = endDivRef.current.getBoundingClientRect();
const isVisible = rect.top >= 0 && rect.bottom <= window.innerHeight;
if (isVisible) return;
endDivRef.current.scrollIntoView({ behavior: fast ? "auto" : "smooth" });
setHasPerformedInitialScroll(true); setHasPerformedInitialScroll(true);
}, 50); }, 50);
}; };
@@ -1725,7 +1733,9 @@ export function ChatPage({
/> />
)} )}
{documentSidebarInitialWidth !== undefined && isReady ? ( {documentSidebarInitialWidth !== undefined &&
isReady &&
!isLoadingUser ? (
<Dropzone onDrop={handleImageUpload} noClick> <Dropzone onDrop={handleImageUpload} noClick>
{({ getRootProps }) => ( {({ getRootProps }) => (
<div className="flex h-full w-full"> <div className="flex h-full w-full">