"use client"; import { Loader2 } from "lucide-react"; import { usePathname } from "next/navigation"; import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery"; import { DoclingHealthBanner } from "@/components/docling-health-banner"; import { KnowledgeFilterPanel } from "@/components/knowledge-filter-panel"; import { TaskNotificationMenu } from "@/components/task-notification-menu"; import { useAuth } from "@/contexts/auth-context"; import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; import { useTask } from "@/contexts/task-context"; import { cn } from "@/lib/utils"; import { useDoclingHealthQuery } from "@/src/app/api/queries/useDoclingHealthQuery"; import { ChatRenderer } from "./chat-renderer"; export function LayoutWrapper({ children }: { children: React.ReactNode }) { const pathname = usePathname(); const { isMenuOpen } = useTask(); const { isPanelOpen } = useKnowledgeFilter(); const { isLoading, isAuthenticated, isNoAuthMode } = useAuth(); const { data: settings, isLoading: isSettingsLoading } = useGetSettingsQuery({ enabled: isAuthenticated || isNoAuthMode, }); const { data: health, isLoading: isHealthLoading, isError, } = useDoclingHealthQuery(); // List of paths that should not show navigation const authPaths = ["/login", "/auth/callback"]; const isAuthPage = authPaths.includes(pathname); const isOnKnowledgePage = pathname.startsWith("/knowledge"); const isUnhealthy = health?.status === "unhealthy" || isError; const isBannerVisible = !isHealthLoading && isUnhealthy; const isSettingsLoadingOrError = isSettingsLoading || !settings; // Show loading state when backend isn't ready if (isLoading || (isSettingsLoadingOrError && (isNoAuthMode || isAuthenticated))) { return (

Starting OpenRAG...

); } if (isAuthPage) { // For auth pages, render without navigation return
{children}
; } // For all other pages, render with Langflow-styled navigation and task menu return (
{children} {/* Task Notifications Panel */} {/* Knowledge Filter Panel */}
); }