mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-29 01:34:37 +01:00
A host page that opts in with `?save=managed` (or `data-save="managed"`
on the canvas) now gets each Save and Save As of the document with an
`id` (`save-1`, `save-2`, ...), and the document keeps its unsaved
changes until the host answers `figcraft:saved` with that `id`. Hosts
that don't opt in see no change: a file still counts as saved once it is
posted.
- `host_saves.rs`: the bookkeeping, apart from the browser so it is
tested natively. One save waits at a time; a newer one replaces it;
answers for any other `id` are ignored; a file the host opens forgets
the waiting save; a save unanswered after 30 s counts as not stored
(the clock is passed in). A Save As becomes the document's file only
once confirmed, so a retry after a failure is still `saveAs: true`.
- `host.rs`: the listener only queues what the host sent; the shell
handles it in order each frame. Exports and copies carry no `id` and
`saveAs: false`. A timeout tells the user and posts `figcraft:failed`
with the `id`, and the app wakes itself for it.
- ui-egui: `Services::deliver_document` hands the document's own file
over (its default is `download`, so desktop and plain browser saves
are unchanged). `Delivery::Pending` skips `file.markSaved`;
`FigApp::document_stored` and `document_not_stored` finish the save.
- engine: `FileSnapshot::delivered` marks the snapshot's tab saved as of
the snapshot, so edits made while the save was in flight stay unsaved,
and a tab closed or saved since is left alone. It shares its tail with
`FileSnapshot::save`.
`craft-web-host` at the pinned rev has no host-to-app refusal message
and no `host {confirmsSaves}` handshake (storytold/craft-libs#1338), so
a host's refusal shows as the timeout until the crate adds them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>