XB-BOX - 🔗 引用任意
One output, many optional upstreams — pick the live one by name
- 输出
XB_ReferenceAny is the "which branch is live?" problem solved with a dropdown instead of a pile of switches. You attach any number of upstream nodes to its dynamic input sockets, pick which one should be active, and it passes that node's data through its single 输出 (output). The unselected upstreams get muted by the frontend so their work - and their VRAM cost - simply doesn't happen.
It belongs to the same plumbing family as the switch node and the Dynamic Bus: XB_ToolBox's answer to the "noodle wire" problem of having five model loaders or five prompt branches in one workflow. Where a fallback switch (rgthree's Any Switch, the classic) auto-picks the first non-empty input, this one is explicitly manual - you tell it which branch, either with the widget or with a string.
How it works
The inputs are dynamic - you add or remove sockets by clicking (the frontend builds FlexibleOptionalInputType sockets for you). Each socket accepts anything (any type), and each is bound to one upstream node. The node then:
- Scans its received inputs for the one that's non-None. Only the active upstream actually executes and delivers data - the rest are muted, so their values never arrive.
- Checks the
选择(selection) string against the active input's name and logs what it routed. - Returns that value out of
输出, orNoneif nothing is active.
The 选择 widget is itself a STRING with a defaultInput - meaning you can wire it. Feed it from another node and the selection becomes programmable: a script or a prior node decides which branch is live instead of you clicking the dropdown. That's the underrated trick here, and it's how people build "config-driven" workflows where one text value routes everything.
Inputs & outputs
选择- the STRING dropdown; default全部关闭(all off). Pick the active upstream by name, or drive it from a wire.- Dynamic
*input sockets - one per upstream branch you want to switch between. 输出(*) - the active branch's value, passed through untouched.
Because every socket is *-typed, this routes models, latents, images, strings - anything. There's no type checking to fight you.
Where it fits
The genuinely good use is keeping heavy branches lazy. Wire four model loaders into it - each on a different checkpoint or VAE - and only the selected one ever loads. Your graph stays small, only the chosen model eats VRAM, and switching is one dropdown click. Same for prompt branches: four CLIP-encoded conditionings, pick which one feeds the sampler.
The 全部关闭 default is the trap. Leave it there and nothing is selected, so you get a None output and downstream optional inputs quietly receive nothing. First thing you do after wiring: set the dropdown to a real branch. And unlike a fallback switch, there's no "first non-null wins" safety net - if you select a branch that's not connected, you get None, not a graceful fallback to another input.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
# or: ComfyUI Manager → "XB_ToolBox"
Pure JS+Python plumbing, no deps. If sockets don't appear when you expect them, remember they're added from the node's UI (the plus on the input side), not from dragging a wire onto an existing fixed port.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| 选择 | STRING | 全部关闭 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 输出 | * | — |