fix layout not showing on chat

This commit is contained in:
Lucas Oliveira 2025-09-29 14:52:21 -03:00
parent 3bdf13b973
commit f51960476e

View file

@ -2,8 +2,12 @@
import { Bell, Loader2 } from "lucide-react"; import { Bell, Loader2 } from "lucide-react";
import { usePathname } from "next/navigation"; import { usePathname } from "next/navigation";
import { useGetConversationsQuery, type ChatConversation } from "@/app/api/queries/useGetConversationsQuery"; import {
type ChatConversation,
useGetConversationsQuery,
} from "@/app/api/queries/useGetConversationsQuery";
import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery"; import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery";
import { DoclingHealthBanner } from "@/components/docling-health-banner";
import { KnowledgeFilterPanel } from "@/components/knowledge-filter-panel"; import { KnowledgeFilterPanel } from "@/components/knowledge-filter-panel";
import Logo from "@/components/logo/logo"; import Logo from "@/components/logo/logo";
import { Navigation } from "@/components/navigation"; import { Navigation } from "@/components/navigation";
@ -13,12 +17,11 @@ import { UserNav } from "@/components/user-nav";
import { useAuth } from "@/contexts/auth-context"; import { useAuth } from "@/contexts/auth-context";
import { useChat } from "@/contexts/chat-context"; import { useChat } from "@/contexts/chat-context";
import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context";
import { LayoutProvider } from "@/contexts/layout-context";
// import { GitHubStarButton } from "@/components/github-star-button" // import { GitHubStarButton } from "@/components/github-star-button"
// import { DiscordLink } from "@/components/discord-link" // import { DiscordLink } from "@/components/discord-link"
import { useTask } from "@/contexts/task-context"; import { useTask } from "@/contexts/task-context";
import { DoclingHealthBanner } from "@/components/docling-health-banner";
import { useDoclingHealthQuery } from "@/src/app/api/queries/useDoclingHealthQuery"; import { useDoclingHealthQuery } from "@/src/app/api/queries/useDoclingHealthQuery";
import { LayoutProvider } from "@/contexts/layout-context";
export function LayoutWrapper({ children }: { children: React.ReactNode }) { export function LayoutWrapper({ children }: { children: React.ReactNode }) {
const pathname = usePathname(); const pathname = usePathname();
@ -34,7 +37,11 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
const { isLoading: isSettingsLoading, data: settings } = useGetSettingsQuery({ const { isLoading: isSettingsLoading, data: settings } = useGetSettingsQuery({
enabled: isAuthenticated || isNoAuthMode, enabled: isAuthenticated || isNoAuthMode,
}); });
const { data: health, isLoading: isHealthLoading, isError } = useDoclingHealthQuery(); const {
data: health,
isLoading: isHealthLoading,
isError,
} = useDoclingHealthQuery();
// Only fetch conversations on chat page // Only fetch conversations on chat page
const isOnChatPage = pathname === "/" || pathname === "/chat"; const isOnChatPage = pathname === "/" || pathname === "/chat";
@ -66,7 +73,9 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
// Dynamic height calculations based on banner visibility // Dynamic height calculations based on banner visibility
const headerHeight = 53; const headerHeight = 53;
const bannerHeight = 52; // Approximate banner height const bannerHeight = 52; // Approximate banner height
const totalTopOffset = isBannerVisible ? headerHeight + bannerHeight : headerHeight; const totalTopOffset = isBannerVisible
? headerHeight + bannerHeight
: headerHeight;
const mainContentHeight = `calc(100vh - ${totalTopOffset}px)`; const mainContentHeight = `calc(100vh - ${totalTopOffset}px)`;
// Show loading state when backend isn't ready // Show loading state when backend isn't ready
@ -81,7 +90,7 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
); );
} }
if (isAuthPage || (settings && !settings.edited)) { if (isAuthPage) {
// For auth pages, render without navigation // For auth pages, render without navigation
return <div className="h-full">{children}</div>; return <div className="h-full">{children}</div>;
} }
@ -157,7 +166,10 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
}`} }`}
style={{ height: mainContentHeight }} style={{ height: mainContentHeight }}
> >
<LayoutProvider headerHeight={headerHeight} totalTopOffset={totalTopOffset}> <LayoutProvider
headerHeight={headerHeight}
totalTopOffset={totalTopOffset}
>
<div className="container py-6 lg:py-8 px-4 lg:px-6">{children}</div> <div className="container py-6 lg:py-8 px-4 lg:px-6">{children}</div>
</LayoutProvider> </LayoutProvider>
</main> </main>