Session restore fails silently when sessions-index.json misses entries (Windows)

Resolved 💬 3 comments Opened Feb 6, 2026 by bosmadev Closed Feb 6, 2026

Description

Session resume (claude --resume "name" or /resume) frequently restores a blank/wrong session on Windows. Root cause investigation reveals 3 compounding issues:

Root Cause Analysis

1. Index Gap (Critical)

  • sessions-index.json only tracks 25 of 95 actual session files on disk
  • Orphaned .jsonl files exist but are invisible to the resume picker
  • Likely caused by sessions ending abnormally or index write failures

2. Resume Only Matches customTitle

  • The Em() function in cli.js only searches the customTitle field
  • Sessions without /rename applied are completely unfindable by name
  • No fallback to summary or firstPrompt

3. /clear Creates Blank Shells

  • /clear preserves the session ID and index entry but wipes all messages
  • /rename after /clear sets a customTitle on what is now an empty session
  • Resuming this session loads the blank shell instead of the original content

Reproduction Steps

  1. Start a new Claude Code session, do substantial work
  2. Run /clear to clear the context
  3. Run /rename "MySession" to name it
  4. Exit Claude Code
  5. Run claude --resume "MySession"
  6. Expected: Original session content restored
  7. Actual: Blank session with only post-clear messages

Environment

  • Platform: Windows 11
  • Claude Code: 2.1.34
  • Node.js: 25.x

Related Issues

  • #23610 — Session name overwritten after /resume
  • #23421 — sessions-index.json stops updating
  • #22614 — Incomplete session context loaded despite full file
  • #23275 — /resume shows empty list (Windows)

Suggested Fix

  1. Index should be rebuilt/verified on startup or periodically
  2. Resume search should fall back to summary when no customTitle match
  3. /clear should warn that resume will only restore post-clear content

View original on GitHub ↗

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