[BUG] Desktop app: local session index file gets zero-filled (corrupted) after unclean shutdown, causing chat to disappear from sidebar despite transcript being intact

Status Fixed / completed
Maintainer reply None cached
Activity 0 comments · opened Jul 21, 2026 · closed Aug 25, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude desktop app for Windows, MSIX package Claude_1.22209.3.0_x64__pzs8sxrjxfjjc
Windows 10 Pro 10.0.19045
Affected file: %APPDATA%\Roaming\Claude\claude-code-sessions\<accountUuid>\<orgUuid>\<local_sessionId>.json
Summary:
After an unclean system shutdown (hard power-off / crash — confirmed via Windows Event Log Kernel-Power Event ID 41 and Event ID 6008 "previous shutdown was unexpected"), the local session-state JSON file for an active Claude Code session becomes entirely zero-filled (all \x00 bytes, no valid JSON). This causes that conversation to disappear from the desktop app's sidebar/history list entirely, even though the underlying conversation transcript (~/.claude/projects/<project>/<cliSessionId>.jsonl) remains fully intact and unaffected.

This has now happened twice to the same session across two separate unclean shutdowns, each time producing an identical corruption pattern (file size matches the last known content length, but 100% null bytes).

mail: erickterro22@gmail.com

<img width="1366" height="768" alt="Image" src="https://github.com/user-attachments/assets/27b9b895-578a-4795-9e4c-03e7d5874ffd" />

<img width="1366" height="768" alt="Image" src="https://github.com/user-attachments/assets/27a14d11-72e9-469c-a2b6-90865aa2892c" />

What Should Happen?

Steps to reproduce (best-effort reconstruction):

Have an active Claude Code session open in the desktop app with recent activity (so the local session-state JSON is being written/updated).
Force a hard power-off (hold the physical power button) or experience an unexpected reboot/power loss while the app is open.
Reopen the app afterward.
The session that was active at the time of the power loss is missing from the sidebar. Its corresponding claude-code-sessions//<local_id>.json file exists on disk but contains only null bytes.
Expected behavior:
Either the session file survives (via atomic write) and the chat still appears, or — if corruption is unavoidable — the app detects the corrupt/unparseable file at startup and rebuilds a minimal entry from the underlying transcript file (~/.claude/projects/
/*.jsonl) rather than silently dropping the session from the list.

Error Messages/Logs

Actual behavior:
The session silently disappears from the UI with no error shown to the user, who has no way to know the underlying data is actually safe. This caused significant (avoidable) user distress/confusion, since it looks identical to permanent data loss.

Steps to Reproduce

Suspected root cause:
The session-state JSON at claude-code-sessions/<account>/<org>/<local_sessionId>.json appears to be written in-place rather than via an atomic write pattern (write to a temp file in the same directory + fsync + rename). An in-place write that gets interrupted by a hard power-off leaves a file that is neither the old nor the new valid content — in this case, a fully zero-filled file (consistent with NTFS pre-allocating file length before the content write completes).

Suggested fix:

Use atomic writes (temp file + rename) for all files under claude-code-sessions/ (and any other frequently-updated local app-state files) so an interrupted write always leaves either the previous valid content or the new valid content, never a corrupted/zero-filled file.
As a defense-in-depth measure, on startup the app could detect unparseable/zero-filled session JSON files and reconstruct a minimal valid entry (title, cliSessionId, cwd, timestamps) directly from the corresponding transcript file in ~/.claude/projects/, since that data isn't lost — only the small index/metadata file is.

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Desktop app (Claude): 1.22209.3.0

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

<img width="1366" height="768" alt="Image" src="https://github.com/user-attachments/assets/2c5aefa4-8fd6-48a5-8f4b-f3efe4a7459c" />

<img width="1366" height="768" alt="Image" src="https://github.com/user-attachments/assets/84ddac48-c99d-4f9f-a295-7ce6172516cd" />

View original on GitHub ↗