Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions apps/web/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,20 @@ export const Route = createRootRouteWithContext<{
}),
});

const APP_SHELL = (
<CommandPalette>
<AppSidebarLayout>
<Outlet />
</AppSidebarLayout>
</CommandPalette>
);

function RootRouteView() {
const pathname = useLocation({ select: (location) => location.pathname });
const { authGateState } = Route.useRouteContext();
const primaryEnvironmentAuthenticated = authGateState.status === "authenticated";

useEffect(() => {
const frame = window.requestAnimationFrame(() => {
syncBrowserChromeTheme();
});
return () => {
window.cancelAnimationFrame(frame);
};
}, [pathname]);
useBrowserChromeThemeSync(pathname);

if (pathname === "/pair") {
return <Outlet />;
Expand All @@ -121,14 +122,6 @@ function RootRouteView() {
return <Outlet />;
}

const appShell = (
<CommandPalette>
<AppSidebarLayout>
<Outlet />
</AppSidebarLayout>
</CommandPalette>
);

return (
<ToastProvider>
<AnchoredToastProvider>
Expand All @@ -142,15 +135,26 @@ function RootRouteView() {
{primaryEnvironmentAuthenticated ? <WebSocketConnectionCoordinator /> : null}
{primaryEnvironmentAuthenticated ? <SlowRpcAckToastCoordinator /> : null}
{primaryEnvironmentAuthenticated ? (
<WebSocketConnectionSurface>{appShell}</WebSocketConnectionSurface>
<WebSocketConnectionSurface>{APP_SHELL}</WebSocketConnectionSurface>
) : (
appShell
APP_SHELL
)}
</AnchoredToastProvider>
</ToastProvider>
);
}

function useBrowserChromeThemeSync(pathname: string) {
useEffect(() => {
const frame = window.requestAnimationFrame(() => {
syncBrowserChromeTheme();
});
return () => {
window.cancelAnimationFrame(frame);
};
}, [pathname]);
}

function HostedStaticEnvironmentBootstrap() {
const savedEnvironmentCount = useSavedEnvironmentRegistryStore(
(state) => Object.keys(state.byId).length,
Expand Down
Binary file not shown.
Binary file not shown.
Loading