anthropics / anthropics/claude-code

Desktop: auto-compaction writes to two transcripts in parallel, then the session switches files mid-conversation (history appears to roll back)

Open
#81,290 0 comments 0 reactions 0 assignees View on GitHub
area:core
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

## Summary

On Claude Desktop, after auto-compaction the session's visible conversation history was
abruptly replaced mid-conversation — it appeared to "roll back" to a much earlier state.
No data was lost on disk, but the session became pinned to the compacted transcript,
hiding ~76 turns of detailed history.

Inspecting the transcripts shows the old and new transcript files were **both being written
to in parallel for ~43 minutes** before the switch.

## Environment

- Claude Desktop 1.24012.9
- macOS 26.5.2 (arm64)
- Model: claude-opus-5, effort: high
- Session was long-running (created ~26h earlier), multiple compactions had occurred

## What happened

Timeline for a single desktop session (`local_a1f2813a-…`):

| Time (UTC) | Event |
|---|---|
| 00:18:21 | Compaction creates a new transcript `207cc5f9…`, copying 248 entries forward |
| 00:18 – 01:01 | **Both** `30de0e57…` (old) and `207cc5f9…` (new) receive writes |
| 01:01:42 | Last write to the old transcript (252 entries were appended after 00:18) |
| 01:01:52 onward | Only the new transcript continues |

From the UI, the conversation visibly changed at that point: the detailed history was
replaced by a summary plus a handful of recent turns.

## Evidence

- The two transcript files share **248 entries with identical UUIDs**, spanning
00:18:21 → 00:47:42 — i.e. the same conversation was recorded into both files, not two
independent conversations.
- The old transcript kept receiving new entries until 01:01:42, i.e. **43 minutes after**
the new transcript was created.
- The desktop session metadata's `cliSessionId` pointed at the compacted transcript
(504 lines / 9 user turns), while the fuller transcript (2389 entries / 76 user turns)
was still present on disk and readable via `claude --resume `.

## Impact

- Conversation history appears to be lost from the UI. It is recoverable, but only if the
user knows to look in `~/.claude/projects//*.jsonl` and resume the older
transcript id manually.
- The two transcripts diverge: work done after the switch exists only in the new file, so
restoring the fuller history means the session no longer "remembers" the most recent turns.

## Workaround

Edit the desktop session metadata under
`~/Library/Application Support/Claude/claude-code-sessions/<…>/local_.json`
and point `cliSessionId` at the older transcript, then fully quit and relaunch the app.
This restored the expected conversation.

## Related

- #66947 — same underlying area (compaction re-writing entries with identical UUIDs), but a
different symptom: that report is about duplicate bubbles rendered *within one* transcript
file. Here the entries are duplicated *across two* transcript files that are both live, and
the session then switches which one it treats as authoritative. That issue was closed as
stale/not-planned; this may be worth revisiting together.
- #27242 — "data preserved but UI inaccessible" after compaction. Same user-facing outcome
(history unreachable from the UI), different trigger.

## Expected

Compaction should be seamless: a single transcript should be authoritative at any moment,
and the visible conversation should not change retroactively while the session is in use.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining the session metadata under ~/Library/Application Support/Claude/claude-code-sessions/ and the transcript files under ~/.claude/projects//*.jsonl, then use claude --resume to compare the old and compacted transcript IDs. Reproduce auto-compaction and verify that only one transcript remains authoritative, the UI does not switch history mid-session, and all turns remain accessible.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, python
Domain
cli, desktop
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.