Repository navigation
Commit 49d16b8
committed
fix(diagrams): #104 review — a repair is known by what it says, a replaced drawing is not handed back, and a replay keeps the order
Three findings from the Copilot review. All three are right.
agent.js:1041 — "this discards parsed.value and passes the raw string … the
original is degraded and a second card is drawn". The service decides whether a
call is the waiting diagram's repair by its title and its node ids, and it read
them off the arguments as they arrived. Arguments that are loose JSON arrive as
text — no title, no nodes — so a repair written with a trailing comma was a
"different diagram": the first attempt was settled as a degraded picture of its
own and the correction was drawn as a second. The same went for a first attempt
in loose JSON (its repair never found it), for a spec inside a `{"spec": …}`
envelope, and for one that says `name` for `title`.
The identity is now read from the spec as the ladder reads it — normalize(),
the lossless rung — whatever form it came in. agent.js is unchanged: it still
hands over the text, so the loose JSON is still counted as the auto-fix it was.
The placeholder's title comes from the same reading, so a call that arrived as
text has one too. And a second drawing of the same title in one run is
recognised as a redraw when it arrives as text.
service.js:260 — "this emits stubs for records that a later drawing replaced".
A redraw replaces the earlier drawing in the chat and a reopened session leaves
it out, but at compaction the model was handed a stub for each — so it could
see, fetch and edit a diagram the user no longer has. A replaced drawing now
gets no stub, wherever its replacement is in the conversation; it is not among
the known ids; and get_diagram, asked for it by an id the model may still
remember, answers with the id of the drawing the chat shows — the end of the
chain when it was redrawn more than once. A record that names itself, or two
that name each other, is a damaged file and not a reason to hang.
sessionEvents.js:149 — "all text blocks are collapsed and emitted before the
diagram". A message that says something, draws, and says more was replayed as
all of its prose and then the picture. It is now walked block by block: prose,
picture, prose, as it was on screen. Every piece after the first carries
`cont: true`, so a reader of the turns can still tell where a message ends
(the chat page does not need it: it already gives a run of answers one
speaker label). A message with no picture in it comes out exactly as it did,
one turn of all its text — and so does every caller that passes no records.
The Markdown export is built on those turns, and getting its order right
showed two more things wrong with it. A picture with no prose before it was
written under whoever spoke last — after a question, under "You". And once a
message is split, the prose after its picture would have been a turn of its
own. The export now works message by message: one rule and one speaker label
per message that says something, its pictures where they stood; a message that
is only a picture joins the answer above it, as before, unless there is none;
a diagram that was never drawn is dropped only after the pieces are grouped,
so the prose after it is not appended to the message before; and the count in
the header is still the number of messages that said something.
Tests, each failing on the code as reviewed. Through the real agent loop: a
repair in loose JSON, a first attempt in loose JSON, three envelope and
renamed-field shapes, a repair with the title reworded, and a redraw in loose
JSON — one diagram on file each time — and a different diagram in loose JSON,
which must NOT be taken for the same one. Three drawings of one diagram leave
one stub, and none in a stretch that holds only a replaced one; the same after
a reload, and in a file whose records name each other. A message of prose,
picture, another tool's call, prose and picture replays in that order with the
same words, and is exported as expected in five shapes.1 parent e84b368 commit 49d16b8
4 files changed
Lines changed: 282 additions & 23 deletions
File tree
- extensions/levelcode-ai
- diagram
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
| |||
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
153 | | - | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
172 | 184 | | |
173 | 185 | | |
174 | 186 | | |
175 | | - | |
| 187 | + | |
176 | 188 | | |
177 | 189 | | |
178 | 190 | | |
| |||
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
233 | 264 | | |
234 | 265 | | |
235 | 266 | | |
236 | 267 | | |
| 268 | + | |
237 | 269 | | |
238 | | - | |
| 270 | + | |
239 | 271 | | |
240 | 272 | | |
| 273 | + | |
241 | 274 | | |
242 | 275 | | |
243 | 276 | | |
244 | 277 | | |
245 | 278 | | |
246 | 279 | | |
247 | | - | |
| 280 | + | |
| 281 | + | |
248 | 282 | | |
249 | 283 | | |
250 | 284 | | |
| 285 | + | |
251 | 286 | | |
252 | 287 | | |
253 | 288 | | |
254 | 289 | | |
255 | 290 | | |
256 | | - | |
| 291 | + | |
257 | 292 | | |
258 | 293 | | |
259 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
131 | | - | |
132 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
138 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
142 | 150 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
146 | 157 | | |
147 | | - | |
148 | | - | |
| 158 | + | |
| 159 | + | |
149 | 160 | | |
| 161 | + | |
| 162 | + | |
150 | 163 | | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
| |||
190 | 205 | | |
191 | 206 | | |
192 | 207 | | |
193 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
194 | 216 | | |
195 | 217 | | |
196 | 218 | | |
| |||
200 | 222 | | |
201 | 223 | | |
202 | 224 | | |
203 | | - | |
| 225 | + | |
204 | 226 | | |
205 | 227 | | |
206 | 228 | | |
207 | 229 | | |
208 | 230 | | |
209 | 231 | | |
210 | 232 | | |
211 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
212 | 238 | | |
213 | | - | |
214 | 239 | | |
215 | 240 | | |
216 | 241 | | |
| |||
223 | 248 | | |
224 | 249 | | |
225 | 250 | | |
226 | | - | |
| 251 | + | |
227 | 252 | | |
228 | | - | |
229 | 253 | | |
230 | | - | |
231 | | - | |
232 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
233 | 262 | | |
234 | 263 | | |
235 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
240 | 298 | | |
241 | 299 | | |
242 | 300 | | |
| |||
245 | 303 | | |
246 | 304 | | |
247 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
248 | 310 | | |
249 | 311 | | |
250 | 312 | | |
| |||
0 commit comments