# Sequencer Undo Redo

Task: `TODOS.phase-72.72.15.2.7`

The sequencer undo/redo surface is a V2Editor TimelineVisualizer history model
for editor operations that mutate a sequence. It records before/after sequence
snapshots, exposes deterministic undo and redo stacks, preserves the active
track and keyframe selection, and clears stale redo history when a new edit is
pushed after an undo.

## Runtime API

- Panel spec: `FV2SequencerUndoRedoPanelSpec`
- Snapshot: `FV2SequencerUndoRedoSnapshot`
- Request: `FV2SequencerUndoRedoRequest`
- State: `FV2SequencerUndoRedoState`
- Result: `FV2SequencerUndoRedoResult`
- Issue enum: `EV2SequencerUndoRedoIssueType`

`ApplySequencerUndoRedoRequest` accepts a current `FV2SequencerUndoRedoState`
and an action request. Push requests append a validated snapshot to the undo
stack, apply the after-sequence, clear the redo stack, and enforce the
configured history capacity. Undo requests pop from the undo stack, apply the
before-sequence, and move the snapshot to redo. Redo requests pop from redo,
apply the after-sequence, and restore the snapshot to undo. Clear requests
remove both stacks without changing the current sequence.

## Behavior

- The panel spec targets `TimelineVisualizer`, uses icon controls, and exposes a
  visible history stack.
- Operation snapshots cover track management, keyframe editing, curve editing,
  and recording-driven edits. Timeline playback is represented in the enum for
  editor surfaces that snapshot playback-affecting sequence mutations.
- Each snapshot stores `SequenceBefore`, `SequenceAfter`, operation id, action
  description, frame number, selected track, and selected keyframes.
- New push operations invalidate stale redo entries so later edits cannot replay
  an obsolete branch.
- History capacity trims the oldest undo snapshots once `MaxHistory` is
  exceeded.
- Validation reports invalid state, invalid request, sequence mismatch, missing
  operation id, missing undo snapshot, and missing redo snapshot issues.

The default QA fixture uses `Seq.DataModel.CouncilIntro`, operation
`Op.Track.AddVisibility`, max history `64`, and a property-track add operation
to prove that the applied sequence changes across push, undo, and redo.

## QA Inventory

- Panel controls: verify undo, redo, icon-button mode, history stack, and
  operation coverage flags.
- Push: verify track/keyframe/curve/recording operation coverage, after-sequence
  application, undo stack append, redo invalidation, and selection preservation.
- Undo: verify before-sequence restoration, undo stack pop, redo stack append,
  and `bUndoApplied` state.
- Redo: verify after-sequence restoration, redo stack pop, undo stack append,
  and `bRedoApplied` state.
- Off-path: reject empty undo, empty redo, missing operation id, mismatched
  sequence ids, invalid state, and over-capacity history.

`js_repl` Playwright interaction was unavailable in this session and the
affected surface is Unreal editor data rather than browser-rendered UI, so
verification is through UE editor automation and contract gates.

## Verification

- `python3 V2/ue/Tools/check-v2-sequencer-undo-redo.py`
- `V2.Editor.Sequencer.UndoRedo`
- `python3 V2/ue/Tools/check-v2-editor-module.py`
- `python3 V2/ue/Tools/check-v2-ci-workflow.py`
