Skip to content

Claude Desktop update loses Code session history (migration from local-agent-mode-sessions to claude-code-sessions) #29373

Closed as not planned

Description

@mbbender

Bug Description

After reinstalling/updating Claude Desktop (to v1.1.4498), all Code sessions disappear from the sidebar. Chat and Cowork sessions are unaffected. The session data remains on disk but is not displayed in the app.

Root Cause

The update changed the session storage directory from local-agent-mode-sessions to claude-code-sessions (under ~/Library/Application Support/Claude/). The app's LocalSessionManager.loadSessions() reads from the new claude-code-sessions/<accountId>/<orgId>/ directory, but no migration runs to copy existing session JSON files from the old local-agent-mode-sessions/<accountId>/<orgId>/ directory.

There is a migrateLegacySessions() method in the codebase, but it only handles migration from a single local-sessions.json file — it does not handle migration from the local-agent-mode-sessions directory structure.

Steps to Reproduce

  1. Have an existing Claude Desktop installation with Code sessions
  2. Update/reinstall Claude Desktop to the version that uses claude-code-sessions
  3. Open the app — Code sessions are gone from the sidebar

Expected Behavior

Existing Code sessions should be migrated from local-agent-mode-sessions to claude-code-sessions automatically during the update, or the app should check both directories.

Workaround

Copy the session JSON files from the old directory to the new one:

OLD_DIR="$HOME/Library/Application Support/Claude/local-agent-mode-sessions/<accountId>/<orgId>"
NEW_DIR="$HOME/Library/Application Support/Claude/claude-code-sessions/<accountId>/<orgId>"

# The account/org IDs can be found by listing the subdirectories
# Copy all session files that don't already exist in the new location
for f in "$OLD_DIR"/local_*.json; do
    basename=$(basename "$f")
    [ ! -f "$NEW_DIR/$basename" ] && cp "$f" "$NEW_DIR/$basename"
done

Then restart Claude Desktop. Sessions will reappear.

Technical Details

  • Platform: macOS (Darwin 25.2.0, Apple Silicon)
  • Claude Desktop version: 1.1.4498
  • Old directory: ~/Library/Application Support/Claude/local-agent-mode-sessions/
  • New directory: ~/Library/Application Support/Claude/claude-code-sessions/
  • App bundle code reference: .vite/build/index.js line 771 — const $6t="claude-code-sessions" and the loadSessions() / getStorageDir() methods in LocalSessionManager

Suggested Fix

Add a migration step in LocalSessionManager initialization that checks for the existence of local-agent-mode-sessions/<accountId>/<orgId>/ and copies any local_*.json files not already present in claude-code-sessions/<accountId>/<orgId>/.


Note: This bug was diagnosed and fixed by Claude (Opus 4.6) running inside Claude Desktop — it reverse-engineered the session storage change by extracting and reading the app's asar bundle, then copied the session files to restore 30 lost sessions. The user (filing this issue) did not perform the debugging themselves.

Activity

  1. github-actions commented on Feb 27, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Session history lost after updating to v1.1.4328 #29154
    2. Claude Code sessions disappear from desktop app sidebar after restart #29172
    3. Desktop app: Previous sessions not visible in sidebar after restart #29220

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. mbbender commented on Feb 27, 2026

    @mbbender
    Author

    Follow-up: Additional issue found — VM/Cowork sessions vs local Code sessions

    After the initial fix (copying JSON files from local-agent-mode-sessions to claude-code-sessions), the sessions appeared in the sidebar but all showed "Folder no longer exists. Please start a new session."

    Root Cause

    The local-agent-mode-sessions directory contained both VM/Cowork sessions and local Code sessions. The VM/Cowork sessions have cwd paths like /sessions/friendly-lucid-edison (VM paths that don't exist on the local machine) and a vmProcessName field. The app's getAllSessions() calls checkFolderExistsCached(n.cwd) which fails for these VM paths, causing the error message.

    These VM sessions should not have been copied into claude-code-sessions — they belong in the Cowork section and were already showing correctly there.

    The actual missing Code sessions

    The real local Code sessions (ones run from Claude Desktop with terminal access) store their conversation history in ~/.claude/projects/<project-dir>/<sessionId>.jsonl, but the Desktop sidebar reads session metadata from claude-code-sessions/<accountId>/<orgId>/local_*.json. After the update, the metadata files were never created for pre-existing Code sessions.

    Complete fix

    1. Remove any VM/Cowork sessions erroneously copied into claude-code-sessions (ones with vmProcessName or cwd starting with /sessions/)
    2. Create Desktop metadata JSON files in claude-code-sessions/<accountId>/<orgId>/ for each .jsonl session in ~/.claude/projects/, using this format:
    {
      "sessionId": "local_<new-uuid>",
      "cliSessionId": "<the .jsonl filename without extension>",
      "cwd": "<actual local project path>",
      "originCwd": "<actual local project path>",
      "createdAt": <timestamp_ms>,
      "lastActivityAt": <timestamp_ms>,
      "model": "claude-opus-4-6",
      "isArchived": false,
      "title": "<first user message from the JSONL>",
      "permissionMode": "default"
    }

    The cliSessionId field is the critical link between the Desktop sidebar entry and the conversation history stored in ~/.claude/projects/.

    Suggested fix for Anthropic

    On app startup/update, scan ~/.claude/projects/ for .jsonl session files that don't have corresponding entries in claude-code-sessions/ and create the metadata files automatically.


    Diagnosed and fixed by Claude (Opus 4.6) running inside Claude Desktop.

  3. tomer-dev commented on Feb 28, 2026

    @tomer-dev

    Thank you!

  4. github-actions commented on Mar 28, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  5. github-actions commented on Apr 4, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  6. locked as resolved and limited conversation to collaborators on Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssue doesn't seem to be related to Claude CodestaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions