📚 Simplify workspace persistence memory name

Keep the save lifecycle guidance together under a direct name and
update references across the client and server guidance.

AI-assisted-by: gpt-6.1-terra
This commit is contained in:
Andrey Antukh 2026-11-24 09:33:25 +00:00
parent 172e70df22
commit ff49804ae9
10 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
# File save acceptance
- Start at `app.rpc.commands.files-update`; for client handling and retry see `mem:frontend/workspace-state-persistence-subtleties`, and for version and fragment lifetime see `mem:backend/file-data/reads-and-versions`.
- Start at `app.rpc.commands.files-update`; for client handling and retry see `mem:frontend/workspace-persistence`, and for version and fragment lifetime see `mem:backend/file-data/reads-and-versions`.
- Partial acceptance requires `:changes-with-metadata` with a `:commit-id` on every group. Flat changes or groups without IDs remain all-or-nothing. Try the entire batch first: a later commit may repair an earlier one. On a change failure, `apply-commits` searches for an accepted prefix and returns HTTP 200 with a `:rejected` suffix. `:preexisting-damage` means the data touched by the first rejected commit already failed validation on the base before that commit.
- Persist and broadcast only the accepted prefix. A fully rejected save does not write a revision, change `revn`, or broadcast file changes. Database, I/O, interruption and missing-fragment errors fail the request rather than reject a commit. `app.http.errors` distinguishes transient failures the client can retry from permanent errors; do not classify every I/O error as transient.
- Each `apply-prefix` attempt starts from the original file, resets pointer tracking to its baseline and clears media-reference state. Keep only the accepted attempt's tracked pointers and references. A pointer already marked modified can retain its ID across edits, so leaking failed tracking can persist the rejected version under an accepted ID.

View File

@ -4,7 +4,7 @@
## Construction and compaction
- Preserve redo and undo order when compacting: merge `:reg-objects` per container and place registrations after changes that resize children. Never compact across commit boundaries; the backend can reject individual commits by `commit-id`. Client save ordering is in `mem:frontend/workspace-state-persistence-subtleties`.
- Preserve redo and undo order when compacting: merge `:reg-objects` per container and place registrations after changes that resize children. Never compact across commit boundaries; the backend can reject individual commits by `commit-id`. Client save ordering is in `mem:frontend/workspace-persistence`.
- Do not send a deleted component's entire object map for a metadata-only edit. Scope shape edits to `:component-id` using the builder's container context. Omitted `:objects` preserves stored shapes; explicit nil clears them. Reserve `:objects? true` for repairs that intentionally move or clear the whole map.
- Apply fixture edits through `app.common.test-helpers.files/apply-changes`; disable its validation only for intentionally invalid intermediate states. See `mem:common/testing`.

View File

@ -13,7 +13,7 @@ Start at `app.main.ui` for Rumext components, `app.main.data` for Potok events,
- Store, refs, and interaction streams: `mem:frontend/workspace-store`.
- Local and remote commits, rebase, and undo: `mem:frontend/workspace-commits`.
- Save queue, rejected edits, retries, and recovery: `mem:frontend/workspace-state-persistence-subtleties`.
- Save queue, rejected edits, retries, and recovery: `mem:frontend/workspace-persistence`.
- Modifier previews, transform commits, and WASM bridge: `mem:frontend/workspace-transforms`.
- Design token model, workspace application and propagation: `mem:common/tokens`.

View File

@ -4,4 +4,4 @@
- The store's `:exception` clears on `rt/navigated`, but React render errors live inside the boundary. Its reset keys are a real JS array of screen-name strings: the library uses JS array methods and `Object.is`, so a CLJS vector fails and rebuilt keyword objects reset unnecessarily. Reset on screen changes, not solely param changes; a crash on the same screen may need a reload.
- `app.main.repo/retryable-types` is the shared transient set. An unexpected transport response is not necessarily an app defect; repo classifies it before downstream handlers choose retry or notification. Keep environment failures on the audit-only path, not the internal defect reporter. Stale compiled chunks may need a throttled reload; plugin errors must stay isolated from the global exception page.
- Reserve the dedup slot before formatting. Keep the cache and payload bounded; a single error hint can embed a whole file and block a batch. Report names participate in dedup because external consumers distinguish handled errors from defects. Reset the governor between test cases that expect an emission.
- `flash` schedules reporting and the toast off the failing stack and resolves even if reporting fails; tests may await it. Do not reclassify a caller's report name just to select a compact display. For persistence use the underlying `:cause-type` to classify the wrapped error. Authentication and `vern` conflict delegate; `:not-found` is a terminal save failure that keeps the workspace open. The reload action on the save-failure report is a full restart, not a retry of the halted queue. See `mem:frontend/workspace-state-persistence-subtleties`.
- `flash` schedules reporting and the toast off the failing stack and resolves even if reporting fails; tests may await it. Do not reclassify a caller's report name just to select a compact display. For persistence use the underlying `:cause-type` to classify the wrapped error. Authentication and `vern` conflict delegate; `:not-found` is a terminal save failure that keeps the workspace open. The reload action on the save-failure report is a full restart, not a retry of the halted queue. See `mem:frontend/workspace-persistence`.

View File

@ -3,5 +3,5 @@
- For a store exception, inspect `(:exception @app.main.store/state)`: `:type`, `:code`, `:status`, `:hint`, `:details` and `:uri` can identify the failing operation. Validation details can include shape IDs and invariant failures.
- A React error boundary can display an error without setting the store's `:exception`; a nil value alone does not prove the UI recovered. See `mem:frontend/error-reporting`.
- If the live REPL is available, `(.reload js/location)` reloads the browser; otherwise select and reload the workspace tab. Confirm both that the workspace renders and that the store exception is clear. For runtime selection see `mem:frontend/cljs-repl`.
- Before reloading, account for unsaved edits and partial saves: an earlier commit from a rejected batch can already be durable. Review `mem:frontend/workspace-state-persistence-subtleties` before retrying edits.
- Before reloading, account for unsaved edits and partial saves: an earlier commit from a rejected batch can already be durable. Review `mem:frontend/workspace-persistence` before retrying edits.
- `execute_code` waits for save and fails on errors or rollback detected during that wait, but later failures can still occur. Plugin availability and rollback notice persistence have separate limits; see `mem:mcp/save-and-rollback` and `mem:frontend/plugin-save-events`.

View File

@ -1,7 +1,7 @@
# Plugin save and rollback events
- 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-state-persistence-subtleties`.
- `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`, while a terminal failure keeps rejecting until the file is reopened. Other error codes include `save-timeout`, `rolled-back` and the stored failure code (default `save-failed`). Timeout validation accepts a positive finite number up to `u/max-timeout`; rejection must be an `Error`, not a string.
- `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.

View File

@ -1,6 +1,6 @@
# Workspace commits, rebase and undo
- Start at `app.main.data.changes`, `app.main.data.persistence.commits` and `app.main.data.workspace.undo`. For the shared change vocabulary see `mem:common/changes`; for save ordering see `mem:frontend/workspace-state-persistence-subtleties`.
- Start at `app.main.data.changes`, `app.main.data.persistence.commits` and `app.main.data.workspace.undo`. For the shared change vocabulary see `mem:common/changes`; for save ordering see `mem:frontend/workspace-persistence`.
- `commit-changes` requires edit permission, no historical preview and no save-failure lock. Its refusal completes an empty stream, not nil. `:ignore-save-lock` is for rollback compensation and information derived from existing commits (position data, component touch), not user edits or an origin allowlist. Remote changes apply through `commit`, outside this local gate.
- When a peer commit arrives, undo pending edits for that file, apply the remote change and replay local redo. Read pending edits from both the save queue **and** the unflushed buffer; otherwise the local and server order can disagree. Isolate files and versions, and keep index updates for all replay legs.
- An undo group is one user action even if it spans several files; dependent commits such as component sync must inherit it. Persistence uses this same group for rollback. A stacked commit that records undo may inherit the current history entry's group; a repair that records no undo must not inherit it or failure could roll back the previous user action. Let an open nonempty transaction keep its grouping.

View File

@ -5,4 +5,4 @@
- Preserve page-object map identity when possible: `refs/workspace-page-objects` compares with `identical?`. Keep the selection input equality check before processing selected shapes. Prefer selecting libraries from `refs/files` with component memoization over the broad deprecated `refs/libraries`.
- Keyboard modifier state must clear on window blur. Focus mode tracks added and removed objects as the page changes; exit when none remain and restore the surviving pre-focus selection. Otherwise a later draw can re-arm a mode the user already left.
- Reloading a workspace initializes again without finalizing the existing one; finalizing would drop transient state. Consumers started by initialization must stop on a newer initialization, not just on exit, or reload doubles undo and other side effects.
- Undo and remote rebase: `mem:frontend/workspace-commits`. Save queue and unload guard: `mem:frontend/workspace-state-persistence-subtleties`.
- Undo and remote rebase: `mem:frontend/workspace-commits`. Save queue and unload guard: `mem:frontend/workspace-persistence`.

View File

@ -2,7 +2,7 @@
- Start at `app.main.data.workspace.transforms`, `app.main.data.workspace.modifiers` and `app.main.streams`. High-frequency WASM modifier and selection-rectangle previews use behavior subjects and refs outside normal store commits; they are not persisted shape data.
- Clear `wasm-modifiers` and `workspace-selrect` on gesture end **and** when a control unmounts mid-gesture. Otherwise stale preview state can displace the next selection overlay. `app.main.streams/clear-transform-preview!` resets both.
- A normal `mse/drag-stopper` can end a drag on `:interrupt` as well as mouse release. On save failure, `::plk/cancel-gestures` arrives first; `plk/gesture-stopper` marks the gesture cancelled so it clears the transform or drawing preview instead of committing. New drag gestures need that cancellation or equivalent unmount/read-only cleanup: the commit gate alone does not clear WASM preview state. See `mem:frontend/workspace-state-persistence-subtleties`.
- A normal `mse/drag-stopper` can end a drag on `:interrupt` as well as mouse release. On save failure, `::plk/cancel-gestures` arrives first; `plk/gesture-stopper` marks the gesture cancelled so it clears the transform or drawing preview instead of committing. New drag gestures need that cancellation or equivalent unmount/read-only cleanup: the commit gate alone does not clear WASM preview state. See `mem:frontend/workspace-persistence`.
- `apply-modifiers*` updates frame guides and comment threads before `update-shapes`, with `:reg-objects? true` and `transform-attrs` limiting the diff. `assoc-position-data` preserves the original text shape context when applying derived text positions. Keep the `:position-data` tag on derived commits so its watcher does not react to itself.
- `calculate-ignore-tree` and its WASM counterpart compare each copy and its root before and after transforms. Small relative movement with effectively unchanged size and rotation can suppress geometry touched for descendants; resizes and rotations must still propagate it. For touched semantics and geometric precision see `mem:common/components` and `mem:common/geometry`.
- WASM modifier updates write local/plugin props rather than directly mutating file data. Rotation has distinct WASM and non-WASM event paths; check both when changing semantics. Rendering flush and tile invalidation are in `mem:render-wasm/rendering`.