Skip to content

DYN-10184: Nestable undoredo#16923

Open
chubakueno wants to merge 5 commits intoDynamoDS:masterfrom
chubakueno:nestable_undoredo
Open

DYN-10184: Nestable undoredo#16923
chubakueno wants to merge 5 commits intoDynamoDS:masterfrom
chubakueno:nestable_undoredo

Conversation

@chubakueno
Copy link
Contributor

@chubakueno chubakueno commented Feb 25, 2026

Purpose

This allows the ActionGroupDisposable to be nestable instead of throwing an exception on nesting. It works by merging inner ActionGroupDisposable into the parent one, unless its the root one. This allows to wrap any set of actions inside of an using(UndoRecorder.BeginActionGroup())

Declarations

Check these if you believe they are true

Release Notes

Make ActionGroupDisposable nestable to allow for easily groupable undo-redo actions.

Reviewers

@johnpierson
@BogdanZavu

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables nestable undo/redo action groups in Dynamo by allowing BeginActionGroup() calls to be nested. The implementation flattens nested action groups into the outermost (root) group instead of throwing an exception, which simplifies code that wraps actions in undo groups without needing to check if an action group is already open.

Changes:

  • Modified BeginActionGroup() to detect nesting and only create a new action group at the root level
  • Updated ActionGroupDisposable to track whether it represents a root action group and only call EndActionGroup() for root groups
  • Added UpdateUndoRedoStack() method to IUndoRedoRecorderClient interface to notify UI of undo/redo state changes
  • Connected property change notifications from workspace to view model to update UI when undo/redo state changes

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/DynamoCore/Core/UndoRedoRecorder.cs Core logic changes: added nesting support to BeginActionGroup, modified ActionGroupDisposable to track root status, added UpdateUndoRedoStack to interface, updated comment in EnsureValidRecorderStates
src/DynamoCore/Graph/Workspaces/UndoRedo.cs Implemented UpdateUndoRedoStack method to raise property change notification
src/DynamoCore/Models/DynamoModel.cs Added property change forwarding for CanUndoRedoCommand
src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs Added property change handling for CanUndoRedoCommand to update UI
test/DynamoCoreTests/UndoRedoRecorderTests.cs Added empty UpdateUndoRedoStack implementation to test dummy workspace

Comment on lines +158 to +161
public void UpdateUndoRedoStack()
{

}
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

There are no tests that verify the new nested action group behavior. Consider adding tests that verify: 1) nested action groups (using statements) correctly flatten all actions into the outermost group, 2) undo operations work correctly with nested action groups, and 3) multiple levels of nesting work as expected. This will ensure the feature works as intended and prevent future regressions.

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +160
public void UpdateUndoRedoStack()
{

Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

The test TestBeginActionGroup00 expects an InvalidOperationException when calling BeginActionGroup twice without using statements. However, with the new nestable behavior, this test will fail because nested action groups are now allowed and will not throw an exception. This test needs to be removed or updated to test the new expected behavior (i.e., that nested action groups are properly flattened into the parent group).

Copilot uses AI. Check for mistakes.
@chubakueno chubakueno changed the title Nestable undoredo DYN-10184: Nestable undoredo Feb 25, 2026
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

See the ticket for this pull request: https://jira.autodesk.com/browse/DYN-10184

@chubakueno chubakueno requested a review from a team February 25, 2026 18:53
@@ -111,9 +113,14 @@ public UndoRedoRecorder(IUndoRedoRecorderClient undoClient)
Copy link
Contributor

Choose a reason for hiding this comment

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

"Failing to do so will result in subsequent calls to BeginActionGroup to throw an exception." I think this is no longer true, and should be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated to "...will result in the recorder being stuck in an invalid state."

@sonarqubecloud
Copy link

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.

3 participants