Repository navigation
Conversation
Keep the SVG host mounted while a diagram error is shown so a later successful parse can write the diagram and clear the stale error without toggling code/edit mode. Fixes #18370 (cherry picked from commit 2fc1c7c1e15fa9a4b9f285343a697d8055145fe5)
Extend Wooseong Kim’s #18449 recovery coverage with delayed success/error, unmount, and empty parser error controls. Keep the current formatted-label sanitizer when adopting the original change.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
MermaidBlock.tsx— keep the SVG host mounted. The render host now stays in the tree at all times (hiddenwhile an error is shown) instead of being unmounted by the error branch. On successsetError(null)is moved outside thecontainerRef.currentguard, and the error path clears the host so a stale diagram cannot linger. Root cause: the old error branch removed the host, so a later successful render found no destination and the error never cleared.MermaidBlock.test.tsx— regression coverage. Eight new tests pin empty parser messages, error-source visibility, recovery without remount, valid→invalid regression, cancelled stale success/error, and late success/error after unmount.
I verified the coverage is real: the suite passes 8/8 against this branch, and temporarily restoring the base-branch MermaidBlock.tsx makes the recovery and stale-outcome tests fail. I also checked the renderer CSS for any display rule that could defeat the hidden attribute on the bare host div and found none.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
91a2f2c to
2ef2b34
Compare
f16b7db to
380ba0c
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed commits 9f61962ef6 and 380ba0c7ec, which are rebased re-applications of the previously approved fix and tests onto the updated nwparker/editor-mermaid-html-labels base (2ef2b340e8). The re-applied code is identical to the prior revision; the base-subtree churn the range-diff shows is base-branch noise, not this PR.
- Re-applied Mermaid recovery fix. The SVG host stays mounted (
hiddenduring error),setError(null)runs outside thecontainerRef.currentguard, the error path clears the retained host, and the banner guard useserror !== nullso an empty parser message still renders. - Re-applied regression coverage. Eight tests pin error/source visibility, recovery without remount, valid→invalid regression, delayed cancelled outcomes, and late outcomes after unmount.
Ran pnpm test src/renderer/src/components/editor/MermaidBlock.test.tsx against this head: 8/8 pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Closing as superseded by merged #26480 (79a8cff), which fixes the same Mermaid error-to-success recovery. I compared this PR’s complete production and regression-test diff with current main ( Validation: This closure is based on the landed replacement, not branch age or conflicts. |

ELI5
Fixing a Mermaid syntax error now redraws the diagram immediately, including in the floating workspace. Switching modes or reopening the document is no longer needed.
What Changed
Keep the diagram output container mounted while showing an error. A successful render writes into that container and clears the error; a failed render clears the previous SVG while keeping the error and current source visible.
Why
The error view removed the output container, so the next successful render found no destination and left the error unchanged. Retaining the container fixes that lifecycle without extra retries or changes to the rendering queue.
Linked Issue
Fixes #18370.
Visual Proof
Testing
Review
The production change received independent source review. This PR is stacked on #25554; its diff contains one production file and one test file. The rendering queue, cancellation contract, strict Mermaid configuration, and final sanitizer are preserved.
Agent skill upstream boundary
Notes
Preserves Wooseong Kim (@innocarpe)'s authored commit from #18449, with its cherry-pick reference, diagnosis, and stable-container approach. The sanitizer conflict was resolved to retain the parent fix. The follow-up adds cancellation coverage, concise comments, and consistent handling of an empty parser error message. Original report credited to @DreamyDuck.
Cross-checked the exact Mermaid 11.17.2 render promise. The engine resolves or rejects the render independently of Orca's output container; no library patch is required.
Verification used local git documents and app-owned floating documents on macOS. Native Windows/Linux, live SSH, and a folder-project UI were not exercised. This renderer lifecycle change adds no execution-host, path, wire, CSP, or dependency behavior. The extra block wrapper was checked against existing descendant SVG styles and measured against the previous layout.
Checklist