Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Sidebar: the status waits for hydration, so a fast answer no longer rebuilds the page

Adarshb322ecf2dbc4
diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx
index 4b9829cd..c9ab56fc 100644
--- a/src/components/app-sidebar.tsx
+++ b/src/components/app-sidebar.tsx
@@ -40,7 +40,7 @@ import { IntentLink } from "@/components/intent-link";
import { JobNotifications } from "@/components/job-notifications";
import { NAV, type NavGroupDef } from "@/components/nav-items";
import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";
-import { CONNECT_GPU_EVENT, signInHref, useEngineMode, useStatus, useViewer, type StatusInfo } from "@/lib/api";
+import { CONNECT_GPU_EVENT, signInHref, useEngineMode, useHydrated, useStatus, useViewer, type StatusInfo } from "@/lib/api";
import { deviceLabel } from "@/lib/gpu/readiness";
import { useModKey } from "@/lib/keys";
import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, NEW_CREATION_HREF, parseClosed, scrollFades, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";
@@ -530,8 +530,11 @@ export function AppSidebar() {
if (isMobile && (e.target as Element).closest("a[href]")) setOpenMobile(false);
};
const content = useScrollFades<HTMLDivElement>();
- const status = useStatus().data;
- const computer = useViewer().data?.computer === true;
+ // Until hydrated, the server's (status-less) sidebar: a status that lands mid-hydration must not change it.
+ const hydrated = useHydrated();
+ const statusData = useStatus().data;
+ const status = hydrated ? statusData : undefined;
+ const computer = useViewer().data?.computer === true && hydrated;
const cloud = status && (status.providers.fal?.configured || status.providers.replicate?.configured);
const comfy = status?.providers.comfyui?.configured;
const mode = useEngineMode();
diff --git a/src/components/studio/engine-switch.tsx b/src/components/studio/engine-switch.tsx
index 89be82c1..d5927adb 100644
--- a/src/components/studio/engine-switch.tsx
+++ b/src/components/studio/engine-switch.tsx
@@ -5,7 +5,7 @@ import Link from "next/link";
import { openAddKey } from "@/components/keys/your-keys";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { Engine } from "@/lib/catalog/types";
-import { useEngineMode, useStatus, useViewer } from "@/lib/api";
+import { useEngineMode, useHydrated, useStatus, useViewer } from "@/lib/api";
import { accountEngine } from "@/lib/your-keys";
import { cn } from "@/lib/utils";
import { radioKeys, radioTab } from "./radio-keys";
@@ -32,10 +32,14 @@ export function EngineSwitch({
compact?: boolean;
}) {
const mode = useEngineMode();
+ // Until hydrated, the server's switch (as useEngineMode): a viewer or status that lands mid-hydration must not change it.
+ const hydrated = useHydrated();
+ const viewer = useViewer().data;
+ const status = useStatus().data;
// Only the owner can change the engine mode (Settings): anyone else gets a plain badge, not a link to a page they can't use.
- const owner = useViewer().data?.owner === true;
+ const owner = hydrated && viewer?.owner === true;
// An account (public sign-up): locked on open source until it adds its own key, and why; with one, who pays.
- const account = accountEngine(useStatus().data);
+ const account = accountEngine(hydrated ? status : undefined);
const locked = account && "locked" in account ? account.locked : null;
const idx = OPTIONS.findIndex((o) => o.value === value);
if (mode !== "both" || locked) {