fix(exports): preserve SVG HTML labels in image exports - #277
Merged
Conversation
Contributor
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
yaacovcorcos
force-pushed
the
codex/svg-export-fix-20260910
branch
from
September 11, 2026 03:50
e366f74 to
abde9e5
Compare
yaacovcorcos
marked this pull request as ready for review
September 11, 2026 04:05
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.
Problem
Mermaid's sanitized, HTML-compatible SVG is not always valid standalone XML (notably HTML line breaks). Separately, loading an SVG containing HTML labels from a blob URL can taint Chromium's canvas and prevent PNG encoding. Copying a saved SVG in the shared image viewer follows the same affected path.
Targeted fix
The production change is confined to three files and removes duplicate decoding code. Most added lines are regression tests.
Verification
pnpm run test: 19,903 passed, 108 skipped across 27 package suites. The original PR CI passed in full.git diff --checkpassed. Existing unrelated lint warnings remain; no lockfile change.No computer-use or manual visual acceptance was performed. A target-isolated app from the rebased commit is running for owner review. The targeted hidden Electron test uses a temporary profile and does not touch the user's clipboard.
Relationship to the other Mermaid work
Rebased onto current main after #276 merged. The sole command-list conflict retained both complementary smoke tests, and #276's rendering test now requires successful standalone SVG and PNG export instead of preserving the old known-failure baseline. No repair-UX or rendering behavior was changed.
This fixes export correctness; SVG readers still need HTML-label (
foreignObject) support. Converting HTML labels to SVG text is not included.Documentation impact: Updated —
docs/internals/scient-chat-diagrams.md.Model and harness: GPT-5; Codex desktop harness.