Repository navigation
Commit 694bed4
committed
fix(diff-view): close tabs on a clean buffer and stand the rollback down after the commit point
Three CodeRabbit threads on #1932 plus the two review rows they point at.
Data Integrity & Integration (Critical, DiffViewProvider.ts:691): "revertChanges() can
delete a file that this edit never created ... reset() (Lines 1213-1241) does not clear
relPath ... That is exactly the state that takes the new-file branch: fileExists is false,
the if (this.activeDiffEditor) block is skipped, and removeCreatedFile(absolutePath) runs
fs.unlink." reset() now clears relPath and newContent, so no path survives its session, and
the regression test the thread asked for proves revertChanges() after reset() never reaches
fs.unlink.
Deliberate deviation, recorded because it is a scope call rather than an oversight: the
thread's other half - gating the rollback on an active edit session - is NOT taken here.
That guard belongs to #1931's shape of revertChanges() (5c0f212), which lands before this
unit in the merge order; carrying a second shape of the same guard in the last unit is how
one method ends up with two. It is filed as a follow-up against #1931's next push, and the
tests here record the current behaviour rather than the desired one.
Functional Correctness (Minor, writeToFileTool.spec.ts:1344): "Both 'keeps approved diff
content' tests assert only revertChanges not called, so they always pass ... A regression
that discards the user's approved edit would pass both tests." Both now assert on
discardUnapprovedStream(), the method the error path actually calls.
Maintainability (Minor, writeToFileTool.spec.ts:957): "Two new early-release tests check off
with expect.any(Function). They still pass if the tool removes a different function." Both
sites capture the registered listener and assert off with that reference.
Maintainability (Trivial, writeToFileTool-partial-state-cleanup.spec.ts:196): "Every rollback
test here makes discardUnapprovedStream reject. No test proves that a successful discard
stays silent." Added for both teardown boundaries; they kill the return-true and if
(!reverted) survivors the mutation advisory named.
Ported from the units that land before this one, so the chain converges on one shape:
- 5c0f212 (#1931): discardFileTab() restores the pre-stream buffer and saves it clean
BEFORE closing, and close() is called without its second argument - that parameter is
preserveFocus, not a force-discard flag, so a dirty tab was silently refused while the
rollback kept deleting the file underneath it. saveBufferClean() comes with it.
- 2a9bfab (#1931): saveChanges() takes an onCommit signal raised at the document save, and
execute() stands the rollback down once it fires. saveDirectly() commits when it returns,
because performing the write is what it does.
- 8084eab (#1929): saveChanges() releases placeholderPath only after the approved save
lands, so a rejected save leaves the discard something to remove.
Security & Privacy (Major, WriteToFileTool.ts:315): "If handlePartial() opened the denied
path before the final block, the denial branch clears only task stream state. It does not
revert the streamed content or reset the diff view." The rooignore denial now runs the same
discard-then-reset teardown as the other boundaries. The two missing-parameter returns are
corrected in the reply on that thread - they did already reset - but neither discarded what
an earlier delta had streamed, so they run the same helper now.
Negative controls (Buffer snapshots, sha256 a1fa0dd263514c5c provider / 49b07146e60b1f4a
tool, verified after every mutant): forced close restored -> 2 red; no saveBufferClean -> 1
red; reset() keeping relPath -> 1 red; commit point raised on return -> 1 red; placeholder
released before the save -> 1 red; rooignore branch not tearing the view down -> 1 red;
either missing-parameter branch back to a bare reset() -> 1 red each; commit point never
wired -> 1 red; detach passing a different function -> 9 red; cleanup always reporting -> 1
red; parse-failure teardown always reporting -> 1 red. Two mutants are equivalent and carry
documented Stryker directives: dropping writeCommitted after saveDirectly, and shortening
the catch guard to !writeApproved - on this unit the approval flag already stands the
rollback down on every path the commit point can be reached from.
Local: sweep (core/tools, integrations/editor, core/task, core/webview) 97 files / 2002
passed / 5 skipped; tsc --noEmit 0 with the local @roo-code/types paths override; eslint .
--ext=ts --max-warnings=0 exit 0; prettier --check clean on all five files and on the
current refs/pull/1932/merge (9dcf3d8, 0 dirty); eslint-suppressions.json untouched;
it( 65 -> 68, 95 -> 98, 9 -> 11, no removals.1 parent cda6aea commit 694bed4
5 files changed
Lines changed: 291 additions & 22 deletions
File tree
- src
- core/tools
- __tests__
- integrations/editor
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
| 288 | + | |
288 | 289 | | |
289 | | - | |
| 290 | + | |
290 | 291 | | |
291 | 292 | | |
292 | 293 | | |
| |||
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
300 | | - | |
| 301 | + | |
301 | 302 | | |
302 | | - | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
315 | 318 | | |
| 319 | + | |
316 | 320 | | |
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
320 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
321 | 332 | | |
322 | 333 | | |
323 | 334 | | |
| |||
409 | 420 | | |
410 | 421 | | |
411 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
412 | 430 | | |
413 | 431 | | |
414 | 432 | | |
| |||
442 | 460 | | |
443 | 461 | | |
444 | 462 | | |
445 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
446 | 469 | | |
447 | 470 | | |
448 | 471 | | |
| |||
477 | 500 | | |
478 | 501 | | |
479 | 502 | | |
480 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
481 | 511 | | |
482 | 512 | | |
483 | 513 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
198 | 233 | | |
199 | 234 | | |
200 | 235 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
954 | 954 | | |
955 | 955 | | |
956 | 956 | | |
957 | | - | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
958 | 964 | | |
959 | 965 | | |
960 | 966 | | |
| |||
968 | 974 | | |
969 | 975 | | |
970 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
971 | 983 | | |
972 | 984 | | |
973 | 985 | | |
| |||
1002 | 1014 | | |
1003 | 1015 | | |
1004 | 1016 | | |
1005 | | - | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1006 | 1023 | | |
1007 | 1024 | | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1008 | 1043 | | |
1009 | 1044 | | |
1010 | 1045 | | |
| |||
1341 | 1376 | | |
1342 | 1377 | | |
1343 | 1378 | | |
1344 | | - | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
1345 | 1404 | | |
1346 | 1405 | | |
1347 | 1406 | | |
| |||
1598 | 1657 | | |
1599 | 1658 | | |
1600 | 1659 | | |
1601 | | - | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
1602 | 1663 | | |
1603 | 1664 | | |
1604 | 1665 | | |
1605 | 1666 | | |
1606 | 1667 | | |
1607 | 1668 | | |
1608 | 1669 | | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1609 | 1685 | | |
1610 | 1686 | | |
1611 | 1687 | | |
| |||
1634 | 1710 | | |
1635 | 1711 | | |
1636 | 1712 | | |
1637 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
1638 | 1720 | | |
1639 | 1721 | | |
1640 | 1722 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
| |||
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | 357 | | |
360 | 358 | | |
361 | 359 | | |
362 | 360 | | |
363 | 361 | | |
364 | 362 | | |
365 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
| |||
1065 | 1075 | | |
1066 | 1076 | | |
1067 | 1077 | | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1068 | 1085 | | |
1069 | 1086 | | |
1070 | 1087 | | |
1071 | | - | |
| 1088 | + | |
1072 | 1089 | | |
1073 | 1090 | | |
1074 | 1091 | | |
1075 | 1092 | | |
1076 | 1093 | | |
1077 | | - | |
1078 | 1094 | | |
1079 | | - | |
| 1095 | + | |
1080 | 1096 | | |
1081 | 1097 | | |
1082 | 1098 | | |
| |||
1100 | 1116 | | |
1101 | 1117 | | |
1102 | 1118 | | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
1103 | 1133 | | |
1104 | 1134 | | |
1105 | 1135 | | |
| |||
1364 | 1394 | | |
1365 | 1395 | | |
1366 | 1396 | | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
1367 | 1402 | | |
1368 | 1403 | | |
1369 | 1404 | | |
| |||
0 commit comments