Repository navigation
feat(diff): render diffs with Pierre diffs and share one syntax palette - #10234
Conversation
Code diffs in ```diff fences now render through @pierre/diffs: syntax highlighting by file type, word-level changes, and per-file headers for multi-file git diffs, themed with Sim's surface and badge tokens. Our parser still validates the fence and resolves sim: sources; its hunks are written back out as a well-formed patch, so agent diffs without hunk line numbers keep working with line numbers hidden and hunk headings shown. DiffView keeps only the side-by-side document comparison, which Pierre does not cover.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryThis PR moves code diffs to Pierre and shares syntax colors between docs and the app.
Reviews (4) · Last reviewed commit: "fix(diff): resolve a code field's langua..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Workflow comparison field diffs now render through Pierre too, on the full before and after text: syntax highlighted by field (code language, JSON, prose), word-level changes, and expandable folds. The hand-rolled line engine in text-diff-lines.ts and its test are gone; the size guard, the one-sided cap and the expand-all control stay. Both diff surfaces render through SimFileDiff, which owns the theme, the +/- markers and Sim's change colors. Diffs color code like Code does: the Prism palette in code.css is now --code-token-* variables, and the Shiki scope mapping docs already maintained moved into emcn (syntax-theme.ts) so docs and the app share it. Docs output is byte-identical and Prism code blocks are pixel-identical. Embed polish: hunk separators show only the heading, diffs without line numbers keep their first heading, and the patch conversion moved to lib/diff/patch.ts with tests.
A numbered hunk that only inserts or only deletes has no line carrying the empty side's position, so it was re-derived from the previous hunk and the header pointed at the wrong lines. The parser now keeps the header's starts and the patch conversion emits them verbatim, inventing positions only for diffs written without line numbers.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
5 issues found across 20 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | 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/docs/scripts/compile-content.ts">
<violation number="1" location="apps/docs/scripts/compile-content.ts:476">
P2: Watching the file itself loses the watcher after an atomic editor save, so docs watch mode stops rebuilding on later syntax-theme changes. Watch the containing directory and filter for this filename instead.</violation>
</file>
<file name="apps/sim/components/diff/patch-view.tsx">
<violation number="1" location="apps/sim/components/diff/patch-view.tsx:21">
P2: A mixed numbered/un-numbered patch displays fabricated line numbers for its un-numbered hunks. Disable line numbers unless every hunk is numbered, or compute this per rendered file so the adapter’s invented positions remain hidden.</violation>
</file>
<file name="apps/sim/app/workspace/[workspaceId]/w/components/workflow-diff/components/change-list/field-change-row.tsx">
<violation number="1" location="apps/sim/app/workspace/[workspaceId]/w/components/workflow-diff/components/change-list/field-change-row.tsx:145">
P2: Daytona TypeScript code diffs are highlighted as JavaScript. `isValidCodeLanguage` does not include `typescript`, and the Daytona code config has no language fallback, so pass through or explicitly map the supported `typescript` value for syntax highlighting.</violation>
</file>
<file name="apps/sim/app/workspace/[workspaceId]/w/components/workflow-diff/components/change-list/text-diff.tsx">
<violation number="1" location="apps/sim/app/workspace/[workspaceId]/w/components/workflow-diff/components/change-list/text-diff.tsx:92">
P2: This renders an empty diff when a changed text value differs only by line ending or a final newline. Handle the no-hunk case explicitly (or normalize before `FieldChangeRow` decides to render `TextDiff`) so the change is not shown as a blank field.</violation>
</file>
<file name="apps/sim/lib/diff/patch.ts">
<violation number="1" location="apps/sim/lib/diff/patch.ts:68">
P2: `toFileDiffs` lets Pierre’s default line matcher rewrite the synthetic patch, so agent hunk order or boundaries can change. Pass `{ disableLineMatching: true }` to preserve the parsed hunks.</violation>
</file>
- Render a diff's lines in the order they were written: Pierre's similarity realignment could split one written change into several blocks. - Show line numbers only when every hunk has them, so positions invented for an unnumbered hunk never appear in a mixed diff. - Highlight code fields through an explicit map of the languages blocks offer, adding TypeScript (Daytona) and keeping shell as bash. - Say "Only line endings changed" when normalizing line endings leaves a changed value with no visible difference, instead of an empty diff. - Watch the syntax theme's folder in docs watch mode, since an editor's atomic save ends a watch on the file itself.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 20 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
A removed block's language exists only in the base version, and an empty saved language short-circuited the lookup, so both fell back to JavaScript or to no highlighting. The language now comes from the target values, then the base values, then the field default, through a Map so only the listed languages can match.
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
```difffences in chat and files) render code diffs with@pierre/diffs(pinned 1.6.4): syntax highlighting by file type, word-level changes,+/−markers, per-file headers for multi-file git diffs. Hunk separators show only the heading. Our parser still validates the fence and resolvessim:sources;lib/diff/patch.tsconverts its hunks to Pierre's model, so agent diffs without line numbers keep working (numbers hidden, headings kept).text-diff-lines.tsand its test are removed; the 2000-line guard, the 12-line cap for one-sided bodies, and the expand-all control stay.SimFileDiff, which owns the theme, markers and change colors mapped onto Sim's tokens.code.cssare now--code-token-*variables. The Shiki scope mapping docs already maintained moved to@sim/emcn/syntax-theme; docs and diffs both build on it, so diffs color code exactly likeCode.DiffViewkeeps only the side-by-side document comparison, which Pierre does not cover.Notes
sim-codetheme. No!important.hast-util-to-htmlresolves to 9.0.5 (Pierre pins it) instead of 9.0.6.Test plan
lib/diff/patch.test.ts: lines kept in order and side, heading-only separators (including the first hunk), real line numbers kept, add-only hunks, multi-file split. Mutation-checked: removing the heading gap or the heading override turns tests red.code.css: 0 differing pixels, light and dark.