Summary
In parallel mode each visible task runs in its own webview (its own ClineProvider instance), but all instances share a single global state store. Settings such as mode, currentApiConfigName, and apiConfiguration are therefore written globally: a switch in one view leaks into every other view, and restoring a task from history rewrites the shared global mode for all views.
This change gives every ClineProvider instance a per-view identity and a durable per-view state bucket:
- Per-view identity — every provider instance owns a unique
viewId (renderContext plus a monotonic counter) and registers a stable viewStateId (sanitized; __proto__ rejected) under which its state is persisted.
- Durable per-view storage — a new
viewStates global-state key holds a map from view id to that view's non-secret mode / currentApiConfigName / apiConfiguration overrides. Writes go through a serialized queue so concurrent provider instances merge without lost updates, and the map is pruned to the newest 50 entries.
- View-local restore — reopening a task from history now pins the restored mode into the view-local buffer (persisted durably) instead of writing the shared global
mode.
The in-memory viewLocalState buffer continues to feed postStateToWebview; getState() merging of hydrated per-view values arrives in a follow-up.
Context
Part of the durable per-view state series tracked in easonLiangWorldedtech#41 (fix unit F1a of the F1 → F1a/F1b/F1c split).
Reproduction (before)
- Open two task views in parallel mode.
- Switch the mode in one view (e.g. Code → Architect).
- The other view's mode follows the change — the switch leaked through shared global state.
Expected (after)
Each view keeps its own mode and API configuration; switching in one view no longer affects the other, and the restored mode of a reopened task is pinned to that view only.
Summary
In parallel mode each visible task runs in its own webview (its own
ClineProviderinstance), but all instances share a single global state store. Settings such asmode,currentApiConfigName, andapiConfigurationare therefore written globally: a switch in one view leaks into every other view, and restoring a task from history rewrites the shared global mode for all views.This change gives every
ClineProviderinstance a per-view identity and a durable per-view state bucket:viewId(renderContextplus a monotonic counter) and registers a stableviewStateId(sanitized;__proto__rejected) under which its state is persisted.viewStatesglobal-state key holds a map from view id to that view's non-secretmode/currentApiConfigName/apiConfigurationoverrides. Writes go through a serialized queue so concurrent provider instances merge without lost updates, and the map is pruned to the newest 50 entries.mode.The in-memory
viewLocalStatebuffer continues to feedpostStateToWebview;getState()merging of hydrated per-view values arrives in a follow-up.Context
Part of the durable per-view state series tracked in easonLiangWorldedtech#41 (fix unit F1a of the F1 → F1a/F1b/F1c split).
Reproduction (before)
Expected (after)
Each view keeps its own mode and API configuration; switching in one view no longer affects the other, and the restored mode of a reopened task is pinned to that view only.