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.

Merge branch 'r4/ux-shell' into claude/fuobe-parity-4

Claudeebf361fc772e
diff --cc src/components/command-palette.tsx
index 00000000,a0902876..5a88e95c
mode 000000,100644..100644
--- a/src/components/command-palette.tsx
+++ b/src/components/command-palette.tsx
@@@ -1,0 -1,302 +1,302 @@@
+ "use client";
+
+ import { useQuery } from "@tanstack/react-query";
+ import { Bell, Clapperboard, Cpu, Film, KeyRound, LayoutGrid, Loader2, Plus, Server, Settings2, ShieldCheck, Sparkles, Wand2, type LucideIcon } from "lucide-react";
+ import { useRouter } from "next/navigation";
+ import { createContext, lazy, Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
+ import { NAV } from "@/components/nav-items";
+ import { MediaThumb } from "@/components/studio/result-media";
+ import { CommandDialog, CommandEmpty, CommandGroup, CommandItem, CommandList } from "@/components/ui/command";
+ import { Kbd } from "@/components/ui/kbd";
+ import { Command as CommandPrimitive } from "cmdk";
+ import { useEngineMode, useGenerations } from "@/lib/api";
+ import type { Generation } from "@/lib/catalog/types";
+ import { indexEntries, KIND_LABELS, rankPalette, type PaletteEntry, type PaletteIndex, type PaletteKind } from "@/lib/command-search";
+ import { useModKey } from "@/lib/keys";
+ import { userTitle } from "@/lib/library";
+ import { cn } from "@/lib/utils";
+
+ // The viewer is only needed once a recent creation is opened from the palette.
+ const Viewer = lazy(() => import("@/components/studio/viewer").then((m) => ({ default: m.Viewer })));
+
+ interface PaletteState {
+ open: boolean;
+ setOpen: (open: boolean | ((open: boolean) => boolean)) => void;
+ }
+
+ const PaletteContext = createContext<PaletteState>({ open: false, setOpen: () => {} });
+
+ /** Opens and closes the ⌘K palette from anywhere in the app frame (the sidebar's Search row, the phone header, ⌘K). */
+ export const useCommandPalette = () => useContext(PaletteContext);
+
+ /** What had focus when the palette opened: it gets focus back when the palette closes without going anywhere. */
+ const returnFocus: { current: Element | null } = { current: null };
+
+ export function CommandPaletteProvider({ children }: { children: React.ReactNode }) {
+ const [open, setOpenState] = useState(false);
+ const openRef = useRef(false);
+ const setOpen = useCallback((v: boolean | ((open: boolean) => boolean)) => {
+ const next = typeof v === "function" ? v(openRef.current) : v;
+ if (next && !openRef.current) returnFocus.current = document.activeElement;
+ openRef.current = next;
+ setOpenState(next);
+ }, []);
+ const value = useMemo(() => ({ open, setOpen }), [open, setOpen]);
+ return <PaletteContext.Provider value={value}>{children}</PaletteContext.Provider>;
+ }
+
+ /** Settings sections the palette jumps to (ids in settings-form.tsx). */
+ const SETTINGS: { id: string; label: string; icon: LucideIcon; keywords: string }[] = [
+ { id: "cloud", label: "API keys", icon: KeyRound, keywords: "fal replicate higgsfield paid cloud connect" },
+ { id: "comfyui", label: "ComfyUI server", icon: Server, keywords: "open source gpu url connect local" },
+ { id: "engine", label: "Engine mode", icon: Cpu, keywords: "open source cloud both" },
- { id: "enhance", label: "Prompt enhancement", icon: Sparkles, keywords: "claude ollama enhancer llm" },
++ { id: "text-ai", label: "Prompt enhancement", icon: Sparkles, keywords: "claude ollama enhancer llm" },
+ { id: "notifications", label: "Notifications", icon: Bell, keywords: "browser done alerts" },
+ { id: "security", label: "Password and API tokens", icon: ShieldCheck, keywords: "security sign in mcp token" },
+ { id: "demo", label: "Demo mode", icon: Settings2, keywords: "placeholder free try" },
+ ];
+
+ const PAGES: (PaletteEntry & { icon: LucideIcon })[] = NAV.flatMap((g) =>
+ g.items.map((i) => ({ key: `page:${i.href}`, kind: "page" as const, label: i.label, hint: g.label, href: i.href, keywords: i.keywords, icon: i.icon })),
+ );
+ const SETTING_ENTRIES: (PaletteEntry & { icon: LucideIcon })[] = SETTINGS.map((s) => ({
+ key: `setting:${s.id}`,
+ kind: "setting",
+ label: s.label,
+ hint: "Settings",
+ href: `/settings#${s.id}`,
+ keywords: s.keywords,
+ icon: s.icon,
+ }));
+ // Icons as elements made once (a component picked during render would remount on every keystroke).
+ const iconEl = (Icon: LucideIcon) => <Icon className="text-muted-foreground" />;
+ const ICONS = new Map<string, React.ReactNode>([...PAGES, ...SETTING_ENTRIES].map((e) => [e.key, iconEl(e.icon)]));
+ const KIND_ICONS: Partial<Record<PaletteKind, React.ReactNode>> = { app: iconEl(LayoutGrid), motion: iconEl(Film), effect: iconEl(Wand2), model: iconEl(Clapperboard) };
+
+ function useDebounced<T>(value: T, ms: number): T {
+ const [v, setV] = useState(value);
+ useEffect(() => {
+ const t = setTimeout(() => setV(value), ms);
+ return () => clearTimeout(t);
+ }, [value, ms]);
+ return v;
+ }
+
+ // The hints are marked as shortcuts so CommandItem drops its check mark, which would share the row's free space with them.
+ function Row({ entry, onPick }: { entry: PaletteEntry; onPick: (e: PaletteEntry) => void }) {
+ return (
+ <CommandItem value={entry.key} onSelect={() => onPick(entry)} className="h-9 gap-2.5 text-[14px]">
+ {ICONS.get(entry.key) ?? KIND_ICONS[entry.kind] ?? KIND_ICONS.app}
+ <span className="min-w-0 truncate">{entry.label}</span>
+ {entry.hint && <span data-slot="command-shortcut" className="ml-auto shrink-0 truncate pl-2 text-[12px] text-muted-foreground max-sm:max-w-[40%]">{entry.hint}</span>}
+ </CommandItem>
+ );
+ }
+
+ function RecentRow({ g, onOpen }: { g: Generation; onOpen: (g: Generation) => void }) {
+ const title = userTitle(g);
+ return (
+ <CommandItem value={`recent:${g.id}`} onSelect={() => onOpen(g)} className="h-11 gap-2.5 text-[14px]">
+ <span className="relative size-8 shrink-0 overflow-hidden rounded-md bg-muted">{g.outputs[0] && <MediaThumb output={g.outputs[0]} g={g} />}</span>
+ <span className="min-w-0 truncate">{title}</span>
+ <span data-slot="command-shortcut" className="ml-auto shrink-0 pl-2 text-[12px] text-muted-foreground">{g.modelName}</span>
+ </CommandItem>
+ );
+ }
+
+ function Hints() {
+ const mod = useModKey();
+ return (
+ <div className="flex items-center gap-3 border-t px-3 py-2 text-[12px] text-muted-foreground [@media(hover:none)]:hidden">
+ <span className="flex items-center gap-1">
+ <Kbd>↑</Kbd>
+ <Kbd>↓</Kbd> to move
+ </span>
+ <span className="flex items-center gap-1">
+ <Kbd>↵</Kbd> to open
+ </span>
+ <span className="flex items-center gap-1">
+ <Kbd>Esc</Kbd> to close
+ </span>
+ <span className="ml-auto flex items-center gap-1">
+ <Kbd>{mod}</Kbd>
+ <Kbd>K</Kbd>
+ </span>
+ </div>
+ );
+ }
+
+ /** What the palette lists and searches; mounted only while it's open. */
+ function PaletteBody({ onPick, onOpenRecent, onClose }: { onPick: (e: PaletteEntry) => void; onOpenRecent: (g: Generation) => void; onClose: () => void }) {
+ const [q, setQ] = useState("");
+ // Not deferred: ranking ~900 entries takes a millisecond, and Enter must act on the list for what was typed.
+ const query = q;
+ const dq = useDebounced(q.trim(), 200);
+ const mode = useEngineMode();
+ // The apps, motions, effects and models load on first open (and stay for the session).
+ const index = useQuery({
+ queryKey: ["palette-index"],
+ queryFn: async () => (await fetch("/api/search-index")).json() as Promise<PaletteIndex>,
+ staleTime: Infinity,
+ });
+ const recent = useGenerations({ q: dq || undefined, limit: 5, statuses: ["succeeded"] }, { keepPrevious: true });
+ const entries = useMemo(() => [...PAGES, ...SETTING_ENTRIES, ...(index.data ? indexEntries(index.data, mode) : [])], [index.data, mode]);
+ const groups = useMemo(() => rankPalette(entries, query), [entries, query]);
+ const recentItems = (recent.data ?? []).filter((g) => g.outputs[0]);
+ const searching = !!query.trim();
+ // cmdk keeps no selection once the rows change (shouldFilter is off): every new query starts on its
+ // best match, so Enter opens it; arrows move from there.
+ const best = searching ? (groups[0]?.entries[0]?.key ?? (recentItems[0] ? `recent:${recentItems[0].id}` : "")) : "new";
+ const [moved, setMoved] = useState<{ query: string; value: string } | null>(null);
+ const selected = moved?.query === query ? moved.value : best;
+
+ return (
+ <CommandPrimitive shouldFilter={false} loop value={selected} onValueChange={(value) => setMoved({ query, value })} label="Search Fuobe" className="flex flex-col overflow-hidden rounded-xl bg-popover text-popover-foreground">
+ <div className="flex items-center gap-2 border-b px-3">
+ <CommandPrimitive.Input
+ value={q}
+ onValueChange={setQ}
+ autoFocus
+ placeholder="Search pages, apps, motions, effects, models…"
+ aria-label="Search Fuobe"
+ className="h-12 min-w-0 flex-1 bg-transparent text-[15px] outline-none placeholder:text-subtle-foreground"
+ />
+ {index.isLoading && searching && <Loader2 className="size-4 shrink-0 animate-spin text-muted-foreground" aria-label="Loading the catalog" />}
+ {/* Touch screens have no Esc (and the hint row is hidden there): a visible way out. */}
+ <button
+ type="button"
+ onClick={onClose}
+ className="-mr-1 hidden h-8 shrink-0 items-center rounded-md px-2 text-[14px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground [@media(hover:none)]:inline-flex"
+ >
+ Cancel
+ </button>
+ </div>
+ <CommandList className="max-h-[min(60vh,440px)] p-1.5">
+ {searching ? (
+ <>
+ <CommandEmpty className="py-10 text-center text-[13px] text-muted-foreground">
+ {index.isLoading ? "Looking through apps, motions and models…" : `Nothing matches “${query.trim()}”.`}
+ </CommandEmpty>
+ {groups.map((g) => (
+ <CommandGroup key={g.kind} heading={g.label}>
+ {g.entries.map((e) => (
+ <Row key={e.key} entry={e} onPick={onPick} />
+ ))}
+ </CommandGroup>
+ ))}
+ {recentItems.length > 0 && (
+ <CommandGroup heading={KIND_LABELS.recent}>
+ {recentItems.map((g) => (
+ <RecentRow key={g.id} g={g} onOpen={onOpenRecent} />
+ ))}
+ </CommandGroup>
+ )}
+ </>
+ ) : (
+ <>
+ <CommandGroup>
+ {/* Enter on an empty query keeps what ⌘K always did: a new creation. */}
+ <CommandItem value="new" onSelect={() => onPick({ key: "new", kind: "page", label: "New creation", href: "/" })} className="h-9 gap-2.5 text-[14px]">
+ <Plus className="text-muted-foreground" />
+ New creation
+ <span data-slot="command-shortcut" className="ml-auto text-[12px] text-muted-foreground">Home</span>
+ </CommandItem>
+ </CommandGroup>
+ {recentItems.length > 0 && (
+ <CommandGroup heading={KIND_LABELS.recent}>
+ {recentItems.map((g) => (
+ <RecentRow key={g.id} g={g} onOpen={onOpenRecent} />
+ ))}
+ </CommandGroup>
+ )}
+ <CommandGroup heading={KIND_LABELS.page}>
+ {PAGES.map((e) => (
+ <Row key={e.key} entry={e} onPick={onPick} />
+ ))}
+ </CommandGroup>
+ <CommandGroup heading={KIND_LABELS.setting}>
+ {SETTING_ENTRIES.map((e) => (
+ <Row key={e.key} entry={e} onPick={onPick} />
+ ))}
+ </CommandGroup>
+ </>
+ )}
+ </CommandList>
+ <Hints />
+ </CommandPrimitive>
+ );
+ }
+
+ /**
+ * The ⌘K / Ctrl+K palette: every page, settings section, app, camera motion, effect and model, and
+ * your recent creations, with a forgiving search (src/lib/command-search.ts). Rendered once, in the
+ * app frame.
+ */
+ export function CommandPalette() {
+ const { open, setOpen } = useCommandPalette();
+ const router = useRouter();
+ const [viewing, setViewing] = useState<Generation | null>(null);
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if ((e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey && e.key.toLowerCase() === "k") {
+ e.preventDefault();
+ setOpen((o) => !o);
+ }
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [setOpen]);
+
+ // Set when the palette closes onto something else (a page, the viewer): focus stays with that.
+ const leaving = useRef(false);
+ const pick = useCallback(
+ (e: PaletteEntry) => {
+ leaving.current = true;
+ setOpen(false);
+ router.push(e.href);
+ },
+ [router, setOpen],
+ );
+ const openRecent = useCallback(
+ (g: Generation) => {
+ leaving.current = true;
+ setOpen(false);
+ setViewing(g);
+ },
+ [setOpen],
+ );
+ const close = useCallback(() => setOpen(false), [setOpen]);
+ // Dismissed (Esc, Cancel, a click outside, ⌘K again): focus goes back to where it was, the
+ // composer you were typing in or the Search row, not to the top of the page.
+ const restoreFocus = useCallback((e: Event) => {
+ e.preventDefault();
+ const el = returnFocus.current;
+ returnFocus.current = null;
+ if (leaving.current) {
+ leaving.current = false;
+ return;
+ }
+ if (el instanceof HTMLElement && el.isConnected) el.focus({ preventScroll: true });
+ }, []);
+
+ return (
+ <>
+ <CommandDialog
+ open={open}
+ onOpenChange={setOpen}
+ title="Search Fuobe"
+ description="Go to a page, an app, a camera motion, an effect, a model, a settings section or a recent creation."
+ className={cn("top-[8vh] gap-0 p-0 sm:top-[14vh] sm:max-w-xl")}
+ onCloseAutoFocus={restoreFocus}
+ >
+ <PaletteBody onPick={pick} onOpenRecent={openRecent} onClose={close} />
+ </CommandDialog>
+ {viewing && (
+ <Suspense fallback={null}>
+ <Viewer generation={viewing} index={0} onClose={() => setViewing(null)} />
+ </Suspense>
+ )}
+ </>
+ );
+ }
diff --cc src/components/home-view.tsx
index 7e56a533,e966b709..2e8cfd79
--- a/src/components/home-view.tsx
+++ b/src/components/home-view.tsx
@@@ -19,9 -19,9 +19,10 @@@ import
ZoomIn,
} from "lucide-react";
import { useRouter } from "next/navigation";
-import { lazy, Suspense, useState } from "react";
+import { lazy, Suspense, useEffect, useRef, useState } from "react";
+import { GetStarted } from "@/components/get-started";
import { PageShell } from "@/components/page-shell";
+ import { CardPending, IntentLink } from "@/components/intent-link";
import { PresetCard } from "@/components/preset-gallery";
import { MediaThumb } from "@/components/studio/result-media";
import { useEngine, useGenerations, useHydrated, useStatus } from "@/lib/api";
@@@ -258,37 -211,10 +259,37 @@@ export function HomeView(
</div>
</div>
</div>
- {nothingConnected && (
+ {runsFor && (
+ <p className="mt-2 text-[12px] text-muted-foreground">
+ {runsFor.text}
+ {runsFor.other && (
+ <>
+ {" · "}
+ <button type="button" onClick={() => setEngine(runsFor.other!)} className="text-brand-text underline underline-offset-2 hover:no-underline">
+ {runsFor.other === "open" ? "Run it free on your GPU" : "Use your paid key"}
+ </button>
+ </>
+ )}
+ </p>
+ )}
+ {guide ? (
+ <>
+ <FirstRunScript />
+ <GetStarted
+ className={cn("mt-6 max-w-[960px]", !status && "[html[data-first-run='0']_&]:hidden")}
+ status={status}
+ prices={prices}
+ onDemo={focusComposer}
+ onMode={(id) => {
+ setMode(MODES.find((m) => m.id === id) ?? MODES[0]);
+ focusComposer();
+ }}
+ />
+ </>
+ ) : nothingConnected && (
<p className="mt-4 text-[13px] text-muted-foreground">
You’re in <span className="font-medium text-foreground">demo mode</span> — outputs are placeholders.{" "}
- <Link href="/settings#get-started" className="text-brand-text underline underline-offset-2 hover:no-underline">
- <Link href="/settings" className="text-brand-text underline underline-offset-2">
++ <Link href="/settings#get-started" className="text-brand-text underline underline-offset-2">
{engineMode === "open" ? "Connect ComfyUI" : engineMode === "cloud" ? "Add a fal.ai or Replicate key" : "Add a fal.ai key or connect ComfyUI"}
</Link>{" "}
to generate for real.
diff --cc src/components/nav-items.ts
index 00000000,b84b2930..cfe09608
mode 000000,100644..100644
--- a/src/components/nav-items.ts
+++ b/src/components/nav-items.ts
@@@ -1,0 -1,135 +1,137 @@@
+ import {
+ AtSign,
+ AudioLines,
+ Boxes,
+ Box,
+ Brush,
+ Camera,
+ Clapperboard,
+ Crop,
+ FastForward,
+ Film,
+ GalleryHorizontal,
+ Home,
+ ImageIcon,
+ Images,
+ Layers,
+ Layers2,
+ LayoutGrid,
+ Library,
+ ListChecks,
+ Megaphone,
+ MessageCircle,
+ Mic2,
+ Network,
+ PersonStanding,
+ Presentation,
+ Scissors,
+ Settings,
+ Shapes,
+ Shirt,
+ SlidersHorizontal,
+ Smartphone,
+ Sparkles,
+ Star,
+ Swords,
+ Target,
+ TrendingUp,
+ Tv,
+ UserRoundCog,
+ Video,
+ Wand2,
++ WandSparkles,
+ Workflow,
+ ZoomIn,
+ type LucideIcon,
+ } from "lucide-react";
+
+ export interface NavItem {
+ href: string;
+ label: string;
+ icon: LucideIcon;
+ /** Shorter label for compact groups (the full one is the tooltip). */
+ short?: string;
+ /** Prefetched as soon as it's on screen (the rows most visits start from); the others wait for a hover or touch. */
+ eager?: boolean;
+ /** More words the ⌘K palette matches ("tts" finds Audio). */
+ keywords?: string;
+ }
+
+ export interface NavGroupDef {
+ label: string;
+ items: NavItem[];
+ /** Can be folded away; the choice is remembered (Studios and Engine start folded, see DEFAULT_NAV_CLOSED). */
+ collapsible?: boolean;
+ /** Two small items per row. */
+ compact?: boolean;
+ }
+
+ /** The sidebar, and the destinations of the ⌘K palette. Add a destination with one line in the right group. */
+ export const NAV: NavGroupDef[] = [
+ {
+ label: "Create",
+ items: [
+ { href: "/", label: "Home", icon: Home, eager: true, keywords: "start new creation" },
+ { href: "/assist", label: "Assist", icon: MessageCircle, eager: true, keywords: "agent chat plan" },
+ { href: "/image", label: "Image", icon: ImageIcon, eager: true, keywords: "text to image picture photo" },
+ { href: "/video", label: "Video", icon: Video, eager: true, keywords: "text to video image to video animate" },
+ { href: "/edit", label: "Edit", icon: Wand2, keywords: "edit image change" },
+ { href: "/layers", label: "Layers", icon: Layers2, keywords: "layered psd split" },
+ { href: "/inpaint", label: "Inpaint", icon: Brush, keywords: "mask fill remove" },
+ { href: "/color-grade", label: "Color grading", icon: SlidersHorizontal, keywords: "grade lut colour" },
+ { href: "/motions", label: "Camera motions", icon: Film, keywords: "camera moves presets" },
+ { href: "/effects", label: "Effects", icon: Sparkles, keywords: "vfx presets" },
+ { href: "/storyboard", label: "Storyboard", icon: GalleryHorizontal, keywords: "frames story" },
+ { href: "/canvas", label: "Canvas", icon: Network, keywords: "nodes flow workflow" },
+ { href: "/apps", label: "Apps", icon: LayoutGrid, keywords: "one-click tools" },
+ ],
+ },
+ {
+ label: "Library",
+ items: [
+ { href: "/library", label: "All creations", icon: Library, eager: true, keywords: "library history results" },
+ { href: "/library?tab=favorites", label: "Favorites", icon: Star, keywords: "starred liked" },
+ ],
+ },
+ {
+ label: "Studios",
+ items: [
+ { href: "/cinema", label: "Cinema Studio", icon: Clapperboard, keywords: "film director shots" },
+ { href: "/shorts", label: "Shorts Studio", icon: Smartphone, keywords: "vertical reels tiktok" },
+ { href: "/mixed-media", label: "Mixed Media", icon: Shapes, keywords: "collage" },
+ { href: "/marketing", label: "Marketing Studio", icon: Megaphone, keywords: "ugc product ads" },
+ { href: "/ads", label: "Ads Studio", icon: Target, keywords: "brand campaign" },
+ { href: "/moodboards", label: "Moodboards", icon: Images, keywords: "style references" },
+ { href: "/photodump", label: "Photodump", icon: Camera, keywords: "photo pack character" },
+ { href: "/fashion-factory", label: "Fashion Factory", icon: Shirt, keywords: "outfits try-on lookbook" },
+ { href: "/character-sheet", label: "Character Sheet", icon: UserRoundCog, keywords: "turnaround" },
+ { href: "/faceless", label: "Faceless Studio", icon: Tv, keywords: "youtube channel episodes" },
+ { href: "/explainer", label: "Explainer", icon: Presentation, keywords: "slides pdf video" },
+ { href: "/lipsync", label: "Lipsync & avatars", icon: Mic2, keywords: "talking avatar" },
++ { href: "/genjutsu", label: "Genjutsu", icon: WandSparkles, keywords: "swap insert character motion transfer" },
+ { href: "/motion-control", label: "Motion control", icon: PersonStanding, keywords: "pose dance transfer" },
+ { href: "/video-edit", label: "Edit video", icon: Scissors, keywords: "video edit restyle" },
+ { href: "/extend", label: "Extend video", icon: FastForward, keywords: "longer continue" },
+ { href: "/reframe", label: "Reframe", icon: Crop, keywords: "aspect ratio outpaint" },
+ { href: "/video-tools", label: "Video tools", icon: Layers, keywords: "join trim matte depth captions" },
+ { href: "/elements", label: "Elements", icon: AtSign, keywords: "characters places props" },
+ { href: "/upscale", label: "Upscale", icon: ZoomIn, keywords: "enhance resolution 4k" },
+ { href: "/audio", label: "Audio", icon: AudioLines, keywords: "voice tts music sfx dub transcribe" },
+ { href: "/katana", label: "Katana", icon: Swords, keywords: "cut edit clips" },
+ { href: "/image-to-3d", label: "Image to 3D", icon: Box, keywords: "3d mesh glb" },
+ { href: "/virality", label: "Virality predictor", icon: TrendingUp, keywords: "hook score" },
+ ],
+ collapsible: true,
+ },
+ {
+ label: "Engine",
+ items: [
+ { href: "/models", label: "Models", icon: Boxes, keywords: "catalog prices" },
+ { href: "/workflows", label: "ComfyUI workflows", short: "Workflows", icon: Workflow, keywords: "open source graphs" },
+ { href: "/settings", label: "Settings", icon: Settings, keywords: "keys preferences" },
+ { href: "/status", label: "Project status", short: "Status", icon: ListChecks, keywords: "parity progress" },
+ ],
+ collapsible: true,
+ compact: true,
+ },
+ ];
diff --cc src/components/studio/studio-page.tsx
index a8ed488c,293a8179..10e2a32a
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@@ -380,42 -369,35 +383,45 @@@ function HandoffSync(
startKey,
start,
build,
+ adopt,
ready,
onNavigate,
+ onStart,
}: {
startKey: string;
start: Draft;
build: React.RefObject<(key: string) => Draft>;
+ adopt: React.RefObject<(key: string) => void>;
ready: boolean;
onNavigate: (key: string) => void;
+ onStart: () => void;
}) {
const { setDraft } = useStudioActions();
- const [url, setUrl] = useState<string | null>(null);
+ const [url, setUrl] = useState<{ key: string; start: string | null } | null>(null);
const applied = useRef({ key: startKey, ready, base: start, seen: false });
+ const started = useRef(false);
+ const onParams = useCallback((key: string, start: string | null) => setUrl((u) => (u?.key === key && u.start === start ? u : { key, start })), []);
useLayoutEffect(() => {
if (url === null) return;
const a = applied.current;
- if (a.seen && url !== a.key) return onNavigate(url);
+ if (a.seen && url.key !== a.key) return onNavigate(url.key);
a.seen = true;
- if (url === a.key && ready === a.ready) return;
- const next = build.current(url);
- const base = a.base;
- setDraft((d) => mergeHandoff(base, d, next));
- adopt.current(url);
- applied.current = { key: url, ready, base: next, seen: true };
- }, [url, ready, build, adopt, setDraft, onNavigate]);
+ if (url.key !== a.key || ready !== a.ready) {
+ const next = build.current(url.key);
+ const base = a.base;
+ setDraft((d) => mergeHandoff(base, d, next));
++ adopt.current(url.key);
+ applied.current = { key: url.key, ready, base: next, seen: true };
+ }
+ if (url.start && ready && !started.current) {
+ started.current = true;
+ if (claimStartToken(url.start)) onStart();
+ window.history.replaceState(null, "", withoutStart(window.location.href));
+ }
- }, [url, ready, build, setDraft, onNavigate, onStart]);
++ }, [url, ready, build, adopt, setDraft, onNavigate, onStart]);
return (
<Suspense fallback={null}>
- <UrlParams onChange={setUrl} />
+ <UrlParams onChange={onParams} />
</Suspense>
);
}
@@@ -459,7 -441,8 +477,7 @@@ function StudioDraft({ config, header,
return (
<ComposerBridgeCtx.Provider value={bridge}>
<StudioProvider key={start.epoch} config={config} initial={initial}>
- <StudioSession header={header} tabs={tabs} sync={{ startKey: start.key, start: initial, build: buildRef, ready: catalog.ready, onNavigate }} />
- <StudioBody header={header} tabs={tabs} />
- <HandoffSync startKey={start.key} start={initial} build={buildRef} adopt={adoptRef} ready={catalog.ready} onNavigate={onNavigate} />
++ <StudioSession header={header} tabs={tabs} sync={{ startKey: start.key, start: initial, build: buildRef, adopt: adoptRef, ready: catalog.ready, onNavigate }} />
</StudioProvider>
</ComposerBridgeCtx.Provider>
);