Repository navigation
Commit 96c9157
committed
fix(config): tell an unreadable mode file from an absent one before registering a batch
The Zoo-Code-Org#2236 row objects to a rollback snapshot that cannot distinguish 'there was nothing to restore'
from 'I could not read what to restore'. loadModesFromFile returned [] for every non-success path:
ENOENT into its catch, corrupt YAML through parseYamlSafely returning an empty object, and a
schema-validation failure after its toast. getCustomModeDefinitions passed that straight into
ClineProvider.createTask's snapshot, so a corrupt definition file looked exactly like an empty one,
registration went ahead, and the rollback had nothing to restore.
The loader now reports an outcome -- absent, unreadable, invalid or ok -- and getCustomModeDefinitions
returns { definitions, failures }, each failure naming the path that produced it. An absent file is an
empty definition list with no failure, which is a legitimate thing to register against; unreadable and
invalid are failures, and createTask refuses the batch before any write when there is one. The merged
read behind getCustomModes still receives [] from every failure case, so its behaviour and its toasts
are unchanged, and parsedAtAll honours the .roomodes JSON fallback parseYamlSafely relies on, so a
.roomodes that is valid JSON but not valid YAML stays readable instead of becoming a new refusal.
What a refused registration does to the task, because this is behavioural in a ClineProvider write
path: createTask rejects before either definition file is touched. Nothing is registered, nothing is
removed, setValues does not run, and no task is constructed -- it does not carry on with the definitions
it did manage to read. The assertions that pin that are
expect(manager.updateCustomMode).not.toHaveBeenCalled() and expect(setValuesSpy).not.toHaveBeenCalled()
against the same call as the rejects. The second new case pins the other side: an empty snapshot with
no failure (an absent file) still registers, so a missing file does not become a refusal.
Measured in one run; the numstat line below is from git show of this commit in the same run.
Controls keep every case and take production files from 41bd742:
both production files at 41bd742, manager suite Test Files 1 failed (1) Tests 3 failed | 50 passed (53) (exit 1)
both production files at 41bd742, provider suite Test Files 1 failed (1) Tests 5 failed | 380 passed (385) (exit 1)
provider file at 41bd742 only, provider suite Test Files 1 failed (1) Tests 5 failed | 380 passed (385) (exit 1)
manager file at 41bd742 only, manager suite Test Files 1 failed (1) Tests 3 failed | 50 passed (53) (exit 1)
This commit's shapes:
manager suite Test Files 1 passed (1) Tests 53 passed (53) (exit 0) provider suite Test Files 1 passed (1) Tests 385 passed (385) (exit 0)
whole core/config Test Files 10 passed (10) Tests 324 passed (324) (exit 0) whole core/webview Test Files 34 passed (34) Tests 970 passed (970) (exit 0)
tsc --noEmit -p . exit 0, eslint --max-warnings=0 --no-warn-ignored exit 0, prettier --check 0,0,0,0 on the committed sources and 0 on the committed suppressions file; the same invocation reports 0,0,0,0 for the four HEAD copies. The pre-commit and commit-msg hooks executed with the content commit (lint-staged ran over the four staged sources); the message-only amend that follows had nothing staged for lint-staged.
Diff 116/40 in CustomModesManager.ts, 55/0 in CustomModesManager.spec.ts, 16/3 in ClineProvider.ts, 70/3 in ClineProvider.spec.ts, 2/2 in eslint-suppressions.json -- 307 changed lines, 175 of them in executable production code.
Three existing cases (ClineProvider.spec.ts:6966, 7006, 7042) were re-pointed from the array-returning
reader to the outcome-returning reader; their assertions are untouched, and the provider-only control
above shows they go red without the provider change rather than passing quietly.
Two no-explicit-any counts went 5 -> 4, for core/config/CustomModesManager.ts and core/config/__tests__/ContextProxy.spec.ts.
CustomModesManager.ts drops the dead alreadyHandled branch (parseYamlSafely never throws). The ContextProxy.spec.ts
entry was already stale at 677e5e3 -- --prune-suppressions against that commit writes 4 for it -- and this
commit carries the correction because eslint exits 2 while an old count stands. Both edits were made by hand
because --prune-suppressions leaves the same per-file numbers but rewrites all 1441 lines of
eslint-suppressions.json. After the edit the file reads CustomModesManager.ts {"@typescript-eslint/no-explicit-any":{"count":4}}, ClineProvider.ts {"@typescript-eslint/no-explicit-any":{"count":7}}, CustomModesManager.spec.ts {"@typescript-eslint/no-explicit-any":{"count":12}}, ClineProvider.spec.ts {"@typescript-eslint/no-explicit-any":{"count":195}}, nothing else moved, and eslint
exits 0 against it (it exits 2 while the old counts stand).1 parent 677e5e3 commit 96c9157
5 files changed
Lines changed: 259 additions & 48 deletions
File tree
- src
- core
- config
- __tests__
- webview
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
46 | 60 | | |
47 | 61 | | |
48 | 62 | | |
| |||
180 | 194 | | |
181 | 195 | | |
182 | 196 | | |
183 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
184 | 205 | | |
185 | | - | |
186 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
187 | 220 | | |
188 | | - | |
189 | | - | |
190 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
191 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
192 | 239 | | |
193 | | - | |
| 240 | + | |
194 | 241 | | |
195 | | - | |
196 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
197 | 245 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
203 | 250 | | |
204 | | - | |
205 | | - | |
| 251 | + | |
206 | 252 | | |
207 | | - | |
208 | | - | |
| 253 | + | |
| 254 | + | |
209 | 255 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
213 | 261 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 262 | + | |
221 | 263 | | |
222 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
223 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
224 | 280 | | |
225 | 281 | | |
226 | 282 | | |
| |||
358 | 414 | | |
359 | 415 | | |
360 | 416 | | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
361 | 421 | | |
362 | | - | |
| 422 | + | |
363 | 423 | | |
364 | 424 | | |
365 | | - | |
366 | 425 | | |
367 | | - | |
368 | 426 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
377 | 453 | | |
378 | 454 | | |
379 | 455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
828 | 828 | | |
829 | 829 | | |
830 | 830 | | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
831 | 886 | | |
832 | 887 | | |
833 | 888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
5005 | 5005 | | |
5006 | 5006 | | |
5007 | 5007 | | |
5008 | | - | |
| 5008 | + | |
5009 | 5009 | | |
5010 | 5010 | | |
5011 | 5011 | | |
5012 | | - | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
5013 | 5026 | | |
5014 | 5027 | | |
5015 | 5028 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6963 | 6963 | | |
6964 | 6964 | | |
6965 | 6965 | | |
6966 | | - | |
| 6966 | + | |
| 6967 | + | |
| 6968 | + | |
6967 | 6969 | | |
6968 | 6970 | | |
6969 | 6971 | | |
| |||
7003 | 7005 | | |
7004 | 7006 | | |
7005 | 7007 | | |
7006 | | - | |
| 7008 | + | |
7007 | 7009 | | |
7008 | 7010 | | |
7009 | 7011 | | |
| |||
7039 | 7041 | | |
7040 | 7042 | | |
7041 | 7043 | | |
7042 | | - | |
| 7044 | + | |
7043 | 7045 | | |
7044 | 7046 | | |
7045 | 7047 | | |
| |||
7071 | 7073 | | |
7072 | 7074 | | |
7073 | 7075 | | |
| 7076 | + | |
| 7077 | + | |
| 7078 | + | |
| 7079 | + | |
| 7080 | + | |
| 7081 | + | |
| 7082 | + | |
| 7083 | + | |
| 7084 | + | |
| 7085 | + | |
| 7086 | + | |
| 7087 | + | |
| 7088 | + | |
| 7089 | + | |
| 7090 | + | |
| 7091 | + | |
| 7092 | + | |
| 7093 | + | |
| 7094 | + | |
| 7095 | + | |
| 7096 | + | |
| 7097 | + | |
| 7098 | + | |
| 7099 | + | |
| 7100 | + | |
| 7101 | + | |
| 7102 | + | |
| 7103 | + | |
| 7104 | + | |
| 7105 | + | |
| 7106 | + | |
| 7107 | + | |
| 7108 | + | |
| 7109 | + | |
| 7110 | + | |
| 7111 | + | |
| 7112 | + | |
| 7113 | + | |
| 7114 | + | |
| 7115 | + | |
| 7116 | + | |
| 7117 | + | |
| 7118 | + | |
| 7119 | + | |
| 7120 | + | |
| 7121 | + | |
| 7122 | + | |
| 7123 | + | |
| 7124 | + | |
| 7125 | + | |
| 7126 | + | |
| 7127 | + | |
| 7128 | + | |
| 7129 | + | |
| 7130 | + | |
| 7131 | + | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
| 7136 | + | |
| 7137 | + | |
| 7138 | + | |
| 7139 | + | |
| 7140 | + | |
7074 | 7141 | | |
7075 | 7142 | | |
7076 | 7143 | | |
| |||
0 commit comments