Skip to content

Session name set by /rename is overwritten after /resume #23610

Closed

Description

@tobedoit

Description

When resuming a named session via /resume, the custom session name set by /rename gets overwritten with an auto-generated title based on conversation content.

Steps to Reproduce

  1. Start a session
  2. Run /rename my-session-name to name the session
  3. Exit the session
  4. Run /resume or claude --resume my-session-name to resume the session
  5. Work in the session, then exit
  6. Run /resume again to see the session list

Expected Behavior

The session should retain the custom name my-session-name set by /rename.

Actual Behavior

The custom name is replaced with an auto-generated title based on conversation content. The original name is lost.

Additional Context

  • This happens consistently across multiple sessions
  • Renaming again with /rename works temporarily, but the name gets overwritten again after the next resume
  • Version: 2.1.33
  • OS: macOS (Darwin 25.2.0)

Activity

  1. github-actions commented on Feb 6, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Session auto-titler uses raw XML markup and overrides /rename #22994
    2. [Bug] Session rename does not persist in /resume picker #23274
    3. [Bug] Custom session names lost - showing first message instead of renamed titles #22938

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. zhijun42 commented on Feb 7, 2026

    @zhijun42

    I can confirm that this issue can easily be reproduced on version 2.1.34

    Image
  3. kuzmany commented on Feb 10, 2026

    @kuzmany

    up

  4. giulioiannelli commented on Feb 11, 2026

    @giulioiannelli

    up, please this is really annoying!

  5. krasmussen37 commented on Feb 11, 2026

    @krasmussen37

    Adding another voice here — this is a significant UX blocker for power users.

    I run multiple concurrent Claude Code sessions across different projects and tasks. /rename is great for labeling terminal tabs, but the fact that session names don't persist through /resume makes session management painful in practice:

    • After a restart, /resume shows a list of auto-generated titles that all look similar
    • I've accidentally launched the same session multiple times because I couldn't tell them apart
    • I end up hopping between sessions trying to find the right one

    This feels like a small fix that would be a big unlock. /rename should durably set the session name so it survives resume cycles. Right now the feature is half-built — it names the tab but the name evaporates on resume.

  6. DanielPBak commented on Feb 11, 2026

    @DanielPBak

    Please fix this, it would be highly impactful.

  7. rfaile313 commented on Feb 12, 2026

    @rfaile313

    ROOT CAUSE

    In the compiled bundle (versions/2.1.39), the function yw8 performs a fast metadata read of session JSONL files for the /resume picker:

    let BbR = 16384;  // 16KB tail buffer
    let J = Math.max(0, R - BbR);  // offset = fileSize - 16KB
    let W = /* read last 16KB of file */;
    let Q = nKT(W, "customTitle");  // string scan for customTitle
    

    The /rename command (function x$T) appends a single line to the JSONL:

    {"type":"custom-title","customTitle":"my-name","sessionId":"<uuid>"}
    

    This line is ~80–100 bytes. After 16KB of additional conversation (roughly 2–5 more exchanges depending on tool use), the custom-title line falls outside the tail window and nKT returns null.

    The full JSONL parser (R1T) correctly reads custom-title events from anywhere in the file, but R1T is only used for the first ~10 sessions shown in the picker (the “enrichment” pass via A1T). All other sessions use the fast yw8 path and lose their titles.


    REPRODUCTION

    1. Start a new session:

      claude
      
    2. Rename it:

      /rename test-rename-bug
      
    3. Have a conversation that generates >16KB of JSONL content
      (typically 3–5 exchanges with tool use, or ~10 text-only exchanges)

    4. Exit the session

    5. Run:

      claude
      
    6. Open /resume and search for test-rename-bug

    7. Expected: Session appears with custom title

    8. Actual: Session appears with first prompt text, not searchable by title


    VERIFICATION

    To confirm the bug on any session, check if the custom-title line is in the last 16KB:

    python3 -c "
    import os, json, sys
    path = sys.argv[1]
    size = os.path.getsize(path)
    tail_start = max(0, size - 16384)
    offset = 0
    with open(path) as f:
        for line in f:
            if '\"custom-title\"' in line:
                in_tail = offset >= tail_start
                obj = json.loads(line.strip())
                print(f'{\"OK\" if in_tail else \"MISS\"}: {obj.get(\"customTitle\")} (offset={offset}, tail_starts={tail_start})')
            offset += len(line.encode('utf-8'))
    " ~/.claude/projects/<project-dir>/<session-id>.jsonl
    

    WORKAROUND

    Re-append the custom-title line to the end of affected JSONL files. This puts it back within the 16KB tail window:

    python3 -c "
    import json, os
    from pathlib import Path
    TAIL = 16384
    for d in (Path.home() / '.claude/projects').iterdir():
        if not d.is_dir(): continue
        for f in d.glob('*.jsonl'):
            size = f.stat().st_size
            title_line = title_off = None; off = 0
            with open(f) as fh:
                for line in fh:
                    if '\"custom-title\"' in line:
                        try:
                            obj = json.loads(line.strip())
                            if obj.get('type') == 'custom-title':
                                title_line, title_off = line.strip(), off
                        except: pass
                    off += len(line.encode('utf-8'))
            if title_line and title_off < max(0, size - TAIL):
                with open(f, 'a') as fh: fh.write(title_line + '\n')
                print(f'Fixed: {json.loads(title_line)[\"customTitle\"]}')
    "
    

    This can be automated via a Stop hook in ~/.claude/settings.json:

    {
      "hooks": {
        "Stop": [{
          "hooks": [{
            "type": "command",
            "command": "claude-rebuild-session-index -q",
            "timeout": 10
          }]
        }]
      }
    }
    

    SUGGESTED FIX (UPSTREAM)

    Option A (minimal):
    In x$T (the /rename handler), after writing the custom-title event, also write it as the last line of the file. The duplicate is harmless since R1T uses Map.set() which overwrites, and nKT just does a string scan. This ensures it is always in the tail.

    Option B (better):
    In yw8, if nKT fails to find customTitle in the tail buffer, fall back to scanning from the head. The custom-title line is small and typically near the end of the non-message section, so a secondary scan of the first ~64KB would catch it.

    Option C (best):
    Avoid relying on tail-scanning for metadata. Write an explicit metadata header or maintain a small sidecar JSON file per session (e.g., <session-id>.meta.json) that stores customTitle, tags, and other metadata written by slash commands. This removes the dependency on JSONL byte offsets entirely.


    RELATED ISSUES

    Both likely stem from the same 16KB tail-read limitation.

  8. added a commit that references this issue on Feb 18, 2026
    b757fc9
  9. github-actions commented on Feb 27, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  10. locked as resolved and limited conversation to collaborators on Feb 27, 2026
  11. added a commit that references this issue on Apr 10, 2026
    453b721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:tuibugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions