Repository navigation
Mermaid diagrams in Markdown (#462): installed Mermaid in an isolated, script-free, offline Chromium page - #502
Merged
Merged
Conversation
…ted, script-free, offline Chromium page; pixels only; on request by default, bounded and cached; source fallback with the reason
…oned by a closing document is forgotten not failed, the per-document cap holds in hybrid, reasons carry no terminal controls
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #462
Mermaid fences in Markdown are drawn as real diagrams in NMSh's rendered views when a Mermaid the person installed and the real browser are available. The fence text stays the only source; anything not drawn shows the fence as written with
(diagram not drawn: reason). Design, acceptance criteria and limits:docs/design/diagrams.md.Renderer
Official mermaid (MIT), the copy the person installed (
npm install -g mermaid, orNMSH_MERMAID), located like Chromium and never bundled or downloaded. Its single-file bundle contains EPL-2.0 code (ELK), so vendoring it into this GPL-3.0-only package is left to the maintainer. Rejected: mermaid as a dependency (122 MB + ~20 deps), mermaid-cli (Puppeteer + its own Chromium), beautiful-mermaid / Rust re-implementations (partial syntax that could be drawn wrongly).Security boundary
previewpage with its own throwaway context, and every network request is failed. A CSP setsdefault-src 'none', and page scripts are disabled.callFunctionOnargument.securityLevel: strictwith HTML labels off,maxTextSizeandmaxEdgesset, and these keys plusdompurifyConfig,themeCSSand fonts are locked viasecure. The reviewer confirmed that directives and front matter cannot loosen them.<img>, captured as a PNG (≤4096 px a side, ≤8.4 MP) and decoded by NMSh's bounded decoder. It never reaches the terminal, clipboard or files.data:image/png;base64image.Integration
iopens a drawing in the image viewer (zoom/pan).D, or F1 › Diagrams / Draw diagrams while editing. Opening a document starts nothing.Resources
D, the diagram drawn afterD, none after exit.Tests
tests/diagrams{Mermaid,Library,Service,Document}.test.ts, plus new cases indocumentWorkspaceAppandbrowserPreviewMarkdown. They cover bounds, locked config, the locator, the deterministic queue/cancel/cache/timeout/crash/idle/close behaviour, fallbacks, 30/50/80/120 columns, NO_COLOR/Safe Glyphs, Hybrid/Split/Preview/Source, undo/redo, the viewport anchor, input returning to the composer, and that nothing is created at open.tests/diagramsChrome.test.tsuses real Chrome and real Mermaid. It covers the 17 types, syntax errors, and a hostile set that sent zero requests to a local server and ran no page script. It also covers hanging libraries (timeout), a crashed page, and repeated open/close. It skips with a reason when Chrome or Mermaid is missing.Din the Chromium preview, a drawing abandoned by a closing document being recorded as failed, the hybrid per-document cap re-queueing forever, and control characters in locator reasons.verify:fastplus the related suites.Needs human testing
Physical Ghostty and Zed QA: NOT RUN. The checklist is in
docs/testing/v024-editor-physical-qa.md.Not in this PR (remaining #462)
#fragmentlink following<details>toggling/doctorline for Mermaid