forked from 1b-agent/opencadstudio-upstream
web: autosave snapshots with crash-recovery restore, persistent storage
The web build had no autosave: on_autosave was a no-op and the subscription was native-only. Both gates are gone; every savetime tick now serializes each dirty tab (same pre-serialize sync as the web save path, no thumbnail, serialized serially off the critical paint path) into a dedicated opencadstudio-autosave OPFS directory, keyed by drawing name, without touching the dirty flag, downloads, or recents. On boot the web app scans that directory and offers any snapshot newer than the last saved copy in a localized Recover Drawing modal (Restore opens it as "name (recovered).dwg" through the standard open pipeline; Discard removes it; Escape discards). Saving or closing a drawing clears its snapshot; the boot scan also garbage- collects stale entries. run_web now requests navigator.storage.persist so settings and OPFS data survive browser eviction.
This commit is contained in:
1 parent
ad60be11ed
commit
101d167ebc
31 files changed
+746
-11
No files matched your search
@@ -959,6 +959,17 @@ impl OpenCADStudio {
|
||||
}
|
||||
},
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::WebAutosavesScanned(result) => self.on_web_autosaves_scanned(result),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::WebAutosaveRestore => self.on_web_autosave_restore(),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::WebAutosaveDiscard => self.on_web_autosave_discard(),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::WebAutosaveBytes(name, result) => self.on_web_autosave_bytes(name, result),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Message::WebAutosaveSnapshotFinished(result) => self.on_web_autosave_finished(result),
|
||||
|
||||
Message::ImagePick => {
|
||||
Task::perform(crate::io::pick_image_file(), Message::ImagePickResult)
|
||||
}
|
||||
@@ -7054,6 +7065,12 @@ impl OpenCADStudio {
|
||||
if self.active_modal == Some(super::ModalKind::RecoveryPrompt) {
|
||||
return self.update(Message::RecoveryDecline);
|
||||
}
|
||||
// Closing the crash-recovery prompt (✕ or Escape) discards
|
||||
// the offered snapshot — otherwise it would requeue itself.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
if self.active_modal == Some(super::ModalKind::AutosaveRestore) {
|
||||
return self.update(Message::WebAutosaveDiscard);
|
||||
}
|
||||
// Closing the shortcut editor with un-applied rows needs an
|
||||
// explicit discard; a second close attempt (or the overlay's
|
||||
// Discard button) goes through.
|
||||
|
||||
Reference in new issue
Block a user