Codex Desktop loses visible chat history when local state SQLite index is corrupted
What issue are you seeing?
After quitting Codex Desktop with Cmd+Q and reopening it, previous chat history appeared to be gone. The underlying rollout/session files were still present under ~/.codex/sessions, but the app history UI could not show them.
Diagnosis:
- codex doctor reported: state database integrity check failed
- state DB: ~/.codex/state_5.sqlite
- error: database disk image is malformed
- rollout files scan: no errors
The actual conversation data was not lost. The history index database was corrupted. Rebuilding state_5.sqlite from rollout files restored the history.
Why this is a product issue
Users should not need to know about state_5.sqlite, SQLite WAL files, or manually rebuild a local thread index. If the index is corrupt but rollout files are intact, Codex should detect this automatically and rebuild/repair the index, or at least show a clear recovery prompt.
Expected behavior
- Codex should not show history as empty when rollout files still exist.
- On startup, if state_5.sqlite integrity check fails, Codex should automatically rebuild the thread index from ~/.codex/sessions and ~/.codex/archived_sessions.
- The app should preserve the corrupted DB as a backup for diagnostics.
- The UI should show a clear message like: History index was repaired; your conversations were preserved.
Actual behavior
History appeared missing after restart, even though rollout files were still present.
Suggested fix
Add startup integrity checking for the local state DB and automatic recovery from rollout JSONL files.
Environment
- Codex Desktop app
- macOS 15.5
- Codex CLI/runtime: 0.138.0-alpha.7
- Storage path: ~/.codex
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗