Repository navigation
Commit 21cc345
committed
test(webview): prove the rollback reaches storage and never publishes to the view-local buffer
CodeRabbit's review of head 4bf26f1 (run 130412734156, finished 2026-11-11T08:38:27Z, unprompted:
no trigger comment of mine preceded it) posted two actionable rows on the test added by that commit.
Row 4535691396, Major, Maintainability & Code Quality, source: path instructions, asked for the shared
durable value to be asserted and not only the proxy cache. Row 4535691402, same severity and source,
asked for the view-local buffer to be asserted as well. Both are right for this repository: the
persisted-setting checklist requires the persistence leg to be tested, and this unit's contract is
that the per-view record is persisted before the local buffer is advanced. Neither needed a production
change: the assertions pass against the shipped code, which is what makes them worth pinning.
Why the durable assertion is not a restatement of the cache assertion: ContextProxy.updateGlobalState
sets the cache and then awaits globalState.update, and ClineProvider.setValues awaits that shared write
before the per-view write, so storage really did hold "profile-a" when the per-view write rejected.
Rather than infer that, the storage double now records the durable profile value at the instant it
rejects and the test asserts it was "profile-a", so the rollback below is a rollback of a value that
moved and not a no-op over a key that never left the cache. The assertion after the rejection then
proves the restore reached storage through contextProxy.setValues, which is the only path that would
leave a stale profile behind after a reload.
The buffer assertion pins the ordering rather than fixing a live defect: _saveViewLocalStateFromMutation
awaits _persistViewLocalStateFromMutation before _updateViewLocalStateFromMutation, so a failed durable
write cannot leave viewLocalState holding the profile, and the test now fails if anyone moves that
await. It asserts hasOwn rather than the value because the shipped invalidation deletes the key, so a
buffer left holding an explicit undefined would also be a divergence.
Legs: pnpm --dir src exec vitest run --config vitest.core.config.ts
core/webview/__tests__/ClineProvider.persistedViewState.spec.ts -> 14 passed (14). eslint
--prune-suppressions --max-warnings=0 on this file exits 0 and this file has no entry in
src/eslint-suppressions.json before or after the run; the command rewrites that file in place on every
run and it was checked out from HEAD again, which also keeps the repository-root format check green
(the rewritten JSON is not prettier-clean). tsc --noEmit for src exits 0. prettier --write on this file
from the repository directory reports it unchanged and prettier --check . exits 0.
Still 6 of 500 for packages/types and 491 of 500 for src with 0 advisories above merge base
53cb5b5, re-measured in worktree mode before this commit and in
committed mode after it: packageForPath excludes *.spec.ts, so a test file costs nothing against the
cap, and ClineProvider.ts is untouched here.1 parent 4bf26f1 commit 21cc345
1 file changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| 162 | + | |
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
| |||
171 | 176 | | |
172 | 177 | | |
173 | 178 | | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
| |||
467 | 473 | | |
468 | 474 | | |
469 | 475 | | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
470 | 481 | | |
471 | | - | |
472 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
473 | 486 | | |
| 487 | + | |
474 | 488 | | |
| 489 | + | |
475 | 490 | | |
476 | 491 | | |
477 | 492 | | |
0 commit comments