import { redirect } from "next/navigation"; import { LeftRail } from "@/components/shell/LeftRail"; import { ApiAuthError } from "@/lib/api/http"; import { fetchClaws, fetchCredits, fetchMe } from "@/lib/api/team"; import type { Agent, Credits, User } from "@/lib/api/schemas"; // Every workspace page shares the persistent rail (§4). This layout reads // only path-level data — search params stay client-side (see panel-params). export default async function WorkspaceLayout({ children, }: Readonly<{ children: React.ReactNode }>) { let user: User; let roster: Agent[]; let credits: Credits; try { [user, roster, credits] = await Promise.all([ fetchMe(), fetchClaws(), fetchCredits(), ]); } catch (error) { if (error instanceof ApiAuthError) { redirect("/login"); } throw error; } return (
{children}
); }