Repository navigation
Commit ec54bce
committed
fix(webview): roll back custom-mode registrations that fail partway through a batch
createTask captured the pre-batch snapshot of the mode slugs it was about to install and
registered the batch's modes before the try block, so a registration that threw halfway (mode
2 of 3) escaped to the outer catch and none of the rollback ran: mode 1 stayed installed,
either having overwritten a saved definition or added a slug the batch never finished using.
The registration loop now runs inside the try, ahead of setValues, so the existing rollback -
restore the captured definitions, remove the slugs this batch introduced, rethrow - covers it.
(src/core/webview/ClineProvider.ts: the registration block was at 5013-5016 outside the try at
5019; it now sits at 5015-5021 inside it. 6253 -> 6255 lines.)
Test: a new case in the buffer/rollback describe hands createTask two modes - one whose slug
already exists under a different definition, one brand new - and rejects the second
registration. It asserts the whole call sequence, so the restore cannot be confused with the
registration: existing-mode/Overridden, new-mode/New, existing-mode/Existing, then that the
new slug was removed through removeCustomModeEntry (never the saved slug) and that setValues
never ran. Before the change the sequence stops at two entries.
The pre-existing sibling case ("should remove a custom mode the batch registered when the
batch fails") had the same blind spot: it re-registered the identical object it had
snapshotted, so its restore assertion was satisfied by the registration call. It now hands in
an overridden definition and asserts against the snapshot, which is the assertion it was meant
to make. Strengthened, not weakened: emptying the rollback restore loop now fails it where it
previously passed.
Controls (ClineProvider.ts snapshotted at cafa6bc and restored by content hash after each):
hoisting the registration back above the try fails the new case only (expected [ ...2 ] to
deeply equal [ ...3 ]); moving it below setValues fails the new case through the setValuesSpy
guard; emptying the restore loop fails both rollback cases; emptying the removal loop fails
both through the removeCustomModeEntry guard.
Gates: prettier --check clean; tsc --noEmit -p . clean; eslint --max-warnings=0 clean on both
files; vitest core/webview + core/config 44 files / 1285 tests green (1284 before, +1 case).
Scope unchanged at 751 extension-package executable lines (types 8): the change moves existing
lines and adds coverage only.1 parent 877ea0a commit ec54bce
2 files changed
Lines changed: 62 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5008 | 5008 | | |
5009 | 5009 | | |
5010 | 5010 | | |
5011 | | - | |
5012 | | - | |
5013 | | - | |
5014 | | - | |
5015 | | - | |
5016 | | - | |
5017 | | - | |
| 5011 | + | |
| 5012 | + | |
5018 | 5013 | | |
5019 | 5014 | | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
5020 | 5022 | | |
5021 | 5023 | | |
5022 | 5024 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6949 | 6949 | | |
6950 | 6950 | | |
6951 | 6951 | | |
6952 | | - | |
| 6952 | + | |
| 6953 | + | |
| 6954 | + | |
| 6955 | + | |
6953 | 6956 | | |
6954 | 6957 | | |
6955 | 6958 | | |
6956 | | - | |
| 6959 | + | |
6957 | 6960 | | |
6958 | 6961 | | |
6959 | 6962 | | |
| |||
6965 | 6968 | | |
6966 | 6969 | | |
6967 | 6970 | | |
6968 | | - | |
| 6971 | + | |
6969 | 6972 | | |
6970 | 6973 | | |
6971 | 6974 | | |
6972 | 6975 | | |
6973 | 6976 | | |
| 6977 | + | |
| 6978 | + | |
| 6979 | + | |
| 6980 | + | |
| 6981 | + | |
| 6982 | + | |
| 6983 | + | |
| 6984 | + | |
| 6985 | + | |
| 6986 | + | |
| 6987 | + | |
| 6988 | + | |
| 6989 | + | |
| 6990 | + | |
| 6991 | + | |
| 6992 | + | |
| 6993 | + | |
| 6994 | + | |
| 6995 | + | |
| 6996 | + | |
| 6997 | + | |
| 6998 | + | |
| 6999 | + | |
| 7000 | + | |
| 7001 | + | |
| 7002 | + | |
| 7003 | + | |
| 7004 | + | |
| 7005 | + | |
| 7006 | + | |
| 7007 | + | |
| 7008 | + | |
| 7009 | + | |
| 7010 | + | |
| 7011 | + | |
| 7012 | + | |
| 7013 | + | |
| 7014 | + | |
| 7015 | + | |
| 7016 | + | |
| 7017 | + | |
| 7018 | + | |
| 7019 | + | |
| 7020 | + | |
| 7021 | + | |
| 7022 | + | |
| 7023 | + | |
6974 | 7024 | | |
6975 | 7025 | | |
6976 | 7026 | | |
| |||
0 commit comments