Skip to content

Commit ddda5ce

Browse files
test(webview): pin what each store holds when a registration write fails
The existing case already proves the rolled-back id and the later retry. It did not say anything about what the two stores hold in the interval, which is the half that a compensating-write question turns on. Three assertions now pin it: the durable record still keys the entry under the temporary id with its mode intact, the stable key was never created durably, and the payload ContextProxy holds for viewStates is the same map the durable store holds - so a registration that was rolled back cannot be visible through one store and invisible through the other. Control for the new assertions, run rather than described: make the failing write partially durable - apply the value to globalState, then reject - and exactly one test in core/webview fails, at Test Files 1 failed | 33 passed (34), Tests 1 failed | 955 passed (956), and it is this case, so the pins have teeth. The removal control on the behaviour itself: delete the rollback line at ClineProvider.ts:973 and core/webview goes red at Test Files 1 failed | 33 passed (34), Tests 13 failed | 943 passed (956), thirteen cases, which is the rollback being load-bearing rather than this assertion being fussy. With production restored: 34 files, 956 tests, 0 failures; tsc exit 0; eslint --max-warnings=0 exit 0; prettier --check exit 0; suppressions untouched. Test-only, and excluded from the mutation bucket by scripts/stryker-diff.mjs:85. Note for whoever reads this next: this PR has no compensating write on the re-key path at all (rekeyPersistedViewStateEntry at ClineProvider.ts:813-857 issues one write and rolls nothing back), so these pins hold the interval on the shape that exists here rather than claiming the shape of #2226's fix, which is tracked separately on the board.
1 parent 0a77cf8 commit ddda5ce

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/core/webview/__tests__/ClineProvider.spec.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5785,6 +5785,15 @@ describe("ClineProvider", () => {
57855785
// guard early-returning for an id that was never persisted.
57865786
expect(provider["viewStateId"]).toBe(provider.viewId)
57875787

5788+
// Pin what the failure left in each store: the durable record still keys the entry under
5789+
// the temporary id (the re-key wrote nothing durable), and the payload ContextProxy holds for
5790+
// viewStates is the same map the durable store holds, so a rolled-back registration cannot be
5791+
// visible through one store and invisible through the other.
5792+
const durableAfterFailure = mockContext.globalState.get("viewStates") as Record<string, { mode?: string }>
5793+
expect(durableAfterFailure[provider.viewId]?.mode).toBe("architect")
5794+
expect(durableAfterFailure["stable-sidebar-view"]).toBeUndefined()
5795+
expect(provider.contextProxy.getValue("viewStates")).toEqual(durableAfterFailure)
5796+
57885797
// A later retry succeeds once the storage write works again, and the
57895798
// pre-launch entry lands under the registered id.
57905799
setValueSpy.mockRestore()

0 commit comments

Comments
 (0)