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.

Palette: a model opens where it runs, on its own engine

Claudee7600e3c0a41
diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsx
index 89aef244..f5ef3fbf 100644
--- a/src/components/model3d/model3d-studio.tsx
+++ b/src/components/model3d/model3d-studio.tsx
@@ -2,7 +2,8 @@
import { Box, Clapperboard, Download, Loader2, Sparkles, Video } from "lucide-react";
import Link from "next/link";
-import { createElement, useEffect, useState } from "react";
+import { useSearchParams } from "next/navigation";
+import { createElement, Suspense, useCallback, useEffect, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
@@ -18,14 +19,31 @@ import type { Generation } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
import { recordableType, recordTurntable } from "./turntable";
+/** A link's ?model= (from ⌘K) picks that model and its engine. Under its own Suspense: it reads the URL. */
+function UrlModel({ onModel }: { onModel: (engine: "cloud" | "open", id: string) => void }) {
+ const id = useSearchParams().get("model");
+ useEffect(() => {
+ const engine = (["cloud", "open"] as const).find((e) => MODELS_3D[e].some((m) => m.id === id));
+ if (id && engine) onModel(engine, id);
+ }, [id, onModel]);
+ return null;
+}
+
/** Image to 3D / Product spin: a product photo → a .glb to spin and download, a turntable video, and on to a video. */
export function Model3dStudio({ names }: { names: Record<string, string> }) {
- const [engine] = useEngine();
+ const [engine, setEngine] = useEngine();
const create = useCreateGeneration();
const results = useGenerations({ features: [MODEL3D_FEATURE, "app:app-image-to-3d"], limit: 24 });
const [photo, setPhoto] = useState<SlotValue | null>(null);
const [picked, setPicked] = useState<Partial<Record<"cloud" | "open", string>>>({});
const modelId = picked[engine] ?? MODELS_3D[engine][0].id;
+ const fromUrl = useCallback(
+ (e: "cloud" | "open", id: string) => {
+ setPicked((p) => ({ ...p, [e]: id }));
+ setEngine(e);
+ },
+ [setEngine],
+ );
const blocker = !photo ? "Add a product photo" : photo.uploading ? "Uploading…" : null;
const go = () => {
if (blocker) return void toast(blocker, { id: "3d-blocker" });
@@ -37,6 +55,9 @@ export function Model3dStudio({ names }: { names: Record<string, string> }) {
const items = results.data ?? [];
return (
<ToolShell title="Image to 3D">
+ <Suspense fallback={null}>
+ <UrlModel onModel={fromUrl} />
+ </Suspense>
<ToolHero title="Your product, in 3D" subtitle="One clear photo → a textured 3D model (.glb) you can spin, download, record as a turntable and turn into a video." />
<div className="mx-auto mt-8 grid max-w-[880px] gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
<MediaDrop kind="image" value={photo} onChange={setPhoto} title="Add a product photo" hint="One object, plain background, well lit" compact />
diff --git a/src/components/models-table.tsx b/src/components/models-table.tsx
index ccf2cf3c..77b07761 100644
--- a/src/components/models-table.tsx
+++ b/src/components/models-table.tsx
@@ -1,7 +1,8 @@
"use client";
import { Cloud, Cpu, Info, Search } from "lucide-react";
-import { memo, useDeferredValue, useMemo, useRef, useState } from "react";
+import { useSearchParams } from "next/navigation";
+import { memo, Suspense, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
import { useProgressive } from "@/components/use-progressive";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { useEngine } from "@/lib/api";
@@ -93,6 +94,18 @@ const Row = memo(function Row({ m }: { m: ModelRow }) {
);
});
+/**
+ * A link's ?q= (the ⌘K palette's "open this model" for models no studio offers) fills the search.
+ * It reads the URL, so it sits under its own Suspense: the table itself stays in the static page.
+ */
+function UrlQuery({ onQuery }: { onQuery: (q: string) => void }) {
+ const q = useSearchParams().get("q");
+ useEffect(() => {
+ if (q !== null) onQuery(q);
+ }, [q, onQuery]);
+ return null;
+}
+
export function ModelsTable({ models }: { models: ModelRow[] }) {
const [engineChoice, setEngine] = useState<Engine | "all">("all");
const [, , mode] = useEngine();
@@ -111,13 +124,24 @@ export function ModelsTable({ models }: { models: ModelRow[] }) {
const rows = useRef<HTMLTableSectionElement>(null);
return (
<div className="space-y-4">
+ <Suspense fallback={null}>
+ <UrlQuery onQuery={setQ} />
+ </Suspense>
<div className="flex flex-col gap-2 lg:flex-row lg:items-center">
<div className="relative w-full lg:w-72">
<Search className="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
<input
type="search"
value={q}
- onChange={(e) => setQ(e.target.value)}
+ onChange={(e) => {
+ setQ(e.target.value);
+ // Typing takes over from the link: drop its ?q=, so the same link fills the search again later.
+ if (new URLSearchParams(window.location.search).has("q")) {
+ const url = new URL(window.location.href);
+ url.searchParams.delete("q");
+ window.history.replaceState(null, "", url);
+ }
+ }}
placeholder={`Search ${models.length} models`}
aria-label="Search models"
className="h-9 w-full rounded-full border bg-background pr-3 pl-9 text-[14px] outline-none placeholder:text-subtle-foreground focus:border-primary focus:ring-4 focus:ring-brand-faint"
diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsx
index a4d78273..293a8179 100644
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@ -39,8 +39,11 @@ function initialDraft(
lookup: { getModel: (id: string) => ModelDef | undefined; getPreset: (id: string) => Preset | undefined },
): Draft {
const preset = sp.get("preset") ? lookup.getPreset(sp.get("preset")!) : config.preset;
- const presetRoute = preset ? ((engine === "open" ? preset.open : preset.cloud) ?? preset.cloud ?? preset.open) : null;
const requested = sp.get("model");
+ // An app opened on one of its own models (?model=, from ⌘K) takes that model's route and params.
+ const presetRoute = preset
+ ? ([preset.cloud, preset.open].find((r) => !!requested && r?.modelId === requested) ?? (engine === "open" ? preset.open : preset.cloud) ?? preset.cloud ?? preset.open)
+ : null;
const modelId =
(requested && lookup.getModel(requested)?.id) ||
(preset?.type === "app" ? presetRoute?.modelId : undefined) ||
@@ -362,7 +365,21 @@ function UrlParams({ onChange }: { onChange: (key: string) => void }) {
* hydrated — are kept. A later change of the params (Animate → Video while on Video) starts a
* fresh draft instead.
*/
-function HandoffSync({ startKey, start, build, ready, onNavigate }: { startKey: string; start: Draft; build: React.RefObject<(key: string) => Draft>; ready: boolean; onNavigate: (key: string) => void }) {
+function HandoffSync({
+ startKey,
+ start,
+ build,
+ adopt,
+ ready,
+ onNavigate,
+}: {
+ startKey: string;
+ start: Draft;
+ build: React.RefObject<(key: string) => Draft>;
+ adopt: React.RefObject<(key: string) => void>;
+ ready: boolean;
+ onNavigate: (key: string) => void;
+}) {
const { setDraft } = useStudioActions();
const [url, setUrl] = useState<string | null>(null);
const applied = useRef({ key: startKey, ready, base: start, seen: false });
@@ -375,8 +392,9 @@ function HandoffSync({ startKey, start, build, ready, onNavigate }: { startKey:
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, setDraft, onNavigate]);
+ }, [url, ready, build, adopt, setDraft, onNavigate]);
return (
<Suspense fallback={null}>
<UrlParams onChange={setUrl} />
@@ -390,7 +408,7 @@ function HandoffSync({ startKey, start, build, ready, onNavigate }: { startKey:
* typed or focused before hydration is lost.
*/
function StudioDraft({ config, header, tabs, initialRefs, initialPrompt }: DraftProps) {
- const [engine] = useEngine();
+ const [engine, setEngine] = useEngine();
const catalog = useCatalog();
const bridge = useMemo<ComposerBridge>(() => ({ current: null }), []);
const build = (key: string) => {
@@ -399,20 +417,32 @@ function StudioDraft({ config, header, tabs, initialRefs, initialPrompt }: Draft
if (initialPrompt && !d.prompt) d.prompt = initialPrompt;
return d;
};
+ // A model named in the URL (?model=, from ⌘K or a hand-off) brings its engine along, as Reuse
+ // does: left on the other engine, the composer would swap it for that engine's default.
+ const adopt = (key: string) => {
+ const id = new URLSearchParams(key).get("model");
+ const m = id ? catalog.getModel(id) : undefined;
+ if (m && m.engine !== engine) setEngine(m.engine);
+ };
const buildRef = useRef(build);
+ const adoptRef = useRef(adopt);
useLayoutEffect(() => {
buildRef.current = build;
+ adoptRef.current = adopt;
});
// The draft the composer starts from: the defaults (the URL is unknown in the static shell), or
// the hand-off params of a client navigation to new ones (a new epoch remounts the provider).
const [start, setStart] = useState({ key: "", epoch: 0 });
const initial = useMemo(() => build(start.key), [start, config]); // eslint-disable-line react-hooks/exhaustive-deps
- const onNavigate = useCallback((key: string) => setStart((s) => ({ key, epoch: s.epoch + 1 })), []);
+ const onNavigate = useCallback((key: string) => {
+ setStart((s) => ({ key, epoch: s.epoch + 1 }));
+ adoptRef.current(key);
+ }, []);
return (
<ComposerBridgeCtx.Provider value={bridge}>
<StudioProvider key={start.epoch} config={config} initial={initial}>
<StudioBody header={header} tabs={tabs} />
- <HandoffSync startKey={start.key} start={initial} build={buildRef} ready={catalog.ready} onNavigate={onNavigate} />
+ <HandoffSync startKey={start.key} start={initial} build={buildRef} adopt={adoptRef} ready={catalog.ready} onNavigate={onNavigate} />
</StudioProvider>
</ComposerBridgeCtx.Provider>
);
diff --git a/src/lib/palette-index.ts b/src/lib/palette-index.ts
index c3008350..305640fc 100644
--- a/src/lib/palette-index.ts
+++ b/src/lib/palette-index.ts
@@ -2,9 +2,11 @@
* The slim catalog behind the ⌘K palette (GET /api/search-index): names, categories and where each item
* opens. Built on the server from the catalog, so the palette never ships prompt templates or routes.
*/
+import { MODELS_3D } from "@/lib/av/model3d";
import { APPS, EFFECTS, MODELS, MOTIONS } from "@/lib/catalog";
-import { OPERATION_LABELS, type ModelDef, type Preset } from "@/lib/catalog/types";
+import { OPERATION_LABELS, type ModelDef, type Operation, type Preset } from "@/lib/catalog/types";
import type { PaletteIndex, PaletteModel, PalettePreset } from "@/lib/command-search";
+import { TOOL_MODELS } from "@/lib/layers";
import type { StudioConfig } from "@/components/studio/studio-context";
import {
AUDIO_STUDIO,
@@ -14,6 +16,7 @@ import {
FOLEY_STUDIO,
IMAGE_STUDIO,
INPAINT_STUDIO,
+ JOIN_CLIPS_STUDIO,
LIPSYNC_STUDIO,
MOTION_CONTROL_STUDIO,
MUSIC_STUDIO,
@@ -21,7 +24,11 @@ import {
SFX_STUDIO,
TRANSCRIBE_STUDIO,
UPSCALE_STUDIO,
+ VIDEO_COLOR_MATCH_STUDIO,
+ VIDEO_DEPTH_STUDIO,
VIDEO_EDIT_STUDIO,
+ VIDEO_MATTE_STUDIO,
+ VIDEO_RELIGHT_STUDIO,
VIDEO_STUDIO,
VIDEO_UPSCALE_STUDIO,
VOICE_CHANGE_STUDIO,
@@ -47,13 +54,41 @@ const MODEL_STUDIOS: [string, StudioConfig][] = [
["/audio/sfx", SFX_STUDIO],
["/audio/music", MUSIC_STUDIO],
["/audio/video", FOLEY_STUDIO],
+ ["/video-tools", VIDEO_MATTE_STUDIO],
+ ["/video-tools/relight", VIDEO_RELIGHT_STUDIO],
+ ["/video-tools/depth", VIDEO_DEPTH_STUDIO],
+ ["/video-tools/join", JOIN_CLIPS_STUDIO],
+ ["/video-tools/colors", VIDEO_COLOR_MATCH_STUDIO],
];
-/** Where a model opens: the first studio that offers it, else its row on the Models page. */
+/** Image to 3D picks its model from ?model= too. */
+const IN_3D = new Set([...MODELS_3D.cloud, ...MODELS_3D.open].map((m) => m.id));
+/** The Layers editor's tools (cut-out, layers, text detection…): its project list is where they start. */
+const IN_LAYERS = new Set(Object.values(TOOL_MODELS).flatMap((t) => [...t.cloud, ...t.open]));
+/** Tools with their own flow (and their own model choice), by operation. */
+const TOOL_PAGES: [string, Operation][] = [
+ ["/video-tools/captions", "captions"],
+ ["/video-tools/trim", "trim"],
+ ["/audio/translate", "dub"],
+];
+
+/**
+ * Where a model opens: the first studio that offers it, Image to 3D, an app that runs it (each with
+ * ?model=, which also brings the model's engine), the Layers editor or a tool of its operation, else
+ * its row on the Models page (which reads ?q=).
+ */
export function modelHref(m: ModelDef): string {
const ops = new Set(m.routes.map((r) => r.op));
- const hit = MODEL_STUDIOS.find(([, c]) => c.kind === m.kind && (c.pickerOps ?? c.ops).some((op) => ops.has(op)));
- return hit ? `${hit[0]}?model=${encodeURIComponent(m.id)}` : `/models?q=${encodeURIComponent(m.name)}`;
+ const pick = `?model=${encodeURIComponent(m.id)}`;
+ const studio = MODEL_STUDIOS.find(([, c]) => c.kind === m.kind && (c.pickerOps ?? c.ops).some((op) => ops.has(op)));
+ if (studio) return studio[0] + pick;
+ if (IN_3D.has(m.id)) return `/image-to-3d${pick}`;
+ const app = APPS.find((a) => a.cloud?.modelId === m.id || a.open?.modelId === m.id);
+ if (app) return `/apps/${app.id}${pick}`;
+ if (IN_LAYERS.has(m.id)) return "/layers";
+ const tool = TOOL_PAGES.find(([, op]) => ops.has(op));
+ if (tool) return tool[0];
+ return `/models?q=${encodeURIComponent(m.name)}`;
}
const preset = (p: Preset): PalettePreset => ({ id: p.id, name: p.name, category: p.category, cloud: !!p.cloud, open: !!p.open });