Skip to content

Conversation

@stutijain2006
Copy link

Solves a long standing query of addition of Undo/Redo Feature
Solves #4561

This PR introduces undo/redo mechanism across various key interactions in music block ensuring common block operations can be safely reversed and reapplied.

Implemented Features-

  1. Undo/Redo functionality for Block Deletion- When a block(or block stack) is deleted, the action can be undone to bring it back or redone to send it again to trash.
  2. Undo/Redo functionality for block movement - The most important utilization of undo/redo being the movement of blocks, allowing the blocks (including entire connected stack) to return to its original positions . It restores the full stack layout not just the start position.
  3. Undo/Redo functionality for Addition of New Block - Undo /Redo can be applied when a new block is added , such that newly added blocks can be undone to remove them and redone to restore them with their original positions and connections intact.

Feature can be accessed through two ways-

  1. Keyboard Shortcuts- Undo can be accessed through Ctrl+Z and Redo through Ctrl+Y
  2. Through tooltip buttons- There are designated buttons for Undo, Redo in the toolbar from where these functions can be accessed.

Current Limitations and Future Enhancements -

  1. Currently undo/redo is restricted only to new block addition, block deletion and block movement but this can further be enhanced to renaming the blocks, value changes (e.g number blocks) and to advanced block addition.

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

SaveInterface.test.js

Copy link
Contributor

@zealot-zew zealot-zew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bugs i encountered:

  1. the trash can seems disabled (the trash doesn't appear in the trash can)
  2. if i undo 'n' number of time (where n > the blocks i deleted) the workspace acts weirdly by removing the start and making a silence block appear.
  3. i like it how the undo feature brings back the block to its original place but it doesn't fit in the block (it just stays in the position in the background)
Screen.Recording.2025-12-27.at.2.25.43.AM.mov

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

SaveInterface.test.js

@stutijain2006
Copy link
Author

3. e block

I have implemented the required changes -

  1. When a block is moved and Undo is performed, the block returns to its original position with all connections retained.
  2. When a block is deleted, it is sent to trash, from where it can be restored manually from restore from trash option or Undo can be performed.
  3. Repeated Undo operations will no longer introduce extra elements like Silence block

@walterbender
Copy link
Member

This is a good start. But pretty flaky. For one thing, there are lots of little glitches, such as:
Screenshot From 2025-12-28 16-39-44

Also, it is a lot of toolbar real estate to dedicate to this functionality.

@AviraL0013
Copy link

IMO, great work on this so far @stutijain2006 — getting undo/redo at the block level is a big step forward.

Before extending it further, it might help to first agree on what a “complete” undo should guarantee. For example:

-- undo should never remove or corrupt the start block

-- undo beyond available history should be a no-op

-- restored blocks should snap back with their original connections, not just position

-- undo/redo should keep trash and save state consistent

One additional thought: instead of treating undo purely as state reversal, would it make sense to classify undo actions by intent (e.g., structural vs positional vs ephemeral)? That might allow collapsing noisy actions (like continuous drag movements) into a single undo step and reduce flakiness while keeping the feature intuitive.

Once these invariants are clear, it may be easier to decide what to stabilize first versus what can come later.

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.

4 participants