Repository navigation
Commit 19e8512
committed
fix(write-to-file): cover the pre-streaming window and discard without saving
CodeRabbit Lifecycle Resource Cleanup on Zoo-Code-Org#1932: "handlePartial() then awaits
provider?.getState() at lines 510-511 outside its local cleanup try. If that await, or a
later synchronous operation, rejects, BaseTool.handle() only calls callbacks.handleError()
... it does not clear the map entry or remove the listener", and "if the task is aborted
while diffViewProvider.open() is pending and open() then rejects, the abort listener has
already cleared the state and task disposal can already start diff cleanup, but the catch
still unconditionally finalizes the ask and calls revert/reset cleanup. This duplicates
cleanup after cancellation." Everything after the entry is registered now runs inside a
boundary that releases it: the pre-streaming window is wrapped, its catch releases this
delta's entry (identity-guarded, so a newer stream's entry survives) and rethrows; the
streaming catch checks liveness before it marks, finalizes, or restores, and again
between the two cleanup awaits, so a cancellation that lands in either gap stops instead
of running a second cleanup over a view disposal already owns.
This is the mirror image of U4/Zoo-Code-Org#1929 61dd05a: that unit wrapped the setup work and left
open()/update() outside, this one wrapped open()/update() and left provider.getState()
outside. The rule is recorded in #41 (Zoo-Code-Org#41 (comment)):
an await that happens after per-task state is registered belongs inside the boundary that
releases it, including awaits that look like read-only setup.
CodeRabbit Persistence Integrity on Zoo-Code-Org#1932: "revertChanges() now avoids saving
activeDiffEditor.document and calls discardFileTab() ... That helper only finds
TabInputText tabs (lines 912-920), but openDiffEditor() creates a vscode.diff tab with
TabInputTextDiff ... A user can later save the still-open dirty modified-side buffer and
recreate the unapproved streamed file." The rollback of an unapproved stream now goes
through discardUnapprovedStream(), ported from the earliest unit that defines it
(U7/Zoo-Code-Org#1928 f8f7ce1), together with the placeholderPath ownership tracking that keeps the
discard from deleting a file the user approved, and with the discard's own suite. It
empties or restores the buffer in memory, closes the tab only once it is clean, and then
removes the placeholder and the directories this edit created; the target file is never
written, so nothing the user did not approve reaches disk.
One deliberate change to the ported shape: closeAllDiffViews() now runs AFTER the buffer
restore instead of before it. A vscode.diff tab is dirty while its modified side holds the
streamed content and closeAllDiffViews() deliberately skips dirty tabs, so calling it
first left exactly the tab the row names open over a file the discard then unlinked. The
same one-line move has to land in Zoo-Code-Org#1928 and Zoo-Code-Org#1929 so the primitive stays identical across
the chain; it is called out here rather than silently diverging.
Out of Scope Changes was answered before this commit: the per-file declaration is in #41
(Zoo-Code-Org#41 (comment)) and appended to
Zoo-Code-Org#1937's body. BaseTool.ts belongs to U3/Zoo-Code-Org#1931 (e3c1040) and ClineProvider.ts to U4/Zoo-Code-Org#1929
(d172c95) and only appear in this PR's file list because the chain is opened against main;
DiffViewProvider.ts and its spec are this unit's own, because the cleanup that U6's finally
invokes is that code.
Negative controls (Buffer snapshots, sha256 cd36a1095acd4c72 / 39863d8ea2df56c8 /
781972c962cf3882 verified after every mutant): outer catch not releasing -> 1 red; no
liveness check at the top of the streaming catch -> 1 red; no liveness check between the
two cleanup awaits -> 1 red; rollback routed back through revertChanges -> 16 red;
closeAllDiffViews moved back before the restore -> 3 red; placeholder ownership guard
removed -> 3 red.
Local: sweep (core/tools, integrations/editor, core/task, core/webview) 97 files / 1994
passed / 5 skipped; tsc --noEmit 0 with the local @roo-code/types paths override; eslint .
--ext=ts --max-warnings=0 exit 0; eslint-suppressions.json untouched.1 parent 443993e commit 19e8512
5 files changed
Lines changed: 831 additions & 86 deletions
File tree
- src
- core/tools
- __tests__
- integrations/editor
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
163 | 171 | | |
164 | | - | |
| 172 | + | |
165 | 173 | | |
166 | | - | |
| 174 | + | |
167 | 175 | | |
168 | | - | |
169 | | - | |
| 176 | + | |
| 177 | + | |
170 | 178 | | |
171 | 179 | | |
172 | 180 | | |
| |||
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
207 | | - | |
| 215 | + | |
208 | 216 | | |
209 | 217 | | |
210 | 218 | | |
| |||
239 | 247 | | |
240 | 248 | | |
241 | 249 | | |
242 | | - | |
| 250 | + | |
243 | 251 | | |
244 | 252 | | |
245 | 253 | | |
| |||
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
473 | | - | |
| 481 | + | |
474 | 482 | | |
475 | 483 | | |
476 | 484 | | |
| |||
507 | 515 | | |
508 | 516 | | |
509 | 517 | | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
517 | 524 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
522 | 528 | | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
531 | 537 | | |
532 | | - | |
533 | | - | |
534 | | - | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
535 | 542 | | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
542 | 551 | | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
548 | 555 | | |
549 | | - | |
550 | | - | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
551 | 562 | | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
559 | 568 | | |
560 | | - | |
561 | | - | |
| 569 | + | |
| 570 | + | |
562 | 571 | | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
567 | 598 | | |
568 | 599 | | |
| 600 | + | |
569 | 601 | | |
570 | 602 | | |
571 | 603 | | |
| |||
583 | 615 | | |
584 | 616 | | |
585 | 617 | | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
586 | 626 | | |
587 | 627 | | |
588 | 628 | | |
| |||
599 | 639 | | |
600 | 640 | | |
601 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
602 | 649 | | |
603 | 650 | | |
604 | 651 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | | - | |
| 83 | + | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | | - | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
128 | | - | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
149 | 151 | | |
150 | 152 | | |
151 | 153 | | |
152 | | - | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
| |||
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
177 | | - | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
0 commit comments