claude-code - 💡(How to fix) Fix [BUG] /rename session name is lost after process exit — /resume from new terminal shows first message instead of session name [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#47197Fetched 2026-04-14 05:55:34
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3closed ×1commented ×1

Error Message

Error Messages/Logs

Root Cause

Root Cause Analysis:

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?

Session name only survives within the same terminal session. Closing the terminal loses the name permanently.

What Should Happen?

The session name set via /rename should persist across terminal restarts. The name should be written to a durable location — either:

  • Embedded in the JSONL file as a metadata entry (e.g. {"type":"session-meta","name":"MySessionName"})
  • Or stored in a separate index file not keyed by PID

Error Messages/Logs

Steps to Reproduce

  1. Start a Claude Code session: claude
  2. Rename the session: /rename MySessionName
  3. Exit the session: /exit
  4. In the same terminal, run claude again and type /resume → session name "MySessionName" is displayed correctly
  5. Close the terminal window entirely
  6. Open a new terminal, run claude, type /resume → session name is gone, first user message is shown instead

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.92 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

Root Cause Analysis:

The /rename command writes the name field only to /.claude/sessions/{pid}.json (the session metadata file keyed by process ID). The conversation JSONL file (/.claude/projects/{project-hash}/{session-id}.jsonl) does not store the session name anywhere.

When the process exits and the terminal is closed, the sessions/{pid}.json file is cleaned up (since the PID is no longer valid). On next launch, /resume rebuilds the session list from the JSONL files, which contain no name field — so it falls back to displaying the first message content.

extent analysis

TL;DR

To persist the session name across terminal restarts, the session name should be written to a durable location, such as the conversation JSONL file or a separate index file.

Guidance

  • The current implementation only stores the session name in the session metadata file keyed by process ID, which is cleaned up when the process exits.
  • To fix this, the session name should be stored in a durable location, such as the conversation JSONL file, for example, as a metadata entry like {"type":"session-meta","name":"MySessionName"}.
  • The /rename command should be updated to write the session name to this durable location.
  • The /resume command should be updated to read the session name from this durable location instead of relying on the session metadata file keyed by process ID.

Example

{
  "type": "session-meta",
  "name": "MySessionName"
}

This example shows how the session name could be stored as a metadata entry in the conversation JSONL file.

Notes

The exact implementation details may vary depending on the specific requirements and constraints of the Claude Code project. This guidance provides a general direction for fixing the issue.

Recommendation

Apply workaround: Store the session name in a durable location, such as the conversation JSONL file, to persist it across terminal restarts. This approach allows the session name to be retained even after the terminal is closed and reopened.

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