From c2966e01679c73c9fc83a11aeb6e6574b6908e60 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 18:13:52 +0000 Subject: [PATCH 1/3] Initial plan From d4222af84dca504bbf9959eefadc34f389f07678 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 18:18:32 +0000 Subject: [PATCH 2/3] DYN-9151 show trust warning before file open execution Agent-Logs-Url: https://github.com/DynamoDS/Dynamo/sessions/6a0b0707-437a-4932-99a5-642be0cb85b4 Co-authored-by: johnpierson <15744724+johnpierson@users.noreply.github.com> --- .../ViewModels/Core/DynamoViewModel.cs | 57 +++++++++++++------ test/DynamoCoreWpfTests/DynamoViewTests.cs | 28 +++++++++ 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 2fbe44f1901..201dfb2c32d 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2203,6 +2203,7 @@ private void Open(object parameters) fileContents = string.Empty; bool forceManualMode = false; bool isTemplate = false; + bool trustWarningWasShown = false; try { if (parameters is Tuple packedParams) @@ -2229,25 +2230,36 @@ private void Open(object parameters) && !DynamoModel.IsTestMode && !PreferenceSettings.DisableTrustWarnings && FileTrustViewModel != null; - RunSettings.ForceBlockRun = displayTrustWarning; - // Execute graph open command - ExecuteCommand(new DynamoModel.OpenFileCommand(filePath, forceManualMode, isTemplate)); - // Apply annotation updates based on the preference setting - RefreshAnnotationDescriptions(); - - // Only show trust warning popop when current opened workspace is homeworkspace and not custom node workspace - if (displayTrustWarning && (currentWorkspaceViewModel?.IsHomeSpace ?? false)) + if (displayTrustWarning) { - // Skip these when opening dyf FileTrustViewModel.AllowOneTimeTrust = false; FileTrustViewModel.DynFileDirectoryName = directoryName; FileTrustViewModel.ShowWarningPopup = true; (HomeSpaceViewModel as HomeWorkspaceViewModel)?.UpdateRunStatusMsgBasedOnStates(); + trustWarningWasShown = true; + } + + RunSettings.ForceBlockRun = displayTrustWarning; + // Execute graph open command + ExecuteCommand(new DynamoModel.OpenFileCommand(filePath, forceManualMode, isTemplate)); + + if (trustWarningWasShown) + { + ShowHideFileTrustWarningIfCurrentWorkspaceTrusted(); } + + // Apply annotation updates based on the preference setting + RefreshAnnotationDescriptions(); } catch (Exception e) { + if (trustWarningWasShown) + { + FileTrustViewModel.ShowWarningPopup = false; + RunSettings.ForceBlockRun = false; + } + if (!DynamoModel.IsTestMode) { string commandString = String.Format(Resources.MessageErrorOpeningFileGeneral); @@ -2301,6 +2313,7 @@ private void Insert(object parameters) filePath = string.Empty; fileContents = string.Empty; bool forceManualMode = true; + bool trustWarningWasShown = false; try { if (parameters is Tuple packedParams) @@ -2321,24 +2334,34 @@ private void Insert(object parameters) && !DynamoModel.IsTestMode && !PreferenceSettings.DisableTrustWarnings && FileTrustViewModel != null; - RunSettings.ForceBlockRun = displayTrustWarning; - // Execute graph open command - ExecuteCommand(new DynamoModel.InsertFileCommand(filePath, forceManualMode)); - this.FitViewCommand.Execute(null); - - // Only show trust warning popup when current opened workspace is homeworkspace and not custom node workspace - if (displayTrustWarning && (currentWorkspaceViewModel?.IsHomeSpace ?? false)) + if (displayTrustWarning) { - // Skip these when opening dyf FileTrustViewModel.AllowOneTimeTrust = false; FileTrustViewModel.DynFileDirectoryName = directoryName; FileTrustViewModel.ShowWarningPopup = true; (HomeSpaceViewModel as HomeWorkspaceViewModel)?.UpdateRunStatusMsgBasedOnStates(); + trustWarningWasShown = true; + } + + RunSettings.ForceBlockRun = displayTrustWarning; + // Execute graph open command + ExecuteCommand(new DynamoModel.InsertFileCommand(filePath, forceManualMode)); + + this.FitViewCommand.Execute(null); + if (trustWarningWasShown) + { + ShowHideFileTrustWarningIfCurrentWorkspaceTrusted(); } } catch (Exception e) { + if (trustWarningWasShown) + { + FileTrustViewModel.ShowWarningPopup = false; + RunSettings.ForceBlockRun = false; + } + if (!DynamoModel.IsTestMode) { string commandString = String.Format(Resources.MessageErrorOpeningFileGeneral); diff --git a/test/DynamoCoreWpfTests/DynamoViewTests.cs b/test/DynamoCoreWpfTests/DynamoViewTests.cs index 030edfefbcd..8ed929573bd 100644 --- a/test/DynamoCoreWpfTests/DynamoViewTests.cs +++ b/test/DynamoCoreWpfTests/DynamoViewTests.cs @@ -106,6 +106,34 @@ public void OpeningWorkspaceWithTclsrustWarning() DynamoModel.IsTestMode = true; } + [Test] + public void OpeningWorkspaceShowsTrustWarningBeforeOpenCommandStarts() + { + DynamoModel.IsTestMode = false; + bool? popupStateWhenOpenStarts = null; + + void OnCommandStarting(DynamoModel.RecordableCommand command) + { + if (command is DynamoModel.OpenFileCommand) + { + popupStateWhenOpenStarts = ViewModel.FileTrustViewModel.ShowWarningPopup; + } + } + + Model.CommandStarting += OnCommandStarting; + try + { + Open(@"core\CustomNodes\TestAdd.dyn"); + } + finally + { + Model.CommandStarting -= OnCommandStarting; + DynamoModel.IsTestMode = true; + } + + Assert.IsTrue(popupStateWhenOpenStarts.GetValueOrDefault(false)); + } + [Test] public void TestHomeWorkspaceClosedBeforeCustomNode() { From 21f667478e07096a5265c8b1249980a8c3e04ede Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 18:22:11 +0000 Subject: [PATCH 3/3] DYN-9151 add ordering regression tests for open and insert trust warnings Agent-Logs-Url: https://github.com/DynamoDS/Dynamo/sessions/6a0b0707-437a-4932-99a5-642be0cb85b4 Co-authored-by: johnpierson <15744724+johnpierson@users.noreply.github.com> --- .../ViewModels/Core/DynamoViewModel.cs | 25 ++++++++------ test/DynamoCoreWpfTests/DynamoViewTests.cs | 34 ++++++++++++++++++- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs index 201dfb2c32d..29f61fd54ca 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs @@ -2180,6 +2180,18 @@ private void OpenFromJson(object parameters) this.ShowStartPage = false; // Hide start page if there's one. } + /// + /// Resets trust warning state when a preemptively shown popup should be dismissed. + /// + /// True when this open/insert flow displayed the trust warning before command execution. + private void ResetTrustWarningStateIfNeeded(bool trustWarningWasShown) + { + if (!trustWarningWasShown || FileTrustViewModel == null) return; + + FileTrustViewModel.ShowWarningPopup = false; + RunSettings.ForceBlockRun = false; + } + /// /// Open a definition or workspace. /// For most cases, parameters variable refers to the file path to open @@ -2246,6 +2258,7 @@ private void Open(object parameters) if (trustWarningWasShown) { + // Hide the preemptively shown popup if trust is now satisfied (trusted path or warnings disabled). ShowHideFileTrustWarningIfCurrentWorkspaceTrusted(); } @@ -2254,11 +2267,7 @@ private void Open(object parameters) } catch (Exception e) { - if (trustWarningWasShown) - { - FileTrustViewModel.ShowWarningPopup = false; - RunSettings.ForceBlockRun = false; - } + ResetTrustWarningStateIfNeeded(trustWarningWasShown); if (!DynamoModel.IsTestMode) { @@ -2356,11 +2365,7 @@ private void Insert(object parameters) } catch (Exception e) { - if (trustWarningWasShown) - { - FileTrustViewModel.ShowWarningPopup = false; - RunSettings.ForceBlockRun = false; - } + ResetTrustWarningStateIfNeeded(trustWarningWasShown); if (!DynamoModel.IsTestMode) { diff --git a/test/DynamoCoreWpfTests/DynamoViewTests.cs b/test/DynamoCoreWpfTests/DynamoViewTests.cs index 8ed929573bd..ba704d70f79 100644 --- a/test/DynamoCoreWpfTests/DynamoViewTests.cs +++ b/test/DynamoCoreWpfTests/DynamoViewTests.cs @@ -107,7 +107,7 @@ public void OpeningWorkspaceWithTclsrustWarning() } [Test] - public void OpeningWorkspaceShowsTrustWarningBeforeOpenCommandStarts() + public void WhenOpeningWorkspaceThenTrustWarningIsShownBeforeCommand() { DynamoModel.IsTestMode = false; bool? popupStateWhenOpenStarts = null; @@ -134,6 +134,38 @@ void OnCommandStarting(DynamoModel.RecordableCommand command) Assert.IsTrue(popupStateWhenOpenStarts.GetValueOrDefault(false)); } + [Test] + public void WhenInsertingWorkspaceThenTrustWarningIsShownBeforeCommand() + { + DynamoModel.IsTestMode = false; + bool? popupStateWhenInsertStarts = null; + + void OnCommandStarting(DynamoModel.RecordableCommand command) + { + if (command is DynamoModel.InsertFileCommand) + { + popupStateWhenInsertStarts = ViewModel.FileTrustViewModel.ShowWarningPopup; + } + } + + Model.CommandStarting += OnCommandStarting; + try + { + var insertMethod = typeof(DynamoViewModel).GetMethod("Insert", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(insertMethod); + + var insertPath = Path.Combine(GetTestDirectory(ExecutingDirectory), @"core\CustomNodes\TestAdd.dyn"); + insertMethod.Invoke(ViewModel, new object[] { insertPath }); + } + finally + { + Model.CommandStarting -= OnCommandStarting; + DynamoModel.IsTestMode = true; + } + + Assert.IsTrue(popupStateWhenInsertStarts.GetValueOrDefault(false)); + } + [Test] public void TestHomeWorkspaceClosedBeforeCustomNode() {