Skip to content

Add optional parameter to PromptForSelectionsAsync#14961

Merged
davidfowl merged 4 commits intorelease/13.2from
dev/machaff/prompt-selections-not-required
Mar 5, 2026
Merged

Add optional parameter to PromptForSelectionsAsync#14961
davidfowl merged 4 commits intorelease/13.2from
dev/machaff/prompt-selections-not-required

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Mar 5, 2026

Description

Add a notRequired parameter to PromptForSelectionsAsync so callers can allow users to submit the multi-selection prompt without choosing any items.

Changes:

  • Added bool notRequired = false parameter to IInteractionService.PromptForSelectionsAsync
  • Updated ConsoleInteractionService to conditionally call .NotRequired() on the Spectre.Console MultiSelectionPrompt when the parameter is true
  • Updated ExtensionInteractionService to pass through the parameter
  • Updated TestConsoleInteractionService test implementation
  • Enabled notRequired: true at all three existing call sites (InitCommand x2, AgentInitCommand x1) since they all handle empty selections gracefully

Fixes #14841
Fixes #14460

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Add a notRequired parameter (default false) to PromptForSelectionsAsync across the interface, all implementations, and test services. When true, the Spectre.Console MultiSelectionPrompt allows submitting without selecting any items. Enable notRequired at all three existing call sites (InitCommand and AgentInitCommand) since they all handle empty selections gracefully.
Copilot AI review requested due to automatic review settings March 5, 2026 01:07
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14961

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14961"

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 adds a notRequired parameter to PromptForSelectionsAsync across the interaction service interface and its implementations, allowing callers to let users submit a multi-selection prompt without choosing any items. The parameter is then enabled at all existing call sites.

Changes:

  • Added bool notRequired = false parameter to the PromptForSelectionsAsync method signature in the interface, console service, extension service, and test service.
  • Applied .NotRequired() on the Spectre.Console MultiSelectionPrompt when the parameter is true in ConsoleInteractionService.
  • Passed notRequired: true at all three existing call sites (InitCommand ×2, AgentInitCommand ×1).

Reviewed changes

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

Show a summary per file
File Description
src/Aspire.Cli/Interaction/IInteractionService.cs Added notRequired parameter to the interface method signature.
src/Aspire.Cli/Interaction/ConsoleInteractionService.cs Implemented conditional .NotRequired() call on the Spectre.Console prompt.
src/Aspire.Cli/Interaction/ExtensionInteractionService.cs Added parameter and passes it through to the console interaction service.
tests/Aspire.Cli.Tests/TestServices/TestConsoleInteractionService.cs Updated test implementation to accept the new parameter.
src/Aspire.Cli/Commands/InitCommand.cs Enabled notRequired: true at both multi-selection call sites.
src/Aspire.Cli/Commands/AgentInitCommand.cs Enabled notRequired: true at the agent init multi-selection call site.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 258d30b:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AgentInitCommand_WithMalformedMcpJson_ShowsErrorAndExitsNonZero ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateStartWaitAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ❌ Upload failed
StopNonInteractiveSingleAppHost ❌ Upload failed
StopWithNoRunningAppHostExitsSuccessfully ❌ Upload failed
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #22700986081

JamesNK added 2 commits March 5, 2026 10:02
…nsolidate duplicates

- Renamed TestConsoleInteractionService to TestInteractionService across all test files
- Enhanced shared implementation with response queue, call tracking, and cancellation support
- Removed TestConsoleInteractionServiceWithPromptTracking from PublishCommandPromptingIntegrationTests (merged into shared impl)
- Removed OrderTrackingInteractionService from NewCommandTests (replaced with shared impl + callback)
- Removed private TestInteractionService stub from DotNetTemplateFactoryTests (uses shared impl)
- Kept CancellationTrackingInteractionService as-is (decorator pattern, different purpose)
The double-negative naming pattern (notRequired: false meaning 'required') was
confusing at call sites. Renamed to 'optional' for clarity across the interface,
all implementations, and call sites.
@JamesNK JamesNK changed the title Add notRequired parameter to PromptForSelectionsAsync Add optional parameter to PromptForSelectionsAsync Mar 5, 2026
@davidfowl davidfowl merged commit bed78ee into release/13.2 Mar 5, 2026
760 of 763 checks passed
@davidfowl davidfowl deleted the dev/machaff/prompt-selections-not-required branch March 5, 2026 05:58
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 5, 2026
eerhardt pushed a commit to eerhardt/aspire that referenced this pull request Mar 7, 2026
* Add notRequired parameter to PromptForSelectionsAsync

Add a notRequired parameter (default false) to PromptForSelectionsAsync across the interface, all implementations, and test services. When true, the Spectre.Console MultiSelectionPrompt allows submitting without selecting any items. Enable notRequired at all three existing call sites (InitCommand and AgentInitCommand) since they all handle empty selections gracefully.

* Rename TestConsoleInteractionService to TestInteractionService and consolidate duplicates

- Renamed TestConsoleInteractionService to TestInteractionService across all test files
- Enhanced shared implementation with response queue, call tracking, and cancellation support
- Removed TestConsoleInteractionServiceWithPromptTracking from PublishCommandPromptingIntegrationTests (merged into shared impl)
- Removed OrderTrackingInteractionService from NewCommandTests (replaced with shared impl + callback)
- Removed private TestInteractionService stub from DotNetTemplateFactoryTests (uses shared impl)
- Kept CancellationTrackingInteractionService as-is (decorator pattern, different purpose)

* Code clean up

* Rename notRequired parameter to optional in PromptForSelectionsAsync

The double-negative naming pattern (notRequired: false meaning 'required') was
confusing at call sites. Renamed to 'optional' for clarity across the interface,
all implementations, and call sites.
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
* Add notRequired parameter to PromptForSelectionsAsync

Add a notRequired parameter (default false) to PromptForSelectionsAsync across the interface, all implementations, and test services. When true, the Spectre.Console MultiSelectionPrompt allows submitting without selecting any items. Enable notRequired at all three existing call sites (InitCommand and AgentInitCommand) since they all handle empty selections gracefully.

* Rename TestConsoleInteractionService to TestInteractionService and consolidate duplicates

- Renamed TestConsoleInteractionService to TestInteractionService across all test files
- Enhanced shared implementation with response queue, call tracking, and cancellation support
- Removed TestConsoleInteractionServiceWithPromptTracking from PublishCommandPromptingIntegrationTests (merged into shared impl)
- Removed OrderTrackingInteractionService from NewCommandTests (replaced with shared impl + callback)
- Removed private TestInteractionService stub from DotNetTemplateFactoryTests (uses shared impl)
- Kept CancellationTrackingInteractionService as-is (decorator pattern, different purpose)

* Code clean up

* Rename notRequired parameter to optional in PromptForSelectionsAsync

The double-negative naming pattern (notRequired: false meaning 'required') was
confusing at call sites. Renamed to 'optional' for clarity across the interface,
all implementations, and call sites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants