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
Workers: lanes named by the apps that use them and their model, with the file under it, and a lane search
Adarsh498d86fb53fd
diff --git a/src/components/workers-admin.tsx b/src/components/workers-admin.tsxindex 6e7eb976..cf01672e 100644--- a/src/components/workers-admin.tsx+++ b/src/components/workers-admin.tsx@@ -1,7 +1,7 @@"use client";import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";-import { Copy, Cpu, KeyRound, Pause, Play, Plus, RotateCw, Square, Trash2 } from "lucide-react";+import { Copy, Cpu, Download, KeyRound, Pause, Play, Plus, RotateCw, Search, Square, Trash2 } from "lucide-react";import Link from "next/link";import { useState } from "react";import { toast } from "sonner";@@ -13,6 +13,7 @@ import { Input } from "@/components/ui/input";import { useHydrated, useViewer } from "@/lib/api";import { copyWithToast } from "@/lib/clipboard";import { deviceLabel } from "@/lib/gpu/readiness";+import { laneMatches } from "@/lib/lane-names";import { PLACE_NAME_DEFAULT, PLACE_NAME_MAX } from "@/lib/place-name";import { cn } from "@/lib/utils";@@ -47,11 +48,26 @@ interface WorkerView {seenAt: number | null;version: string | null;current: { taskId: string; lane: string | null; startedAt: number | null } | null;+ /** Its program against the site's version (a server from before sends none). */+ update?: WorkerUpdate;+}+interface WorkerUpdate {+ state: "current" | "updating" | "behind";+ words: string;+ askedAt: number | null;+ peopleHeld: number;}interface Lane {lane: string;+ /** Who uses it and its model: "InfiniteTalk · Wan 2.1 I2V 480p fp8". */label: string;workflows: number;+ /** A server from before sends none of these. */+ apps?: string[];+ model?: string | null;+ /** Its largest model file. */+ file?: string | null;+ workflowIds?: string[];}/** Runs made but waiting to enter the line (hosted runs), by why they wait, and when the oldest was pressed. */@@ -178,13 +194,20 @@ export function LanesEditor({ w, lanes, onSave }: { w: WorkerView; lanes: Lane[]// Every workflow first, then some of them, then none; by name within each.const sorted = [...lanes].sort((a, b) => FIT_RANK[laneFit(w, a.lane).kind] - FIT_RANK[laneFit(w, b.lane).kind] || a.label.localeCompare(b.label));const runnable = runnableLanes(w).length;+ const [query, setQuery] = useState("");+ const shown = sorted.filter((l) => laneMatches(l, query));return (<details className="text-[13px]"><summary className="cursor-pointer text-muted-foreground">Lanes it may run: {Object.keys(w.allow).length} of {lanes.length} ({runnable} it can run)</summary>+ <label className="mt-2 flex items-center gap-2">+ <Search className="size-4 shrink-0 text-muted-foreground" />+ <Input aria-label="Search lanes" placeholder="Search by app, model or lane" value={query} onChange={(e) => setQuery(e.target.value)} className="h-8" />+ </label><ul className="mt-2 max-h-72 space-y-1 overflow-y-auto">- {sorted.map((l) => {+ {query && !shown.length && <li className="text-muted-foreground">No lane matches.</li>}+ {shown.map((l) => {const fit = laneFit(w, l.lane);const note = laneNote(fit);return (@@ -200,8 +223,13 @@ export function LanesEditor({ w, lanes, onSave }: { w: WorkerView; lanes: Lane[]setAllow(next);}}/>- <span className={cn("truncate", fit.kind === "none" && "text-muted-foreground")}>{l.label}</span>- {note && <span className="text-[11px] text-muted-foreground">{note}</span>}+ <span className="min-w-0">+ <span className={cn("block truncate", fit.kind === "none" && "text-muted-foreground")}>+ {l.label}+ {note && <span className="ml-2 text-[11px] text-muted-foreground">{note}</span>}+ </span>+ {l.file && <span className="block truncate text-[11px] text-muted-foreground">{l.file}</span>}+ </span></label>{l.lane in allow && (<label className="flex items-center gap-1 text-[12px] text-muted-foreground">@@ -254,6 +282,34 @@ export function unloadedLine(u: { pack: string; classes: string[]; workflows: st);}+/**+ * Its program against the site's version: nothing while it is on it; while it updates by itself, the words only; behind+ * for longer, a warning and Update now (it looks for new code at once and restarts after the job in hand).+ */+export function UpdateLine({ w, now }: { w: Pick<WorkerView, "id" | "words" | "update">; now: number }) {+ const qc = useQueryClient();+ const ask = useMutation({+ mutationFn: () => call<{ worker: WorkerView }>("POST", `/api/admin/workers/${encodeURIComponent(w.id)}/update`, {}),+ onSuccess: () => {+ toast.success("Asked: it updates after the job in hand");+ void qc.invalidateQueries({ queryKey: ["admin", "workers"] });+ },+ onError: (e) => toast.error((e as Error).message),+ });+ const u = w.update;+ if (!u || u.state === "current") return null;+ if (u.state === "updating") return u.words === w.words ? null : <p className="text-[12px] text-muted-foreground">{u.words}</p>;+ const asked = u.askedAt !== null && now - u.askedAt < 15 * 60_000;+ return (+ <div className="flex flex-wrap items-center justify-between gap-2 rounded-lg border border-amber-500/40 bg-amber-500/5 px-2.5 py-2 text-[13px]">+ <span>{asked ? `${u.words}. Update asked ${Math.max(0, Math.round((now - u.askedAt!) / 60_000))} min ago.` : u.words}</span>+ <Button size="sm" className="h-8" disabled={ask.isPending} onClick={() => ask.mutate()}>+ <Download /> Update now+ </Button>+ </div>+ );+}+function WorkerCard({ w, lanes, onToken }: { w: WorkerView; lanes: Lane[]; onToken: (t: string) => void }) {const qc = useQueryClient();const now = useNow(10_000);@@ -297,6 +353,7 @@ function WorkerCard({ w, lanes, onToken }: { w: WorkerView; lanes: Lane[]; onTok)}</div></div>+ <UpdateLine w={w} now={now} /><p className="text-[12px] text-muted-foreground">{hoursWords(w.hours)}</p>{w.unloaded?.map((u) => (<p key={u.pack} className="text-[12px] text-destructive">diff --git a/src/lib/lane-names.ts b/src/lib/lane-names.tsnew file mode 100644index 00000000..7af11f51--- /dev/null+++ b/src/lib/lane-names.ts@@ -0,0 +1,60 @@+/**+ * Lanes by name for the owner (Settings → Workers): a lane is the workflows that share their largest model file+ * (src/lib/lanes.ts), so its name says who uses it and which model it loads, "InfiniteTalk · Wan 2.1 I2V 480p fp8", with+ * the file itself under it. Pure: the server and the tests share it.+ */++/** Parts of a model file's name that say how it was stored, not what it is. */+const STORAGE_WORDS = /^(e4m3fn|e5m2|e4m3|scaled|kj|comfy|comfyui|repackaged|model|diffusion|fp8e4m3fn|fp8e5m2)$/i;++/**+ * A model file's name as a title: no folder or extension, words apart, versions with their dot ("Wan2_1" → "Wan 2.1"),+ * without the parts that only say how it was stored or how many parameters it has.+ * "Wan2_1-I2V-14B-480p_fp8_e4m3fn_scaled_KJ.safetensors" → "Wan 2.1 I2V 480p fp8".+ */+export function modelTitle(file: string): string {+ const base = (file.split("/").pop() ?? file).replace(/\.(safetensors|gguf|pth|ckpt|pt|bin|sft|onnx)$/i, "");+ const words = base+ .replace(/(\d)_(\d)/g, "$1.$2")+ .split(/[_\-\s]+/)+ .filter(Boolean)+ .filter((w) => !STORAGE_WORDS.test(w) && !/^\d+(\.\d+)?[bm]$/i.test(w))+ .map((w) => w.replace(/^([A-Za-z]+)(\d+\.\d+)$/, "$1 $2"));+ const title = words.join(" ").trim();+ return title ? title[0].toUpperCase() + title.slice(1) : base;+}++export interface LaneName {+ lane: string;+ /** "InfiniteTalk · Wan 2.1 I2V 480p fp8": who uses it (at most two names, then "+N"), and its model. */+ label: string;+ /** Every app and model that runs a workflow of the lane, by name. */+ apps: string[];+ /** Its model's title (modelTitle of its largest file), or null. */+ model: string | null;+ /** Its largest file, as the index names it (no folder), or null. */+ file: string | null;+}++/** At most this many names in a lane's label; the rest as "+N". */+const LABEL_NAMES = 2;++/**+ * A lane's name from its largest file (`file`, null for none) and who uses its workflows (`apps`, in order, repeats+ * left out). `fallback`: the label it had before, for a lane with neither.+ */+export function laneName(lane: string, o: { file: string | null; apps: string[]; fallback: string }): LaneName {+ const apps = [...new Set(o.apps.filter(Boolean))];+ const model = o.file ? modelTitle(o.file) : null;+ const who = apps.length ? `${apps.slice(0, LABEL_NAMES).join(", ")}${apps.length > LABEL_NAMES ? ` +${apps.length - LABEL_NAMES}` : ""}` : null;+ const label = who && model ? `${who} · ${model}` : (who ?? model ?? o.fallback);+ return { lane, label, apps, model, file: o.file ? (o.file.split("/").pop() ?? o.file) : null };+}++/** Does a lane match a search: its label, apps, model, file, lane id or workflows hold the words (any case)? */+export function laneMatches(l: { lane: string; label: string; apps?: string[]; model?: string | null; file?: string | null; workflowIds?: string[] }, query: string): boolean {+ const q = query.trim().toLowerCase();+ if (!q) return true;+ const hay = [l.lane, l.label, ...(l.apps ?? []), l.model ?? "", l.file ?? "", ...(l.workflowIds ?? [])].join("\n").toLowerCase();+ return q.split(/\s+/).every((w) => hay.includes(w));+}