Skip to content

feat: mermaid diagrams #6455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Jul 4, 2025

Description

Render mermaid diagrams into chat area.

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screenshots

feat.mp4

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Added support for rendering Mermaid diagrams in the chat area, including zoom and pan controls.

  • Dependencies
    • Added mermaid and @panzoom/panzoom packages.

basic mermaid js implementation

add panzoom and change color theme variables
@uinstinct uinstinct requested a review from a team as a code owner July 4, 2025 16:44
@uinstinct uinstinct requested review from Patrick-Erichsen and removed request for a team July 4, 2025 16:44
Copy link

netlify bot commented Jul 4, 2025

👷 Deploy request for continuedev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d6713d8

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 4, 2025
@uinstinct uinstinct force-pushed the mermaid-diagrams-2 branch from 2257c73 to b090f04 Compare July 4, 2025 16:44
@sestinj
Copy link
Contributor

sestinj commented Jul 5, 2025

@uinstinct this is beautiful 🤩

Seems like a couple of tests failing, maybe just with import problems?

Run cd gui
Error: src/components/StyledMarkdownPreview/MermaidBlock.tsx([6](https://github.com/continuedev/continue/actions/runs/16078012521/job/45377510205?pr=6455#step:11:7),21): error TS2307: Cannot find module '@panzoom/panzoom' or its corresponding type declarations.
Error: src/components/StyledMarkdownPreview/MermaidBlock.tsx(7,21): error TS230[7](https://github.com/continuedev/continue/actions/runs/16078012521/job/45377510205?pr=6455#step:11:8): Cannot find module 'mermaid' or its corresponding type declarations.
Error: src/components/StyledMarkdownPreview/MermaidBlock.tsx(99,18): error TS7031: Binding element 'svg' implicitly has an 'any' type.
Error: src/components/StyledMarkdownPreview/MermaidBlock.tsx(124,17): error TS7006: Parameter 'err' implicitly has an 'any' type.
Error: Process completed with exit code 2.

Super excited to get this merged, and you should demo it next week!

Edit: I think you just need to run npm i in order to get them into package-lock.json

return (
<>
{isLoading && (
<div className="text-vsc-foreground text-sm">Generating diagram...</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<div className="text-vsc-foreground text-sm">Generating diagram...</div>
<div className="text-vsc-foreground text-xs">Generating diagram...</div>

nitpick

setIsLoading(true);
}, [code]);

useDebouncedEffect(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we use async/await here for readability/consistency with the rest of the codebase?


const MINIMUM_ZOOM_STEP = 0.05;

const MERMAID_THEME_COLORS = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we pull in any of the theme variables from our tailwind config here? At least for some things like background, primaryColor, etc, it should map pretty cleanly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right. I had tried this.

currently mermaid does not support var for colors
image

Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

Few nitpick comments but this looks great!

Copy link
Collaborator

@Patrick-Erichsen Patrick-Erichsen left a comment

Choose a reason for hiding this comment

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

Thanks for making those changes! Bummer that mermaid doesn't support CSS vars.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Jul 8, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants