/desktop fails to import CLI sessions when first JSONL line has no cwd
Resolved 💬 3 comments Opened Apr 1, 2026 by kays0x Closed Apr 4, 2026
Bug
/desktop (CLI-to-Desktop session transfer) fails with "transcript has no cwd - cannot import" for roughly half of all sessions.
Root cause
importCliSession in the Desktop app reads only the first line of the session JSONL to extract cwd:
for await (const b of _) {
const A = JSON.parse(b);
typeof A.cwd == "string" && A.cwd.length > 0 && be.isAbsolute(A.cwd) && (a = A.cwd);
break; // exits after first line regardless
}
if (!a) throw new Error(`CLI session ${e} transcript has no cwd — cannot import`);
The first line of a session JSONL is nondeterministic. It can be:
progress- hascwdfield, import worksfile-history-snapshot- nocwdfield, import failsqueue-operation- nocwdfield, import fails
Out of 31 local sessions: 15 start with progress (would work), 12 with file-history-snapshot (broken), 4 with queue-operation (broken).
Expected fix
Replace the break with a loop that scans until it finds a line with a valid cwd:
for await (const b of _) {
const A = JSON.parse(b);
if (typeof A.cwd == "string" && A.cwd.length > 0 && be.isAbsolute(A.cwd)) {
a = A.cwd;
break;
}
}
Repro
- Start a CLI session (
claudein terminal) - Use the session for a bit (especially if file tracking or
/cleartriggers afile-history-snapshotas the first entry) - Run
/desktop - CLI says "Session transferred to Claude Desktop" but Desktop shows error dialog: "Couldn't open session" / "transcript has no cwd - cannot import"
Environment
- CLI version: 2.1.87
- Desktop app: latest (2025-03-31)
- macOS
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗