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
Canvas: undo deletes, pinned nodes offer unpin, attention count, 3D results
Claudea1c45ecc9460
diff --git a/src/components/canvas/canvas-editor.tsx b/src/components/canvas/canvas-editor.tsxindex d7b98240..48fd15ec 100644--- a/src/components/canvas/canvas-editor.tsx+++ b/src/components/canvas/canvas-editor.tsx@@ -313,13 +313,32 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canv[touch],);+ /** Deleted nodes come back with their edges from the toast's Undo. */+ const offerUndo = useCallback(+ (count: number, before: { nodes: FlowNode[]; edges: Edge[] }) =>+ toast(count === 1 ? "Node deleted" : `${count} nodes deleted`, {+ duration: 5000,+ action: {+ label: "Undo",+ onClick: () => {+ setNodes(before.nodes);+ setEdges(before.edges);+ touch();+ },+ },+ }),+ [touch],+ );+const remove = useCallback((nodeId: string) => {+ const before = latest.current;setNodes((ns) => ns.filter((n) => n.id !== nodeId));setEdges((es) => es.filter((e) => e.source !== nodeId && e.target !== nodeId));touch();+ offerUndo(1, before);},- [touch],+ [touch, offerUndo],);const duplicate = useCallback(@@ -362,10 +381,13 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canvconst onNodesChange = useCallback((changes: NodeChange<FlowNode>[]) => {+ const removed = changes.filter((c) => c.type === "remove").length;+ const before = latest.current;setNodes((ns) => applyNodeChanges(changes, ns));if (changes.some((c) => c.type === "remove" || c.type === "add" || c.type === "replace" || (c.type === "position" && !c.dragging))) touch();+ if (removed) offerUndo(removed, before);},- [touch],+ [touch, offerUndo],);const onEdgesChange = useCallback((changes: EdgeChange<Edge>[]) => {@@ -616,11 +638,17 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canvconst m = getModel(s.request.modelId);return m && isDemo(m);});- const summary = plan.steps.length- ? `${plan.steps.length} to run · ${planDemo ? "Demo · free" : plan.costUnknown ? "price unknown" : plan.costUsd === 0 ? "Free" : `≈ ${formatCost(plan.costUsd)}`}`- : generators.length- ? "Up to date"- : "";+ const attention = new Set(plan.errors.map((e) => e.nodeId)).size;+ const summary = [+ plan.steps.length+ ? `${plan.steps.length} to run · ${planDemo ? "Demo · free" : plan.costUnknown ? "price unknown" : plan.costUsd === 0 ? "Free" : `≈ ${formatCost(plan.costUsd)}`}`+ : generators.length && !attention+ ? "Up to date"+ : "",+ attention ? `${attention} need${attention === 1 ? "s" : ""} attention` : "",+ ]+ .filter(Boolean)+ .join(" · ");return (<EditorContext.Provider value={api}>diff --git a/src/components/canvas/node-list.tsx b/src/components/canvas/node-list.tsxindex cdbb0b63..87fd0797 100644--- a/src/components/canvas/node-list.tsx+++ b/src/components/canvas/node-list.tsx@@ -1,6 +1,6 @@"use client";-import { AlertCircle, Play, RotateCcw, Square, Upload } from "lucide-react";+import { AlertCircle, PinOff, Play, RotateCcw, Square, Upload } from "lucide-react";import { useRef } from "react";import { getModel } from "@/lib/catalog";import { isGenerator, NODE_SPECS, nodeLabel, topoOrder, type CanvasNode } from "@/lib/catalog/canvas";@@ -58,11 +58,11 @@ function NodeCard({ node, index }: { node: CanvasNode; index: number }) {<EngineBadge model={model} />{gen && (<button- onClick={() => (running ? ed.cancel(node.id) : ed.run([node.id], !step))}- className={cn("grid size-9 shrink-0 place-items-center rounded-full", running ? "bg-muted" : "bg-primary text-primary-foreground")}- aria-label={running ? "Cancel" : step ? "Run node" : "Run it again"}+ onClick={() => (running ? ed.cancel(node.id) : node.data.pinned ? ed.update(node.id, { pinned: false }) : ed.run([node.id], !step))}+ className={cn("grid size-9 shrink-0 place-items-center rounded-full", running || node.data.pinned ? "bg-muted" : "bg-primary text-primary-foreground")}+ aria-label={running ? "Cancel" : node.data.pinned ? "Unpin result" : step ? "Run node" : "Run it again"}>- {running ? <Square className="size-3.5" /> : step ? <Play className="size-4" /> : <RotateCcw className="size-4" />}+ {running ? <Square className="size-3.5" /> : node.data.pinned ? <PinOff className="size-4" /> : step ? <Play className="size-4" /> : <RotateCcw className="size-4" />}</button>)}</header>diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex 19aecb4e..c6ae7a5d 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -4,6 +4,7 @@ import { Handle, Position, useUpdateNodeInternals, type Node, type NodeProps } fimport {AlertCircle,AudioLines,+ Box,Check,Cloud,Copy,@@ -253,6 +254,13 @@ function OutputThumb({ o, onOpen, className, large }: { o: OutputFile; onOpen: (</button>);}+ if (o.kind === "model3d") {+ return (+ <button onClick={onOpen} className={cn("flex h-20 w-full items-center justify-center gap-2 rounded-lg bg-muted text-[12px] font-medium text-muted-foreground hover:text-foreground", NO_DRAG, className)}>+ <Box className="size-4" /> 3D model+ </button>+ );+ }if (o.kind === "audio") {return (<div className={cn("flex items-center gap-2 rounded-lg bg-brand-faint p-2 text-brand-text", NO_DRAG, className)}>@@ -434,11 +442,16 @@ const GeneratorNode = memo(function GeneratorNode({ id, type, data, selected }:};const running = r.state === "running" || r.state === "queued";+ // A pinned node never runs: its menu offers the unpin instead of Run.const menu: MenuItem[] = [- { label: "Run node", icon: Play, onSelect: () => ed.run([id]) },- { label: "Re-run", icon: RotateCcw, onSelect: () => ed.run([id], true) },+ ...(data.pinned+ ? []+ : [+ { label: "Run node", icon: Play, onSelect: () => ed.run([id]) },+ { label: "Re-run", icon: RotateCcw, onSelect: () => ed.run([id], true) },+ ]),...(running ? [{ label: "Cancel", icon: Square, onSelect: () => ed.cancel(id) }] : []),- { label: data.pinned ? "Unpin result" : "Pin result", icon: data.pinned ? PinOff : Pin, onSelect: () => ed.update(id, { pinned: !data.pinned }), separatorBefore: true },+ { label: data.pinned ? "Unpin result" : "Pin result", icon: data.pinned ? PinOff : Pin, onSelect: () => ed.update(id, { pinned: !data.pinned }), separatorBefore: !data.pinned },...(r.outputs.some((x) => ["image", "video", "audio"].includes(x.o.kind)) ? [{ label: "Use result as an input", icon: ImagePlus, onSelect: () => ed.toInput(id) }] : []),...baseMenu(ed, id),];@@ -479,19 +492,19 @@ const GeneratorNode = memo(function GeneratorNode({ id, type, data, selected }:<Tooltip><TooltipTrigger asChild><button- onClick={() => (running ? ed.cancel(id) : ed.run([id], !step && !!reused))}+ onClick={() => (running ? ed.cancel(id) : data.pinned ? ed.update(id, { pinned: false }) : ed.run([id], !step && !!reused))}disabled={ed.running && !running}className={cn("grid size-7 shrink-0 place-items-center rounded-full transition-colors disabled:opacity-50",- running ? "bg-muted text-foreground hover:bg-accent" : "bg-primary text-primary-foreground hover:bg-primary/90",+ running || data.pinned ? "bg-muted text-foreground hover:bg-accent" : "bg-primary text-primary-foreground hover:bg-primary/90",NO_DRAG,)}- aria-label={running ? "Cancel" : step ? "Run node" : "Run node again"}+ aria-label={running ? "Cancel" : data.pinned ? "Unpin result" : step ? "Run node" : "Run node again"}>- {running ? <Square className="size-3" /> : step ? <Play className="size-3.5" /> : <RotateCcw className="size-3.5" />}+ {running ? <Square className="size-3" /> : data.pinned ? <PinOff className="size-3.5" /> : step ? <Play className="size-3.5" /> : <RotateCcw className="size-3.5" />}</button></TooltipTrigger>- <TooltipContent>{running ? "Cancel" : step ? "Run this node (and what it needs)" : "Run it again"}</TooltipContent>+ <TooltipContent>{running ? "Cancel" : data.pinned ? "Unpin to run it again" : step ? "Run this node (and what it needs)" : "Run it again"}</TooltipContent></Tooltip>)}</div>diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 377bdbb2..ad22ff15 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -648,7 +648,12 @@ export function effectiveOp(graph: CanvasGraph, n: CanvasNode): Operation | undeif (!model) return undefined;const built = buildRequest(graph, n, model);if ("error" in built) return undefined;- const op = inferOperation(model, withPlaceholders(built.request));+ let op = inferOperation(model, withPlaceholders(built.request));+ // Connected elements bring reference images (applyMentions on the server): text-only ops become edits / references.+ if (graph.edges.some((e) => e.target === n.id && e.targetHandle === "elements")) {+ if (op === "t2i" && supportsOp(model, "edit")) op = "edit";+ else if (op === "t2v" && supportsOp(model, "ref2v")) op = "ref2v";+ }return ops.includes(op) ? op : ops[0];}diff --git a/tests/canvas.test.ts b/tests/canvas.test.tsindex d6883d03..e081cc38 100644--- a/tests/canvas.test.ts+++ b/tests/canvas.test.ts@@ -126,6 +126,8 @@ describe("canvas graph → plan", () => {expect(by.avatar.request).toMatchObject({ op: "avatar", inputs: { images: ["/api/files/u/face.png"] }, chain: [{ slot: "audio" }] });expect(by.avatar.deps).toEqual(["tts"]);expect(by.still.request.prompt).toBe("On a rooftop at night\n\nWith @Maya.");+ // The element's reference images turn text-to-image into an edit (as the server's applyMentions does).+ expect(effectiveOp(g, g.nodes.find((n) => n.id === "still")!)).toBe("edit");// Tool order: join's clip and the voice come before the nodes that use them.expect(plan.order.indexOf("tts")).toBeLessThan(plan.order.indexOf("avatar"));expect(plan.order.indexOf("c1")).toBeLessThan(plan.order.indexOf("join"));