Desktop app: auto-clean orphaned Code sessions from sidebar
Problem
The Claude desktop app's Code tab sidebar accumulates orphaned sessions over time. These are sessions whose working directory no longer exists (e.g., deleted projects, removed git worktrees). They clutter the sidebar and show "Folder no longer exists. Please start a new session." when clicked, but there's no way to dismiss or bulk-remove them from the UI.
Current workaround
Manually deleting session JSON files from:
~/Library/Application Support/Claude/claude-code-sessions/<account-id>/<user-id>/
...then restarting the app. This requires knowing the internal file structure.
Proposed solution
- Auto-detect orphaned sessions: On app launch (or periodically), check if each Code session's
cwdstill exists. If not, mark it as orphaned. - Allow deletion from UI: Add a right-click "Delete session" or "Remove" option on sidebar items, and/or a "Clean up orphaned sessions" bulk action.
- Visual indicator: Optionally dim or badge orphaned sessions so users know they're stale before clicking into them.
Context
In my case, 21 out of 53 sessions were orphaned — mostly from deleted git worktrees (.claude/worktrees/) and removed project directories. This is a natural consequence of using worktrees and experimenting with projects.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗