/resume command missing most sessions - sessions-index.json not syncing with session files on disk
Summary
Sir, we've identified a critical desynchronization in the session persistence layer. The sessions-index.json file -- which governs what /resume presents to the operator -- is failing to register the majority of session files that exist on disk.
In our case: only 6 out of 38 sessions were indexed. That's 84% of conversation history rendered invisible. The data is not lost -- the .jsonl files remain intact -- but the index simply does not acknowledge them.
The Problem
The sessions-index.json located under ~/.claude/projects/<project-path>/ should maintain a registry of all session files. Instead, it falls dramatically out of sync. The operator experiences this as conversations "disappearing" from /resume, which naturally leads to the conclusion that data has been erased.
Additionally, the metadata for sessions that are indexed is stale. We observed session files exceeding 30MB with messageCount: 6 in the index -- a clear impossibility. The index appears to capture an initial snapshot at session creation and never update it.
How We Identified It
- Noticed that long, substantive sessions were vanishing from
/resumewhile short trivial ones persisted - Inspected
~/.claude/projects/<project-path>/sessions-index.json-- found only 6 entries - Listed
.jsonlfiles in the same directory -- found 38 - Cross-referenced: 32 sessions existed on disk but were absent from the index
- Verified the
.jsonlcontent was intact -- full conversation data, summaries, all present
Impact
- Operators believe their data is gone. This is the most damaging consequence -- it breaks trust in the tool
- Session continuity is severed.
/resumebecomes unreliable for picking up previous work - No indication anything is wrong. The failure is completely silent -- no warnings, no errors
Suspected Cause
- The index may only be written at session creation and never updated on subsequent saves
- On WSL2 environments, cross-boundary filesystem operations may cause silent write failures
- Concurrent Claude Code instances or rapid session switches could produce race conditions on the index file
Workaround
Operators can rebuild the index by scanning the .jsonl files on disk and reconstructing the entries programmatically. We wrote a Python script that re-parses all session files and regenerates a correct sessions-index.json. This restored all 38 sessions to /resume immediately.
Suggested Fix
- Atomic index updates on every session save -- write to a temp file, then rename
- Self-healing reconciliation on startup -- scan
.jsonlfiles and re-index any that are missing from the registry - Filesystem fallback -- if the index count diverges significantly from the file count on disk, scan directly
- Accurate metadata -- recount messages from actual
.jsonlcontent rather than caching stale values
---
Reported by Amyd Caballero & JARVIS Think AI
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗