-
-
Notifications
You must be signed in to change notification settings - Fork 345
Description
Description
All "Code" tab session history is lost every time the Claude Desktop app is restarted. After closing and reopening the app, the session list appears empty with no way to resume previous conversations.
Environment
- OS: Ubuntu 22.04 (Linux 6.8.0-100-generic)
- Claude Desktop: installed via claude-desktop-debian
- Claude Code SDK version: 2.1.49
Root Cause Analysis
The session metadata files stored in ~/.config/Claude/claude-code-sessions/{accountId}/{orgId}/ are not persisted across app restarts. From ~/.config/Claude/logs/main.log:
[LocalSessionManager] Cannot initialize sessions: accountId=null, orgId=null. Keeping existing sessions.
No persisted sessions found
Org changed from null to d40dde79-..., reinitializing sessions
Failed to read sessions directory: ENOENT: no such file or directory, scandir '.../{accountId}/{orgId}'
[LocalSessionManager] loadSessions failed during account transition, restoring previous sessionsThe startup sequence has a race condition:
- App starts with
accountId=null, orgId=null→ "No persisted sessions found" - Authentication completes,
orgIdloads → triggers session reinitialization loadSessionstries to scan the{orgId}subdirectory, but it doesn't exist yet (ENOENT)- Falls back to "restoring previous sessions" — but none were loaded in step 1
- Result: all previous session metadata is gone
The {orgId} directory is only created during an active session and appears to be removed on app shutdown. So on every restart, the directory doesn't exist at the time loadSessions runs.
Note: The actual conversation data (JSONL files in ~/.claude/projects/) survives, but the Desktop app cannot display them without the corresponding session metadata JSON files.
Steps to Reproduce
- Open Claude Desktop, go to the "Code" tab
- Create one or more code sessions
- Close the app completely
- Reopen the app
- Observe: all previous code sessions are gone from the sidebar
Expected Behavior
Code tab sessions should persist across app restarts, similar to how the main chat history is preserved.
Workaround
A systemd user service that monitors the session directory and backs up/restores session metadata files on directory recreation. Happy to share if anyone needs it.