Nodes/FxAi(凤希全能节点)/凤希AI - 条件选择
ComfyUI Node

凤希AI - 条件选择

Pick a branch, and the branch you didn't pick never runs

By fxai666·Created 7 months ago·Updated a day ago· 46
凤希AI - 条件选择
  • on_true
  • on_false
  • *
◄booleantrue►

The switch that doesn't waste your time

Every ComfyUI user eventually builds the same two-branch graph: one path for portrait inputs, one for landscape; one for "face detected", one for "nothing to refine". The naive way to do it is to run both and throw one away, which is how a 30-second branch becomes a 3-minute run.

FxAiIfElse (凤希AI - 条件选择) is the version that doesn't run both. It takes a boolean and two inputs, and the losing side is never evaluated. Not "evaluated and discarded" - never executed. The expensive sampler sitting on the branch you didn't choose simply doesn't fire.

How it works

ComfyUI lets a node declare an input as lazy, and then ask for it only when it needs it. This node marks both on_true and on_false as lazy and implements the handshake:

def check_lazy_status(self, boolean=True, on_true=None, on_false=None):
    if boolean and on_true is None:
        return ["on_true"]
    if not boolean and on_false is None:
        return ["on_false"]
    return []

So the executor walks the branch it was asked for and never even resolves the other one. The pick() function then returns whichever arrived.

This isn't a micro-optimisation, it's load-bearing. The pack's own loop nodes rely on it: when a loop's iteration count is wired in rather than typed, it can't be known up front whether the loop will run, so the result is wrapped in this node with the (possibly blocked) loop body on one side and the plain seed values on the other. The blocking side never gets pulled.

Inputs and outputs

Three required inputs, no optional ones:

  • boolean (BOOLEAN, defaults true) - usually from FxAiCompare, or a boolean you converted to an input on a sampler.
  • on_true (wildcard) - what comes out when the boolean is true.
  • on_false (wildcard) - what comes out when it's false.

Output: a single wildcard socket, displayed as *. Whatever type went in comes out, so this node slots between anything.

Both inputs are required and both have to be connected. There's no "leave one empty" mode here - if you want a fallback-when-missing behaviour (first non-null wins), that's a different node shape entirely; this one is a selector, and the selector needs two candidates.

Where it earns its keep

The textbook case is guarding an expensive stage. Compare a face-detection confidence or a frame count, route "worth refining" to the face-refine chain and "nothing to do" to a straight pass-through, and the non-matching inputs cost you nothing but the compare.

The second case is politeness to your hardware: route to the 2x upscale path when you have headroom, the 1.5x path when you don't, and only one of them ever allocates.

The third is repair work. Because the unchosen side isn't evaluated, this node can sit in front of a branch that would error if it ran - a decode of a segment that doesn't exist, a model that isn't installed. Guarded behind the boolean, it just doesn't happen.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit

Restart ComfyUI, or search fxai-toolkit in ComfyUI Manager (registry publisher fxai). The pack auto-installs soundfile and psutil on import. This node needs neither, and needs no model files - it's pure graph plumbing, which is also why it's one of the few things in this pack that will load on almost any recent ComfyUI.

Where it bites

No type checking between the branches. The output is a wildcard, so ComfyUI will happily let you put an IMAGE on one side and a LATENT on the other, and then fail somewhere downstream with a confusing shape error. Keep both sides the same type; the node won't do it for you.

Lazy means "not evaluated", not "not validated". The unselected branch's nodes still have to exist and be loadable - missing checkpoints, deleted model files and broken node classes are caught when the graph is built, before any lazy evaluation happens.

It doesn't merge. Unlike a first-non-null switch, this node has no opinion about empty inputs. Feed it a None on the winning side and None is what comes out.

Missing from the node list. Each node in this pack is imported individually inside try/except, and a failure prints ❌[凤希AI] 节点加载失败 to the console while the rest of the pack loads fine. If FxAiIfElse isn't in the 凤希AI/逻辑 menu, read your startup log before you go reinstalling anything.

Category凤希AI/逻辑

Inputs (3)

NameTypeDefaultDescription
booleanBOOLEANtrue—
on_true*—
on_false*—

Outputs (1)

NameTypeDescription
**—