VS Code sidebar loses all session history after restart — sessions-index.json not updated for new sidebar sessions

Open 💬 5 comments Opened Jun 9, 2026 by ChadGu

Description

When Claude Code conversations are started from the VS Code sidebar, the session history is not preserved after VS Code is closed and reopened. The sidebar appears blank on restart, and historical conversations are invisible even though their .jsonl files are fully intact on disk.

The root cause is that sessions-index.json is not being updated when new sessions are created — the index becomes the bottleneck for sidebar session discovery, and it's only partially written.

Reproduction Steps

  1. Open VS Code with Claude Code extension
  2. Start several conversations from the sidebar
  3. Close VS Code
  4. Reopen VS Code → sidebar is blank / shows only old sessions

Diagnostic Findings

Environment

  • OS: Windows 10 x64
  • Claude Code version: 2.1.167 (vscode entrypoint), 2.1.138 (cli entrypoint)
  • Sessions directory: ~/.claude/sessions/ (12 session JSON files)
  • Project directory: ~/.claude/projects/<project-name>/ (16 .jsonl files)

Evidence

1. sessions-index.json is stale and incomplete

.jsonl files on disk:  16
Entries in index:       6
Missing from index:    10 sessions

10 sessions have valid .jsonl history files but are completely absent from the index, making them invisible to the sidebar.

2. Status never transitions from active to idle

{
  "sessionId": "2d2b6524-39b3-4c1f-b268-301509be8508",
  "status": "active"  // ← session ended 3 days ago, still "active"
}

The session ended on 2026-06-06 but remains stuck as "active". The close callback does not appear to fire or update the status.

3. New sidebar sessions are not indexed

Two sessions created today (entrypoint: claude-vscode) exist in ~/.claude/sessions/ as JSON files but are NOT in sessions-index.json. This means even current sidebar-started sessions won't survive a restart.

4. Incomplete session JSON files from VS Code

{"pid":38528,"sessionId":"8aa6c44d-...","entrypoint":"claude-vscode"}
// Missing: "status" field, "updatedAt" field

Some VS Code session JSONs are missing status and updatedAt fields entirely — suggesting the session record was never properly finalized.

Summary Table

| Issue | Severity |
|---|---|
| Index covers only 6/16 sessions (37%) | Critical |
| Status stuck as "active" after close | High |
| New sessions never added to index | Critical |
| Incomplete session JSON from vscode entrypoint | Medium |

Expected Behavior

  1. Every new session should be added to sessions-index.json at creation time
  2. On VS Code close, all active sessions should transition to status: "idle"
  3. The sidebar should be able to reconstruct session lists from .jsonl files on disk as a fallback (not rely solely on the index)

Workaround

Manually scanning all .jsonl files and rebuilding the index. Users can run:

for f in ~/.claude/projects/*/sessions-index.json; do
  project_dir=$(dirname "$f")
  # Rebuild index from .jsonl files...
done

But this requires terminal knowledge and shouldn't be necessary.

Related Issues

May be related to:

  • #16716 (terminal/sidebar integration gap)
  • #22718 (native terminal streaming)
  • The broader pattern of sidebar↔CLI session lifecycle mismanagement

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗