Skip to content

Detect, surface, and recover orphaned Copilot Chat sessions from moved/renamed/deleted workspaces #305818

Description

Problem

VS Code stores Copilot Chat sessions under workspaceStorage/<hash>/chatSessions/, where the hash is derived from the workspace folder URI. When a workspace folder is moved, renamed, or deleted, VS Code creates a new hash on next open — making all prior chat sessions permanently inaccessible through the UI. There is no mechanism to:

  1. Discover orphaned chat data (workspace hashes whose folder no longer exists on disk)
  2. Browse those sessions (they remain invisible in the Chat view)
  3. Migrate sessions to the current workspace hash after a folder move/rename

Real-World Impact

Orphaning happens through routine project management: renaming a folder, moving a project to a different drive, reorganizing a workspace directory, or deleting a folder after archiving. Each of these silently severs the link between VS Code and its stored chat sessions. Over time, a significant percentage of a user's workspaceStorage entries can become orphaned — containing hours of valuable Copilot conversations that are completely invisible in the UI.

Proposed Solution

  1. Orphan Detection: On startup or via a command, scan workspaceStorage for entries whose workspace.json folder URI points to a path that no longer exists. Surface these in the Chat history panel with a visual indicator (e.g., ⚠️ Workspace not found).

  2. Orphaned Session Browser: Allow users to browse and read chat sessions from orphaned workspaces, even if the original folder is gone. The JSONL session files are fully self-contained and readable without the workspace context.

  3. Session Migration / Re-linking: When a user opens a folder that appears to match an orphaned workspace (same folder name, similar path), offer to migrate or link the old chat sessions to the new workspace hash.

  4. Global Chat History View: A centralized view showing all chat sessions across all workspaces (active and orphaned), similar to how "Recent Workspaces" shows all known workspaces. This directly supports the goal outlined in Unified management for persisted Copilot Chat history across different workspace contexts #285106.

Implementation Notes

  • Each workspaceStorage/<hash>/workspace.json contains the original folder URI (e.g., {"folder":"file:///c%3A/Users/.../MyProject"}). Orphan detection is simply: decode the URI, check if the path exists on disk.
  • Chat session JSONL files are fully self-contained: kind:0 records hold session metadata (creationDate, sessionId, requests), kind:1 records hold key-value pairs like customTitle, and kind:2 records hold incremental request/response data. No workspace context is needed to render them.
  • A StreamReader-based approach reading only the first ~200 lines of each JSONL is sufficient to extract title and metadata without loading full conversation history — useful for building a lightweight index.
  • Folder-name matching (comparing the last path segment of the orphaned URI against currently open folders) is a simple heuristic for suggesting re-linking candidates.
  • The community has already built external tools to address parts of this gap — vscdb-fix repairs corrupted state.vscdb indices and detects cross-workspace orphans, and copilot-chat-history provides a browsing UI — but neither is integrated into VS Code itself, and neither fully addresses orphaned workspace recovery.

Related Issues

Environment

  • VS Code Version: 1.101+
  • OS: Windows 11

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions