`/desktop` fails: "Cannot determine working directory … transcript may be incomplete" after EnterWorktree→ExitWorktree (transcript fragmented across project dirs; bridge-session record has no cwd)
Summary
Running /desktop after an EnterWorktree → ExitWorktree 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:
~/.claude/projects/<parent-slug>/<SID>.jsonl— 1 line, nocwd:
``json``
{"type":"bridge-session","sessionId":"<SID>","bridgeSessionId":"cse_…","lastSequenceNum":0}
~/.claude/projects/<worktree-slug>/<SID>.jsonl— the real conversation (~1.2k lines). Itscwdvalues 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)
- Start a CLI session in a git repo
EnterWorktree(create/enter a worktree)- Do some work
ExitWorktreewithkeep/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
/desktopbridge 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 nocwd. - Desktop's cwd resolution then sees a fragment with no usable
cwd(no field at all, or a leadingcwd:nullline) and gives up.
Suggested fix direction
- When resolving a CLI session's cwd, consult all
projects/*/<SID>.jsonlfragments for that session id, not just the one under the current slug. - Scan for the last non-null
cwd(the first line can legitimately becwd: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):
/desktopon an empty first-command session →CLI session transcript not found. Same theme —/desktopresolves 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:nullfirst-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.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗