Skip to content

Commit

Permalink
Squash misc UX bugs (#2356)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx authored Sep 7, 2024
1 parent fb3d733 commit 350482e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function ChatPage({
userInputPrompts,
} = useChatContext();

const { user, refreshUser } = useUser();
const { user, refreshUser, isLoadingUser } = useUser();

// chat session
const existingChatIdRaw = searchParams.get("chatId");
Expand All @@ -137,6 +137,7 @@ export function ChatPage({
const existingChatSessionId = existingChatIdRaw
? parseInt(existingChatIdRaw)
: null;

const selectedChatSession = chatSessions.find(
(chatSession) => chatSession.id === existingChatSessionId
);
Expand Down Expand Up @@ -205,6 +206,7 @@ export function ChatPage({
selectedAssistant ||
filteredAssistants[0] ||
availableAssistants[0];

useEffect(() => {
if (!loadedIdSessionRef.current && !currentPersonaId) {
return;
Expand Down Expand Up @@ -278,6 +280,7 @@ export function ChatPage({
);

const [isReady, setIsReady] = useState(false);

useEffect(() => {
Prism.highlightAll();
setIsReady(true);
Expand Down Expand Up @@ -775,11 +778,16 @@ export function ChatPage({

const clientScrollToBottom = (fast?: boolean) => {
setTimeout(() => {
if (fast) {
endDivRef.current?.scrollIntoView();
} else {
endDivRef.current?.scrollIntoView({ behavior: "smooth" });
if (!endDivRef.current) {
return;
}

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);
}, 50);
};
Expand Down Expand Up @@ -1725,7 +1733,9 @@ export function ChatPage({
/>
)}

{documentSidebarInitialWidth !== undefined && isReady ? (
{documentSidebarInitialWidth !== undefined &&
isReady &&
!isLoadingUser ? (
<Dropzone onDrop={handleImageUpload} noClick>
{({ getRootProps }) => (
<div className="flex h-full w-full">
Expand Down

0 comments on commit 350482e

Please sign in to comment.