CWK Wan2.2 Loop Open
The loop node that turns a Wan 2.2 clip list into one long video
- pipeline
- start_image
- current_image
- prev_latent
- prompt
- frame_count
- lora_stack_high
- lora_stack_low
- clip_seed
- loop_state
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_CHANGEDreturns 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_resetis 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- theWAN22_PIPELINEfrom the Composer. Connect anything else and it raises "Pipeline is empty."start_image- the first frame of the whole video. It seeds clip 1'scurrent_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.overlapis the number of frames to cross-fade (default 5),overlap_modeisblend_linear/blend_sqrt/replace, andoverlap_sideisstart(continuation) orend(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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| pipeline | WAN22_PIPELINE | — | |
| start_image | IMAGE | — | |
| overlap | INT | 50–32 | — |
| overlap_mode | COMBO | blend_linear | 3 options: blend_linear, blend_sqrt, replace |
| overlap_side | COMBO | start | 2 options: start, end |
| force_reset | BOOLEAN | false | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| current_image | IMAGE | — |
| prev_latent | LATENT | — |
| prompt | STRING | — |
| frame_count | INT | — |
| lora_stack_high | LORA_STACK | — |
| lora_stack_low | LORA_STACK | — |
| clip_seed | INT | — |
| loop_state | WAN22_LOOP_STATE | — |