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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Your GPU: orbit presets run only the Orbit graph, and a missing file is named with Get it
Adarsh38ec3026ea82
diff --git a/src/components/gpu/file-steps.tsx b/src/components/gpu/file-steps.tsxnew file mode 100644index 00000000..cc70d774--- /dev/null+++ b/src/components/gpu/file-steps.tsx@@ -0,0 +1,148 @@+"use client";++import { CheckCircle2, Cpu, Download, ExternalLink, Loader2, RefreshCw } from "lucide-react";+import { openGpuSetup, useGpuCheck, useGpuPlan } from "@/hooks/use-gpu";+import { fileSteps, getItLabel, putItIn, readinessLine, type FileStep } from "@/lib/gpu/file-steps";+import type { Badge, FixPlan } from "@/lib/gpu/types";+import { cn } from "@/lib/utils";++/**+ * The files a tool needs on the viewer's GPU: each one's name and size, its exact file name, the folder it goes in, and+ * "Get it" (its download, or its page when that comes first). The guided fix lists them; the readiness line above a+ * preset's Render names them; a failed run's tile can show the same rows. A one-click install (Fuobe Connect, with its+ * SHA-256 check) would sit next to Get it, as the step's `via` "helper": until then every file is by hand.+ */++/** Get it: a link that leaves Fuobe (https only, checked when the plan was built). */+export function GetIt({ f, className }: { f: Pick<FileStep, "url" | "page" | "file">; className?: string }) {+ if (!f.url) return null;+ const label = getItLabel(f);+ return (+ <a+ href={f.url}+ target="_blank"+ rel="noopener noreferrer"+ onClick={(e) => e.stopPropagation()}+ aria-label={`${label}: ${f.file}`}+ className={cn("inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full bg-highlight px-3 text-[12px] font-medium text-highlight-foreground hover:opacity-90", className)}+ >+ {f.page ? <ExternalLink aria-hidden className="size-3.5" /> : <Download aria-hidden className="size-3.5" />}+ {label}+ </a>+ );+}++/** One row per file: what it is, the exact file, the folder, and Get it. */+export function FileStepRows({ plan, className }: { plan: Pick<FixPlan, "steps">; className?: string }) {+ const files = fileSteps(plan);+ if (!files.length) return null;+ return (+ <ul className={cn("divide-y rounded-lg border", className)}>+ {files.map((f) => (+ <li key={f.id} className="flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2.5 text-[13px]">+ <div className="min-w-0 flex-1 basis-56">+ <p className="font-medium">+ {f.title}+ {f.size && <span className="font-normal text-muted-foreground"> · {f.size}</span>}+ </p>+ <p className="mt-0.5 font-mono text-[12px] break-all">{f.file}</p>+ <p className="mt-0.5 text-[12px] break-words text-muted-foreground">+ {f.again ? "The one there isn't usable: download it again. " : ""}+ {putItIn(f)}+ {f.page ? ". Sign in or accept its licence on its page first." : ""}+ </p>+ </div>+ <GetIt f={f} />+ </li>+ ))}+ </ul>+ );+}++/**+ * A failed run's tile (or any small place): the files its tool needs, from the plan the server builds from the last GPU+ * check, with Get it and Check again. Nothing when the plan has no file to add.+ */+export function GpuFileSteps({ gpuRef, className }: { gpuRef: string; className?: string }) {+ const plan = useGpuPlan(gpuRef).data;+ const check = useGpuCheck();+ const files = fileSteps(plan);+ if (!files.length) return null;+ return (+ <div className={cn("space-y-1.5 text-[12px]", className)} onClick={(e) => e.stopPropagation()}>+ {files.map((f) => (+ <div key={f.id} className="flex flex-wrap items-start gap-x-2 gap-y-1">+ <div className="min-w-0 flex-1 basis-40">+ <p className="font-medium">+ {f.title}+ {f.size && <span className="font-normal text-muted-foreground"> · {f.size}</span>}+ </p>+ <p className="font-mono text-[11px] break-all">{f.file}</p>+ <p className="text-[11px] break-words text-muted-foreground">{putItIn(f)}</p>+ </div>+ <GetIt f={f} className="h-7 px-2.5" />+ </div>+ ))}+ <button+ type="button"+ disabled={check.running}+ onClick={() => void check.start()}+ className="inline-flex h-7 items-center gap-1 rounded-full bg-secondary px-2.5 font-medium hover:bg-accent disabled:opacity-70"+ >+ {check.running ? <Loader2 aria-hidden className="size-3 animate-spin" /> : <RefreshCw aria-hidden className="size-3" />}+ Check again+ </button>+ </div>+ );+}++/**+ * The readiness line above Render (a preset on the viewer's own GPU): "Ready on your GPU", or "Needs 1 file on your GPU:+ * Orbit LoRA · Get it · Check again". It reads the cached badge, and the tool's plan only when something is missing (the+ * plan reads the last GPU check; only Check again asks the GPU). It never stops Render.+ */+export function GpuReadinessLine({ badge, gpuRef, name, className }: { badge: Badge | null; gpuRef: string; name?: string; className?: string }) {+ const missing = !!badge && (badge[0] === "a" || badge[0] === "s");+ const plan = useGpuPlan(missing ? gpuRef : null).data;+ const check = useGpuCheck();+ const line = readinessLine(badge, plan);+ if (!line) return null;+ const open = () => openGpuSetup({ ref: gpuRef, name, ...(plan && { plan }) });+ if (line.state === "ready")+ return (+ <p role="status" className={cn("flex items-center gap-1.5 text-[12px] text-muted-foreground", className)}>+ <CheckCircle2 aria-hidden className="size-3.5 text-success" /> {line.words}+ </p>+ );+ const one = line.files.length === 1 ? line.files[0] : undefined;+ return (+ <div role="status" className={cn("flex flex-wrap items-center gap-x-2 gap-y-1.5 rounded-xl bg-muted/60 px-3 py-2 text-[12px]", className)}>+ {line.state === "gpu" ? <Cpu aria-hidden className="size-3.5 shrink-0" /> : <Download aria-hidden className="size-3.5 shrink-0" />}+ <button type="button" onClick={open} className="min-w-0 flex-1 basis-48 text-left font-medium underline-offset-2 hover:underline">+ {line.words}+ {one?.size && <span className="font-normal text-muted-foreground"> · {one.size}</span>}+ </button>+ <span className="flex flex-wrap items-center gap-1.5">+ {one ? (+ <GetIt f={one} className="h-7 px-2.5" />+ ) : (+ <button type="button" onClick={open} className="inline-flex h-7 items-center rounded-full bg-highlight px-2.5 font-medium text-highlight-foreground hover:opacity-90">+ {line.files.length ? "See the files" : "See how"}+ </button>+ )}+ {line.state !== "gpu" && (+ <button+ type="button"+ disabled={check.running}+ onClick={() => void check.start()}+ className="inline-flex h-7 items-center gap-1 rounded-full bg-secondary px-2.5 font-medium hover:bg-accent disabled:opacity-70"+ >+ {check.running ? <Loader2 aria-hidden className="size-3 animate-spin" /> : <RefreshCw aria-hidden className="size-3" />}+ Check again+ </button>+ )}+ </span>+ {check.error && <p className="w-full text-destructive">{check.error}</p>}+ </div>+ );+}diff --git a/src/components/gpu/guided-fix.tsx b/src/components/gpu/guided-fix.tsxindex d1238774..31251718 100644--- a/src/components/gpu/guided-fix.tsx+++ b/src/components/gpu/guided-fix.tsx@@ -5,6 +5,7 @@ import { CheckCircle2, ChevronRight, Circle, Cpu, Download, Layers, Loader2, Wreimport Link from "next/link";import { useEffect, useRef, useState } from "react";import { CommandTabs } from "@/components/gpu/command-block";+import { FileStepRows } from "@/components/gpu/file-steps";import { Button } from "@/components/ui/button";import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";@@ -111,20 +112,25 @@ interface Actions {function PlanState({ plan, kind, actions, checking, onCheck, checkError }: { plan: FixPlan; kind?: string; actions: Actions; checking: boolean; onCheck: () => void; checkError: string | null }) {const real = plan.steps.filter((s) => s.kind !== "restart" && s.kind !== "hf-licence" && s.kind !== "civitai-key");- const shown = real.length ? real : plan.steps;+ // Files get rows of their own (name, size, folder, Get it); the list keeps the other steps and what is already there.+ const files = real.filter((s) => s.download);+ const shown = files.length ? real.filter((s) => !s.download) : real.length ? real : plan.steps;const why = WHY[plan.why] ?? WHY["manual-only"]!;const [lo, hi] = plan.etaMin;return (<div className="space-y-4"><p className="text-[13px] text-muted-foreground">{intro(plan, kind)}</p>- <ul className="divide-y rounded-lg border px-3">- {shown.map((s) => (- <StepRow key={s.id} n={s} />- ))}- {plan.have.slice(0, 6).map((h) => (- <StepRow key={h.key} n={h} done />- ))}- </ul>+ {files.length > 0 && <FileStepRows plan={plan} />}+ {(shown.length > 0 || plan.have.length > 0) && (+ <ul className="divide-y rounded-lg border px-3">+ {shown.map((s) => (+ <StepRow key={s.id} n={s} />+ ))}+ {plan.have.slice(0, 6).map((h) => (+ <StepRow key={h.key} n={h} done />+ ))}+ </ul>+ )}{plan.downloadBytes > 0 && (<p className="text-[13px]">{formatBytes(plan.downloadBytes)} from Hugging Face · about {lo === hi ? lo : `${lo}–${hi}`} min on fast internet.{" "}diff --git a/src/components/preset-header.tsx b/src/components/preset-header.tsxindex 35a601bf..5784d5fa 100644--- a/src/components/preset-header.tsx+++ b/src/components/preset-header.tsx@@ -1,6 +1,7 @@"use client";import { Cloud, Cpu, Info, Sparkles, X } from "lucide-react";+import { GpuReadinessLine } from "@/components/gpu/file-steps";import { HeaderPill } from "@/components/gpu/readiness-chip";import { PresetPreview, usePreviewPlayback } from "@/components/preset-preview";import { openGpuSetup, useGpuBadges } from "@/hooks/use-gpu";@@ -57,6 +58,9 @@ export function PresetHeader({const badges = useGpuBadges().data;const [engine] = useEngine();const gpu = gpuKey && engine === "open" ? (badges?.presets[gpuKey] ?? null) : null;+ // Something to add on the GPU (or a card too small): the readiness line under the card says what, with Get it; the pill+ // stays for Ready. Neither stops Render.+ const lineFirst = !!gpu && (gpu[0] === "a" || gpu[0] === "s" || gpu[0] === "g");return (<div className={cn("mx-auto w-full max-w-[760px] rounded-2xl border bg-background p-2 pr-3 text-left shadow-soft", examples && "p-3", className)}><div className="flex w-full items-center gap-3">@@ -76,7 +80,7 @@ export function PresetHeader({<p className="truncate font-heading text-[19px] leading-snug">{preset.name}</p><p className="line-clamp-2 text-[13px] text-muted-foreground max-sm:line-clamp-3">{presetHowTo(preset)}</p></div>- {gpu && <HeaderPill badge={gpu} gpu={badges?.gpu} compact onOpen={() => openGpuSetup({ ref: `preset:${gpuKey}`, name: preset.name })} />}+ {gpu && !lineFirst && <HeaderPill badge={gpu} gpu={badges?.gpu} compact onOpen={() => openGpuSetup({ ref: `preset:${gpuKey}`, name: preset.name })} />}<Popover><PopoverTrigger asChild><button@@ -130,6 +134,7 @@ export function PresetHeader({</button>)}</div>+ {lineFirst && gpuKey && <GpuReadinessLine badge={gpu} gpuRef={`preset:${gpuKey}`} name={preset.name} className="mt-2" />}{examples && <div className="mt-3">{examples}</div>}</div>);diff --git a/src/lib/comfy-variants.ts b/src/lib/comfy-variants.tsindex 1e4b236e..be055918 100644--- a/src/lib/comfy-variants.ts+++ b/src/lib/comfy-variants.ts@@ -130,7 +130,9 @@ export function resolveWorkflowId(endpointTemplate: string, r: VariantRequest):const latentDraft = H3_LATENT_DRAFT_GRAPH[endpoint];// The 2K tier's text-to-video draft that keeps its latent (never a Flex take's: h3TwoKRequests drafts that on Flex's graph).if (latentDraft && r.extra.latentDraft === true && r.has(latentDraft)) endpoint = latentDraft;- else if (orbit && r.extra.orbit === true && r.has(orbit)) endpoint = orbit;+ // An orbit is only ever the Orbit graph: the plain graph with the orbit's words makes a clip where nothing moves. A library+ // without it fails the run by name instead (the GPU pre-flight names the Orbit LoRA when a GPU lacks it).+ else if (orbit && r.extra.orbit === true) endpoint = orbit;else if (flex && r.extra.quality === "flex" && r.has(flex)) endpoint = flex;else if (small) endpoint = small;else if (best && r.extra.quality === "best" && r.has(best)) endpoint = best;diff --git a/src/lib/gpu/file-steps.ts b/src/lib/gpu/file-steps.tsnew file mode 100644index 00000000..f1c96be6--- /dev/null+++ b/src/lib/gpu/file-steps.ts@@ -0,0 +1,87 @@+import { formatBytes } from "./requirements";+import type { Badge, FixPlan, FixStep } from "./types";++/**+ * The files a tool needs on the viewer's GPU, in plain words: for the guided fix's file rows, the readiness line above a+ * preset's Render, and a failed run's tile. Pure (browser and tests): it reads a fix plan the server built and a badge.+ */++/** A file to put on the GPU: what it is, its exact name and size, its folder, and where it downloads from. */+export interface FileStep {+ id: string;+ /** "Orbit LoRA", "Video model", "Decoder". */+ title: string;+ file: string;+ size?: string;+ /** "models/loras", relative to the ComfyUI folder. */+ folder: string;+ /** That folder on the viewer's ComfyUI, when its check read a plain path. */+ path?: string;+ /** https only: the file itself, or its page (`page`) when it needs a sign-in, a licence or a key. */+ url?: string;+ page?: boolean;+ /** The one there isn't usable (cut short, or another file under its name): download it again. */+ again: boolean;+}++export function fileSteps(plan: Pick<FixPlan, "steps"> | null | undefined): FileStep[] {+ return (plan?.steps ?? []).flatMap((s: FixStep) =>+ s.download+ ? [+ {+ id: s.id,+ title: s.label,+ file: s.download.file,+ ...(s.sizeBytes ? { size: formatBytes(s.sizeBytes) } : {}),+ folder: s.download.folder,+ ...(s.download.path && { path: s.download.path }),+ ...(s.download.url && { url: s.download.url }),+ ...(s.download.page && { page: true }),+ again: s.kind === "model-replace",+ },+ ]+ : [],+ );+}++/** The button that opens a file's download: "Get it", or "Open its page" when the page comes first. */+export const getItLabel = (f: Pick<FileStep, "page">): string => (f.page ? "Open its page" : "Get it");++/** "Put it in models/loras" (or the folder on their ComfyUI). */+export const putItIn = (f: Pick<FileStep, "folder" | "path">): string => `Put it in ${f.path ?? `ComfyUI/${f.folder}`}`;++/** What the readiness line says. `files`: the files it names (one gets its own Get it). Null: no line. */+export interface ReadinessLine {+ state: "ready" | "files" | "setup" | "gpu";+ words: string;+ files: FileStep[];+}++/**+ * The line above Render for a preset on the viewer's GPU, from its badge (cached) and, when files are missing, its plan:+ * "Ready on your GPU", "Needs 1 file on your GPU: Orbit LoRA", "Needs 2 things on your GPU". It never stops a run: Render+ * stays where it is.+ */+export function readinessLine(badge: Badge | null | undefined, plan: Pick<FixPlan, "steps" | "state"> | null | undefined): ReadinessLine | null {+ if (!badge) return null;+ const [s, steps] = badge;+ if (s === "r") return { state: "ready", words: "Ready on your GPU", files: [] };+ if (s === "g") return { state: "gpu", words: "Needs a bigger GPU than yours", files: [] };+ if (s === "u") return null;+ // The plan is the server's newer read: once it says ready, so does the line.+ if (plan?.state === "ready") return { state: "ready", words: "Ready on your GPU", files: [] };+ const files = fileSteps(plan);+ const others = (plan?.steps ?? []).filter((x) => !x.download && x.kind !== "restart" && x.kind !== "hf-licence" && x.kind !== "civitai-key").length;+ if (files.length && !others) {+ const again = files.every((f) => f.again);+ const names = files.map((f) => f.title).filter((t, i, a) => a.indexOf(t) === i);+ const n = files.length;+ return {+ state: "files",+ words: again ? `Download ${n === 1 ? "1 file" : `${n} files`} again on your GPU: ${names.join(", ")}` : `Needs ${n === 1 ? "1 file" : `${n} files`} on your GPU: ${names.join(", ")}`,+ files,+ };+ }+ const n = plan ? files.length + others || steps : steps;+ return { state: "setup", words: `Needs ${n === 1 ? "1 thing" : `${n || 1} things`} on your GPU`, files };+}diff --git a/src/lib/gpu/plan.ts b/src/lib/gpu/plan.tsindex a0af11ff..71903afd 100644--- a/src/lib/gpu/plan.ts+++ b/src/lib/gpu/plan.ts@@ -1,6 +1,7 @@-import { commandsFor, type CommandStep } from "./commands";+import { commandsFor, safePath, type CommandStep } from "./commands";+import { splitKey } from "./requirements";import type { LoraNeed } from "./readiness";-import type { FixPlan, FixStep, GpuInventory, Need, Readiness, RequirementIndex, StepKind, ToolReadiness, ToolRef, WhyCode } from "./types";+import type { FixPlan, FixStep, GpuInventory, IndexFile, Need, Readiness, RequirementIndex, StepKind, ToolReadiness, ToolRef, WhyCode } from "./types";/*** A tool's fix plan (SPEC §8): its steps in run order, each with why it can't be one click and the commands@@ -77,6 +78,44 @@ export function hfPage(url: string | undefined): string | undefined {return m ? `https://huggingface.co/${m[1]}` : undefined;}+/** A link that leaves Fuobe: https only, one plain URL. */+const HTTPS = /^https:\/\/[^\s"'<>]+$/i;+const https = (u: string | undefined) => (u && HTTPS.test(u) ? u : undefined);++/** A civitai download URL answers only with the person's key: its model page is where they get it. */+const keyed = (u: string | undefined) => !!u && /civitai\.com\/api\/download/i.test(u);++/** A folder the check didn't list, under the ComfyUI folder another listed folder names (".../ComfyUI/models/vae"). */+function folderUnderComfy(inv: GpuInventory | null, folder: string): { path: string } | undefined {+ for (const dirs of Object.values(inv?.comfy?.modelRoots ?? {}))+ for (const d of dirs) {+ const s = safePath(d);+ const m = s ? /^(.*[\\/]models)([\\/])[^\\/]+$/.exec(s.path) : null;+ if (m && /^[\w.-]+$/.test(folder)) return { path: `${m[1]}${m[2]}${folder}` };+ }+ return undefined;+}++/**+ * A model or LoRA step's file: its name, its folder (and that folder on the viewer's ComfyUI, when the check read a plain+ * path), and where it downloads from (the pinned file; a gated or keyed one's page).+ */+export function stepDownload(n: Need, inv: GpuInventory | null, idx: RequirementIndex, lora?: LoraNeed): FixStep["download"] {+ if (n.kind !== "model" && n.kind !== "model-replace" && n.kind !== "lora") return undefined;+ const f: IndexFile | undefined = n.file ? idx.files[n.file] : undefined;+ const file = f?.file ?? lora?.file ?? n.lora ?? (n.file ? splitKey(n.file).file : undefined);+ if (!file) return undefined;+ const folder = f?.folder ?? (n.file ? splitKey(n.file).folder : "loras");+ const root = (inv?.comfy?.modelRoots?.[folder] ?? []).map((d) => safePath(d)).find(Boolean) ?? folderUnderComfy(inv, folder);+ // The file itself when anyone can download it; else the page where the person signs in, accepts or uses their key.+ const direct = f ? f.pinnedUrl || f.url : lora?.url;+ const open = f ? !f.gated && !keyed(direct) : lora?.download === "direct" && !keyed(direct);+ const url = open ? https(direct) : https(lora?.page) ?? hfPage(f?.url ?? lora?.url);+ const page = !open;+ const sha256 = f?.sha256 ?? lora?.sha256;+ return { file, folder: `models/${folder}`, ...(root && { path: root.path }), ...(url && { url }), ...(url && page && { page: true as const }), ...(sha256 && { sha256 }) };+}+export interface PlanOptions {/** sha256 hex of a string (the server's). */hash: (s: string) => string;@@ -99,7 +138,8 @@ export function fixPlan(t: ToolReadiness, inv: GpuInventory | null, idx: Requireconst lora = n.lora ? loras.get(n.lora) : undefined;const f = n.file ? idx.files[n.file] : undefined;const link = n.kind === "hf-licence" ? (lora?.page ?? hfPage(f?.url ?? n.detail)) : lora?.page;- return { ...n, id: `s${i + 1}`, via: "manual", why: whyOf(n, inv, idx, lora), commands: { bash: "", powershell: "" }, ...(link && { link }) };+ const download = stepDownload(n, inv, idx, lora);+ return { ...n, id: `s${i + 1}`, via: "manual", why: whyOf(n, inv, idx, lora), commands: { bash: "", powershell: "" }, ...(link && { link }), ...(download && { download }) };});const cmdSteps: CommandStep[] = steps.map((s) => {const lora = s.lora ? loras.get(s.lora) : undefined;diff --git a/src/lib/gpu/readiness.ts b/src/lib/gpu/readiness.tsindex 3ac0b910..a3a9ad80 100644--- a/src/lib/gpu/readiness.ts+++ b/src/lib/gpu/readiness.ts@@ -39,25 +39,39 @@ export function shortGpu(name: string | undefined): string {/** Extensions ComfyUI's folder listings show (supported_pt_extensions). */const LISTED = /\.(ckpt|pt|pt2|bin|pth|safetensors|pkl|sft)$/i;-export type FileState = "present" | "partial" | "missing" | "unknown" | "unobservable";+/**+ * - "partial": smaller than the index's file (cut short).+ * - "other": a file pinned to one revision whose size is larger than that revision's: another file under the same name,+ * which loads but doesn't do what the graph needs (an Orbit LoRA that leaves the clip frozen).+ */+export type FileState = "present" | "partial" | "other" | "missing" | "unknown" | "unobservable";++/** A file the index pins to one revision (Hugging Face resolve/<commit>): its size is that file's, exactly. */+const pinnedRevision = (f: Pick<IndexFile, "pinnedUrl">) => /\/resolve\/[0-9a-f]{40}\//.test(f.pinnedUrl ?? "");++/** What the folder listing's size says of a file that is there. A size the listing didn't give says nothing. */+function bySize(f: IndexFile, size: number | null | undefined): "present" | "partial" | "other" {+ if (typeof size !== "number" || !(f.sizeBytes > 0) || size <= 0) return "present";+ if (size < 0.99 * f.sizeBytes) return "partial";+ return pinnedRevision(f) && size > 1.01 * f.sizeBytes ? "other" : "present";+}/** Is this index file on that ComfyUI: by its loader's combo list first, then the folder listing. */export function filePresence(f: IndexFile, inv: GpuInventory): FileState {if (f.presence === "unobservable") return "unobservable";const listing = inv.models[f.listFolder ?? f.folder];const size = listing && !listing.folderMissing ? listing.have[f.file] : undefined;- const short = typeof size === "number" && f.sizeBytes > 0 && size < 0.99 * f.sizeBytes;if (f.presence === "loader") {let said: boolean | undefined;for (const [cls, input] of f.loaders ?? []) {const combo = inv.combos[`${cls}.${input}`];if (combo) said = said || combo.includes(f.file);}- if (said === true) return short ? "partial" : "present";+ if (said === true) return bySize(f, size);if (said === false) return "missing";}// No loader read: the folder listing decides, for the files a listing can show.- if (size !== undefined) return short ? "partial" : "present";+ if (size !== undefined) return bySize(f, size);if (!LISTED.test(f.file)) return "unknown";if (listing) return "missing";return "unknown";@@ -82,6 +96,20 @@ const FOLDER_LABEL: Record<string, string> = {geometry_estimation: "Depth reader",};+/**+ * Files whose job has a name people know: the guided fix and the readiness line say it ("Orbit LoRA") instead of the+ * folder's role. By the file's base name.+ */+const FILE_TITLES: Record<string, string> = {+ // pablodawson's MiniMax H3 360 Orbit LoRA (the orbit presets: Bullet Time, 360 Orbit, 3D Rotation, Product 360).+ "minimax_h3_flf2v_lora_v1.safetensors": "Orbit LoRA",+};++/** A file's name for people: its known title, else its folder's role ("Decoder", "Video model"). */+export function fileTitle(folder: string, file: string, kind?: string): string {+ return FILE_TITLES[file] ?? fileLabel(folder, kind);+}+export function fileLabel(folder: string, kind?: string): string {const base = FOLDER_LABEL[folder];if (base === "Main model" && kind) return `${kind[0].toUpperCase()}${kind.slice(1)} model`;@@ -154,7 +182,7 @@ function fileNeed(key: FileKey, f: IndexFile, kind: "model" | "model-replace", creturn {key: `file:${key}`,kind,- label: fileLabel(f.folder, ctx.kind),+ label: fileTitle(f.folder, f.file, ctx.kind),detail: `${f.file} → models/${f.folder}`,sizeBytes: f.sizeBytes,file: key,@@ -220,6 +248,7 @@ export function workflowReadiness(id: string, inv: GpuInventory, idx: Requiremenif (s === "unobservable") out.unobservable.push(f.file);else if (s === "present") out.have.push(fileNeed(key, f, "model", ctx));else if (s === "partial") out.needs.push({ ...fileNeed(key, f, "model-replace", ctx), detail: `${f.file} in models/${f.folder} is only partly downloaded` });+ else if (s === "other") out.needs.push({ ...fileNeed(key, f, "model-replace", ctx), detail: `${f.file} in models/${f.folder} isn't the file this needs (its size is different)` });else if (s === "missing") {out.needs.push(fileNeed(key, f, "model", ctx));if (f.gated) out.needs.push({ key: `licence:${key}`, kind: "hf-licence", label: "Accept the model's licence on Hugging Face", detail: f.url, file: key });diff --git a/src/lib/gpu/types.ts b/src/lib/gpu/types.tsindex 8fb5124d..b06d3fa2 100644--- a/src/lib/gpu/types.ts+++ b/src/lib/gpu/types.ts@@ -322,6 +322,12 @@ export interface FixStep extends Need {commands: { bash: string; powershell: string };/** A page to open first (a gated model's Hugging Face page, a LoRA's civitai page). */link?: string;+ /**+ * A file to put on the GPU (a model or LoRA step): its name, where it goes and where it downloads from. `url` is https+ * only: the file itself, or its page when the download needs a sign-in, a licence or a key (`page`). A one-click install+ * through Fuobe Connect (with its SHA-256 check) would set `via` "helper" and use `sha256`; P1 leaves it by hand.+ */+ download?: { file: string; folder: string; path?: string; url?: string; page?: true; sha256?: string };}export interface FixPlan {diff --git a/tests/orbit-own-gpu.test.ts b/tests/orbit-own-gpu.test.tsnew file mode 100644index 00000000..b8fde859--- /dev/null+++ b/tests/orbit-own-gpu.test.ts@@ -0,0 +1,194 @@+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";+import { NextRequest } from "next/server";+import { startFakeComfy, readyFor, type FakeComfy, type FakeScenario } from "./helpers/fake-comfy";+import { tempDir } from "./helpers/temp-dir";++/**+ * The orbit presets on an account's own GPU: they only ever run H3's Orbit graph (the Orbit LoRA), and a GPU without that+ * LoRA (or with another file under its name) gets the missing-file step that names it, its size, its folder and its+ * download, never a run on a graph that can't orbit.+ */++vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));+vi.setConfig({ testTimeout: 30_000 });++const dir = tempDir("fuobe-orbit-gpu-");+process.env.FUOBE_DATA_DIR = dir;+process.env.FUOBE_PUBLIC_SIGNUP = "1";+delete process.env.FUOBE_PASSWORD;+delete process.env.FUOBE_ALLOW_PRIVATE_URLS;+delete process.env.FUOBE_GPU_PREFLIGHT;++const auth = await import("@/server/auth");+const { loadIndex } = await import("@/server/gpu/index-file");+const { gpuTargetFor } = await import("@/server/gpu/target");+const { gateGeneration } = await import("@/server/gpu/gate");+const { presetTool } = await import("@/server/gpu/tools");+const check = await import("@/app/api/gpu/check/route");+const plan = await import("@/app/api/gpu/plan/route");+const badges = await import("@/app/api/gpu/badges/route");+const { getPreset } = await import("@/lib/catalog");+const { presetRoutes, ORBIT_WORDS } = await import("@/lib/catalog/preset-recipe-routes");+const { resolveWorkflowId } = await import("@/lib/comfy-variants");+const { fileSteps, readinessLine } = await import("@/lib/gpu/file-steps");+const { stepDownload } = await import("@/lib/gpu/plan");++const idx = loadIndex();+const ORBIT = "minimax-h3-orbit";+const LORA = "minimax_h3_flf2v_lora_v1.safetensors";+const LORA_KEY = `loras/${LORA}` as const;+/** Every preset whose recipe is H3's orbit (preset-recipe-book.json quality "orbit"). */+const ORBIT_PRESETS = ["app-bullet-time-splash", "app-bullet-time-scene", "app-bullet-time-white", "app-3d-rotation", "app-product-360", "motion-bullet-time", "motion-360-orbit", "motion-3d-rotation", "effect-frozen-in-motion"];+const CARD = { version: "0.42.1", devices: [{ name: "cuda:0 NVIDIA GeForce RTX 5090 : cudaMallocAsync", type: "cuda", vramGb: 32 }] };++const fakes: FakeComfy[] = [];+afterAll(async () => {+ globalThis.__fuobeGpuTestTransport = undefined;+ await Promise.all(fakes.map((f) => f.close()));+});+beforeAll(() => {+ auth.setPassword("install password");+ globalThis.__fuobeGpuTestTransport = { resolve: async (h) => (h.endsWith(".gpu.test") ? ["127.0.0.1"] : ["203.0.113.9"]), blocked: () => false };+});++let n = 0;+async function accountWith(s: FakeScenario) {+ const f = await startFakeComfy(s);+ fakes.push(f);+ const a = auth.createAccount(`orbit${++n}@example.com`, "long enough");+ auth.setAccountGpu(a.id, { url: `http://o${n}.gpu.test:${f.port}` });+ const cookie = auth.createSession(a.id).value;+ const res = await check.POST(req("/api/gpu/check", { method: "POST", cookie }));+ await res.text();+ return { cookie, f };+}++function req(url: string, o: { method?: string; cookie?: string } = {}) {+ const headers: Record<string, string> = { host: "localhost:3000", "sec-fetch-site": "same-origin" };+ if (o.cookie) headers.cookie = `${auth.SESSION_COOKIE}=${o.cookie}`;+ return new NextRequest(`http://localhost:3000${url}`, { method: o.method ?? "GET", headers });+}++/** The Orbit graph's needs on this GPU, with the LoRA left out, or given at another size. */+function orbitGpu(lora: "there" | "missing" | number): FakeScenario {+ const s = readyFor(idx, [ORBIT], CARD);+ if (lora === "there") return s;+ s.files = { ...s.files, loras: (s.files?.loras ?? []).filter((x) => x.name !== LORA) };+ s.combos = { ...s.combos, LoraLoaderModelOnly: { lora_name: (s.combos?.LoraLoaderModelOnly?.lora_name ?? []).filter((x) => x !== LORA) } };+ if (typeof lora === "number") {+ s.files.loras!.push({ name: LORA, size: lora });+ s.combos.LoraLoaderModelOnly.lora_name.push(LORA);+ }+ return s;+}++/** A run of the app as the composer sends it on the open engine: H3's image-to-video with the orbit's setting. */+const run = (presetId: string) => ({+ request: { feature: "video", modelId: "oss-minimax-h3", op: "i2v" as const, presetId, prompt: "", params: { duration: 3, extra: { orbit: true } }, account: "x", engine: "open" as const },+ route: { provider: "comfyui", endpoint: "minimax-h3-i2v" },+ op: "i2v",+ modelId: "oss-minimax-h3",+ actor: "x",+});++describe("an orbit never runs a graph that can't orbit", () => {+ it("resolves an orbit to the Orbit graph even when a library lacks it (the run then fails by name)", () => {+ const base = { op: "i2v", clips: 0, images: 1, audio2: false, extra: { orbit: true } };+ expect(resolveWorkflowId("minimax-h3-i2v", { ...base, has: () => true })).toBe(ORBIT);+ expect(resolveWorkflowId("minimax-h3-i2v", { ...base, has: () => false })).toBe(ORBIT);+ // Whatever the Quality or the card's tier asks.+ expect(resolveWorkflowId("minimax-h3-i2v", { ...base, extra: { orbit: true, quality: "best" }, has: () => true })).toBe(ORBIT);+ expect(resolveWorkflowId("minimax-h3-i2v", { ...base, extra: { orbit: true, quality: "flex" }, has: () => true })).toBe(ORBIT);+ expect(resolveWorkflowId("minimax-h3-i2v", { ...base, extra: {}, has: () => true })).toBe("minimax-h3-i2v");+ });++ it("checks every orbit preset's GPU tool against the Orbit graph and its LoRA, never the plain image-to-video graph", () => {+ expect(idx.workflows[ORBIT].files).toContain(LORA_KEY);+ for (const id of ORBIT_PRESETS) {+ const tool = presetTool(id);+ expect(tool?.workflows, id).toContain(ORBIT);+ expect(tool?.workflows, id).not.toContain("minimax-h3-i2v");+ }+ });++ it("words: the orbit's own say the camera moves; no other route of an orbit preset says only to freeze", () => {+ expect(ORBIT_WORDS).toMatch(/Only the camera moves\. In a continuous 360 orbit\./);+ const moves = /camera|orbit|rotat|spin|sweep|360/i;+ for (const id of ORBIT_PRESETS) {+ const p = getPreset(id)!;+ for (const engine of ["open", "cloud"] as const)+ for (const r of presetRoutes(p, engine, () => true)) expect(r.promptTemplate ?? p.promptTemplate, `${id} ${engine} ${r.modelId}`).toMatch(moves);+ }+ });+});++describe("an account's GPU without the Orbit LoRA", () => {+ it("is stopped before the run with the step that names the Orbit LoRA, its size, its folder and its download", async () => {+ const { cookie, f } = await accountWith(orbitGpu("missing"));+ const t = gpuTargetFor(req("/", { cookie }), "read");+ for (const id of ["app-bullet-time-splash", "motion-bullet-time"]) {+ const g = await gateGeneration(t, run(id));+ expect(g.ok, id).toBe(false);+ if (g.ok) continue;+ const files = fileSteps(g.plan);+ expect(files).toHaveLength(1);+ expect(files[0]).toMatchObject({ title: "Orbit LoRA", file: LORA, folder: "models/loras", again: false, size: "155 MB" });+ expect(files[0].url).toBe(idx.files[LORA_KEY].pinnedUrl);+ expect(files[0].url).toMatch(/^https:\/\/huggingface\.co\/pablodawson\/MiniMax-H3-360-Orbit-LoRA\/resolve\/[0-9a-f]{40}\//);+ expect(g.message).toMatch(/before it can run/);+ }+ // Nothing reached the GPU but reads.+ expect(f.requests.some((r) => r.method !== "GET" || r.path.includes("/prompt"))).toBe(false);+ // The badge (cached) and the plan the readiness line reads say the same.+ const map = await (await badges.GET(req("/api/gpu/badges", { cookie }))).json();+ const badge = map.presets["app-bullet-time-splash"];+ expect(badge.slice(0, 2)).toEqual(["a", 1]);+ const p = await (await plan.GET(req("/api/gpu/plan?ref=preset:app-bullet-time-splash", { cookie }))).json();+ expect(readinessLine(badge, p)).toMatchObject({ state: "files", words: "Needs 1 file on your GPU: Orbit LoRA" });+ });++ it("asks for the file again when the one under its name is another size (a pinned file's size is exact)", async () => {+ const { cookie } = await accountWith(orbitGpu(idx.files[LORA_KEY].sizeBytes * 2));+ const g = await gateGeneration(gpuTargetFor(req("/", { cookie }), "read"), run("app-bullet-time-splash"));+ expect(g.ok).toBe(false);+ if (!g.ok) {+ expect(g.plan.steps.find((s) => s.download)?.kind).toBe("model-replace");+ expect(fileSteps(g.plan)[0]).toMatchObject({ title: "Orbit LoRA", again: true });+ expect(readinessLine(["a", 1, 2, 0], g.plan)?.words).toBe("Download 1 file again on your GPU: Orbit LoRA");+ }+ });+});++describe("an account's GPU with the Orbit LoRA", () => {+ it("runs the Orbit graph: the gate lets it through and the badge reads Ready", async () => {+ const { cookie } = await accountWith(orbitGpu("there"));+ const t = gpuTargetFor(req("/", { cookie }), "read");+ for (const id of ORBIT_PRESETS.filter((x) => presetTool(x)?.workflows.length === 1)) expect(await gateGeneration(t, run(id)), id).toEqual({ ok: true });+ const map = await (await badges.GET(req("/api/gpu/badges", { cookie }))).json();+ expect(map.presets["app-bullet-time-splash"][0]).toBe("r");+ expect(readinessLine(map.presets["app-bullet-time-splash"], null)).toMatchObject({ state: "ready", words: "Ready on your GPU" });+ });+});++describe("where a file downloads from", () => {+ const lora = (o: Partial<{ url: string; page: string; download: "direct" | "civitai-token" | "hf-gated" }>) => ({ file: "x.safetensors", download: "direct" as const, ...o });+ const need = { key: "lora:x.safetensors", kind: "lora" as const, label: "Style file (LoRA)", detail: "", lora: "x.safetensors" };+ it("is the file itself when anyone can download it, else its page (https only)", () => {+ expect(stepDownload(need, null, idx, lora({ url: "https://huggingface.co/a/b/resolve/main/x.safetensors" }))).toMatchObject({ file: "x.safetensors", folder: "models/loras", url: "https://huggingface.co/a/b/resolve/main/x.safetensors" });+ expect(stepDownload(need, null, idx, lora({ url: "https://civitai.com/api/download/models/1", download: "civitai-token", page: "https://civitai.com/models/1" }))).toMatchObject({ url: "https://civitai.com/models/1", page: true });+ expect(stepDownload(need, null, idx, lora({ url: "https://huggingface.co/a/b/resolve/main/x.safetensors", download: "hf-gated" }))).toMatchObject({ url: "https://huggingface.co/a/b", page: true });+ expect(stepDownload(need, null, idx, lora({ url: "http://example.com/x.safetensors" }))?.url).toBeUndefined();+ expect(stepDownload({ ...need, kind: "restart" }, null, idx)).toBeUndefined();+ });++ it("names the folder on the person's ComfyUI when its check read a plain path", () => {+ const inv = { comfy: { modelRoots: { loras: ["C:\\ComfyUI\\models\\loras"] } } } as never;+ expect(stepDownload({ ...need, kind: "model", file: LORA_KEY, lora: undefined }, inv, idx)).toMatchObject({ file: LORA, folder: "models/loras", path: "C:\\ComfyUI\\models\\loras" });+ // A folder the check didn't list: under the ComfyUI folder another one names.+ const other = { comfy: { modelRoots: { vae: ["/home/me/ComfyUI/models/vae"] } } } as never;+ expect(stepDownload({ ...need, kind: "model", file: LORA_KEY, lora: undefined }, other, idx)?.path).toBe("/home/me/ComfyUI/models/loras");+ // A path the commands wouldn't take isn't shown either.+ const odd = { comfy: { modelRoots: { loras: ["/home/me/$(x)/models/loras"] } } } as never;+ expect(stepDownload({ ...need, kind: "model", file: LORA_KEY, lora: undefined }, odd, idx)?.path).toBeUndefined();+ });+});