Skip to content

fix(ui): distinguish Mermaid renderer failures from invalid diagrams - #138465

Merged
steipete merged 1 commit into
mainfrom
fix/mermaid-renderer-load-errors
Sep 4, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/mermaid-renderer-load-errors

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #138419. Reporter credit: @thomastraum on X; report and original diagram supplied by @steipete.

What Problem This Solves

Fixes an issue where Control UI users are told to correct valid Mermaid source when the renderer cannot load. This happens behind cookie-authenticated reverse proxies: the opaque rendering frame requests its scripts without SameSite=Lax/Strict cookies, so authentication can reject those assets even though the dashboard itself is logged in. Lazy component download failures and SVG image display failures also used the same misleading syntax message.

Why This Change Was Made

The component now preserves MermaidTransientError and represents rendering, diagram errors, renderer failures, and image failures with one status value. This removes the separate pending/failed flags and duplicated completion cleanup. The lazy-module failure path uses the same renderer guidance. Invalid diagrams keep their existing text and all failures retain readable, copyable source.

The Mermaid documentation describes the required proxy access to the two static renderer assets, including path-prefixed deployments. No automatic retry was added: repeating the same cookie-blocked requests would delay actionable guidance by another renderer timeout.

Credentialed parent fetching was evaluated. Inline srcdoc scripts must be authorized by both the inherited dashboard CSP and the native renderer CSP. The current asset manifest does not expose that authorization to either document. Implementing it correctly requires coordinated build, server-policy, native-host, and fetch-lifecycle changes beyond the agreed approximately net-neutral robustness scope. The sandbox, CSP, renderer, and SVG sanitizer remain unchanged.

User Impact

Renderer failures now suggest reloading and checking proxy/authentication rules for renderer asset URLs. Image-display failures suggest reloading without blaming source syntax. Cookie-gated deployments still need their static renderer assets reachable without SameSite cookies; the documentation limits any proxy exception to those assets and preserves dashboard/API authentication.

Evidence

  • Baseline unit regressions: renderer and image failures both displayed the source/simplify message; both new cases failed for that reason. Candidate: all 13 presentation tests pass.
  • Production-bundle Chromium E2E: block the actual frame script and, separately, the lazy Mermaid UI module. Both cases failed against baseline; both pass with the fix and render a decoded SVG after removing the block and reloading.
  • Existing real-Chromium renderer/native coverage: all 14 tests passed, covering opaque sandboxing, passive SVG, source/edge limits, diagram families, independent themes, timeout classification, and recovery.
  • Keyless i18n baseline/verification passed. Only English source changed; translation generation follows the post-merge workflow.

Commands:

node scripts/run-vitest.mjs run --config ui/vitest.config.ts ui/src/components/markdown-mermaid.test.ts
node scripts/run-vitest.mjs run --config ui/vitest.config.ts ui/src/components/markdown-mermaid.runtime.browser.test.ts ui/src/components/markdown-mermaid-native.browser.test.ts
node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-mermaid-load-errors.e2e.test.ts
pnpm ui:i18n:baseline
node scripts/check-changed.mjs -- ui/src/components/markdown-blocks.ts ui/src/components/markdown-mermaid.ts ui/src/components/markdown-mermaid.test.ts ui/src/e2e/chat-mermaid-load-errors.e2e.test.ts ui/src/i18n/locales/en.ts docs/web/control-ui.md

git diff --numstat classification:

Surface Added Removed Net
Production, including English copy 21 23 -2
Tests 92 34 +58
Documentation 10 0 +10

No config/env options, SQLite/schema changes, protocol bumps, dependency overrides, or changelog edits.

Crabbox cookie-proxy reproduction

Baseline source 832ce3c68b761e90f8b9087a1b65629cbbdfffaf, Blacksmith Testbox lease tbx_01m1pr660npa59vgn6gs84vgnk, Actions run. Real CLI Gateway, isolated temporary state and free ports, persisted sessions.create / chat.inject message, token-authenticated dashboard handoff, Chromium 144.0.7559.0, and a synthetic SameSite=Lax cookie-gated Node reverse proxy. No provider call or operator state was used.

The verbatim reported flowchart failed at both / and /openclaw/. Both engine and frame requests had cookie:false, sec-fetch-site:cross-site, and HTTP 401, followed by the old source/simplify message. Prefix requests correctly targeted /openclaw/assets/…. Exempting only the two static renderer scripts returned HTTP 200 with cookies still absent, and the diagram SVG decoded in both deployments. This reproduces the reported valid-source failure class and rules out path-prefix URL resolution for that class. The reporter's actual proxy/browser setup remains unconfirmed.

Baseline successful command inside the lease (temporary proof harness):

node --import tsx ui/src/e2e/mermaid-proxy-proof.mts before /tmp/mermaid-before-ui.oxHA5w
# root: both scripts HTTP 401, cross-site, no cookie; source/simplify error
# /openclaw: both scripts HTTP 401, cross-site, no cookie; source/simplify error
# both deployments after asset exemption: HTTP 200, decoded diagram
# exit 0; 136.0 seconds

The preserved baseline index SHA-256 was c7ca073cb57083fb2b4e4014206f48fda8cc4ad92945dacdee0d2411eb231db7. Baseline proof setup first needed the repository's installed Chromium resolver and token/dashboard handoff fixture; those setup failures occurred before diagram rendering and are not presented as product failures.

Candidate 6f2587c1f0ff7d6646fdef9e6dd39c977e781857 passed the same real Gateway/Chromium flow on fresh Blacksmith Testbox lease tbx_01m1pstxze8p22119xq26gshzh (Actions run). The tracked tree was 8b133ba4294dba1e7fa9f31694ff3c3d7b78044c; served index SHA-256 f99997ee0ae6e5018b5a53e90ae6ff6803c5a6af51fc3c7997f779decf091189 and component markdown-mermaid-Bc4ORrDk.js confirm the new build.

node --import tsx ui/src/e2e/mermaid-proxy-proof.mts after
# root: both scripts HTTP 401, cross-site, no cookie; renderer/proxy/reload guidance
# /openclaw: same 401 diagnosis, correct prefixed asset URLs
# both deployments after asset exemption: HTTP 200, decoded diagram
# exit 0; 195.345 seconds

All four baseline and four candidate screenshots were inspected; they contain synthetic data only. Mandatory local and branch review through P2 found no accepted/actionable findings.

Initial CI found a pre-existing startup-budget overage: candidate 350,479 B versus unchanged limit 350,141 B; baseline proof 350,386 B. All other checks passed. Main subsequently acquired the Model Providers copy deferral in f804e08cba8 (#137342), so this branch was mechanically rebased to 9c84aab615eeaab9ad2392fab3c60eebcfa389fd on main 0062f2b127bbbdc9fd7db65c679066a11101b6c3. The same-toolchain comparison now passes at 349,103 B, with no budget/baseline edits. The 13 unit and two production-bundle browser regressions pass again, and fresh branch review through P2 is clean. Exact-head CI is green, and the fresh Crabbox proof passed for the rebased commit.

Final-head proof: Blacksmith Testbox lease tbx_01m1pv5mf3mqgnaf00g8wrns9n (Actions run), exact source 9c84aab615eeaab9ad2392fab3c60eebcfa389fd, tree f8a1122d4d5e5a0cae2d151cf036d5a0ef84f56e. Rebuilt index SHA-256 cd7cb202b373372f273bb1340866b66eb65e8eef3f21abe7491cc7fb5ffca3e0, component markdown-mermaid-7bXoHXde.js. Both root and /openclaw again recorded cookie-less cross-site HTTP 401 for both renderer scripts, displayed the new guidance, and recovered a decoded SVG after only those assets returned HTTP 200. The same after command shown above exited 0 in 276.504 seconds. Testbox startup size was 349,088 B against the unchanged 350,141 B limit. All final captures were inspected; every proof lease is confirmed stopped.

ClawSweeper's final-head review found no correctness or security defect. Its requested data-model compatibility check is not applicable: renderStatus at ui/src/components/markdown-mermaid.ts:58 is private in-memory Lit state replacing private booleans. Only render callbacks write it; no serialized record, database schema, migration, config, or protocol changes. The real Gateway proof reloads the original persisted chat message unchanged. Maintainer review confirms that no migration is needed.

NO-FOLLOW-UP: the useful render-state owner simplification is integral to this repair; no separate rent-paying refactor was found in the touched paths.

Before: a logged-in cookie proxy blocks renderer scripts, but Control UI blames valid source

After at the final commit: blocked renderer scripts produce reload and proxy guidance

Recovery at the final commit: the verbatim diagram renders through the prefixed cookie proxy

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 4, 2026 18:10
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Sep 4, 2026
Preserve transient renderer failures in Control UI status, report image failures separately, and document SameSite proxy requirements. Related: #138419. Reported by @thomastraum on X.
@steipete
steipete force-pushed the fix/mermaid-renderer-load-errors branch from 6f2587c to 9c84aab Compare September 4, 2026 18:33
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 2:44 PM ET / 18:44 UTC.

ClawSweeper review

What this changes

The PR gives Control UI users distinct recovery guidance for invalid Mermaid source, unavailable renderer assets, and browser image-display failures.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open for normal maintainer handling: this is a MEMBER-authored, maintainer-labeled PR. The introduced status model correctly preserves the renderer’s typed transient-error distinction and adds focused coverage; no actionable introduced defect was found.

Priority: P2
Reviewed head: 9c84aab615eeaab9ad2392fab3c60eebcfa389fd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative production repair with direct component and built-browser coverage and no identified correctness issue.
Proof confidence 🌊 off-meta tidepool Not applicable: The Repository State records a MEMBER author, so the external-contributor proof gate does not apply; the submitted Chromium before/after evidence is consistent with the changed renderer path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The Repository State records a MEMBER author, so the external-contributor proof gate does not apply; the submitted Chromium before/after evidence is consistent with the changed renderer path.
Evidence reviewed 7 items Current-main behavior: The fetched current-main version still uses one general failed state after a renderer rejection, so the reported misleading syntax guidance remains unfixed outside this PR.
Renderer error contract: The target-owned renderer defines MermaidTransientError for unavailable, load, timeout, and removal failures; this is the appropriate boundary for distinct renderer recovery guidance.
Owner-boundary repair: The Markdown component maps only MermaidTransientError to rendererError, retains general errors as diagram errors, and clears the status after a successful SVG render.
Findings None None.
Security None None.

How this fits together

Control UI turns fenced Mermaid Markdown into a sandboxed renderer request and then either shows a passive SVG image or preserves readable source. Renderer and image outcomes feed back into the Markdown block so the user receives the appropriate recovery message.

flowchart LR
  A[Chat Markdown] --> B[Mermaid block]
  B --> C[Sandboxed renderer]
  C --> D{Render outcome}
  D -->|SVG| E[Diagram image]
  D -->|Diagram error| F[Source guidance]
  D -->|Renderer failure| G[Proxy guidance]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -2, Tests +58, Docs +10. Total +66 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 23 -2
Tests 2 92 34 +58
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 123 57 +66

Review metrics

Metric Value Why it matters
Production vs test LOC production -2 (21 added, 23 removed); tests +58 (92 added, 34 removed); docs +10 The repair reduces production surface while adding direct component and browser-level regression coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: ui/src/components/markdown-mermaid.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #138419
Summary: This PR is the concrete candidate fix for the reported valid-diagram failure in the Control UI.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep the single closed render-status owner, preserve the renderer’s typed transient-error boundary, and land after ordinary maintainer review and the exact-head merge gate complete.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: aborting either isolated renderer script reaches MermaidTransientError, and the added browser test exercises that path before verifying successful reload recovery.

Is this the best way to solve the issue?

Yes. The renderer already distinguishes transient failures, so propagating that typed result into one closed presentation state is narrower and safer than adding retries or changing sandbox and CSP behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 26f87a37009b.

Labels

Label changes:

  • add P2: This fixes misleading recovery guidance for a bounded Control UI rendering failure class.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The Repository State records a MEMBER author, so the external-contributor proof gate does not apply; the submitted Chromium before/after evidence is consistent with the changed renderer path.

Label justifications:

  • P2: This fixes misleading recovery guidance for a bounded Control UI rendering failure class.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The Repository State records a MEMBER author, so the external-contributor proof gate does not apply; the submitted Chromium before/after evidence is consistent with the changed renderer path.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 01d4b64 into main Sep 4, 2026
146 checks passed
@steipete
steipete deleted the fix/mermaid-renderer-load-errors branch September 4, 2026 18:57
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…penclaw#138465)

Preserve transient renderer failures in Control UI status, report image failures separately, and document SameSite proxy requirements. Related: openclaw#138419. Reported by @thomastraum on X.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant