You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Idea: render settled mermaid fences as diagrams in the web GUI
#2711
Assistant replies carrying ```mermaid fences currently render as plain code blocks in the web GUI. The fence language already declares the intent — rendering the diagram in place would save a copy-paste round trip to an external renderer.
Proposal
Add a settled-only mermaid branch to the markdown renderer's fence handling (packages/client/ui-primitives, mirroring the existing math fence precedent):
Load mermaid behind a dynamic import (~500 KB stays out of the boot chunk; sessions without diagrams never pay it).
Initialize once with securityLevel: 'strict' — fence source is untrusted assistant output, and mermaid DOMPurify-sanitizes labels before emitting the SVG.
Validate with mermaid.parse before mermaid.render; any failure (chunk load, parse, or render) degrades to the source CodeBlock instead of throwing, matching the unknown-grammar fallback rule.
While streaming, the fence stays a plain CodeBlock so the frozen-block streaming cache never bakes in async work.
Theme: mermaid's built-in neutral palette. (base + themeVariables mapped to --dsw-* tokens was rejected: mermaid's color math cannot parse CSS var() references, and literal colors would violate the tokens-only styling rule and freeze diagrams against light/dark switches.)
Unit tests mock the mermaid module and pin the loading/fallback contract; MermaidBlock.tsx and render.tsx hold 100% line/branch coverage; the byte-pinned markdown DOM-parity fixtures are untouched.
A keyless assembled-browser e2e scenario (apps/web/tests/mermaid-fence.e2e.ts, hand-authored session fixture + Playwright Chromium + aria golden) proves the diagram replaces the source CodeBlock in the real app with no console warnings.
Full local ladder green: test:gui (273 files / 3765 tests), lint, doc-sync (28 gates), duplication, hygiene, DSH_SNAPSHOT=replay test:web (76 files / 255 tests), and the full-repo vitest run --coverage gate (804 files / 13411 tests). An Agent Note in the repo's format is included.
I understand external pull requests are not accepted at the moment — posting this here in case the team wants to pick the idea (or the branch) up. Happy to adjust the design (theme mapping, error affordance, rendering site) if a different direction fits better.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Summary
Assistant replies carrying
```mermaidfences currently render as plain code blocks in the web GUI. The fence language already declares the intent — rendering the diagram in place would save a copy-paste round trip to an external renderer.Proposal
Add a settled-only
mermaidbranch to the markdown renderer's fence handling (packages/client/ui-primitives, mirroring the existingmathfence precedent):securityLevel: 'strict'— fence source is untrusted assistant output, and mermaid DOMPurify-sanitizes labels before emitting the SVG.mermaid.parsebeforemermaid.render; any failure (chunk load, parse, or render) degrades to the source CodeBlock instead of throwing, matching the unknown-grammar fallback rule.neutralpalette. (base+themeVariablesmapped to--dsw-*tokens was rejected: mermaid's color math cannot parse CSSvar()references, and literal colors would violate the tokens-only styling rule and freeze diagrams against light/dark switches.)Working implementation
I have this implemented and fully gated on a fork branch:
feat/mermaid-fence-rendering(reviewable diff: MarchLiu/deepseek-harness#1).MermaidBlock.tsxandrender.tsxhold 100% line/branch coverage; the byte-pinned markdown DOM-parity fixtures are untouched.apps/web/tests/mermaid-fence.e2e.ts, hand-authored session fixture + Playwright Chromium + aria golden) proves the diagram replaces the source CodeBlock in the real app with no console warnings.test:gui(273 files / 3765 tests),lint,doc-sync(28 gates),duplication,hygiene,DSH_SNAPSHOT=replay test:web(76 files / 255 tests), and the full-repovitest run --coveragegate (804 files / 13411 tests). An Agent Note in the repo's format is included.I understand external pull requests are not accepted at the moment — posting this here in case the team wants to pick the idea (or the branch) up. Happy to adjust the design (theme mapping, error affordance, rendering site) if a different direction fits better.
All reactions