Skip to content

Conversation

@ivaylo-matov
Copy link
Contributor

Purpose

This PR addresses DYN-9014.

Changes:

  • Dynamo now preserves port connections when deleting inline Watch nodes by rewiring upstream/downstream connectors
  • recreates connector pins on the new connections, merging pins from both the Watch input and output wires and deduplicating by location
  • added unit tests to cover reconnection and pin preservation

DYN-9014-Fix

Declarations

Check these if you believe they are true

Release Notes

Dynamo now preserves port connections when deleting inline Watch nodes by rewiring upstream/downstream connectors.

Reviewers

@zeusongit
@DynamoDS/eidos

FYIs

@dnenov

Copilot AI review requested due to automatic review settings February 10, 2026 13:40
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-9014

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 fixes deletion behavior for inline Watch nodes by rewiring upstream/downstream connectors and preserving connector pins during the reconnection.

Changes:

  • Capture upstream→Watch→downstream connection data (including pin locations) before deletion.
  • Recreate direct connectors after deletion and re-add connector pins onto the new connectors.
  • Add NUnit unit tests for reconnection behavior and pin preservation.

Reviewed changes

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

File Description
test/DynamoCoreTests/Models/DynamoModelEventsTest.cs Adds unit tests validating reconnection and connector-pin preservation when deleting inline Watch nodes.
src/DynamoCore/Graph/Workspaces/UndoRedo.cs Implements collection of rewire data and creation of replacement connectors (including pin recreation) during deletion.

Comment on lines +423 to +433
// Recreate pins from both watch connectors on the new connector.
foreach (var pinLocation in rewire.PinLocations)
{
var connectorPinModel = new ConnectorPinModel(
pinLocation.X,
pinLocation.Y,
Guid.NewGuid(),
connector.GUID);
connector.AddPin(connectorPinModel);
undoRecorder.RecordCreationForUndo(connectorPinModel);
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The implementation recreates pins for every entry in rewire.PinLocations without deduplication, but the PR description says pins are “deduplicating by location”. If PinLocations contains duplicates (likely when input/output share the same pin location), this will create duplicate pins. Deduplicate by (X, Y) before creating ConnectorPinModels (either when collecting or immediately before the loop).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We rebuild pins from both upstream and downstream sides of the deleted Watch node, and if one upstream connector fans out to multiple downstream connectors, that upstream pin location is intentionally replayed onto each new connector.
So same coordinates across different connectors are not true duplicates.
We should only dedupe when duplicates occur within the same connector (same connector + same location), not globally by (x, y).

Comment on lines 384 to 385
if (node is null) return false;
return string.Equals(node.GetOriginalName(), "Watch", StringComparison.Ordinal);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Identifying inline Watch nodes via GetOriginalName() == "Watch" is brittle (renames/localization/custom nodes can break this). Prefer a type-based check (e.g., node is Watch) or a more stable identifier used elsewhere in Dynamo to distinguish Watch nodes.

Suggested change
if (node is null) return false;
return string.Equals(node.GetOriginalName(), "Watch", StringComparison.Ordinal);
return node is Watch;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UndoRedo is in DynamoCore, which cannot reference CoreNodeModels.Watch directly.
I switched to a runtime-type-name check with GetOriginalName fallback to keep it type-identity based without violating assembly boundaries.

@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.

1 participant