Repository navigation
Description
What happens
resetIncompatibleOperationalStateDatabase (packages/storage/src/operational-state-store.ts:67, added in #2122) deletes runtime.sqlite and its WAL/SHM sidecars whenever any of the eight tracked schema versions differs from the running build. It runs at apps/desktop/src/main/boot.ts:228, before any store opens, and reports the deletion as a single console.warn.
session_metadata lives in that database. Deleting it removes every conversation from the UI.
I hit this on a real profile: a production install at runtime schema 10, opened by a build at schema 11. All 40 sessions disappeared from the sidebar; the database dropped from 254 MB to 896 KB.
Why this is broader than "operational state"
The trigger is routine, not exceptional. hasCurrentOperationalSchema requires all eight schema versions to match exactly, in both directions — an upgrade and a downgrade are equally fatal. runtime alone was bumped 8 times in the last three months (4 of them between 2026-08-02 and 2026-08-06); session_metadata was bumped 15 times in six months. Any one of those bumps wipes the profile. For anyone tracking main or nightly builds, this is closer to "every update" than to "rare incompatible version".
The conversation text is not actually lost. sessions/<id>/session.jsonl survives untouched — I recovered full assistant messages from it after the reset. session_metadata is a projection over data that is still on disk. The truth is "the index can be rebuilt"; the code is written as "the data is disposable".
The same boot path holds two different standards. Twelve lines earlier, resolveDesktopStorageRoot gates a repair behind a confirmation dialog (confirmDesktopStorageRootRepair, boot.ts:216). The more destructive action — rmSync(..., { force: true }) with no backup, no prompt, no undo — runs silently right after it.
Suggested directions, cheapest first
- Rename instead of delete. Move the file to
runtime.sqlite.incompatible-v<n>rather thanrmSync. The no-migration policy is unchanged; the outcome becomes recoverable, and support can ask the user to hand the file back. This is a few lines. - Reuse the gate that already exists. Route the reset through the same confirmation seam as the storage-root repair, so the user learns their history is about to be cleared before it happens.
- Rebuild the index. Repopulate
session_metadatafromsessions/*.jsonl, which is already the authority for message content. This removes the data-loss question rather than softening it.
Notes
#2122 describes this as "the requested no-migration policy", but the PR has no linked issue, review, or discussion, so the original requirement isn't recorded anywhere I can find. If the intent was specifically "conversations are expendable across versions", it would be worth writing that down — the current behaviour reads as an accident to anyone who loses a profile to it.
Activity
Astro-Han commentedon Aug 6, 2026
Claiming this.
I confirmed the root cause: Desktop deletes the shared
runtime.sqlitebefore the existing forward migrators can run. The database contains durable session and message state, so schema mismatch must never be handled by deleting the file.I’ll address this in two stages:
The first PR will stay focused on stopping data loss and restoring normal upgrades; no database split, per-table reset, or automatic migration backup.