perf(webui): defer non-chat startup interfaces
This commit is contained in:
1 parent
ae7fed88e2
commit
4bd1b74c6b
20 files changed
+710
-70
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { lazy, Suspense, type ComponentProps } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StartupShell } from "@/components/StartupShell";
|
||||
import { SurfaceErrorBoundary } from "@/components/SurfaceErrorBoundary";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
const RemoteConnectionsPage = lazy(async () => {
|
||||
const module = await import("./RemoteConnectionsPage");
|
||||
return { default: module.RemoteConnectionsPage };
|
||||
});
|
||||
|
||||
export function LazyRemoteConnectionsPage(props: ComponentProps<typeof RemoteConnectionsPage>) {
|
||||
const { t } = useTranslation();
|
||||
return <SurfaceErrorBoundary fallback={
|
||||
<div className="flex min-h-0 flex-1 flex-col items-center justify-center gap-3 bg-background p-6 text-center">
|
||||
<p role="alert" className="max-w-sm text-sm text-destructive">{t("app.loading.failed")}</p>
|
||||
<Button variant="ghost" onClick={props.onBackToChat}>{t("remote.back")}</Button>
|
||||
</div>
|
||||
}>
|
||||
<Suspense fallback={
|
||||
<div className="relative min-h-0 flex-1">
|
||||
<StartupShell embedded surface="remote" sidebarExpanded={props.mainNavigationExpanded ?? false} />
|
||||
<Button variant="ghost" className={`touch-target absolute left-4 z-10 ${props.hostChromeInset ? "top-20" : "top-4"}`}
|
||||
onClick={props.onBackToChat}>{t("remote.back")}</Button>
|
||||
</div>
|
||||
}>
|
||||
<RemoteConnectionsPage {...props} />
|
||||
</Suspense>
|
||||
</SurfaceErrorBoundary>;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { groupRemoteProfiles, isCompatibilityError, needsRemoteSetup } from "@/lib/remote-instances";
|
||||
import { HostCompatibilityDialog } from "./HostCompatibilityDialog";
|
||||
import { RemoteConnectionsPage } from "./RemoteConnectionsPage";
|
||||
import { LazyRemoteConnectionsPage } from "./LazyRemoteConnectionsPage";
|
||||
import { ThemeProvider } from "@/hooks/useTheme";
|
||||
import { useHostSessions } from "./useHostSessions";
|
||||
import { HostNavigationContext, HostSwitcher, RemoteHostMenu, type HostPicker } from "./HostSwitcher";
|
||||
@@ -174,7 +174,7 @@ export function RemoteInstances({ children }: { children: ReactNode }) {
|
||||
className="absolute bottom-0 right-0 flex min-h-0 flex-col bg-background"
|
||||
style={{ left: offline ? 0 : Math.min(bridge.surface?.left || 0, Math.max(0, window.innerWidth - 280)), top: offline ? 0 : Math.min(bridge.surface?.top || 0, Math.max(0, window.innerHeight - 280)) }}>
|
||||
<ThemeProvider theme={bridge.surface?.theme || "light"}>
|
||||
<RemoteConnectionsPage onBackToChat={() => changeManagement(false)} mainNavigationExpanded={!!bridge.surface?.left} />
|
||||
<LazyRemoteConnectionsPage onBackToChat={() => changeManagement(false)} mainNavigationExpanded={!!bridge.surface?.left} />
|
||||
</ThemeProvider>
|
||||
</main>}
|
||||
{!managing && selected && (offline || !activeFrame?.loaded) && <div role="region" aria-label={t(offline ? recoveryTitle : "remote.opening")} className="absolute inset-0 overflow-y-auto bg-background p-6 text-center"><div className="flex min-h-full flex-col items-center justify-center gap-3">
|
||||
|
||||
Reference in new issue
Block a user