claude-code - 💡(How to fix) Fix Named sessions not resumable by name after process exit [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48469Fetched 2026-04-16 06:59:17
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Root Cause

Root cause: Session names are only stored in ~/.claude/sessions/<pid>.json, which gets cleaned up when the process exits. The name is not persisted in the session JSONL file or any durable index.

Code Example

# Active sessions only track running PIDs — name lives here and dies with the process
~/.claude/sessions/31372.json{"pid":31372,"sessionId":"6784ab79-...","name":"reprocess tool"}

# Session JSONL (72MB, 12810 lines) has no name metadata
~/.claude/projects/<project>/06c8aeae-....jsonl → no "sessionName" or "name" field in any record

# history.jsonl references sessionId but not session name
RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

When a named session's process exits (terminal closed, crash, etc.), claude -r <name> can no longer find it. The session data (JSONL) is fully intact on disk and claude --resume <session-id> works fine — but the name is lost.

Root cause: Session names are only stored in ~/.claude/sessions/<pid>.json, which gets cleaned up when the process exits. The name is not persisted in the session JSONL file or any durable index.

Evidence from disk inspection:

# Active sessions only track running PIDs — name lives here and dies with the process
~/.claude/sessions/31372.json → {"pid":31372,"sessionId":"6784ab79-...","name":"reprocess tool"}

# Session JSONL (72MB, 12810 lines) has no name metadata
~/.claude/projects/<project>/06c8aeae-....jsonl → no "sessionName" or "name" field in any record

# history.jsonl references sessionId but not session name

This is especially painful for long-lived sessions (this one was 72MB with multiple compactions over weeks of work).

What Should Happen?

claude -r <name> should find named sessions even after the owning process has exited. Session name should be persisted durably — either in the JSONL file (e.g., as a metadata record) or in a separate session index that survives process exit.

Steps to Reproduce

  1. Start a session: claude
  2. Name it via /name v4 (or however session naming works)
  3. Close the terminal (or kill the process)
  4. Try claude -r v4not found
  5. Try claude --resume 06c8aeae-... (full session ID) → works

Claude Model

Opus

Is this a regression?

Unknown — may have always been this way

Claude Code Version

2.1.101

Platform

Anthropic API (Claude Max)

Operating System

Windows 11 Pro

Terminal/Shell

Git Bash

Additional Information

Related issues: #40081 (sessions disappearing from /resume after restart), #46553 (incomplete session list), #42681 (resume broken after update). This is a distinct root cause — the name specifically is not persisted, while the session data itself survives.

🤖 Generated with Claude Code

extent analysis

TL;DR

To fix the issue, the session name needs to be persisted durably, either in the JSONL file or a separate session index that survives process exit.

Guidance

  • The current implementation only stores session names in ~/.claude/sessions/<pid>.json, which is deleted when the process exits, causing the name to be lost.
  • To persist session names, consider adding a "name" field to the session JSONL file or creating a separate session index that maps session IDs to names.
  • Verify that the proposed solution works by testing claude -r <name> after the process has exited and ensuring the session is found.
  • Review related issues (#40081, #46553, #42681) to ensure the proposed solution does not introduce new problems.

Example

No code snippet is provided as the issue does not contain sufficient information about the Claude Code implementation.

Notes

The exact implementation details of the fix are not specified, and the issue may have always existed. Further investigation is needed to determine the best approach for persisting session names.

Recommendation

Apply a workaround to persist session names, such as modifying the Claude Code to store session names in a durable location, as the current implementation is not sufficient.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Named sessions not resumable by name after process exit [1 comments, 2 participants]