Nodes/ComfyUI_Mira/Function Select Auto
ComfyUI Node

Function Select Auto

Auto-pick whichever branch fired

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Function Select Auto
  • func1
  • func2
  • Y

Function Select Auto merges two branches into one output by automatically picking whichever one actually produced something. Give it func1 and func2; it hands back the one that isn't None, with func1 winning if both are present. No toggle to set - it just reads which branch fired and forwards it. Because it's typed as "any" (*), it works on images, latents, masks, conditioning, whatever.

This is the clean way to collapse an either/or in a graph. The classic example, straight from the pack's own docs, is two paths to a final image: one route through an upscale-model node, the other through a plain VAE decode. Only one runs for a given generation; Function Select Auto grabs whichever exists and sends it downstream, so you don't wire a manual switch and remember to flip it. It's part of ComfyUI_Mira, mirabarukaso's toolkit of small routing and logic nodes - the same family that makes their regional and character-select workflows practical. Branch-heavy graphs are half of why people tolerate ComfyUI at all, and merge nodes like this keep them from becoming unmanageable.

How it works

It inspects the inputs. If func1 is present (not None), it forwards func1. If func1 is None but func2 is present, it forwards func2. If both are None, the output is None. That priority - func1 first - is the one rule to remember: when both branches somehow produce a value, func1 wins, so put your preferred path there.

The inputs and outputs that matter

  • func1 (optional) - the higher-priority branch (any type).
  • func2 (optional) - the fallback branch (any type).
  • Y (output) - whichever input is non-None, func1 preferred; None if both are empty.

Wire the two mutually-exclusive branches into func1/func2 and take Y as your single downstream wire.

Installing it

ComfyUI Manager: search ComfyUI_Mira, install, restart. Or clone:

cd ComfyUI/custom_nodes && git clone https://github.com/mirabarukaso/ComfyUI_Mira.git

then restart. If it errors on load, run pip install -r requirements.txt in the ComfyUI_Mira folder. It's under Mira/Logic.

Common issues

  • func1 wins ties. If both branches produce a value, you get func1 - always. If it's picking the "wrong" one, swap which branch feeds func1. This node has no manual override; the priority is the control.
  • It expects one branch to be None. The design assumes your two inputs are genuinely exclusive (one fired, one didn't). If both are always live, this isn't a switch - you'll just get func1 every time.
  • Swap vs. select. Function Select Auto outputs a single merged wire. If you instead want to reorder two wires that both stay live, that's Function Swap.
  • Type safety is on you. With * inputs, a mismatch surfaces at the downstream node, not here - make sure both branches produce the type Y's consumer expects.
CategoryMira/Logic

Inputs (2)

NameTypeDefaultDescription
func1opt*
func2opt*

Outputs (1)

NameTypeDescription
Y*