claude-code - 💡(How to fix) Fix `/desktop` fails: "Cannot determine working directory … transcript may be incomplete" after EnterWorktree→ExitWorktree (transcript fragmented across project dirs; bridge-session record has no cwd)

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…

Running /desktop after an EnterWorktreeExitWorktree cycle in the same session fails to hand off to the Desktop app with:

Cannot determine working directory for CLI session <session-id> — the transcript may be incomplete

The session has plenty of transcript content. The real problem is that the session's transcript is fragmented across two ~/.claude/projects/<slug>/ directories, and the fragment /desktop resolves to is a bridge-session record that has no cwd field.

Root Cause

  • A session that changes cwd via Enter/Exit worktree writes transcript entries under different projects/<slug>/ dirs (the slug is derived from cwd).
  • The /desktop bridge record is written under the current (post-exit) cwd's slug, which need not be the slug holding the conversation — and the bridge record itself carries no cwd.
  • Desktop's cwd resolution then sees a fragment with no usable cwd (no field at all, or a leading cwd:null line) and gives up.

Code Example

Cannot determine working directory for CLI session <session-id> — the transcript may be incomplete

---

{"type":"bridge-session","sessionId":"<SID>","bridgeSessionId":"cse_…","lastSequenceNum":0}
RAW_BUFFERClick to expand / collapse

Summary

Running /desktop after an EnterWorktreeExitWorktree cycle in the same session fails to hand off to the Desktop app with:

Cannot determine working directory for CLI session <session-id> — the transcript may be incomplete

The session has plenty of transcript content. The real problem is that the session's transcript is fragmented across two ~/.claude/projects/<slug>/ directories, and the fragment /desktop resolves to is a bridge-session record that has no cwd field.

Environment

  • Claude Code CLI: 2.1.158
  • Desktop: Claude 1.9659.2 (390d6c) — 2026-05-28T21:50:01Z
  • Platform: macOS (Darwin 24.6.0)

What's on disk

For a single session id <SID> there are two transcript files:

  1. ~/.claude/projects/<parent-slug>/<SID>.jsonl1 line, no cwd:
    {"type":"bridge-session","sessionId":"<SID>","bridgeSessionId":"cse_…","lastSequenceNum":0}
  2. ~/.claude/projects/<worktree-slug>/<SID>.jsonl — the real conversation (~1.2k lines). Its cwd values are present (both the worktree path and the parent path), but note the first line is {"type":"last-prompt","cwd":null,…}.

/desktop is invoked after ExitWorktree (so the session cwd is back at the parent). It writes the bridge-session record under the parent slug; the Desktop app then resolves session <SID> to that parent-slug fragment — which carries no cwd — and errors.

Repro (worktree-in-iCloud / separate gitdir NOT required)

  1. Start a CLI session in a git repo
  2. EnterWorktree (create/enter a worktree)
  3. Do some work
  4. ExitWorktree with keep
  5. /desktop

→ Desktop errors: Cannot determine working directory … the transcript may be incomplete

Root cause

  • A session that changes cwd via Enter/Exit worktree writes transcript entries under different projects/<slug>/ dirs (the slug is derived from cwd).
  • The /desktop bridge record is written under the current (post-exit) cwd's slug, which need not be the slug holding the conversation — and the bridge record itself carries no cwd.
  • Desktop's cwd resolution then sees a fragment with no usable cwd (no field at all, or a leading cwd:null line) and gives up.

Suggested fix direction

  • When resolving a CLI session's cwd, consult all projects/*/<SID>.jsonl fragments for that session id, not just the one under the current slug.
  • Scan for the last non-null cwd (the first line can legitimately be cwd:null) rather than failing on the first/only line.
  • Fallback: derive cwd from the projects/<slug> directory name, which already encodes the path.

Related

  • #62017 (same area, my earlier report): /desktop on an empty first-command session → CLI session transcript not found. Same theme — /desktop resolves to a transcript that can't yield a cwd.
  • #41723 — "/desktop fails to import CLI sessions when first JSONL line has no cwd" (closed/dup); the cwd:null first-line angle.
  • #41688 — "transcript has no cwd — cannot import after worktree deletion" (closed; a fix was said to ship in the next Desktop version), and #48809 (a later recurrence, marked stale). This Enter/Exit-worktree transcript-fragmentation path does not appear to be covered by that fix.

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` fails: "Cannot determine working directory … transcript may be incomplete" after EnterWorktree→ExitWorktree (transcript fragmented across project dirs; bridge-session record has no cwd)