[BUG] VS Code: Session vanishes from history after closing tab, despite .jsonl file intact on disk

Resolved 💬 4 comments Opened Apr 8, 2026 by amagginetti Closed May 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Closing a Claude Code session tab in VS Code causes the session to permanently disappear from the session history list, even though the .jsonl session file remains intact on disk with valid data and a valid ai-title record.

The session history UI is powered by agentSessions.model.cache in VS Code's workspace state.vscdb (SQLite), not by scanning session files on disk. When a tab is closed, the session is either removed from or never written to this cache. Since the extension doesn't rescan the sessions directory to reconcile, the session becomes invisible.

In my workspace: 105 session .jsonl files exist on disk, but only 60 are indexed in agentSessions.model.cache. 45 sessions are invisible to the UI despite having valid data.

Repro steps:

  1. Have a Claude Code conversation in VS Code
  2. Reboot or restart VS Code (tab is restored via editor state recovery, session still visible)
  3. Close the session tab manually
  4. Open session history — the session is gone

The session can still be resumed via claude --resume <session-id>, confirming the data is intact. The issue is purely that the UI index loses track of it.

What Should Happen?

Closing a session tab should persist the session to the history index. Ideally, the extension should also rescan the sessions directory on startup and reconcile with its cache, adding any .jsonl files that are missing from the index.

Error Messages/Logs

No error messages. The session silently disappears from the history list.

Diagnostic evidence:
- Session file exists: .claude-sessions/7c508c44-2615-4ab5-8bf0-85330a9a2bcb.jsonl (5.5 MB, 627 lines)
- ai-title record present: "Align on IC3 log collection scope for May 1st"
- agentSessions.model.cache in state.vscdb: does NOT contain this session ID
- 45 of 105 session files on disk are missing from the cache

Steps to Reproduce

  1. Open a Claude Code session in VS Code and have a full conversation (generates an ai-title)
  2. Close VS Code or reboot the computer
  3. Reopen VS Code — the session tab is restored via VS Code's editor state recovery
  4. Close the session tab manually within VS Code
  5. Open session history — the session is gone from the list

Note: The .jsonl session file remains on disk with valid data. The session can still be resumed via CLI with claude --resume <session-id>.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.49 (Claude Code)

Platform

Other

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

The root cause is that session history in the VS Code extension is powered by agentSessions.model.cache in the workspace's state.vscdb (SQLite), not by scanning .jsonl files on disk. When a tab is closed, the session is removed from or never written to this cache. The extension doesn't rescan the sessions directory to reconcile.

Suggested fix: The extension should either persist sessions to the cache on tab close, rescan the sessions directory on startup, or use the filesystem as the source of truth for session discovery.

View original on GitHub ↗

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