Uh oh!
There was an error while loading. Please reload this page.
feat(files): embed sim files and render mermaid diagrams in markdown preview - #4402
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Updates the markdown preview to render Mermaid code blocks via a new Also adds Reviewed by Cursor Bugbot for commit 380388c. Configure here. |
Greptile SummaryThis PR adds a new Confidence Score: 5/5Safe to merge — no P0/P1 findings; auth and access-control paths are solid and the cross-origin URL rewrite guard is correctly implemented. All findings are P2 (a contract response-mode label mismatch). Auth, access checking, UUID validation, and the same-origin guard in resolveSimFileUrl are all correctly implemented. The remarkMermaid plugin correctly mutates the MDAST in-place following standard remark conventions. apps/sim/lib/api/contracts/storage-transfer.ts — the fileViewContract response mode label is inaccurate but non-blocking. Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant MarkdownRenderer as Markdown Renderer
participant ViewAPI as /api/files/view/[id]
participant ServeAPI as /api/files/serve/[storage]/[key]
participant DB as Database
Browser->>MarkdownRenderer: Render markdown with img src
MarkdownRenderer->>MarkdownRenderer: resolveSimFileUrl() rewrites relative /workspace/.../files/[id] URLs
MarkdownRenderer-->>Browser: img src rewritten to /api/files/view/[id]
Browser->>ViewAPI: GET /api/files/view/[id]
ViewAPI->>ViewAPI: checkSessionOrInternalAuth()
ViewAPI->>DB: getFileMetadataById(id)
DB-->>ViewAPI: FileMetadataRecord
ViewAPI->>ViewAPI: verifyFileAccess(record.key, userId)
ViewAPI-->>Browser: 302 to /api/files/serve/[storage]/[key]
Browser->>ServeAPI: GET /api/files/serve/[storage]/[key]
ServeAPI-->>Browser: Binary file content
Note over MarkdownRenderer: remarkMermaid plugin intercepts mermaid fenced code blocks at MDAST stage and converts them to mermaid-diagram elements
Reviews (7): Last reviewed commit: "fix(files): match mmd skeleton to actual..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 85e5f3d. Configure here.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 989b683. Configure here.
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
…tokens Streamdown intercepts fenced code blocks before components.code is called, so the previous mermaid branch in the code renderer was dead code. Add a remarkMermaid plugin that transforms mermaid code nodes at the MDAST stage via data.hName/hProperties so remark-rehype emits a <mermaid-diagram> element that our MermaidDiagram component handles. This avoids Streamdown's built-in mermaid renderer which uses mismatched Tailwind semantic classes.
… Streamdown Components type
… hydration mismatch
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
May 2, 2026
waleedlatif1
commented
May 2, 2026
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 380388c. Configure here.
Summary
Type of Change
Testing
Tested manually
Checklist