Skip to content

Make Mermaid diagrams in Markdown preview theme-aware #11601

Description

@Lakphy

Problem

Mermaid diagrams rendered in Markdown preview currently appear with a white canvas even when Warp is using a dark terminal or theme background. This is visually jarring in a terminal-first UI where the surrounding Markdown and code block surface is dark.

Current behavior

  • Mermaid diagrams in rendered Markdown use a light Mermaid theme regardless of the active Warp theme.
  • The rendered SVG carries its own white background, so the surrounding dark code or Markdown background is covered by the SVG canvas.

Expected behavior

  • Mermaid diagrams should be theme-aware and match the active Warp theme, especially in dark terminal and Markdown preview contexts.
  • At minimum, dark themes should not render Mermaid diagrams on a white #ffffff canvas.
  • The asset cache key should include the chosen Mermaid theme or background, so switching themes does not reuse a stale light SVG.

Investigation notes

The rendering path appears to be hard-coded to the light Mermaid theme:

  • crates/editor/src/content/mermaid_diagram.rs builds the async asset id as light: and calls mermaid_to_svg::render_mermaid_to_svg(&source, Some(&MermaidTheme::light())).
  • The locked mermaid_to_svg dependency defines MermaidTheme::light().background as #ffffff, and its SVG renderer writes that value into the SVG background-color style.
  • crates/editor/src/render/element/mermaid.rs paints model.styles().code_background around the block, but the generated SVG image is painted on top and its white background covers the dark surface.
  • app/src/notebooks/editor/model.rs also uses MermaidTheme::light() for Mermaid clipboard HTML.
  • app/src/ai/blocklist/block/view_impl/common.rs reuses mermaid_asset_source, so this may affect AI and visual Markdown Mermaid rendering too.

Scope

This issue now covers only theme-aware Mermaid rendering. The interactive lightbox, zoom, and pan request has been split into #14082 so its design can be considered separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:editor-notebooksEditors, notebooks, markdown rendering, LSP, and code display.enhancementNew feature or request.ready-to-implementThe issue is ready for implementation work.repro:highThe report includes enough evidence that the issue appears highly reproducible.triagedIssue has received an initial automated triage pass.warp:auto-triage-review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions