Nodes/SugarCubes/Cube Output
ComfyUI Node

Cube Output

The exit sign on a workflow cube that previews too

By Artificial-Sweetener·Created 4 months ago·Updated 3 days ago· 0
Cube Output
  • value
  • value
cube_id
default_alias
instance_alias
instance_id

Where Cube Input is the front door of a reusable SugarCube, Cube Output is the exit sign - and it's the only SugarCubes marker that does something you can actually see. Like its sibling, it's a passthrough: whatever value you hand it comes out the other side unchanged. But it's also an output node, which in ComfyUI is a meaningful distinction. Output nodes run every time, show up in the results UI, and if you feed one an image batch it saves a temp PNG and displays it, just like a Preview Image node.

That's the trick that makes it worth having. You build a section of graph, mark its input boundary with Cube Input, mark its output with Cube Output, and save the whole thing as a .cube - a reusable unit with named inputs and outputs, versioned identity, and a stable public surface that the Sugar toolchain (the same author's project that writes ComfyUI workflows as readable text) can compile against. Cube Output is where that surface is declared and where, at runtime, the results show up. The design philosophy from the author's own writing: keep cubes to one input and one output so they wire together along a single path, and the mega-graph problem largely disappears.

How it works

The node's forward() does three things. It validates the metadata (more below), it passes value through, and it announces what happened. That announcement is an event pushed onto a process-local event bus that observers can subscribe to - SugarCubes' own tooling uses it to know a cube ran, what it produced, and from which prompt/node. Each event carries the cube_id, the aliases, the type of the value, and any preview artifacts. The bus is deliberately fault-tolerant: an observer that throws is caught and logged, and generation continues. Your queue won't die because a listener hiccuped.

For previews, it sniffs the value for a 4D tensor that looks like a ComfyUI image batch (B,H,W,C with 1, 3, or 4 channels). If it matches, it saves PNGs into ComfyUI's temp directory under the ComfyUI_temp_* convention and returns them in the node's ui payload, which is what renders the thumbnail. Anything that doesn't look like an image batch still fires the event - just with a media kind of "value" and no preview.

The inputs that matter

Same five fields as Cube Input, and the same rule applies:

  • value - the actual data crossing the boundary. Wire the final output of your segment in here.
  • default_alias - the public name of this output in the cube's surface. Required; empty string raises a ValueError at export.
  • cube_id - which cube this output belongs to. Needed by the exporter to group the markers.
  • instance_alias / instance_id - distinguish multiple copies of the same cube in one workflow. If you leave instance_alias blank, the emitted event falls back to default_alias, so you still get a usable name.

Installing it

Same pack, same steps: ComfyUI Manager → Custom Nodes Manager → search SugarCubes → Install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Artificial-Sweetener/SugarCubes

No models to fetch, and the only Python dependency is aiohttp - but the pack requires Python >= 3.12, so check your ComfyUI environment before installing. AGPL-3.0-or-later licensed, in case licensing matters for how you distribute a pack built on it.

Where people trip

First, the "why is there no preview" moment. Cube Output only previews values that are genuine 4D image tensors. A list of images, a mask with weird shape, a PIL image, or a plain string all pass through fine but render no thumbnail - that's by design, not a bug. Second, the empty-alias error: it's the same trap as Cube Input, and it bites at export time, not at run. And third, don't confuse this with a Save Image node - it's a marker first and a preview second. It doesn't persist anything to your output folder; the previews are temp files, and the real record of the cube's result lives in the event and in whatever Sugar does with it downstream.

CategorySugarCubes/Markers

Inputs (5)

NameTypeDefaultDescription
value*
cube_idSTRING
default_aliasSTRING
instance_aliasSTRING
instance_idSTRING

Outputs (1)

NameTypeDescription
value*