Skip to content

Conversation

@MDrakakis
Copy link

Updated GitHubActionsVS.csproj to include new source files: StringHelpers.cs, YamlHelpers.cs, InputMetadata.cs, and Workflow.cs. Added YamlDotNet package reference. Introduced WorkflowInputsDialog.xaml for user input and modified GHActionsToolWindow to integrate this dialog. Added utility classes for Base64 checking and YAML alias resolution. Enhanced input metadata representation and refactored code for improved readability and maintainability.

Updated `GitHubActionsVS.csproj` to include new source files: `StringHelpers.cs`, `YamlHelpers.cs`, `InputMetadata.cs`, and `Workflow.cs`. Added `YamlDotNet` package reference. Introduced `WorkflowInputsDialog.xaml` for user input and modified `GHActionsToolWindow` to integrate this dialog. Added utility classes for Base64 checking and YAML alias resolution. Enhanced input metadata representation and refactored code for improved readability and maintainability.
@MDrakakis
Copy link
Author

MDrakakis commented Oct 1, 2025

This PR introduces one improvement based on Issue #23

Improvements

  • Dynamic input dialog
  • Workflow inputs are now generated directly from the YAML metadata.
  • Default values and required flags are automatically applied.
  • The dialog adapts to any workflow definition without requiring manual code changes.

Helpers

  • Added YamlHelpers for unaliasing and safe key lookups.
  • Added StringHelpers.IsBase64 for safe Base64 content detection.

Notes
This is a non-breaking change: existing workflows continue to run as before, but workflows with defined inputs now display a dynamic dialog for user input.

User Experience
When a user clicks Run Workflow, the following window is displayed to collect input values:
973958a9-fd50-4430-a1f1-df9985ef3aaf

Example YAML Tested
Here’s an example workflow definition used for testing:
image

@timheuer
Copy link
Owner

timheuer commented Oct 2, 2025

thanks @MDrakakis -- acknowledging this PR -- gonna find some time to look at this and run it a bit. THanks for the screenshots of the change too.

@timheuer timheuer requested a review from Copilot October 2, 2025 15:15
Copy link

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 adds comprehensive workflow input handling and YAML support to the GitHub Actions Visual Studio extension. It introduces functionality to parse workflow YAML files, extract input definitions, and present a dialog for users to provide input values when running workflows.

Key changes:

  • Added YAML parsing capabilities with YamlDotNet package integration
  • Created workflow input dialog UI for user interaction when dispatching workflows
  • Implemented helper classes for Base64 detection and YAML node manipulation

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/GitHubActionsVS.csproj Added new source files and YamlDotNet package reference
src/UserControls/WorkflowInputsDialog.xaml Dialog UI for collecting workflow input values from users
src/UserControls/WorkflowInputsDialog.xaml.cs Dialog logic with dynamic control creation and validation
src/ToolWindows/GHActionsToolWindow.xaml.cs Enhanced workflow dispatch with input parsing and dialog integration
src/ToolWindows/GHActionsToolWindow.xaml Removed themed TreeView styles
src/Models/Workflow.cs YAML deserialization models for workflow structure
src/Models/InputMetadata.cs Input metadata representation and conversion logic
src/Helpers/YamlHelpers.cs YAML node manipulation utilities
src/Helpers/StringHelpers.cs Base64 validation utility

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +107 to +112
foreach (char c in text)
{
if (!(char.IsDigit(c) || c == '-' || c == '.'))
return false;
}
return true;
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The numeric validation logic has several issues: it allows multiple decimal points (e.g., '1.2.3'), multiple minus signs anywhere in the string (e.g., '1-2-3'), and minus signs in invalid positions (e.g., '12-'). Consider using decimal.TryParse() or implementing proper position-based validation.

Suggested change
foreach (char c in text)
{
if (!(char.IsDigit(c) || c == '-' || c == '.'))
return false;
}
return true;
decimal dummy;
return decimal.TryParse(text, out dummy);

Copilot uses AI. Check for mistakes.
}
else if (control is ComboBox cb)
{
string chosen = null;
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The variable 'chosen' should be initialized as 'string.Empty' instead of 'null' to avoid potential null reference issues and maintain consistency with the rest of the codebase that uses string.Empty for empty strings.

Suggested change
string chosen = null;
string chosen = string.Empty;

Copilot uses AI. Check for mistakes.
var workflowContent = contents.FirstOrDefault()?.Content;

if (!string.IsNullOrEmpty(workflowContent) && StringHelpers.IsBase64(workflowContent))
workflowContent = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(workflowContent));
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The Base64 decoding is not wrapped in a try-catch block. If the Base64 validation is incorrect or the string contains invalid Base64 characters, Convert.FromBase64String() will throw an exception, causing the workflow dispatch to fail.

Suggested change
workflowContent = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(workflowContent));
{
try
{
workflowContent = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(workflowContent));
}
catch (FormatException ex)
{
await _pane.WriteLineAsync($"[{DateTime.UtcNow:o}] Error decoding workflow file content: {ex.Message}");
workflowContent = null;
}
}

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,27 @@
namespace GitHubActionsVS.Helpers
{
internal class StringHelpers
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The StringHelpers class should be declared as 'static' since all its methods are static. This prevents instantiation and makes the intent clearer.

Suggested change
internal class StringHelpers
internal static class StringHelpers

Copilot uses AI. Check for mistakes.
}
}

value = null!;
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

[nitpick] Using 'null!' (null-forgiving operator) here is misleading since the method is designed to return false when no value is found. Consider using 'value = default!' or restructuring to avoid the null-forgiving operator.

Suggested change
value = null!;
value = default;

Copilot uses AI. Check for mistakes.
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.

2 participants