Canvas UI undo/redo
Use this workflow for files under web/modules/contrib/canvas/ui that affect
undo or redo behavior.
Quick triage
- •Locate the changed layer:
- •Slice history state (
past/present/future) andundoable(...)setup insrc/app/store.ts. - •Cross-slice timeline invalidation in
historyEraserlogic insrc/app/store.ts. - •Undo/redo sequence coordination in
src/features/ui/uiSlice.ts. - •Auto-tracking of undoable actions in
undoRedoActionIdMiddlewareinsrc/app/store.ts.
- •Identify whether the change is a new action, an undo/redo action, or stack bookkeeping.
- •Enforce linear timeline rules before implementing anything.
Invariants to preserve
- •Treat each undoable slice as an independent timeline managed by
redux-undo. - •Keep global user experience linear by coordinating slice order through UI stacks.
- •Clear
futurestates on any new action that creates a branch. - •Preserve
futurestates during undo/redo navigation. - •Never merge slice histories into one state object.
Read references/architecture.md when you need deeper details or when adding a
new undoable slice.
Change checklist
- •Update reducer wiring in
store.tsif an undoable slice is added or changed. - •Keep
UndoRedoTypeinuiSlice.tssynchronized with participating slices. - •Update middleware slice detection in
store.tswhen introducing new undoable slice namespaces. - •Ensure any
filterfunction excludes initialization actions and only tracks meaningful edits. - •If preview updates must happen on historical states, enforce it with
historyEraseroverrides.
Testing checklist
- •Run targeted Vitest tests for changed hooks, reducers, or utilities.
- •Run impacted Cypress component specs in
ui/tests/unit, especially timeline scenarios. - •Run relevant Playwright specs for keyboard shortcuts or end-to-end undo/redo flow.
- •Finish with full UI Vitest suite once targeted tests pass.
Read references/tests.md for command templates and selection guidance.