import { createFileRoute, Outlet, redirect } from "@tanstack/react-router" import { ConnectionBanner } from "@/components/Common/ConnectionBanner" import { Footer } from "@/components/Common/Footer" import { useFlowSocket } from "@/components/Flow/useFlowSocket" import AppSidebar from "@/components/Sidebar/AppSidebar" import { SidebarInset, SidebarProvider, SidebarTrigger, } from "@/components/ui/sidebar" import { isLoggedIn } from "@/hooks/useAuth" export const Route = createFileRoute("/_layout")({ component: Layout, beforeLoad: async () => { if (!isLoggedIn()) { throw redirect({ to: "/login", }) } }, }) function Layout() { // Dashboards live in this shell and read live values, so the socket belongs // here rather than only inside the editor. useFlowSocket() return ( {/* Renders nothing unless this page is served through a portal. */} {/* The sidebar carries its own collapse control; a phone has no sidebar on screen to carry it. */}