Skip to content

[BUG] Per-view state lost on extension reload — no durable persistence #967

Description

@easonLiangWorldedtech

Problem

PR #966 introduced per-view state isolation (viewLocalState buffer), but this state is stored only in memory. On extension reload, all view-specific values are lost and fall back to shared global defaults.

This creates a "quiet reset" — worse than not having the feature at all:

  • User opens tab A → selects mode architect, API config my-profile
  • Extension reloads (e.g., VS Code restart, extension update)
  • Tab A restores with shared global values (e.g., mode default, API config roo-code)
  • User sees stale/wrong state without any indication that a reset occurred

Current Architecture

User Action → viewLocalState[key] = value  (in-memory buffer only)
                                    ↓
                         No write to durable storage
                                    ↓
Extension Reload → viewLocalState cleared → fallback to global defaults

loadViewState() reads from contextProxy.globalState, but per-view keys (__view_state_{id}_mode) are not included in GLOBAL_STATE_KEYS, so they're never restored.

Impact

Scenario Before PR #966 After PR #966 (current)
Single tab, no reload ✅ Works ✅ Works
Parallel tabs, no reload ✅ Independent state ✅ Independent state
Extension reload N/A (no per-view state) Stale values — worse than before

Proposed Fix

Store per-view state in vscode.workspaceState (or a dedicated durable key in contextProxy.globalState) so that:

  1. View-specific mode/API config survives extension reload
  2. loadViewState() can restore the correct values on startup
  3. Parallel tabs maintain independent persistent state across restarts

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions