Nodes/Comfyui-XYZ-stitch/XYZ Auto Collector
ComfyUI Node

XYZ Auto Collector

The Glue That Makes a Multi-Run Grid Actually Work

By psdwizzard·Created 10 months ago·Updated 10 months ago· 3
XYZ Auto Collector
  • images
  • images
  • collected_count
  • is_complete
  • status
total_combinations9
collection_iddefault
resetfalse

ComfyUI runs are stateless: each queue pass forgets the last one. That's the whole problem this pack solves, and XYZ Auto Collector is the solution. It remembers. You feed it one generated image per run, it quietly accumulates them in memory, and when the count matches what you told it to expect, it hands the whole batch to the grid in one go. No manual mode switching, no counting on your part - the "auto" in the name is real.

How it works

The collector keeps a global in-memory store keyed by collection_id. Every execution appends a copy of your incoming image to that store and compares the running total against total_combinations. Two states:

  • Not complete yet - it returns a 1×1 black placeholder and is_complete false. That placeholder is deliberate: it keeps downstream Save Image nodes from writing a file for every mid-sweep run. You'll see "Collecting... 3/9" in the console.
  • Complete - it stacks the whole collection into one image batch, outputs it with is_complete true (that's what unlocks the Stitch node), and then auto-resets the store so your next sweep starts clean.

So the flow is: wire images in, wire Grid Input's total_combinations in, queue the sweep, and on the final run everything downstream fires once.

Inputs and outputs

  • images - your generated image, one per run.
  • total_combinations - connect this to XYZ Grid Input's total_combinations output. Get it wrong and the collector never knows when to fire.
  • collection_id - a string key for the store. Different grids should use different IDs so their collections don't mix.
  • reset (optional) - flip it true once to wipe the collection and start over.

Outputs: images (the full batch once complete, otherwise the placeholder), collected_count, is_complete, and status - a human-readable "Collecting... N/9" or "✓ Complete!" string you can show on screen.

Where people get burned

The collection lives only in RAM. Restart ComfyUI, reload the workflow, or let the server re-import nodes and your accumulated images are gone - which is confusing the first time it happens mid-sweep. Related trap: duplicate a workflow and both copies share the default collection_id, so their images start polluting each other's grids. Change the ID per grid.

Overshooting is the other classic. Run the queue eleven times for a nine-image grid and you get "Collected 10/9" with a batch that's bigger than the grid expects. The fix is documented in the pack's troubleshooting: set reset to true, run once to clear, flip it back, and start over.

And the wiring that makes or breaks it: is_complete from this node must go into the XYZ Grid Stitch's is_complete input. Skip it and Stitch's default of true means it stitches a one-image "grid" on every run.

Installing

Part of the same pack - ComfyUI Manager (search "XYZ Grid") or:

cd ComfyUI/custom_nodes/
git clone https://github.com/psdwizzard/Comfyui-XYZ-stitch.git

Restart ComfyUI. No requirements.txt, no models, nothing extra; it's in the "XYZ Grid" category with the rest.

CategoryXYZ Grid

Inputs (4)

NameTypeDefaultDescription
imagesIMAGE
total_combinationsINT9Connect this to XYZ Grid Input's total_combinations output
collection_idSTRINGdefaultUnique ID for this collection
resetoptBOOLEANfalseSet to True to clear the collection and start over

Outputs (4)

NameTypeDescription
imagesIMAGE
collected_countINT
is_completeBOOLEAN
statusSTRING