You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Render Mermaid diagrams in chat responses #1497
Add native Mermaid rendering in SurfSense chat responses when the assistant outputs Markdown code blocks tagged as mermaid.
Problem
Currently, Mermaid blocks are displayed as raw code instead of rendered diagrams, which reduces readability for workflows, architectures, sequence diagrams, and technical explanations.
Expected behavior
When the chat response contains:
flowchart TD
A[User question] --> B[Search sources]
B --> C[LLM answer]
C --> D[Display with citations]
Loading
SurfSense should render it as a visual diagram directly in the chat.
Suggested behavior
Detect Markdown blocks tagged with mermaid
Render valid Mermaid diagrams in the chat UI
Keep a fallback to raw code if rendering fails
Add a “Copy source” button
Ensure safe rendering to avoid XSS/security issues
Support light/dark theme if applicable
Value
This would improve technical documentation, architecture explanations, process mapping, and AI-generated visual summaries inside SurfSense.
I would like to take this for the desktop app. #1534 added Mermaid to surfsense_web, but surfsense_local chat replies and Studio documents still show a mermaid block as code. Since this is a new feature, I will start with a proposal PR in docs/proposals/, as AGENTS.md asks.
The proposal: render through @streamdown/mermaid, beside the existing code and math plugins in streamdown-config.ts. Diagrams render only once a reply has finished streaming, the same way code highlighting waits. Mermaid loads in its own lazily loaded chunk, so it does not add to startup. It uses securityLevel: strict and follows the app's light and dark theme. An invalid diagram falls back to the code block.
Activity
feat(markdown): add Mermaid diagram rendering support (#1497)
Merge pull request #1534 from Ryan-PG/fix/1497-mermaid-rendering
feat(markdown): add Mermaid diagram rendering support (MODSetter#1497)
Merge pull request MODSetter#1534 from Ryan-PG/fix/1497-mermaid-rende…
Cedric921 commentedon Oct 17, 2026
I would like to take this for the desktop app. #1534 added Mermaid to
surfsense_web, butsurfsense_localchat replies and Studio documents still show amermaidblock as code. Since this is a new feature, I will start with a proposal PR indocs/proposals/, as AGENTS.md asks.The proposal: render through
@streamdown/mermaid, beside the existing code and math plugins instreamdown-config.ts. Diagrams render only once a reply has finished streaming, the same way code highlighting waits. Mermaid loads in its own lazily loaded chunk, so it does not add to startup. It usessecurityLevel: strictand follows the app's light and dark theme. An invalid diagram falls back to the code block.