Skip to content

Integrate ELKjs for automatic diagram layout#152

Merged
ricardozanini merged 6 commits into
serverlessworkflow:mainfrom
handreyrc:add-elkjs-engine
May 22, 2026
Merged

Integrate ELKjs for automatic diagram layout#152
ricardozanini merged 6 commits into
serverlessworkflow:mainfrom
handreyrc:add-elkjs-engine

Conversation

@handreyrc
Copy link
Copy Markdown
Contributor

Closes #54

Summary

This PR replaces the dummy auto-layout placeholder for an actual layout engine capable of layout nodes and edges.

Changes

  • Added latest ELKjs library as a dependency.
  • Added core function to consume ELK layout workers as an asynchronous operation.
  • Replaced dummy layout implemention in autoLayout.ts for an actual implementation that takes react flow nodes and edges, transforms it to elkGraph, calculate the layout then applies it back to react flow nodes and edges.
  • Integrated diagramBuilder and auto-layout in the Diagram component in order to render layouted workflows.
  • Tests for graph manipulation and auto-layout integration.
image

Copilot AI review requested due to automatic review settings May 20, 2026 21:47
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.

Integrates ELK-based auto-layout into the diagram editor and expands test coverage around layout graph conversion, application, and error handling.

Changes:

  • Add elkjs dependency and introduce processElkLayout core helper.
  • Replace the previous placeholder auto-layout with ELK graph building + layout application (including edge bendpoints).
  • Update Diagram rendering/tests to use ReactFlowProvider and add extensive layout-focused tests.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds elkjs to the workspace catalog for consistent versioning.
packages/serverless-workflow-diagram-editor/package.json Consumes elkjs from the workspace catalog.
packages/serverless-workflow-diagram-editor/src/core/index.ts Re-exports new ELK layout helper from core.
packages/serverless-workflow-diagram-editor/src/core/elkjs.ts Adds processElkLayout wrapper around ELK with error handling.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/autoLayout.ts Implements ELK graph conversion, layout application, and bendpoint mapping.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/diagramBuilder.ts Stops applying auto-layout inside the builder; returns raw nodes/edges.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx Applies auto-layout asynchronously on model changes and fits view.
packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx Adds ReactFlowProvider to support useReactFlow() usage.
packages/serverless-workflow-diagram-editor/tests/react-flow/diagram/Diagram.test.tsx Wraps Diagram with ReactFlowProvider in tests.
packages/serverless-workflow-diagram-editor/tests/react-flow/diagram/autoLayout.integration.test.ts Replaces old placeholder assertions with detailed auto-layout unit/integration coverage.
packages/serverless-workflow-diagram-editor/tests/core/elkjs.test.ts Adds unit tests for processElkLayout success and error scenarios.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 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/Diagram.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/core/elkjs.test.ts Outdated
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.

@handreyrc I left some comment. Please let me know what you think

Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/core/elkjs.test.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/core/elkjs.test.ts Outdated
Copilot AI review requested due to automatic review settings May 21, 2026 13:57
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 12 out of 13 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/serverless-workflow-diagram-editor/tests/core/elkjs.test.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx Outdated
Comment thread pnpm-workspace.yaml Outdated
@handreyrc handreyrc requested a review from fantonangeli May 21, 2026 14:44
@handreyrc
Copy link
Copy Markdown
Contributor Author

@fantonangeli @kumaradityaraj,

This PR is ready for reviews again.

Thanks!

handreyrc added 5 commits May 21, 2026 17:16
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>

# Conflicts:
#	packages/serverless-workflow-diagram-editor/src/diagram-editor/DiagramEditor.tsx
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 21, 2026 21:29
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 12 out of 13 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/serverless-workflow-diagram-editor/vitest.config.ts
Comment thread packages/serverless-workflow-diagram-editor/vitest.config.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/elkjs.ts
Comment thread packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx Outdated
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copy link
Copy Markdown
Contributor

@kumaradityaraj kumaradityaraj left a comment

Choose a reason for hiding this comment

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

LGTM

@handreyrc handreyrc requested a review from ricardozanini May 22, 2026 13:04
@handreyrc
Copy link
Copy Markdown
Contributor Author

@ricardozanini,

If do not have any consideration, this PR is good enouth to be merged!

Thanks

@ricardozanini ricardozanini merged commit 38ea977 into serverlessworkflow:main May 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Integrate ELKjs for automatic diagram layout

5 participants