🐛 Clarify plugin save recovery warning

Warn that recovery may discard unsaved edits instead of implying that
reopening is the only recovery path. Update the API docs and test.

AI-assisted-by: gpt-6.1-terra
This commit is contained in:
Andrey Antukh 2026-11-24 10:24:13 +00:00
parent 8d781fa5b0
commit 719f154b49
5 changed files with 9 additions and 8 deletions

View File

@ -2,7 +2,7 @@
- Start at `app.plugins.persist` for `penpot.waitForSave` and `app.plugins.events` for `contentsave` and `contentrollback`. The runtime forwarder requires `content:read` for `waitForSave`; new event names must also be added to runtime `validEvents`, and a stale runtime build can reject them.
- `waitForSave(timeout?)` observes the shared persistence queue, not only the plugin's commits. Its default timeout is 60 seconds. It waits briefly for incoming commits, capped by the timeout; if work is pending it forces persistence and races settlement against rollback start or completion. A rollback must reject even if the status later becomes `:saved`. See `mem:frontend/workspace-persistence`.
- An earlier `:error` rejects even when no work is pending: a slow retry produces `save-retrying`; terminal failures use the stored failure code (default `save-failed`). Other error codes include `save-timeout` and `rolled-back`. Timeout validation accepts a positive finite number up to `u/max-timeout`; rejection must be an `Error`, not a string. For queue halts and recovery conditions see `mem:frontend/workspace-persistence`.
- An earlier `:error` rejects even when no work is pending: a slow retry produces `save-retrying`; terminal failures use the stored failure code (default `save-failed`) and warn that recovery may discard unsaved changes. Other error codes include `save-timeout` and `rolled-back`. Timeout validation accepts a positive finite number up to `u/max-timeout`; rejection must be an `Error`, not a string. For queue halts and recovery conditions see `mem:frontend/workspace-persistence`.
- `contentsave` is a debounced state watch for transitions to `:saved` and passes no value. It does not prove the buffer is empty.
- `contentrollback` subscribes to `::dps/rolled-back`, not the state watch. It is not debounced and is delivered asynchronously after reverted or reloaded data is in state. Its `{fileIds, pageIds, shapeIds}` payload comes from page-shape redo changes in reverted commits. Remove the stream subscription when the listener is removed.
- MCP forwards rollback notices with task responses and retains unsent notices in per-file plugin local storage when available. Delivery is not an end-to-end acknowledgment; for its storage permissions, handoff and failure limits see `mem:mcp/save-and-rollback`.

View File

@ -46,9 +46,8 @@
err))
(def ^:private earlier-failure-message
(dm/str "Changes could not be saved: the file has a failed save that "
"stays until the file is reopened, so no change can be confirmed "
"as saved. Reopen the file to resume saving."))
(dm/str "Changes could not be saved: a previous save failed. "
"Unsaved changes may be discarded during recovery."))
(def ^:private retrying-message
(dm/str "Changes could not be saved yet: saves are failing and Penpot "
@ -95,7 +94,7 @@
or there is nothing to save after a short intake window.
Rejects when `timeout` is invalid, the save fails (also a failure from
before the call: a terminal one stays until the file is reopened),
before the call while the error remains),
changes are rolled back during the wait, or the deadline elapses. The
Error `code` is `save-timeout`, `rolled-back`, `save-retrying` (an
earlier failure Penpot keeps retrying), or the failure code

View File

@ -105,7 +105,7 @@
(let [outcome (await (await-outcome (persist/wait-for-save 2000)))]
(t/is (contains? outcome :error)
"terminal :error rejects waitForSave")
(t/is (re-find #"(?i)could not be saved.*reopen"
(t/is (re-find #"(?i)unsaved changes may be discarded during recovery"
(or (some-> (:error outcome) .-message) "")))
(t/is (= "save-permission-denied" (error-code outcome))
"the stored failure code is kept")))))))))

View File

@ -10,6 +10,7 @@
### 🩹 Fixes
- **plugin-types:** Clarified that `waitForSave` rejects while a terminal save error remains and recovery may discard unsaved changes.
- **plugins-runtime:** Methods that rejected an invalid value with a plain string (`connectLibrary`, file `restore`, `remove`, `pin`, `export`, `findVersions`, `saveVersion`) now reject with an `Error` carrying the same message.
- **plugin-runtime:** `LibraryComponent.instance()`, `createShapeFromSvg()` and `createShapeFromSvgWithImages()` now create shapes at the page root instead of inside a board at the page origin. Closes #12086.
- **plugin-types, plugin-runtime:** Dashboard property setters now update values after backend success and log failures without interrupting the workspace. File moves reject projects in other teams, backend rejections include their type and code, and `project.fileCount` stays at its listing snapshot. Duplicated projects include their file count and pinned state.

View File

@ -1655,8 +1655,9 @@ export interface Context {
* rejected with an Error on save failure, when changes are rolled back
* during the wait, on timeout, or on an invalid timeout value. A save
* that failed before the call also rejects: with `save-retrying` while
* Penpot keeps retrying it, otherwise with the failure code until the
* file is reopened. The Error `code` property tells the cases apart:
* Penpot keeps retrying it, otherwise with the failure code while the
* error remains. Recovery may discard unsaved changes. The Error `code`
* property tells the cases apart:
* `save-timeout`, `rolled-back`, `save-retrying`, or the failure code
* (`save-failed` unless the backend gave a more specific one).
*/