Skip to content

Add node containment support to composite tasks react flow components (do, for, fork, try) #159

Open
handreyrc wants to merge 6 commits into
serverlessworkflow:mainfrom
handreyrc:add-containment
Open

Add node containment support to composite tasks react flow components (do, for, fork, try) #159
handreyrc wants to merge 6 commits into
serverlessworkflow:mainfrom
handreyrc:add-containment

Conversation

@handreyrc
Copy link
Copy Markdown
Contributor

@handreyrc handreyrc commented May 28, 2026

Closes #80
Closes #81
Closes #82

Summary

This PR enable containment support to tasks containing child tasks integrated with the auto-layout engine.

Changes

  • Added Entry and Exit node types and react flow node components.
  • Enabled diagramBuilder to create child nodes and reference their parent node.
  • Updated ELK auto-layout settings to cover nodes on the root level and inside parent nodes.
  • Refactored the code that creates ELK graph / ElkNode to properly consider and chain child nodes and edges so an accurate representation of nodes and edges is submitted to ELK for processing.
  • Refactored the code that takes the layouted graph from ELK and applies it to react flow nodes and edges.
  • Add support to resize parent nodes automatically to fit its children.
  • Added / updated tests covering diagramBuilder, auto-layout and containent.
image

handreyrc added 3 commits May 27, 2026 22:20
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings May 28, 2026 02:53
@netlify
Copy link
Copy Markdown

netlify Bot commented May 28, 2026

Deploy Preview for swf-editor ready!

Name Link
🔨 Latest commit 4e56044
🔍 Latest deploy log https://app.netlify.com/projects/swf-editor/deploys/6a19aeaba1d7a60008a1e6f2
😎 Deploy Preview https://deploy-preview-159--swf-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds containment (parent/child) support in the React Flow diagram and integrates it with the ELK auto-layout pipeline, including new node types, layout options for parent nodes, edge nesting at lowest common ancestor, and accompanying tests.

Changes:

  • Render child nodes with parentId/extent: "parent"; build ELK graph hierarchically and place edges at the lowest common ancestor; introduce PARENT_LAYOUT_OPTIONS.
  • Add EntryNode and ExitNode placeholder components and register them in ReactFlowNodeTypes.
  • Expand unit tests and update e2e expected node/edge counts.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/react-flow/diagram/diagramBuilder.ts Emit all nodes (not only root) and set parentId/extent for child nodes.
src/react-flow/diagram/autoLayout.ts New parent layout options, nested ELK graph construction, LCA-based edge nesting, and edge waypoint handling for nested edges.
src/react-flow/nodes/Nodes.tsx Register Entry/Exit node types and add placeholder components.
tests/react-flow/diagram/diagramBuilder.test.ts New tests for edge animation, parent/child relations, catch containers, task data, and graph structure.
tests/react-flow/diagram/autoLayout.integration.test.ts New tests for hierarchy/edge placement, waypoint handling, abort signal, error rejection, and updated layout option assertions.
tests-e2e/diagram-editor.spec.ts Update expected node/edge counts to reflect containment-rendered children.
.changeset/containment-auto-layout.md Add changeset entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copy link
Copy Markdown
Member

@fantonangeli fantonangeli left a comment

Choose a reason for hiding this comment

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

Thanks @handreyrc, just 2 small suggestions

const reactFlowNodeMap = new Map(reactFlowGraph.nodes.map((node) => [node.id, node]));

// Helper function to find the common ancestor of two nodes
const findCommonAncestor = (sourceId: string, targetId: string): string => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like an helper function which can be declared at top level in this file, receiving reactFlowNodeMap as input

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

});

// Clean up empty edges arrays from nodes that don't need them
const cleanupEmptyEdges = (node: ElkNode) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would also declare this as top level function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings May 29, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Outdated
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
@handreyrc handreyrc requested a review from fantonangeli May 29, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants