Files
app/frontend/src/routes/_layout.tsx
T
stroblmeandClaude Opus 5 414cda2798 Dashboard: run unchanged when a portal serves it
The same bundle is served by a portal under /i/{id}, so it reads its API base,
credential and router basepath from an injected config instead of the build-time
URL and localStorage. A normal installation finds no config and behaves exactly
as before; the credential deliberately never touches localStorage, since two
installations open in one browser share an origin and would overwrite each
other's session.

The websocket URL was resolving an absolute path against the base, which
discards the base's own path — harmless until the base gained one, then it
aimed the socket at the wrong host entirely.

Connection state gets a store of its own, apart from the engine's: the proxy's
503 carries {offline, last_seen}, which raises a banner naming when the
installation was last heard from and turns a failed mutation into 'not
delivered' rather than a generic error. The screen keeps its last data
underneath, since stale readings with a timestamp beat a blank page. A
reconnecting socket invalidates every query, because whatever happened while it
was down was missed.

Verified in a browser against a real hub and installation: the full UI loads
through the tunnel with no console errors, and killing the installation raises
the banner within a poll.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtBzdDyLsmDaF1W7DLYtYM
2026-08-19 17:09:53 +02:00

53 lines
1.6 KiB
TypeScript

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 (
<SidebarProvider className="bg-card">
{/* Renders nothing unless this page is served through a portal. */}
<ConnectionBanner />
<AppSidebar />
<SidebarInset className="bg-card">
{/* The sidebar carries its own collapse control; a phone has no
sidebar on screen to carry it. */}
<header className="sticky top-0 z-10 flex h-16 shrink-0 items-center gap-2 px-4 md:hidden">
<SidebarTrigger className="-ml-1 text-muted-foreground" />
</header>
<main className="flex-1 p-4 sm:p-6 md:p-8">
<div className="mx-auto max-w-7xl">
<Outlet />
</div>
</main>
<Footer />
</SidebarInset>
</SidebarProvider>
)
}
export default Layout