Skip to content

Conversation

@johnpierson
Copy link
Member

@johnpierson johnpierson commented Jul 10, 2025

Purpose

This is a completion of a previous PR for consolidating Undos. The undos only get added to the stack when the user accepts the result now. We also don't modify the stack with Pop any longer.

20250711-undoRedo

This PR introduces a mechanism to prevent node creation and deletion during DNA (autocomplete) operations by adding a block flag, wiring it into command execution, and toggling it around the autocomplete lifecycle.

  • Added an IsNodeOperationsBlocked flag on DynamoModel (and redundantly on DynamoViewModel)
  • Modified ExecuteCommand in DynamoModelCommands to early-return when the flag is set
  • Toggled the block flag in NodeAutoCompleteBarViewModel during subscribe/unsubscribe and transient cleanup

Declarations

Check these if you believe they are true

  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB
  • This PR introduces new feature code involve network connecting and is tested with no-network mode.

Release Notes

  • During Node Autocomplete operations with the Floating Menu, all workspace commands are now paused.

Reviewers

@DynamoDS/synapse

FYIs

@DynamoDS/eidos

Copilot AI review requested due to automatic review settings July 10, 2025 20:29
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-8602

This comment was marked as outdated.

@BogdanZavu
Copy link
Contributor

Technically this is fine but I'm not sure if we really want to do this/might be seen as a bug/create confusion. Plus it will be tricky to roll it back later when we fix the undo behavior. Let's sleep over it and discuss tomorrow.

@johnpierson
Copy link
Member Author

johnpierson commented Jul 10, 2025

Sounds good, I do think it has a certain amount of precedence as well. In revit when you are in an edit mode, you cannot do a lot of other actions.

Eg. While editing a floor, you cannot place walls.

So I think we can round this out with something that shows it is a process that is ongoing.

Also, in the bug bash today, at least 3 people were trying to hookup and unhook DNA results while working with it, this also prevents that.

@johnpierson johnpierson changed the title DYN-8602: Block Commands During DNA Operation DYN-9107: Block Commands During DNA Operation Jul 11, 2025
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-9107

@johnpierson johnpierson changed the title DYN-9107: Block Commands During DNA Operation DYN-9107: Fix Deletion of Transient Items Jul 11, 2025
@johnpierson johnpierson changed the title DYN-9107: Fix Deletion of Transient Items DYN-9107: Make Undo Redo Work As Expected Jul 11, 2025
@johnpierson johnpierson requested a review from Copilot July 11, 2025 16:33
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 refactors the undo/redo handling around node autocomplete by removing the old lock-based approach and instead explicitly recording undo states, and it updates how transient nodes and connectors are cleaned up.

  • Removed ToggleUndoRedoLocked calls and IsUndoRedoLocked flag, replacing them with targeted RecordUndoModels calls
  • Updated DeleteTransientNodes to directly remove and dispose connectors/nodes rather than using commands and undo-pop
  • Removed lock checks from CanUndo/CanRedo in UndoRedo.cs

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/NodeAutoCompleteViewExtension/Views/NodeAutoCompleteBarView.xaml.cs Removed obsolete ToggleUndoRedoLocked(false) call when closing the autocomplete view
src/NodeAutoCompleteViewExtension/ViewModels/NodeAutoCompleteBarViewModel.cs Replaced lock toggles with DynamoModel.RecordUndoModels; updated transient connector/node cleanup logic
src/DynamoCore/Graph/Workspaces/UndoRedo.cs Removed IsUndoRedoLocked property and related lock checks from CanUndo/CanRedo
Comments suppressed due to low confidence (2)

src/NodeAutoCompleteViewExtension/Views/NodeAutoCompleteBarView.xaml.cs:204

  • With the old ToggleUndoRedoLocked call removed, ensure the new IsNodeOperationsBlocked flag (or equivalent) is reset when the autocomplete closes so that command execution, including undo/redo, is properly unblocked.
                ViewModel?.DeleteTransientNodes();

src/NodeAutoCompleteViewExtension/ViewModels/NodeAutoCompleteBarViewModel.cs:802

  • Consider adding unit tests for DeleteTransientNodes that verify transient connectors are correctly found, deleted, disposed, and removed from the view model.
            var transientConnectors = wsViewModel.Connectors.Where(c => c.IsTransient).ToList();

…arViewModel.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@chubakueno chubakueno left a comment

Choose a reason for hiding this comment

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

LGTM!

@BogdanZavu
Copy link
Contributor

LGTM! Working very nice ! Let's get this in before my pr.

@johnpierson johnpierson merged commit 352a23b into DynamoDS:master Jul 11, 2025
24 of 25 checks passed
@johnpierson johnpierson deleted the blockCanvas branch July 11, 2025 17:32
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