Bug: /resume does not update sessions/{pid}.json sessionId, causing silent JSONL message chain forks

Resolved 💬 3 comments Opened Mar 23, 2026 by KawaBurger Closed Mar 26, 2026

Summary

When using /resume inside a running Claude Code session to switch to a different conversation, ~/.claude/sessions/{pid}.json is not updated with the new session ID. This allows multiple processes to silently operate on the same session, causing JSONL message chain forks.

Reproduction

  1. Window A: Start claude, have a conversation → creates session SA, writes sessions/{pidA}.json with sessionId: SA
  2. Window B: Start claude → creates session SB, writes sessions/{pidB}.json with sessionId: SB
  3. Window B: Type /resume, select session SA, continue chatting
  4. Inspect sessions/{pidB}.jsonstill shows sessionId: SB, not SA

Verified on Claude Code 2.1.81, macOS:

# Window B (PID=42043) resumed session 0cc15eb2, but session file not updated:
PID=42043
sessionId in file: 7d783ff0-b23e-4b97-b55d-6c8a44e10d7b   ← B's original
Expected after /resume: 0cc15eb2-ddb1-4441-a164-f118cf58b083  ← A's session
Match: NO

# Yet B IS writing to A's JSONL file:
-rw------- 8987 Mar 23 17:12 .claude/projects/-Users-.../0cc15eb2-....jsonl
Last message: "this is a test session -- v2"  ← written by B after /resume

Impact

Since sessions/{pid}.json doesn't reflect the actual session, there is no external way to know which session a process is operating on. This leads to:

Silent JSONL message chain forks — Two processes write to the same JSONL, each creating children from the same parentUuid:

# Multiple children sharing the same parentUuid = fork points
$ jq -r '.parentUuid' session.jsonl | sort | uniq -c | sort -rn | head
   2 dc26f80c-bbda-409a-8a8c-5d65bfb2bd5b
   2 939c92b3-8870-4b35-99bd-339e045fb176
   ...6 fork points found in one real session

Both branches have isSidechain: false, so claude --resume later only follows one branch — silently losing the other branch's messages.

SessionStart hooks also cannot reliably prevent this, because the stale session file doesn't match the actual session being operated on.

Expected Behavior

When /resume switches to a different session, update ~/.claude/sessions/{pid}.json to reflect the new sessionId.

Environment

  • Claude Code: 2.1.81
  • OS: macOS Darwin 25.3.0

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗