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.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# ZHILA — план проекта
|
||||
|
||||
Черновик v1.1 · 1 ноября 2026
|
||||
Статус: **P0, P1a, P1b, P1c и P1d выполнены** (см. `P0.md`, `P1.md`). Демо `reference/demo/` — референс, не кодовая база.
|
||||
Статус: **P0, P1a, P1b, P1c, P1d и P1e выполнены** (см. `P0.md`, `P1.md`). Демо `reference/demo/` — референс, не кодовая база.
|
||||
|
||||
**Зафиксировано 1 ноября:** descent — основной вид; камень = паттерн; климат — на жилу (концепт погоды остаётся); платформа v1 — Linux; UI — Svelte 5. Журнал — §9.
|
||||
|
||||
|
||||
@@ -160,3 +160,7 @@ The project is loaded by the daemon from its `--project` folder and saved after
|
||||
## P1d additions
|
||||
|
||||
`Command::set_core_faces` takes `{ core, boundaries: [f32; 17] }` (seconds, strictly ascending). The daemon answers with the state and broadcasts `core_faces { core: CoreSummary }`. The core rejects unordered or out-of-range boundaries. Boundaries are persisted in the project's `cores.faces` column and applied after the asset is decoded again on load; the source bytes and peaks stay unchanged.
|
||||
|
||||
## P1e addition
|
||||
|
||||
No new wire messages. The daemon now persists the session's bounded `history` and `redo` stacks in the project and restores them on load; `State.can_undo`/`can_redo` therefore describe the restored stacks after a restart. The stacks are server-side JSON snapshots of bpm, gains, pattern and core face boundaries.
|
||||
|
||||
Reference in New Issue
Block a user