I have sometimes lost all the state of my archived sessions when updating vscode. Copilot suggests that this is from UnusedWorkspaceStorageDataCleaner.
### Could it get cleared? **Yes — there's a real risk.**
The shared process runs `UnusedWorkspaceStorageDataCleaner` (`src/vs/code/electron-utility/sharedProcess/contrib/storageDataCleaner.ts`) ~30s after startup. For each folder under `workspaceStorage/`:
1. **Length check** — keeps folders whose name length === `NON_EMPTY_WORKSPACE_ID_LENGTH` (32, the MD5 length). `66dbeae8` is 8 chars → **not preserved**.
2. **Open-window check** — `windows.some(w => w.workspace?.id === folder)`. But on the **main side** the agents window's id is computed by `platform/workspaces/node/workspaces.ts`' `getWorkspaceIdentifier`, which uses MD5 (32 chars). So `window.workspace.id` for the agents window is **never** `66dbeae8` — this branch never matches.
3. **`isUsed` check** — returns true only if `StorageMainService` currently has an open `IStorageMain` whose `path` lives under that folder. That happens only when the agents window is actually open at the moment the cleaner fires.
So the only thing protecting `workspaceStorage/66dbeae8/` is having the agents window open within ~30s of Code launching. If you start Code Insiders without opening the agents window in a given session, ~30s later the cleaner will likely `rm -rf` that folder, taking with it everything stored under it (workbench state.vscdb, `chatSessions/`, `chatEditingSessions/`, `vscode-chat-images/`, testResults, etc. — see all the `joinPath(workspaceStorageHome, workspaceId, …)` sites).
This is worth fixing. Two cheap mitigations come to mind:
- Add the agent-sessions workspace id to the cleaner's preserve list (it can compute it from `environmentMainService.agentSessionsWorkspace`).
- Or normalize the agents-window workspace id between main and renderer so the existing `windows.some(…)` check matches when the window is open.
I'd recommend doing both (preserve unconditionally — the agents window is a permanent built-in surface, not a transient empty window).
I have sometimes lost all the state of my archived sessions when updating vscode. Copilot suggests that this is from
UnusedWorkspaceStorageDataCleaner.