claude-code - 💡(How to fix) Fix Desktop app deletes session transcript when cleaning up merged worktree [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#54047Fetched 2026-04-28 06:40:41
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3closed ×1
RAW_BUFFERClick to expand / collapse

What happens

When the Claude Code Desktop app cleans up a worktree after its PR is merged, it also deletes the session JSONL transcript at ~/.claude/projects/<encoded-worktree-path>/<session-id>.jsonl.

The worktree directory is gone, the project dir under ~/.claude/projects/ is left as an empty shell (only stray files under tool-results/ survive), and the conversation history is unrecoverable.

Repro

  1. Start a session in a Claude-Desktop-managed worktree (branch like claude/<name>-<id>).
  2. Open and merge the PR for that branch.
  3. Within ~30s of merge, the worktree is removed and the session's .jsonl is deleted.

Observed concretely: PR merged at 19:13:48 UTC, project dir mtime updated at 19:14 UTC (transcript deletion), worktrees dir mtime updated at 19:31 UTC (worktree removal). No user-configured hooks involved — confirmed empty in ~/.claude/settings.json and project .claude/settings*.json. Session entrypoint was claude-desktop.

Why this is bad

Cleaning up the worktree itself is fine — the code is in master, the dupe checkout is dead weight. But transcript deletion is a separate, unjustified choice. The transcript is the only record of what was tried, what failed, what was decided during that session. Losing it means:

  • You can't go back and ask "why did we do it that way?"
  • You can't --resume or fork the conversation later
  • You can't audit what tools the agent ran, what it read, or what it almost did before backing off
  • The PR body is a sanitized after-the-fact summary, not the working trace

Ask

Decouple transcript retention from worktree cleanup. Either:

  1. Keep the JSONL by default after merge cleanup (preferred), or
  2. Move it to an archive location (e.g. ~/.claude/archived-projects/), or
  3. Provide a setting to opt out of transcript deletion.

Worktrees can go; transcripts shouldn't.

extent analysis

TL;DR

Decouple transcript retention from worktree cleanup by modifying the cleanup process to preserve the session JSONL transcript.

Guidance

  • Identify the code responsible for cleaning up the worktree after a PR is merged and modify it to exclude the session JSONL transcript from deletion.
  • Consider adding a setting to allow users to opt out of transcript deletion or move the transcript to an archive location.
  • Verify that the modified cleanup process preserves the session JSONL transcript after a PR is merged.
  • Test the changes to ensure that worktrees are still properly cleaned up while transcripts are retained.

Example

No code snippet is provided as the issue does not include specific code details.

Notes

The solution requires modifying the existing cleanup process, which may involve updating the Claude Code Desktop app's codebase. The exact implementation details are not provided in the issue.

Recommendation

Apply a workaround by modifying the cleanup process to preserve the session JSONL transcript, as decoupling transcript retention from worktree cleanup is the preferred solution. This approach addresses the issue without requiring a full rewrite of the cleanup process.

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

claude-code - 💡(How to fix) Fix Desktop app deletes session transcript when cleaning up merged worktree [1 participants]