Repository navigation
Commit 9ca9ace
authored
feat(diff): render diffs with Pierre diffs and share one syntax palette (#10234)
* feat(diff): render code diffs in diff embeds with Pierre diffs
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.
* feat(diff): one diff renderer and one syntax palette across Sim
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.
* fix(diff): keep a hunk header's own line positions
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.
* chore(audits): drop baseline entries for the removed text-diff-lines
* fix(diff): address review findings on the diff renderers
- 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.
* fix(diff): resolve a code field's language from either version
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.1 parent 02fb744 commit 9ca9ace
20 files changed
Lines changed: 784 additions & 859 deletions
File tree
- apps
- docs
- lib
- scripts
- sim
- app/workspace/[workspaceId]/w/components/workflow-diff
- components/change-list
- components/diff
- lib/diff
- packages/emcn
- src/components/code
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
11 | 5 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 6 | | |
| 7 | + | |
30 | 8 | | |
31 | 9 | | |
32 | | - | |
| 10 | + | |
33 | 11 | | |
34 | 12 | | |
35 | 13 | | |
| |||
43 | 21 | | |
44 | 22 | | |
45 | 23 | | |
46 | | - | |
| 24 | + | |
47 | 25 | | |
48 | 26 | | |
49 | | - | |
| 27 | + | |
50 | 28 | | |
51 | 29 | | |
52 | 30 | | |
| |||
58 | 36 | | |
59 | 37 | | |
60 | 38 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | 39 | | |
190 | 40 | | |
191 | | - | |
192 | | - | |
| 41 | + | |
| 42 | + | |
193 | 43 | | |
194 | 44 | | |
195 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
| 205 | + | |
200 | 206 | | |
201 | 207 | | |
202 | 208 | | |
| |||
449 | 455 | | |
450 | 456 | | |
451 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
452 | 464 | | |
453 | 465 | | |
454 | 466 | | |
| |||
459 | 471 | | |
460 | 472 | | |
461 | 473 | | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
466 | 479 | | |
467 | 480 | | |
468 | 481 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
26 | 58 | | |
27 | 59 | | |
28 | 60 | | |
| |||
117 | 149 | | |
118 | 150 | | |
119 | 151 | | |
120 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
121 | 157 | | |
122 | 158 | | |
123 | 159 | | |
| |||
0 commit comments