Skip to content

feat(files): render diff fences and theme mermaid diagrams - #8543

Merged
TheodoreSpeaks merged 13 commits into
stagingfrom
feat/diff-embeds
Oct 1, 2026
Merged

TheodoreSpeaks merged 13 commits into
stagingfrom
feat/diff-embeds

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • ```diff fences in markdown files render as line diffs: tinted add/remove rows, word-level highlights, line numbers when hunk headers carry them, and long unchanged runs collapsed behind an expander
  • ---/+++ headers can name a workspace file (sim:file/<id>) or knowledge base document (sim:knowledge/<kbId>/<docId>); the card header shows its icon, name, and a link
  • when --- and +++ name two different documents, the diff renders as two side-by-side excerpt cards with each document's claim highlighted
  • mermaid diagrams use app tokens on Mermaid's base theme; flowcharts look like workflow blocks and edges (rounded cards, 1.5px edges, no arrowheads) and labels are pinned to the font they are measured with so they no longer clip
  • dashboard tables size to their content (up to 400px) instead of a fixed height
  • the embed and the diff parser are lazy-loaded so rich-markdown surfaces only pay for them when a doc contains a diff

Type of Change

  • New feature

Testing

Tested manually in markdown files with file, knowledge base, two-document, and git diffs plus flowchart, sequence, and pie diagrams. bun run lint, bun run check:audits, block registry and tool-registry boundary checks, and diff parser unit tests pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 1, 2026 9:43pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/diff/unified.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds diff rendering and mermaid theming to markdown editor.

The PR appears safe to merge based on the reviewed changes and resolved previous threads.

Summary

The PR renders markdown diff fences as expandable, highlighted diffs with optional workspace-resource links, applies app tokens to Mermaid diagrams, and adjusts dashboard table sizing.

  • The changes since the previous review refine per-run expansion and parser handling for renamed files, diff lines resembling headers, and mixed source types.
  • No new actionable finding was established.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Markdown diff fence"] --> B["Parse unified diff"]
  B --> C{"Different sim: sources?"}
  C -- Yes --> D["Side-by-side excerpt cards"]
  C -- No --> E["Line diff with collapsible context"]
Loading

Reviews (3) · Last reviewed commit: "fix(files): title renames by their new p..."

Comment thread apps/sim/lib/diff/unified.ts
Comment thread apps/sim/components/diff/diff-view.tsx
Comment thread apps/sim/components/diff/diff-embed.tsx
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@TheodoreSpeaks I have started the AI code review. It will take a few minutes to complete.

Comment thread apps/sim/lib/diff/unified.ts Outdated
Comment thread apps/sim/lib/diff/unified.ts Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 11 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/sim/components/diff/diff-view.tsx">

<violation number="1" location="apps/sim/components/diff/diff-view.tsx:161">
P2: Clicking any collapsed run expands every collapsed run in the same hunk because `expanded` is keyed only by `hunkIndex`. Track each run separately so expanding one run does not reveal unrelated context or remove the other expanders.</violation>
</file>

<file name="apps/sim/lib/diff/unified.ts">

<violation number="1" location="apps/sim/lib/diff/unified.ts:84">
P2: No-`@@` diffs drop changes whose first body line starts with `--- ` or `+++ ` because header recognition remains active after both file headers. Track whether the `---` and `+++` headers have been consumed before interpreting subsequent rows.</violation>

<violation number="2" location="apps/sim/lib/diff/unified.ts:91">
P2: Single-file renames show the old filename in the diff card header instead of the changed `+++` filename. Assign `path` when processing the non-source `+++` header, retaining an old-path fallback only for `/dev/null` deletions.</violation>
</file>

Comment thread apps/sim/components/diff/diff-view.tsx Outdated
Comment thread apps/sim/lib/diff/unified.ts Outdated
Comment thread apps/sim/lib/diff/unified.ts Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@TheodoreSpeaks I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 11 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@TheodoreSpeaks
TheodoreSpeaks merged commit 39067d0 into staging Oct 1, 2026
32 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/diff-embeds branch October 1, 2026 22:04

This branch was previously deployed

1 inactive deployment
Preview — 321d23a0 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant