Skip to content

Conversation

@zeusongit
Copy link
Contributor

@zeusongit zeusongit commented Jun 3, 2025

Purpose

When opening large graphs the workspace appears to become dirty, and that kicks off the backup process in the background, which adds delay to the loading process.
This seems to happen when groups are being loaded and setting their text values makes the graph dirty, so for a fix checking if the group has been rendered when TextChange event is triggered, to differentiate from an explicit change and an implicit one at initialization at which point group has not been actually rendered.

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

Fix graphs opening in a dirty state

Reviewers

@DynamoDS/eidos

Copilot AI review requested due to automatic review settings June 3, 2025 19:36
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-8986

@zeusongit zeusongit requested a review from a team June 3, 2025 19:36
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 ensures that setting HasUnsavedChanges only occurs once group text boxes are actually rendered, preventing the workspace from being marked dirty during graph load.

  • Wraps HasUnsavedChanges assignment in an ActualHeight/ActualWidth check for group title and description text boxes
  • Applies the same guard to both GroupTextBox_OnTextChanged and GroupDescriptionTextBox_TextChanged handlers
Comments suppressed due to low confidence (2)

src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs:240

  • Add a comment explaining that this check distinguishes implicit initialization changes from explicit user edits, clarifying why we only mark the workspace dirty after rendering.
if (GroupTextBox.ActualHeight > 0 && GroupTextBox.ActualWidth > 0)

src/DynamoCoreWpf/Views/Core/AnnotationView.xaml.cs:240

  • Add unit or integration tests to verify that HasUnsavedChanges remains false during initialization (when dimensions are zero) and becomes true on actual user edits.
if (GroupTextBox.ActualHeight > 0 && GroupTextBox.ActualWidth > 0)

SetTextMaxWidth();
SetTextHeight();
ViewModel.WorkspaceViewModel.HasUnsavedChanges = true;
if (GroupTextBox.ActualHeight > 0 && GroupTextBox.ActualWidth > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the textbox has custom group name and description already, won't the actual H & W be greater than 0. We don't want to set the HasUnsavedChanges to true in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

H & W are 0 only at initialization, at which point the group title and description are set (custom or default)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, are the height and width greater than zero only after the text is changed?

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, at-least at initialization, when WPF is creating groups.

The group text is bind to AnnotationText, which is set to the stored value when the control is initialized, that action should not trigger HasUnsaved changes, because we are initializing the group for the first time.
I tried capturing this by IsLoaded and IsReady events, but at this point none of them worked, so I needed a way to differentiate between an explicit action by the user to change the text versus group text initialization on workspace load. So I found that H & W are 0 at this point which won't be the case when any user action would trigger it.

Copy link
Contributor

@aparajit-pratap aparajit-pratap left a comment

Choose a reason for hiding this comment

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

I'm curious how you isolated the graph being marked dirty due to the group text changing?

@zeusongit
Copy link
Contributor Author

I'm curious how you isolated the graph being marked dirty due to the group text changing?

Put a breakpoint in HasUnsavedChanges setter, and tracked the call stack

@zeusongit
Copy link
Contributor Author

@zeusongit zeusongit merged commit 869404e into DynamoDS:master Jun 5, 2025
22 checks passed
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