Nodes/CWK_Wan2.2_Nodes/CWK Wan2.2 Loop Open
ComfyUI Node

CWK Wan2.2 Loop Open

The loop node that turns a Wan 2.2 clip list into one long video

By cowneko·Created 3 months ago·Updated 3 months ago· 2
CWK Wan2.2 Loop Open
  • pipeline
  • start_image
  • current_image
  • prev_latent
  • prompt
  • frame_count
  • lora_stack_high
  • lora_stack_low
  • clip_seed
  • loop_state
overlap5
overlap_modeblend_linear
overlap_sidestart
force_resetfalse

The shortest path to a long Wan 2.2 video is not one giant generation - Wan's native context is only about 81 frames, so anything longer gets chunked into clips. The Loop Open node is the front door of the pack's answer to that: instead of generating each clip by hand and stitching in an editor, you feed it the WAN22_PIPELINE from the pack's Prompt Composer and let it walk through the clips one re-queue at a time. Its job is narrow and weird: keep state across ComfyUI re-queues, and hand each clip's data to the sampler section when it's that clip's turn.

How the loop actually works

ComfyUI is a one-shot DAG by default - it runs the graph and stops. To make a loop, this pack cheats in the best possible way: the backend keeps a session in a class variable, so it survives between queue runs, and Loop Close sends a cwk_wan22_loop_continue event that the pack's frontend JS listens for and turns into an automatic re-queue. Each re-queue, Loop Open advances clip_index by one and emits the next clip's prompt, frame count, seed, and LoRA stacks.

A few mechanisms worth knowing because they explain the behavior you'll see:

  • IS_CHANGED returns NaN, so the node (and everything downstream) re-executes every queue no matter what. That's how the loop advances.
  • A fingerprint of the pipeline is stored in the session. Change the Composer's blocks, and the loop notices and resets to clip 1 rather than continuing somewhere meaningless.
  • force_reset is a one-shot trigger - set it true, and the next run resets the session and flips itself back to false so a normal re-queue never accidentally restarts you. The tooltip in the node says it plainly: keep it false in normal use.

Inputs that matter

  • pipeline - the WAN22_PIPELINE from the Composer. Connect anything else and it raises "Pipeline is empty."
  • start_image - the first frame of the whole video. It seeds clip 1's current_image.
  • overlap, overlap_mode, overlap_side - these look like they do something here, but they're actually stored in the loop state and applied by Loop Close when it blends clip boundaries. overlap is the number of frames to cross-fade (default 5), overlap_mode is blend_linear / blend_sqrt / replace, and overlap_side is start (continuation) or end (loop). Set them here, see the effect at the other end.

The outputs are what the sampler section eats: current_image and prev_latent (the previous clip's last frame and latent, so shot N+1 starts where shot N ended), prompt, frame_count, lora_stack_high, lora_stack_low, clip_seed, and loop_state - which you must wire into Loop Close to close the loop.

Install

ComfyUI Manager → CWK Wan2.2 Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/cowneko/CWK_Wan2.2_Nodes.git

Restart ComfyUI. No extra Python dependencies. You'll also want the whole pack, obviously - Loop Open only talks to the pack's own types (WAN22_PIPELINE, WAN22_LOOP_STATE), so it's useless in isolation.

Troubleshooting

  • Nothing advances / loop stalls - the auto re-queue depends on the frontend JS listener for cwk_wan22_loop_continue. If the Composer's UI isn't loading (a real early bug fixed in 1.0.0), the listener isn't either. Update the pack and hard-refresh the tab; worst case, just hit Queue yourself - the state persists, so a manual re-queue advances the loop too.
  • It restarted from clip 1 unexpectedly - the pipeline fingerprint changed (you edited a Composer block) or the session got reset. Editing the Composer mid-loop is a guaranteed restart.
  • Two loops in one workflow fight each other - the session is a single class-level variable, not per-loop. One loop per workflow; if you need two, run them separately or use the Splitter for the static parts.

Honest take: this is clever plumbing held together with state, so it's more fragile than a stock node - but for a coherent multi-clip Wan video, it beats generating clips blind and praying they match.

CategoryCWK/wan22

Inputs (6)

NameTypeDefaultDescription
pipelineWAN22_PIPELINE
start_imageIMAGE
overlapINT50–32
overlap_modeCOMBOblend_linear3 options: blend_linear, blend_sqrt, replace
overlap_sideCOMBOstart2 options: start, end
force_resetBOOLEANfalse

Outputs (8)

NameTypeDescription
current_imageIMAGE
prev_latentLATENT
promptSTRING
frame_countINT
lora_stack_highLORA_STACK
lora_stack_lowLORA_STACK
clip_seedINT
loop_stateWAN22_LOOP_STATE