enhancement: no autosave and no crash recovery #16

Open
opened 2026-11-16 14:26:50 +00:00 by ben · 0 comments
Owner

Version: 0.1.2 (main @ 41c7fc5)
System: any.

Steps to reproduce

  1. Work on a document for ten minutes without saving (the app never asks you to).
  2. Kill it — a crash, a power cut, kill, or the OOM killer on a large canvas (see the memory issue).

What should have happened

The work comes back on the next start, or at least a recovery file is offered.

What happened instead

There is nothing: no autosave, no recovery file, no "restore the document from the last session" prompt. grep -rn "autosave\|recovery" app/src finds nothing. What exists is a crash log (last-crash.log, install_panic_hook) and the "ask before closing unsaved work" prompt, which only covers the case where the app gets to close itself.

The pieces for a fix are all there: project::save writes a complete document (zip, pictures included) atomically (write_atomic), paths::data_dir() is the right place, and the app already tracks unsaved and project_path.

Suggested fix

  • Once every ~60 s, if unsaved and something changed, write data_dir()/recovery/<id>.opendither (or one slot, recovery.opendither) with the same project::save, off the UI thread once there is one.
  • Delete it on a clean save or a clean exit.
  • On start, if a recovery file is newer than the last clean save, offer "Restore the document from the last session" in the status bar (or the close-prompt dialog, reused).

@ mention: this overlaps with the "work on the UI thread" issue only in that a periodic save must not stutter the window — a one-off write of a few MB is acceptable, or it goes to the worker once that exists.

A check that would catch it

An --audit row with a temp data folder: mark a document dirty, run the autosave hook, assert a recovery file exists and loads back with the same picture fingerprint; then save cleanly and assert the recovery file is gone.

Version: 0.1.2 (`main` @ 41c7fc5) System: any. ## Steps to reproduce 1. Work on a document for ten minutes without saving (the app never asks you to). 2. Kill it — a crash, a power cut, `kill`, or the OOM killer on a large canvas (see the memory issue). ## What should have happened The work comes back on the next start, or at least a recovery file is offered. ## What happened instead There is nothing: no autosave, no recovery file, no "restore the document from the last session" prompt. `grep -rn "autosave\|recovery" app/src` finds nothing. What exists is a crash log (`last-crash.log`, `install_panic_hook`) and the "ask before closing unsaved work" prompt, which only covers the case where the app gets to close itself. The pieces for a fix are all there: `project::save` writes a complete document (zip, pictures included) atomically (`write_atomic`), `paths::data_dir()` is the right place, and the app already tracks `unsaved` and `project_path`. ## Suggested fix - Once every ~60 s, if `unsaved` and something changed, write `data_dir()/recovery/<id>.opendither` (or one slot, `recovery.opendither`) with the same `project::save`, off the UI thread once there is one. - Delete it on a clean save or a clean exit. - On start, if a recovery file is newer than the last clean save, offer "Restore the document from the last session" in the status bar (or the close-prompt dialog, reused). @ mention: this overlaps with the "work on the UI thread" issue only in that a periodic save must not stutter the window — a one-off write of a few MB is acceptable, or it goes to the worker once that exists. ## A check that would catch it An `--audit` row with a temp data folder: mark a document dirty, run the autosave hook, assert a recovery file exists and loads back with the same picture fingerprint; then save cleanly and assert the recovery file is gone.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ben/openDither#16
No description provided.