Nodes/XB_ToolBox/XB-BOX - ๐Ÿ”— ๅผ•็”จไปปๆ„
ComfyUI Node

XB-BOX - ๐Ÿ”— ๅผ•็”จไปปๆ„

One output, many optional upstreams โ€” pick the live one by name

By wjluoxiaoยทCreated 7 months agoยทUpdated a day agoยท 406
XB-BOX - ๐Ÿ”— ๅผ•็”จไปปๆ„
    • ่พ“ๅ‡บ
    โ—„้€‰ๆ‹ฉๅ…จ้ƒจๅ…ณ้—ญโ–บ

    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:

    1. 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.
    2. Checks the ้€‰ๆ‹ฉ (selection) string against the active input's name and logs what it routed.
    3. Returns that value out of ่พ“ๅ‡บ, or None if 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.

    CategoryXB_ToolBox/Utils

    Inputs (1)

    NameTypeDefaultDescription
    ้€‰ๆ‹ฉSTRINGๅ…จ้ƒจๅ…ณ้—ญโ€”

    Outputs (1)

    NameTypeDescription
    ่พ“ๅ‡บ*โ€”