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.

Canvas: a run on a page not saved yet adds it, colour names match their hues, a concatenator made without tools asks for the engine

Claude336e6ba82f26
diff --git a/src/components/canvas/canvas-editor.tsx b/src/components/canvas/canvas-editor.tsx
index d237561e..5a28ca1f 100644
--- a/src/components/canvas/canvas-editor.tsx
+++ b/src/components/canvas/canvas-editor.tsx
@@ -1142,7 +1142,7 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canv
))}
</div>
{pages.length > 1 && (
- <select value={pageId} onChange={(e) => pageOps.switchTo(e.target.value)} aria-label="Page" className="h-9 max-w-32 min-w-0 truncate rounded-full bg-muted px-3 text-[13px] font-medium outline-none">
+ <select value={pageId} onChange={(e) => pageOps.switchTo(e.target.value)} aria-label="Page" className="h-9 max-w-32 shrink-0 truncate rounded-full bg-muted px-3 text-[13px] font-medium outline-none">
{pages.map((p) => (
<option key={p.id} value={p.id}>
{p.name}
diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsx
index eb6cea99..8e4da306 100644
--- a/src/components/canvas/nodes.tsx
+++ b/src/components/canvas/nodes.tsx
@@ -818,7 +818,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se
</div>
)}
{type === "concat" ? (
- <ConcatPanel id={id} data={data} engine={model?.engine ?? g.engine} />
+ <ConcatPanel id={id} data={data} engine={model?.engine} />
) : v.error === OPEN_DUB_HINT ? null : (
<div className={cn("flex flex-wrap items-center gap-1.5 [&>button]:h-7 [&>button]:text-[12px]", g.readOnly && "pointer-events-none")}>
{choices.length ? (
@@ -1041,7 +1041,8 @@ function ClipItem({ id, row, index, count, settings, readOnly, onMove }: { id: s
);
}
-function ConcatPanel({ id, data, engine }: { id: string; data: CanvasNodeData; engine: Engine }) {
+/** `engine`: the engine of the node's tools (none yet on a node made without them, e.g. through the API). */
+function ConcatPanel({ id, data, engine }: { id: string; data: CanvasNodeData; engine?: Engine }) {
const actions = useEditorActions();
const g = useEditorGlobals();
const rows = useEditorSelector(selectClipRows, id, sameRows);
@@ -1058,9 +1059,9 @@ function ConcatPanel({ id, data, engine }: { id: string; data: CanvasNodeData; e
<div className="space-y-2">
<div className={cn("flex flex-wrap items-center gap-1.5", g.readOnly && "pointer-events-none")}>
<OptionSelect label="Aspect ratio" value={ratio} options={[...CONCAT_RATIOS]} onChange={(v) => actions.update(id, { params: { ...data.params, aspectRatio: v } })} />
- {g.mode === "both" && (
- <div className={cn("inline-grid h-7 grid-cols-2 rounded-full bg-muted p-0.5 text-[12px] font-medium", NO_DRAG)} role="radiogroup" aria-label="Engine">
- {(["cloud", "open"] as const).map((e) => (
+ {(g.mode === "both" || !engine) && (
+ <div className={cn("inline-flex h-7 rounded-full bg-muted p-0.5 text-[12px] font-medium", NO_DRAG)} role="radiogroup" aria-label="Engine">
+ {(g.mode === "both" ? (["cloud", "open"] as const) : [g.mode]).map((e) => (
<button key={e} role="radio" aria-checked={engine === e} onClick={() => actions.update(id, { modelId: CONCAT_MODELS[e] })} className={cn("rounded-full px-2.5", engine === e ? "bg-background shadow-soft" : "text-muted-foreground")}>
{e === "cloud" ? "Cloud" : "Open source"}
</button>
diff --git a/src/lib/catalog/canvas-board.ts b/src/lib/catalog/canvas-board.ts
index 20f85b46..8708134b 100644
--- a/src/lib/catalog/canvas-board.ts
+++ b/src/lib/catalog/canvas-board.ts
@@ -18,13 +18,14 @@ import type { CanvasGraph, CanvasNode } from "./canvas";
export const BOARD_COLORS = ["ink", "chart-1", "chart-2", "chart-3", "chart-4", "chart-5"] as const;
export type BoardColor = (typeof BOARD_COLORS)[number];
+/** Named by the tokens' hues (src/app/globals.css): 282, 195, 80, 8 and 240. */
export const BOARD_COLOR_LABEL: Record<BoardColor, string> = {
ink: "Ink",
- "chart-1": "Lime",
- "chart-2": "Blue",
- "chart-3": "Violet",
- "chart-4": "Orange",
- "chart-5": "Pink",
+ "chart-1": "Violet",
+ "chart-2": "Teal",
+ "chart-3": "Amber",
+ "chart-4": "Rose",
+ "chart-5": "Blue",
};
/** A frame around nodes: moves them with it, and runs them together. */
diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.ts
index d93cfa2f..a91a5f1d 100644
--- a/src/lib/catalog/canvas.ts
+++ b/src/lib/catalog/canvas.ts
@@ -1113,8 +1113,12 @@ export function describeNode(graph: CanvasGraph, n: CanvasNode, ctx: DescribeCon
const mode = ctx.engineMode ?? "both";
// A Fuobe Original as it runs on the node's engine (its routes, its price).
const model = nodeModel(n, mode);
- // Dubbing has no open model: an open-only install says where it dubs instead.
- if (!model) return { costUsd: null, error: n.data.modelId ? "That model is no longer in the catalog — pick another" : n.type === "translate" && n.data.mediaKind === "video" && mode === "open" ? OPEN_DUB_HINT : "Pick a model" };
+ // Dubbing has no open model: an open-only install says where it dubs instead. The concatenator's tools are
+ // picked by engine, not by model.
+ if (!model) {
+ const pick = n.type === "translate" && n.data.mediaKind === "video" && mode === "open" ? OPEN_DUB_HINT : n.type === "concat" ? "Pick where the film is made: on the cloud or with open source" : "Pick a model";
+ return { costUsd: null, error: n.data.modelId ? "That model is no longer in the catalog — pick another" : pick };
+ }
if (mode !== "both" && !runsOn(model, mode)) {
return {
model,
@@ -1667,29 +1671,28 @@ export const CANVAS_TEMPLATES: CanvasTemplate[] = [
],
),
},
+ {
+ id: "clips-film",
+ name: "Clips → one film",
+ description: "Trim, mute and join clips in one frame, 30 fps, with the Video concatenator",
+ icon: "Film",
+ hue: 250,
+ build: tpl(
+ [
+ ...[0, 1, 2].map((i) => ({ id: `clip${i + 1}`, type: "video-input" as const, x: 0, y: i * 320, data: { label: `Clip ${i + 1}` } })),
+ { id: "film", type: "concat", x: COL, y: 200, data: { label: "Film", params: { aspectRatio: "16:9" } }, models: { cloud: CONCAT_MODELS.cloud, open: CONCAT_MODELS.open } },
+ { id: "out", type: "output", x: COL * 2 + 40, y: 240, data: { label: "Film" } },
+ ],
+ [
+ ["clip1", "film", "videos"],
+ ["clip2", "film", "videos"],
+ ["clip3", "film", "videos"],
+ ["film", "out"],
+ ],
+ ),
+ },
];
-CANVAS_TEMPLATES.push({
- id: "clips-film",
- name: "Clips → one film",
- description: "Trim, mute and join clips in one frame, 30 fps, with the Video concatenator",
- icon: "Film",
- hue: 250,
- build: tpl(
- [
- ...[0, 1, 2].map((i) => ({ id: `clip${i + 1}`, type: "video-input" as const, x: 0, y: i * 320, data: { label: `Clip ${i + 1}` } })),
- { id: "film", type: "concat", x: COL, y: 200, data: { label: "Film", params: { aspectRatio: "16:9" } }, models: { cloud: CONCAT_MODELS.cloud, open: CONCAT_MODELS.open } },
- { id: "out", type: "output", x: COL * 2 + 40, y: 240, data: { label: "Film" } },
- ],
- [
- ["clip1", "film", "videos"],
- ["clip2", "film", "videos"],
- ["clip3", "film", "videos"],
- ["film", "out"],
- ],
- ),
-});
-
export function getTemplate(id: string): CanvasTemplate | undefined {
return CANVAS_TEMPLATES.find((t) => t.id === id);
}
diff --git a/src/server/canvas.ts b/src/server/canvas.ts
index 9a92c93c..91b1e77e 100644
--- a/src/server/canvas.ts
+++ b/src/server/canvas.ts
@@ -7,6 +7,7 @@ import {
BOARD_LIMITS,
FIRST_PAGE_ID,
groupTargets,
+ nextPageName,
pageContent,
pageName,
pageOf,
@@ -307,7 +308,8 @@ const NOT_TRASHED = "NOT EXISTS (SELECT 1 FROM generation_trash t WHERE t.genera
function previewOf(runs: CanvasRuns): CanvasSummary["preview"] {
const ids = Object.values(runs)
.sort((a, b) => b.at - a.at)
- .flatMap((r) => r.ids)
+ // A node made in steps shows its result, not one of its cuts.
+ .flatMap((r) => (r.out ? [r.out] : r.ids))
.slice(0, 60);
if (!ids.length) return null;
const rows = db()
@@ -389,7 +391,12 @@ export function updateCanvas(id: string, patch: CanvasPatch): Canvas | null {
const name = patch.name?.trim() ? patch.name.trim().slice(0, 80) : current.name;
let pages = current.pages;
if (patch.pages?.length) pages = patch.pages.map((p) => ({ ...p, graph: cleanGraph(p.graph) }));
- if (patch.graph) pages = withPageGraph(pages, patch.page, cleanGraph(patch.graph));
+ if (patch.graph) {
+ const graph = cleanGraph(patch.graph);
+ // A page the editor added and hasn't saved yet (a run sent before the autosave): added, never written over page 1.
+ if (patch.page && !pages.some((p) => p.id === patch.page) && pages.length < BOARD_LIMITS.pages) pages = [...pages, { id: patch.page, name: nextPageName(pages), graph }];
+ else pages = withPageGraph(pages, patch.page, graph);
+ }
const edited = pageContent(pages) !== pageContent(current.pages) ? now : current.editedAt;
db().prepare("UPDATE canvases SET name = ?, graph_json = ?, updated_at = ?, edited_at = ? WHERE id = ?").run(name, JSON.stringify({ pages }), now, edited, id);
return getCanvas(id);
diff --git a/tests/canvas-plus.test.ts b/tests/canvas-plus.test.ts
index 95fce750..9f3b6078 100644
--- a/tests/canvas-plus.test.ts
+++ b/tests/canvas-plus.test.ts
@@ -248,6 +248,9 @@ describe("plans for the new nodes", () => {
// Switching engines keeps the frame and the cuts.
const cloud = convertEngine(g, "cloud").graph.nodes[2].data;
expect(cloud).toMatchObject({ modelId: "join-clips", params: { aspectRatio: "9:16" }, clips: { a: { start: 1, end: 4, mute: true } } });
+ // Made without its tools (through the API): it asks for the engine, not for a model it has no picker for.
+ const bare = { ...g.nodes[2], data: { ...g.nodes[2].data, modelId: undefined } };
+ expect(describeNode(g, bare, { engineMode: "open" }).error).toBe("Pick where the film is made: on the cloud or with open source");
});
it("Video concatenator, cloud: 30 clips fold into joins of at most 24", () => {
@@ -407,6 +410,16 @@ describe("pages", () => {
expect(again.canvas.pages[0].graph.nodes[0].data.text).toBe("A red fox");
expect(again.canvas.pages[1].graph.nodes[0].data.text).toBe("A white wolf");
+ // A run on a page the server hasn't stored yet (added just now, before the autosave) adds it.
+ res = await run.POST(req("POST", { page: "page-new", graph: { nodes: [node("p3", "prompt", { text: "A lynx" }), node("img3", "model", { modelId: "nano-banana-pro" }, 400)], edges: [edge("p3", "img3", "prompt")] } }), ctx(c.id));
+ const added = (await res.json()) as { ran: string[]; canvas: Canvas };
+ expect(added.ran).toEqual(["img3"]);
+ expect(added.canvas.pages.map((p) => [p.id, p.name, p.graph.nodes[0].data.text])).toEqual([
+ ["page-1", "Page 1", "A red fox"],
+ ["page-2", "Wolves", "A white wolf"],
+ ["page-new", "Page 3", "A lynx"],
+ ]);
+
// A row stored before pages (one bare graph) still opens, as page 1.
db().prepare("UPDATE canvases SET graph_json = ? WHERE id = ?").run(JSON.stringify({ nodes: [node("old", "prompt", { text: "old" })], edges: [] }), c.id);
const old = (await (await one.GET(req("GET"), ctx(c.id))).json()) as { canvas: Canvas };