P1e: persist undo and redo history across reloads
This commit is contained in:
+24
@@ -176,3 +176,27 @@ The waveform is now an editor. A core's sixteen faces are seventeen contiguous b
|
||||
- Seventeen contiguous cuts only: no zoom, fade, loop points or per-face gain.
|
||||
- The trim is the outer boundaries of the sixteen faces; the original asset is not rewritten.
|
||||
- Cut history survives the session but not yet a reload (the next slice).
|
||||
|
||||
---
|
||||
|
||||
# P1e · history across reloads
|
||||
|
||||
The undo stack is part of the project now.
|
||||
|
||||
## What is stored
|
||||
|
||||
`ProjectEdit` is serialized: bpm, gains, the whole pattern, and every core's seventeen face boundaries. The session keeps up to 64 edits in `history` and a `redo` stack. The store writes both as JSON on the project row (`history`, `redo` columns, migrated with `ALTER TABLE`) every time the session saves; on load the stacks are parsed and handed to `Session::from_project`. `can_undo`/`can_redo` in the state reflect the restored stacks, so the rail buttons light up after a restart.
|
||||
|
||||
The snapshot carries the cores' cuts, not the audio; the audio is still content-addressed and decoded from the asset. Undo after a reload therefore restores pattern, tempo, gains and every face range exactly.
|
||||
|
||||
## Verification
|
||||
|
||||
- `cargo test --workspace`: the core's project-data test and the store test cover the history round-trip; the store test saves an edit with the core boundaries.
|
||||
- `node scripts/persistence-smoke.mjs`: after the daemon restart, `can_undo` is true; `undo` reverts the manual cut from 1.23 s to 1.21 s; `redo` restores 1.23 s; the face edge and the pattern/step/tempo are checked.
|
||||
- `npm --prefix ui run restored-smoke`: the loaded project shows its core and face; the undo button reflects the restored stack.
|
||||
|
||||
## Limits
|
||||
|
||||
- Imports are not undoable; the history is snapshots, not the complete journal.
|
||||
- The cap is 64 edits; older history is dropped.
|
||||
- Corrupt history JSON is ignored with a warning and an empty stack.
|
||||
|
||||
Reference in New Issue
Block a user