Skip to content

Add new VS Code theme for mermaid diagrams#317617

Merged
mjbvz merged 3 commits into
mainfrom
dev/mjbvz/remote-donkey
May 20, 2026
Merged

Add new VS Code theme for mermaid diagrams#317617
mjbvz merged 3 commits into
mainfrom
dev/mjbvz/remote-donkey

Conversation

@mjbvz
Copy link
Copy Markdown
Collaborator

@mjbvz mjbvz commented May 20, 2026

Fixes #316968

Creates a new theme for mermaid diagrams that is derived from the current VS Code color theme

Also makes sure this works for diagrams opened in their own window and in chats

Fixes #316968

Creates a new theme for mermaid diagrams that is derived from the current VS Code color theme
Copilot AI review requested due to automatic review settings May 20, 2026 20:51
@mjbvz mjbvz enabled auto-merge May 20, 2026 20:51
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

This PR adds a new Mermaid theme option ("vscode") that derives Mermaid themeVariables from the active VS Code color theme so diagrams update correctly when the user changes themes, including in standalone diagram editors and chat-rendered diagrams.

Changes:

  • Introduces a VS Code-derived Mermaid theme ("vscode") and makes it the default for both light and dark modes.
  • Injects Mermaid extension configuration into editor/chat webviews so webview-side rendering can resolve the correct theme.
  • Adds a webview-side theme tracker that recomputes Mermaid themeVariables from VS Code CSS variables and triggers rerendering on theme changes.
Show a summary per file
File Description
extensions/mermaid-markdown-features/src/markdownMermaid/config.ts Switches default theme to vscode and factors config-span rendering into reusable helpers.
extensions/mermaid-markdown-features/src/editorManager.ts Injects the Mermaid config span into the standalone diagram editor webview HTML.
extensions/mermaid-markdown-features/src/chatOutputRenderer.ts Injects the Mermaid config span into the chat output webview HTML.
extensions/mermaid-markdown-features/preview-src/shared/vsCodeTheme.ts Adds the VS Code-derived Mermaid theme variable computation and DOM mutation tracking.
extensions/mermaid-markdown-features/preview-src/shared/index.ts Updates defaults to vscode and centralizes Mermaid config building via the theme tracker.
extensions/mermaid-markdown-features/preview-src/markdown/index.ts Rebuilds Mermaid config using the theme tracker before rerendering on preview refresh events.
extensions/mermaid-markdown-features/preview-src/chat/mermaidWebview.ts Re-renders chat/editor diagrams when VS Code theme CSS variables/classes change using the new tracker.
extensions/mermaid-markdown-features/package.nls.json Adds localized descriptions for the new theme option and existing theme choices.
extensions/mermaid-markdown-features/package.json Adds vscode theme to settings enums (with descriptions), sets it as default, and marks notebook renderer messaging as optional.

Copilot's findings

Comments suppressed due to low confidence (1)

extensions/mermaid-markdown-features/preview-src/shared/vsCodeTheme.ts:191

  • --vscode-chart-line does not appear to be a valid VS Code theme CSS variable (the usual pattern is --vscode-charts-lines). Because it’s listed first in the fallback chain, it may resolve to an inherited/default color and block the intended --vscode-charts-lines fallback. Please remove/fix this token name in the lineColor/border fallbacks.
	// Canvas / text
	set('background', '--vscode-editor-background');
	set('textColor', '--vscode-charts-foreground', '--vscode-editor-foreground', '--vscode-foreground');
	set('lineColor', '--vscode-chart-line', '--vscode-charts-lines', '--vscode-editor-foreground', '--vscode-foreground');

	// Primary (default node) colors
	set('primaryColor', '--vscode-editorWidget-background');
	set('primaryTextColor', '--vscode-charts-foreground', '--vscode-editor-foreground', '--vscode-foreground');
	set('primaryBorderColor', '--vscode-chart-line', '--vscode-editorWidget-border', '--vscode-focusBorder');
	set('mainBkg', '--vscode-editorWidget-background');
	set('nodeBorder', '--vscode-chart-line', '--vscode-editorWidget-border', '--vscode-focusBorder');
  • Files reviewed: 10/10 changed files
  • Comments generated: 1

@mjbvz mjbvz merged commit fb7459a into main May 20, 2026
25 checks passed
@mjbvz mjbvz deleted the dev/mjbvz/remote-donkey branch May 20, 2026 22:17
@vs-code-engineering vs-code-engineering Bot added this to the 1.122.0 milestone May 20, 2026
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.

Diagrams don't respond to theme changes

3 participants