Skip to content

[BUG] Invalidate per-view state after reset and settings import (vps2 F4; upstream #980) #1561

Description

@easonLiangWorldedtech

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

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)

  1. 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().
  2. 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).
  3. 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.
  4. 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).
  5. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions