Back up from in-memory state so recovery includes the failed write
- Dominant language
- TypeScript
- Stars
- 481
- Forks
- 108
- Avg merge
- 8d 9h
- Merged PRs (30d)
- 7
Description
## Description
When a persisted write fails terminally (out of storage), the save-status layer (#1857) offers a "Download backup" recovery via `saveLocalForageToFile`. But that backup reads from **IndexedDB**, not from the in-memory Jotai atoms — so it captures everything that *did* persist and is missing exactly the change that just failed. The user recovers all-but-the-last-edit, not the edit they were trying to make when storage ran out.
For the recovery to truly rescue the failed write, the backup would need to serialize from in-memory state (the Jotai atoms / write-through caches) rather than re-reading the durable store.
## Preferred Solution
Add a backup path that serializes the current in-memory state instead of (or in addition to) the persisted IndexedDB contents, so the downloaded file includes changes that never landed durably.
Considerations to work through during design:
- `createBackupData` / `saveLocalForageToFile` (`core/StateProvider/localDb.ts`) are built around localForage keys. An in-memory variant needs access to the live atom values, which lives in the React/Jotai world — a layering question, since `localDb.ts` is storage-layer code.
- The wire format (`SerializedBackup`) and the restore path should stay compatible, so an in-memory backup restores the same way a durable one does.
- Decide whether this replaces the durable backup in the out-of-storage toast or is offered alongside it.
## Related Issues
- Follow-up from #1857
- Builds on the backup/restore in `core/StateProvider/localDb.ts`
> [!IMPORTANT] Internal only — this issue is maintained by the core team and is not accepting external contributions.
Contributor guide
Research direction
Start with core/StateProvider/localDb.ts, especially createBackupData and saveLocalForageToFile, then trace the out-of-storage toast and the live Jotai atom or write-through cache state. Work through how an in-memory path can preserve the existing SerializedBackup format and restore flow. Done means the recovery download includes the failed write and the intended backup behavior is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- database, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100