Repository navigation
Description
Gap
At the F3 head of the stack, resetState (reset / new task) and the settings import invalidate only the calling instance's per-view state. Sibling tabs holding live ClineProvider instances keep stale view-local state — mode, currentApiConfigName, provider profile — after a reset or settings import performed from another tab, so stale per-view entries remain in the global viewStates and keep driving stale mode/profile presentation in those tabs.
Upstream provenance
- Upstream issue: [BUG] Invalidate per-view state after reset and settings import #980 ("[BUG] Invalidate per-view state after reset and settings import") — closed/superseded by the vps2 series.
- Port source: upstream PR fix(webview): invalidate per-view state after reset and import #981 (fix(webview): invalidate per-view state after reset and import) — closed draft, superseded by the vps2 series; the [BUG] GPT-5.5 Codex uses incorrect context window #41 ledger names fix(webview): invalidate per-view state after reset and import #981 as the F4 port source. CS (e9a44b2) does NOT contain the cross-instance part — the parallelMode spec describes are ported from the CS copy (source of record for the spec).
Fix unit
vps2 F4 of the durable per-view state series (fork tracking issue easonLiangWorldedtech#41). Draft PR: #1562 (branch vps2/f4-cross-instance-reset, stacked on the F3 head 8da5c6e; head 80c147f) — #1562
Fix scope (5 files, 342 insertions / 1 deletion = a+d 343 measured vs the F3 head)
- src/core/webview/ClineProvider.ts — the broadcastResetToAllInstances() method (per-instance _clearViewLocalState + one global contextProxy.setValue("viewStates", undefined) write — the single write-queue clear — + sibling postStateToWebview) and its wiring into resetState before the final postStateToWebview().
- src/core/config/importExport.ts — ImportWithProviderOptions gains the optional broadcastResetToAllInstances(): Promise; importSettingsWithFeedback calls it in a guarded try/catch after the settingsImportedAt write (a broadcast failure never fails the import; console.warn on failure).
- src/core/config/tests/importExport.spec.ts — 3 new tests: broadcast on successful import; skip when the callback is missing (with a console.warn negative assertion that pins the guarded call); import result kept successful when the broadcast throws.
- src/core/webview/tests/ClineProvider.parallelMode.spec.ts — the multi-instance + _clearViewLocalState describes appended from the CS copy (116 lines: CS L1674-L1789 — the blank separator + the two describes — byte-identical; 5 new tests).
- src/core/webview/tests/ClineProvider.spec.ts — (a) the forward fix of the F3 resetState sentinel: F4's single global viewStates clear removes the key (real VS Code Memento semantics: update(key, undefined) deletes the key), so the F3-era toEqual({}) expectation becomes toBeUndefined() — the test intent (no persisted per-view entry after reset) is preserved and satisfied more strongly; (b) one new multi-instance test pinning broadcastResetToAllInstances (a sibling's view-local state is cleared by another instance's resetState; each instance receives exactly one state post — the caller only its final post): gate-required, the fix(webview): invalidate per-view state after reset and import #981/CS port alone left 5 surviving mutants on the broadcast path.
Series note
Draft PR; this unit is the 6th of the merge chain (F1a to F1b to F1c to F2 to F3 to F4 to F5 to F6 to F7). The PR body documents the CS not-ported register, the port-fidelity verification, the budget measurement, and the mutation-diff gate. No Closes/Fixes/Resolves linkage — this issue is the series gap record for the unit.
Activity
easonLiangWorldedtech commentedon Nov 18, 2026
FOLLOW-UP ITEM FROM #1562, ROUND 9 (written so a maintainer can pick it up without re-reading the review).
This issue is the one linked by Closes in #1562, so it is the right shelf for the two items that #1562 measured and is not shipping in this unit, plus the pointer to the undecided design question.
A. Keep the stable view ID when host recovery replaces an editor panel. Review comment 4610777426 on #1562, coderabbitai, Major, Heavy lift, against src/core/webview/ClineProvider.ts:1171 on head c9dd5cc. Measured ownership: the enclosing method setViewStateId is absent from trunk 75a93a9, so the code is the unit's own; the finding is not a regression the unit introduced but a capability the code does not have.
Hazard: host recovery builds a new webview panel on the existing provider and disposes the old one. VS Code does not carry getState data into the new panel, so the new renderer generates a different view ID and sends it on launch. Registration migrates only temporary entries, the new ID has no saved selection, and the load replaces the existing buffer with an empty one, so an idle recovered view falls back to the shared profile instead of its own pinned profile.
Acceptance criteria: (1) a panel that is recreated by host recovery for an existing view keeps the previously stable view ID, and the durable per-view selection is found under that ID after the recovery launch; (2) a genuinely new panel still gets a fresh ID, so two live views never share a key; (3) the migration is proven by a test that exercises the recovery path and not by a comment; (4) no per-view write is performed under an ID that a live renderer no longer owns.
B. Invalidate live view state when the initial shared reset fails partway. Review comment 4610777527 on #1562, coderabbitai, Major, Heavy lift, against src/core/webview/ClineProvider.ts:6387 on the same head. Measured ownership: resetState exists in trunk at 33 lines and at 70 lines on this head, so the unit rewrote the method; the gap the reviewer names is inside this issue's own subject, which is invalidating per-view state after a reset or an import.
Hazard: resetAllState clears both caches before the individual storage deletions run. If one deletion rejects, other deletions can already have succeeded. That call sits outside the error boundary that posts the invalidation, so sibling views keep serving pre-reset modes, profiles and credentials after a partial reset.
Acceptance criteria: (1) the initial shared reset participates in the same invalidation path the later reset and import paths use; (2) writes that already started are allowed to settle before views are refreshed, so the refresh cannot be overwritten by a late write; (3) the original reset error is the error the caller sees, not the invalidation error; (4) a test shows a sibling view that no longer reports pre-reset state after a partial reset, and shows that a sibling which has begun teardown is not written into.
Where it lands is a stack-size decision rather than a technical one: the advisory on #1562 measures 2,531 changed executable lines against a 500 line limit, so this item is scheduled either as the next hunk set on #1562 or as its own unit, and the answer is recorded in the #1562 round log.
C. The undecided write-revision question, tracked on #2488. Three review comments on the same head are this one question arriving on three legs, and none of them is decided by this unit: 4610777478 asks the undo path to compare the saved profile in its persisted form; 4610777485 asks the deletion compensation to wait for the replacement activation to finish rather than for its 30 second caller timeout, where the timeout is PENDING_OPERATION_TIMEOUT_MS at ClineProvider.ts:384, the race and abort at 407 and 413, and the activation's single AbortSignal check at 4443 which is before the write fan-out at 4480; and 4610777520 asks compensation to undo sibling writes that already completed when a later sibling fails, which is reconciliation from a committed and a failed list. This unit ships intra-window settle-before-decide for the activation fan-out and claims nothing beyond it.
fix(webview): close the four hunk-class findings at 6d1ce95
fix(webview): close the four hunk-class findings at 6d1ce95