claude-code - 💡(How to fix) Fix /branch from a rewound session leaks rewinded messages into the new session's /rewind picker [1 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#58631Fetched 2026-05-14 03:43:15
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×4unsubscribed ×1

Root Cause

The JSONL files are append-only. /rewind does not truncate the file — it marks messages as "rewound" via an internal pointer, and the UI hides them. /branch copies the entire raw JSONL file without transferring or re-applying the rewind pointer, so the new session sees all messages including the rewound ghosts.

RAW_BUFFERClick to expand / collapse

Describe the bug

When you /rewind a session and then /branch from it, the new branched session's /rewind picker shows messages that were rewound away in the parent session — they reappear in chronological order mixed in with the active messages. The parent session correctly hides these rewound messages, but the child session resurrects them.

Steps to reproduce

  1. Session A: chat with Claude. The conversation has messages 1 → 2 → 3 → 4 → 5
  2. In Session A, /rewind to message 3, restore conversation
  3. Continue chatting in Session A, producing new messages 4' → 4'' → 4'''
  4. At this point, Session A's /rewind picker shows only: 1 → 2 → 3 → 4' → 4'' → 4''' (messages 4 and 5 are gone, as expected)
  5. Run /branch sessionB from Session A
  6. In Session B, open /rewind

Expected behavior

Session B's /rewind picker should show the same active history as Session A:

1 → 2 → 3 → 4' → 4'' → 4'''

Actual behavior

Session B's /rewind picker shows the old rewound messages (4, 5) resurrected and mixed in chronologically:

1 → 2 → 3 → 4 → 4' → 4'' → 4''' → 5

The original messages 4 and 5 — which were explicitly rewound away in Session A — leak back into Session B's history.

Why this matters

This is confusing and dangerous. From the user's perspective:

  • Session A tells me messages 4 and 5 are gone — I rewound them
  • I branch, expecting a clean copy of my current state
  • The new session suddenly resurrects messages I explicitly chose to leave behind

It breaks the mental model of "branch = copy current state." It also makes /rewind in the branched session harder to use — the history list is polluted with ghost messages that shouldn't be there, interleaved with real ones in chronological order.

Root cause analysis

The JSONL files are append-only. /rewind does not truncate the file — it marks messages as "rewound" via an internal pointer, and the UI hides them. /branch copies the entire raw JSONL file without transferring or re-applying the rewind pointer, so the new session sees all messages including the rewound ghosts.

Proposed fix

When /branch copies session history, it should respect the parent session's rewind state. Ideally, ask the user:

"This session has rewound messages. When creating the branch, do you want to:"

  • A) Keep only the active conversation (discard rewound history)
  • B) Include the full history including rewound messages

This gives users control. Some might want the full history in the branch for reference; others want a clean copy of their current state. Currently there's no choice and no warning.

Environment

  • Claude Code v2.1.114
  • Windows 11
  • CLI

Related issues

  • #55347 — same root cause (JSONL append-only, rewind doesn't fork)
  • #32631 — Conversation Branching spec (long-term fix)
  • #27242 — UI can't access preserved data after branch navigation

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…

FAQ

Expected behavior

Session B's /rewind picker should show the same active history as Session A:

1 → 2 → 3 → 4' → 4'' → 4'''

Still need to ship something?

×6

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

Back to top recommendations

TRENDING