[BUG] Session becomes unreachable when projectPath auto-updates mid-session (storage/index mismatch)
Problem
When a session operates on files across multiple directories, the projectPath in sessions-index.json auto-updates to the last working directory, but the .jsonl session file remains in the original directory's storage location. This creates a mismatch that makes the session unreachable from both directories.
Steps to Reproduce
- Start Claude Code in directory A (e.g.,
/Users/me/project-a) - During the session, read/edit files in directory B (e.g.,
/Users/me/project-b) - Exit the session
- Run
claude --resumein directory A → Session not found (projectPath doesn't match) - Run
claude --resumein directory B → Session not found (file not in B's storage)
Evidence
Session file analysis shows the working directory changed mid-session:
| Directory | Activity Count |
|-----------|----------------|
| /Users/me/project-a | 2034 |
| /Users/me/project-b | 2317 |
| /Users/me/project-c | 714 |
Result:
- File stored in:
~/.claude/projects/-Users-me-project-a/xxx.jsonl - projectPath indexed as:
/Users/me/project-c - Resume from project-a: Filtered out (projectPath mismatch)
- Resume from project-c: Not found (no file in project-c storage)
Both locations fail to find the session.
Root Cause
The current design couples storage location with the starting directory, but indexes by the last active directory. These two should be decoupled.
Proposed Solution
Adopt a unified global storage directory for all sessions:
# Current (problematic):
~/.claude/projects/-Users-me-project-a/sessions-index.json
~/.claude/projects/-Users-me-project-b/sessions-index.json
~/.claude/projects/-Users-me-project-c/sessions-index.json
# Proposed:
~/.claude/sessions/
├── sessions-index.json (global index)
├── session-xxx.jsonl
├── session-yyy.jsonl
└── ...
projectPathbecomes metadata for filtering, not storage location--resumeshows all sessions by default, with optional--projectfilter- No more orphaned sessions due to storage/index mismatch
Related Issues
- #5768 - Resuming sessions only works from the directory in which they were started
- #16264 - Switching folders in UI causes confusing session "loss" (closed as not planned)
- #25322 - Allow switching working directory mid-session (/cd command)
- #26123 - /resume is broken — session history inaccessible since v2.1.31
Workaround
The only way to recover the session is using the full session ID:
claude --resume <session-uuid>
Environment
- Claude Code Version: 2.1.x
- OS: macOS
- Shell: fish
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗