Skip to content

Add collection-based For and ForReturn loop nodes - #189

Open
JPPhoto wants to merge 17 commits into
invoke-ai:mainfrom
JPPhoto:JPP/for-node-v7
Open

Add collection-based For and ForReturn loop nodes#189
JPPhoto wants to merge 17 commits into
invoke-ai:mainfrom
JPPhoto:JPP/for-node-v7

Conversation

@JPPhoto

@JPPhoto JPPhoto commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds bounded, collection-based For and ForReturn workflow nodes.

Highlights:

  • Adds sequential loop execution with loop-carried LoopState.
  • Supports empty collections, early termination, final output aggregation, cleanup, persistence, and resume.
  • Supports validated nested For loops and bounded Iterate/Collect bodies.
  • Adds explicit collection operations:
    • CollectionConcat
    • CollectionZip
    • CollectionCartesian
  • Adds durable direct loop_linkage edges between For and ForReturn.
  • Keeps connector paths as editor-only aliases that canonicalize to direct runtime linkage edges.
  • Adds backend and frontend graph validation for invalid, duplicate, escaped, cyclic, and mixed loop structures.
  • Adds loop output scopes for iteration and final outputs.
  • Adds contextual ForReturn discovery and auto-connection in the node picker.
  • Adds loop boundary visualization and connector deletion/reconnection handling.
  • Regenerates OpenAPI and frontend schemas.
  • Adds user and architecture documentation.
  • Reuses the existing happy-dom setup without adding browser-test dependencies.

Related Issues / Discussions

QA Instructions

Create some workflows with nested For loops, For loops containing bounded Iterate/Collect bodies. This is what an example For workflow might look like:
For Loop State Example

Merge Plan

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@JPPhoto JPPhoto closed this Aug 31, 2026
@JPPhoto
JPPhoto deleted the JPP/for-node-v7 branch August 31, 2026 11:31
@JPPhoto
JPPhoto restored the JPP/for-node-v7 branch August 31, 2026 11:33
@JPPhoto
JPPhoto deleted the JPP/for-node-v7 branch August 31, 2026 11:34
@JPPhoto
JPPhoto restored the JPP/for-node-v7 branch August 31, 2026 11:35
@JPPhoto JPPhoto reopened this Aug 31, 2026

@joshistoast joshistoast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

migrate to v7 shell

@JPPhoto
JPPhoto requested a review from joshistoast September 3, 2026 02:56

@joshistoast joshistoast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handy node and a good port for the most part, needs some updates before I'd call it merge-ready.

Comment thread invokeai/app/services/shared/graph.py Outdated
Comment thread invokeai/app/services/shared/graph.py
Comment thread invokeai/app/services/shared/graph.py Outdated
Comment thread invokeai/app/invocations/loops.py Outdated
Comment thread invokeai/frontend/webv2/src/features/workflow/core/forLoops.ts
Comment thread invokeai/frontend/webv2/src/features/workflow/core/forLoops.ts
Comment thread invokeai/frontend/webv2/src/features/workflow/ui/WorkflowWidgetChrome.tsx Outdated
Comment thread invokeai/frontend/webv2/src/features/workflow/core/buildGraph.ts
Comment thread invokeai/frontend/webv2/src/features/workflow/core/document.ts
Comment thread docs/src/content/docs/features/Workflows/loop-nodes.mdx Outdated
@JPPhoto
JPPhoto requested a review from joshistoast September 3, 2026 11:46
JPPhoto and others added 4 commits September 3, 2026 10:45
# Conflicts:
#	invokeai/frontend/webv2/performance/architecture-baseline.json
#	invokeai/frontend/webv2/performance/browser-baseline.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 7.0 Theme: Tabbed Layout UI

Development

Successfully merging this pull request may close these issues.

3 participants