Skip to content

Export diagram from model to mermaid code#174

Merged
ricardozanini merged 12 commits into
serverlessworkflow:mainfrom
cheryl7114:mermaid-export-150
Jun 18, 2026
Merged

Export diagram from model to mermaid code#174
ricardozanini merged 12 commits into
serverlessworkflow:mainfrom
cheryl7114:mermaid-export-150

Conversation

@cheryl7114

@cheryl7114 cheryl7114 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Closes #150

Changes Made
Added two buttons to export diagram model (JSON/YAML) to Mermaid:

  • Copy Mermaid Code - copy mermaid string to clipboard
  • Download as Mermaid File - download workflow as a .mmd file

Cheryl Kong added 3 commits June 8, 2026 15:38
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested review from Copilot, fantonangeli, handreyrc, kumaradityaraj and lornakelly and removed request for Copilot and lornakelly June 9, 2026 08:40
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for swf-editor ready!

Name Link
🔨 Latest commit c10abc6
🔍 Latest deploy log https://app.netlify.com/projects/swf-editor/deploys/6a33b8c83530e900084056e8
😎 Deploy Preview https://deploy-preview-174--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.

@cheryl7114 cheryl7114 requested a review from Copilot June 9, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Mermaid export capabilities to the diagram editor, exposing “copy” and “download” actions from the SidePanel and providing a core utility to generate Mermaid code.

Changes:

  • Add exportToMermaid + clipboard/file download helpers in src/core
  • Expose “Copy Mermaid Code” and “Download as Mermaid File” buttons in SidePanel
  • Add i18n strings and tests for both core export and SidePanel rendering states

Reviewed changes

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

Show a summary per file
File Description
packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Adds UI-state tests for Mermaid export buttons visibility.
packages/serverless-workflow-diagram-editor/tests/core/mermaidExport.test.ts Adds a unit test for Mermaid conversion output shape.
packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Adds export buttons + handlers wired to new Mermaid export helpers.
packages/serverless-workflow-diagram-editor/src/i18n/locales/en.ts Adds English strings for Mermaid export UI.
packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Introduces Mermaid export, clipboard copy, and download helpers.
packages/serverless-workflow-diagram-editor/src/core/index.ts Re-exports the new Mermaid export module.
.changeset/mermaid-export.md Declares a minor release for the new functionality.

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

Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested a review from Copilot June 9, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread .changeset/mermaid-export.md Outdated
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested a review from Copilot June 9, 2026 11:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
Comment thread .changeset/mermaid-export.md Outdated
@cheryl7114 cheryl7114 requested a review from Copilot June 9, 2026 11:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested a review from Copilot June 9, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 out of 7 changed files in this pull request and generated 6 comments.

Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
@cheryl7114 cheryl7114 requested a review from lornakelly June 9, 2026 11:59
Comment thread packages/serverless-workflow-diagram-editor/src/i18n/locales/en.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/core/mermaidExport.ts Outdated

@fantonangeli fantonangeli left a comment

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.

@cheryl7114 I only added one comment in addition to other's comments.
Can you please also add the issue link in the description?

Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/SidePanel.tsx Outdated
Cheryl Kong added 2 commits June 15, 2026 12:26
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Copilot AI review requested due to automatic review settings June 15, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 14 out of 14 changed files in this pull request and generated 7 comments.

Comment thread packages/serverless-workflow-diagram-editor/tests/lib/download.test.ts Outdated
Comment thread packages/serverless-workflow-diagram-editor/tests/side-panel/SidePanel.test.tsx Outdated
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested a review from Copilot June 15, 2026 12:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 15 out of 15 changed files in this pull request and generated 6 comments.

Comment thread packages/serverless-workflow-diagram-editor/src/i18n/locales/en.ts Outdated
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/MermaidActions.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/MermaidActions.tsx Outdated
Comment thread packages/serverless-workflow-diagram-editor/src/side-panel/MermaidActions.tsx Outdated
@cheryl7114

cheryl7114 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@cheryl7114, I noticed that in the build process we have many warnings related to storybook such as the one below. image

Could you take a look?

Hi @handreyrc these warnings are from component tests auto-generated by Storybook's test addon (@storybook/addon-vitest), not the actual test code. The Storybook addon automatically renders each story as a test, and the auto-generated tests don't wrap these async updates in act().
It's just React's testing library being strict about async state updates in the automated Storybook test environment. So in my opinion they're safe to ignore since its auto generated by Storybook.

But I do acknowledge it makes the build look really cluttered. I could add a config to suppress warnings of this type if needed?

@handreyrc

Copy link
Copy Markdown
Contributor

@cheryl7114, I noticed that in the build process we have many warnings related to storybook such as the one below. image
Could you take a look?

Hi @handreyrc these warnings are from component tests auto-generated by Storybook's test addon (@storybook/addon-vitest), not the actual test code. The Storybook addon automatically renders each story as a test, and the auto-generated tests don't wrap these async updates in act(). It's just React's testing library being strict about async state updates in the automated Storybook test environment. So in my opinion they're safe to ignore since its auto generated by Storybook.

But I do acknowledge it makes the build look really cluttered. I could add a config to suppress warnings of this type if needed?

@cheryl7114,

I'd suggest investigating how to wrap it into act(...) as the warning suggests. IMO, suppressing warnings is always the last case scenario because It masks the actual issue even if it is not breaking anything at the moment.

WDYT?

@cheryl7114

Copy link
Copy Markdown
Contributor Author

@cheryl7114,

I'd suggest investigating how to wrap it into act(...) as the warning suggests. IMO, suppressing warnings is always the last case scenario because It masks the actual issue even if it is not breaking anything at the moment.

WDYT?

@handreyrc The tests are auto-generated at runtime by @storybook/addon-vitest, so there's no actual test code we can modify. The options I found for this situation are:

  1. Add play functions to all 35 stories in Examples.stories.tsx, which would look roughly like this for all examples:
export const AuthenticationOAuth2: Story = {
  ...createWorkflowStory(workflows.authenticationOAuth2),
  play: async ({ canvasElement }) => {
    await waitFor(() => {
      // Wait for React Flow to finish rendering
      expect(canvasElement.querySelector('.react-flow')).toBeInTheDocument();
    });
  },
};  // generated by Bob
  1. Configure Storybook test parameters by adding to preview.tsx:
parameters: {
  test: {
    // Disable act warnings for auto-generated tests
    dangerouslyIgnoreUnhandledErrors: true,
  },
}
  1. Suppress act(...) warnings in vitest.config.ts

Option 2 and 3 would be simpler, but I wouldn't mind implementing option 1 if its necessary. Please let me hear you opinions! :)

Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
Copilot AI review requested due to automatic review settings June 18, 2026 09:20
Signed-off-by: Cheryl Kong <cherylkong50@gmail.com>
@cheryl7114 cheryl7114 requested review from lornakelly and removed request for Copilot June 18, 2026 09:22

@lornakelly lornakelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cheryl7114

Copy link
Copy Markdown
Contributor Author

@handreyrc I'll put in a separate PR for the storybook warning fixes after we conclude our discussion

@cheryl7114

Copy link
Copy Markdown
Contributor Author

@ricardozanini this looks ready to merge. Thank you!

@cheryl7114 cheryl7114 requested a review from ricardozanini June 18, 2026 10:20
@ricardozanini ricardozanini merged commit 25e3352 into serverlessworkflow:main Jun 18, 2026
12 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: Export diagram from model to mermaid code

7 participants