Tracking series: vps2 durable per-view state ??easonLiangWorldedtech#41 (fix unit F1a).
Fix: draft PR #1546 (this issue is the issue of record for that PR, created at PR-open time).
Summary
As of upstream/main @ 0d937c0, ClineProvider has no per-view state identity: every view (sidebar, "Open in editor" tab, popout panel) reads and writes the same global mode / currentApiConfigName / apiConfiguration keys, and nothing is persisted per view. State changes in one view are visible in every other view, and nothing is reliably rehydrated after a reload.
Symptoms (verified at upstream/main 0d937c0)
- Shared global keys: mode, API profile and apiConfiguration live under single global keys; a second view shows (and edits) the sidebar's state.
- No per-view durable record: there is no
viewStates record keyed by view identity, so per-view state does not survive a reload.
- Cross-view reset / restore leaks:
resetState and history restore write the shared global mode, affecting other open views instead of only the acting view.
- Wedge on unacknowledged posts:
postMessageToWebview awaits the webview ack; a remounted or disposed page never acknowledges, so task-critical callers can wedge.
Impact
User state leaks across views (one view's mode change, reset or restore changes what every other view sees), per-view state does not survive reload, and a remounted webview can stall task-critical message flows.
- Per-view identity: each
ClineProvider owns a unique viewId (renderContext plus a monotonic counter) and registers a stable viewStateId for durable persistence; entries rekey from the temporary id to the stable id on registration.
- Durable core: a
viewStates map (new GLOBAL_STATE_KEYS entry) persisted through a serialized write queue (concurrent instances merge without lost updates), pruned to the newest 50 entries; __proto__ ids are rejected so a per-view entry can never be keyed through the Object.prototype setter.
- View-local buffer (
viewLocalState): saveViewState / loadViewState / getValues / setValue / setValues hold mode / currentApiConfigName / apiConfiguration (the non-secret subset) per view; persistence is awaited before a save is reported successful; unknown modes are ignored with a log and non-string modes pass through.
- History restore falls back to the default mode view-locally instead of writing the shared global mode.
postMessageToWebview no longer awaits the webview ack.
resetState clears the view-local buffer and the view's persisted entry.
Tracking series: vps2 durable per-view state ??easonLiangWorldedtech#41 (fix unit F1a).
Fix: draft PR #1546 (this issue is the issue of record for that PR, created at PR-open time).
Summary
As of upstream/main @ 0d937c0,
ClineProviderhas no per-view state identity: every view (sidebar, "Open in editor" tab, popout panel) reads and writes the same globalmode/currentApiConfigName/apiConfigurationkeys, and nothing is persisted per view. State changes in one view are visible in every other view, and nothing is reliably rehydrated after a reload.Symptoms (verified at upstream/main 0d937c0)
viewStatesrecord keyed by view identity, so per-view state does not survive a reload.resetStateand history restore write the shared global mode, affecting other open views instead of only the acting view.postMessageToWebviewawaits the webview ack; a remounted or disposed page never acknowledges, so task-critical callers can wedge.Impact
User state leaks across views (one view's mode change, reset or restore changes what every other view sees), per-view state does not survive reload, and a remounted webview can stall task-critical message flows.
Fix (PR #1546)
ClineProviderowns a uniqueviewId(renderContext plus a monotonic counter) and registers a stableviewStateIdfor durable persistence; entries rekey from the temporary id to the stable id on registration.viewStatesmap (newGLOBAL_STATE_KEYSentry) persisted through a serialized write queue (concurrent instances merge without lost updates), pruned to the newest 50 entries;__proto__ids are rejected so a per-view entry can never be keyed through theObject.prototypesetter.viewLocalState):saveViewState/loadViewState/getValues/setValue/setValuesholdmode/currentApiConfigName/apiConfiguration(the non-secret subset) per view; persistence is awaited before a save is reported successful; unknown modes are ignored with a log and non-string modes pass through.postMessageToWebviewno longer awaits the webview ack.resetStateclears the view-local buffer and the view's persisted entry.