Nodes/ComfyUI Web Viewer/Trigger Toggle @ vrch.ai
ComfyUI Node

Trigger Toggle @ vrch.ai

The latch that turns a pulse into a state

By VrchStudio·Created 2 years ago·Updated 18 days ago· 356
Trigger Toggle @ vrch.ai
    • OUTPUT
    • JSON
    initial_statefalse
    debugfalse
    trigger

    Trigger Toggle is a one-bit memory. Every time its trigger input receives a pulse, its output flips - OFF to ON, ON to OFF - and stays there until the next pulse. It's the node you reach for when an input gives you a momentary blip but you need a persistent state, which in the ComfyUI Web Viewer world is more often than you'd think. Flip a physical button once, and a whole behavior stays switched on until you flip it again.

    How it works

    In electronics this is called a T flip-flop, and it does exactly what the name promises. The optional trigger input is a boolean - each time it becomes true, OUTPUT toggles. initial_state sets where it starts (default OFF). The JSON output is a mirror of the current state as JSON, handy if you want to log it or feed it into anything that expects a structured value rather than a plain boolean.

    The two outputs are OUTPUT (a BOOLEAN) and JSON. There's nothing else to it - which is the point. It's the smallest stateful building block in the pack, and it sits underneath half of the interesting wiring.

    Where it earns its keep

    The pack's control nodes fall into two camps: ones that hold state themselves (INT Key Control, SWITCH OSC Control) and ones that just report a momentary event. When you're driving from a momentary source and need a latch, this is the glue:

    • OSC buttons. A momentary OSC button sends 1 on press and nothing on release - useless for holding a state. Run it through a Trigger Toggle and each press latches a boolean that stays until the next press.
    • Keyboard pulses. Chain it after a key control node when you want one key to arm a behavior on, and the same key to disarm it.
    • Branch muting. Toggle whether an upscaler or LoRA branch is active, without touching the graph mid-run.

    It's a logic node, so it works anywhere in the graph and never touches the network or the browser.

    Installing it

    Standard pack install:

    1. ComfyUI Manager → search ComfyUI Web Viewer → install.
    2. Manual:
      cd ComfyUI/custom_nodes
      git clone https://github.com/VrchStudio/comfyui-web-viewer
      pip install -r requirements.txt
      
      Windows portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\comfyui-web-viewer\requirements.txt.
    3. Restart ComfyUI.

    No models, no special config. First install is slow because the pack's requirements.txt also bundles the optional Music2Emotion stack; nothing about this node touches any of it.

    Gotchas

    Two things trip people up. First, trigger is optional and default-empty - if you don't connect it, nothing ever toggles and the output sits at initial_state forever, which looks like a bug until you notice there's no wire. Second, think about when the pulse lands: a high value fed continuously will flip on the first true and flip back on the next true, so a source that stays high will oscillate on every execution. If you want a held button to latch cleanly, make sure you're feeding it a pulse, not a level - or use SWITCH OSC Control, which is state-based by design.

    Categoryvrch.ai/logic

    Inputs (3)

    NameTypeDefaultDescription
    initial_stateBOOLEANfalse
    debugBOOLEANfalse
    triggeroptBOOLEAN

    Outputs (2)

    NameTypeDescription
    OUTPUTBOOLEAN
    JSONJSON