Skip to content

feat(web): render rich Mermaid diagrams in chat - #98

Merged
yaacovcorcos merged 1 commit into
mainfrom
feat/scient-chat-diagrams-20260814
Aug 14, 2026
Merged

yaacovcorcos merged 1 commit into
mainfrom
feat/scient-chat-diagrams-20260814

Conversation

@yaacovcorcos

Copy link
Copy Markdown
Contributor

Problem

Scient rendered Mermaid fences as ordinary code even when a relationship was much easier to understand visually, and supported agents had no reliable way to discover that the Scient chat surface could present diagrams.

What changed

  • Render settled fenced mermaid blocks as polished inline diagram cards in chat and Markdown file previews.
  • Keep streaming fences and unsupported clients on the ordinary readable code path.
  • Add lazy, bounded, locally bundled Mermaid rendering with duplicate-SVG id rebasing and isolated loading/error recovery.
  • Add expanded viewing with fit and 25-400% zoom, source inspection/copy, standalone SVG download, and bounded high-resolution PNG copy/download.
  • Preserve Mermaid source as the canonical Markdown for whole-message copy and external readers.
  • Advertise the capability through the existing narrow Codex and Claude instruction seams.
  • Add user, internal, third-party, and manual fixture documentation.

User impact

Before this change, Mermaid appeared only as source code. After it, completed diagrams become responsive light/dark cards without hiding their source or breaking surrounding Markdown when a diagram is malformed. Mobile remains a readable source-code fallback.

Upstream boundary

The implementation lives under Scient-owned diagram and provider files. The inherited T3 ChatMarkdown change is limited to one import and one settled-fence branch, with a seam regression test. This PR is independent of the open chat-math PR #81 and includes none of its commits; if #81 lands first, this branch only needs that narrow seam reconciled during rebase.

Validation

  • Focused web diagram suite: 4 files, 15 tests passed
  • Focused provider suite: 2 files, 88 tests passed
  • Web and server typechecks passed
  • Targeted lint and formatting passed
  • Production web build passed during the clean desktop candidate launch
  • git diff --check passed
  • Yaacov completed manual light/dark visual review of the diagram fixture in an isolated Scient (Dev) candidate

Implemented and verified with OpenAI Codex in the Codex app.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 11.4 KiB 11.3 KiB −51 B (−0.4%) 15.1 KiB ✅
Codex Thread snapshot wire 5.5 KiB 5.5 KiB −5 B (−0.1%) 7.3 KiB ✅
Codex Live turn WebSocket wire 5.9 KiB 5.9 KiB −46 B (−0.8%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 49.8 KiB 49.7 KiB −59 B (−0.1%) 66.4 KiB ✅
Codex Live turn messages 18 16 −2 (−11.1%) 21 ✅
Claude Total thread wire 11.4 KiB 11.4 KiB +3 B (+0.0%) 15.1 KiB ✅
Claude Thread snapshot wire 5.5 KiB 5.5 KiB −4 B (−0.1%) 7.3 KiB ✅
Claude Live turn WebSocket wire 5.9 KiB 5.9 KiB +7 B (+0.1%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 50.6 KiB 50.6 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 18 18 0 (0.0%) 21 ✅

Baseline: 5c1a63f · PR result: ae33c64 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 94.7 KiB
  • Claude decoded thread snapshot: 95.4 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@yaacovcorcos
yaacovcorcos marked this pull request as ready for review August 14, 2026 15:44
@yaacovcorcos
yaacovcorcos merged commit d80fac0 into main Aug 14, 2026
15 checks passed
@yaacovcorcos
yaacovcorcos deleted the feat/scient-chat-diagrams-20260814 branch August 14, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant