Skip to content

Conversation

@aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented May 22, 2025

Purpose

This approach is similar to #16191, except for initializing a custom HTTP client that returns a service unavailable response and injecting that into the PM client for all requests.

This depends on the version of PM client that has the changes in DynamoDS/PackageManagerClient#116.

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

(FILL ME IN) Brief description of the fix / enhancement. Use N/A to indicate that the changes in this pull request do not apply to Release Notes. Mandatory section

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

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

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-6409

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@aparajit-pratap aparajit-pratap requested a review from avidit May 22, 2025 13:49
@aparajit-pratap aparajit-pratap requested a review from Copilot May 23, 2025 02:14

This comment was marked as duplicate.

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

I would vote for this approach, looks and works better IMO

@aparajit-pratap aparajit-pratap marked this pull request as ready for review May 28, 2025 16:23
@aparajit-pratap aparajit-pratap requested a review from Copilot May 28, 2025 16: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 implements an offline (no-network) mode by propagating a NoNetworkMode flag through sessions, HTTP clients, core nodes, and UI view models to disable network operations when Dynamo is offline.

  • Introduce a NoNetworkMode session parameter and a helper/HTTP handler to intercept and block outgoing requests.
  • Inject the custom handler into the PackageManager client and pass the offline flag to disable PM operations.
  • Update core nodes and view models to guard against network calls and disable related UI commands.

Reviewed Changes

Copilot reviewed 23 out of 33 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/NodeServices/ExecutionSession.cs Add NoNetworkMode key, ThrowIfNoNetworkMode helper, and a NoNetworkModeHandler
src/Libraries/CoreNodes/Web.cs Guard WebRequestByUrl with ThrowIfNoNetworkMode
src/Libraries/CoreNodeModels/WebRequest.cs Refactor NodeDescription attribute to use nameof
src/DynamoPackages/PackageManagerExtension.cs Inject HttpClient with NoNetworkModeHandler, pass offline flag
src/DynamoPackages/PackageManagerClient.cs Store NoNetworkMode, update constructor, clean up field usage
src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs Disable publish commands when offline
src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs Expose NoNetworkMode property
src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs Disable package manager menu commands when offline
src/DynamoCore/Models/DynamoModel.cs Update documentation for NoNetworkMode
src/DynamoCore/Configuration/ExecutionSession.cs Initialize NoNetworkMode in session parameters
Files not reviewed (10)
  • src/DynamoCore/DynamoCore.csproj: Language not supported
  • src/DynamoCoreWpf/DynamoCoreWpf.csproj: Language not supported
  • src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml: Language not supported
  • src/DynamoMLDataPipeline/DynamoMLDataPipeline.csproj: Language not supported
  • src/DynamoPackages/DynamoPackages.csproj: Language not supported
  • src/DynamoPackages/Properties/Resources.Designer.cs: Language not supported
  • src/DynamoPackages/Properties/Resources.en-US.resx: Language not supported
  • src/DynamoPackages/Properties/Resources.resx: Language not supported
  • src/NodeServices/DynamoServices.csproj: Language not supported
  • src/NodeServices/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (5)

src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs:455

  • The previous check for Selection.Count > 0 was removed, causing this to return true when the selection is empty (since All is vacuously true). Reintroduce the count check to prevent publishing with no selected nodes.
return DynamoSelection.Instance.Selection.All(x => x is Function) && AuthenticationManager.HasAuthProvider && !Model.NoNetworkMode;

src/NodeServices/ExecutionSession.cs:2

  • [nitpick] Remove the unused System.Collections.Generic using directive to reduce clutter.
using System.Collections.Generic;

src/Libraries/CoreNodes/Web.cs:16

  • Add a unit test to verify that WebRequestByUrl throws the expected InvalidOperationException with the offline warning when NoNetworkMode is enabled.
ExecutionSessionHelper.ThrowIfNoNetworkMode();

src/NodeServices/ExecutionSession.cs:132

  • Add a unit test for NoNetworkModeHandler to confirm that SendAsync returns HTTP 503 with the expected JSON payload and reason phrase.
var json = "{\"success\":false,\"message\":\"Application is in offline mode\",\"content\":null}";

src/Libraries/CoreNodes/Web.cs:13

  • Add XML documentation to indicate that this method throws InvalidOperationException when running in offline mode via ThrowIfNoNetworkMode().
public static string WebRequestByUrl(string url)

Copy link
Contributor

@reddyashish reddyashish left a comment

Choose a reason for hiding this comment

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

Looks good to me

@aparajit-pratap aparajit-pratap merged commit 5831a52 into DynamoDS:master May 29, 2025
27 of 29 checks passed
@aparajit-pratap aparajit-pratap deleted the dyn-6409_2 branch May 29, 2025 15:02
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