Skip to content

feat: add undo/redo toolbar buttons and fix temporal partialize#9

Open
randroid88 wants to merge 1 commit into
DataAnts-AI:mainfrom
Randroids-Dojo:upstream/undo-redo-buttons
Open

feat: add undo/redo toolbar buttons and fix temporal partialize#9
randroid88 wants to merge 1 commit into
DataAnts-AI:mainfrom
Randroids-Dojo:upstream/undo-redo-buttons

Conversation

@randroid88

Copy link
Copy Markdown

Summary

  • Add Undo/Redo toolbar buttons with proper disabled state, wired to the zundo temporal store
  • Fix temporal partialize config to only snapshot editing state (words, deletedRanges, segments, language)

Before

Undo/redo only worked via keyboard shortcuts (Ctrl+Z / Ctrl+Shift+Z) with no visual indication of whether undo/redo was available. The temporal store captured all state changes including playhead position, hover state, and selection, causing spurious undo steps when the user simply moved the playhead.

After

Undo/Redo buttons visible in the toolbar:

  • Enabled when there are past/future states to navigate
  • Disabled (grayed out) when the history is empty
  • Only editing operations (word deletions, range changes) create undo steps

Files changed

  • frontend/src/App.tsx — Add Undo2/Redo2 toolbar buttons, subscribe to temporal store
  • frontend/src/store/editorStore.ts — Add partialize config to temporal middleware

Test plan

  • Delete some words → Undo button enables → click Undo → words restored
  • Click Redo → words deleted again
  • Move the playhead, hover over words → should NOT create undo steps
  • Keyboard shortcuts (Ctrl+Z, Ctrl+Shift+Z) still work alongside buttons
  • Undo button disabled when no history, Redo disabled when no future states

Add visible Undo/Redo buttons to the toolbar with proper disabled state,
wired to the zundo temporal store.

Fix the temporal middleware's partialize config to only snapshot editing
state (words, deletedRanges, segments, language). Previously, all state
including playhead position, hover state, and selection was captured,
causing spurious undo steps when the user simply moved the playhead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant