Update CLI confirmation prompts to use [Y/n] convention#15663
Update CLI confirmation prompts to use [Y/n] convention#15663
Conversation
Agent-Logs-Url: https://github.com/microsoft/aspire/sessions/a62011ab-6d8c-4a64-b8f2-13ab5a7aaddf Co-authored-by: maddymontaquila <12660687+maddymontaquila@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates Aspire CLI confirmation prompts to follow the common convention of capitalizing the default choice ([Y/n] or [y/N]) instead of Spectre.Console’s default [y/n] (y) rendering.
Changes:
- Replaces
IAnsiConsole.ConfirmAsync(...)with a manually-configuredConfirmationPrompt. - Hides Spectre’s built-in choices/default display and prepends a custom
[Y/n]or[y/N]suffix to the prompt text.
| // Use [Y/n] or [y/N] convention where the capitalized letter indicates the default value. | ||
| var yesChoice = defaultValue ? "Y" : "y"; | ||
| var noChoice = defaultValue ? "n" : "N"; | ||
| var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]"; |
There was a problem hiding this comment.
fullPromptText embeds [Y/n] using single brackets, but Spectre.Console treats [...] as markup tags. This will render incorrectly and can throw InvalidMarkupException because there’s no closing tag. Escape the choice suffix (e.g., use doubled brackets [[...]] or otherwise ensure the brackets are treated as literal text).
| var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]"; | |
| var fullPromptText = $"{promptText} [[{yesChoice}/{noChoice}]]"; |
| var prompt = new ConfirmationPrompt(fullPromptText) | ||
| { | ||
| ShowChoices = false, | ||
| ShowDefaultValue = false, |
There was a problem hiding this comment.
defaultValue is now only used to choose the casing for Y/n, but it is no longer applied to the prompt behavior. To preserve the method contract, set the ConfirmationPrompt default (e.g., prompt.DefaultValue = defaultValue) so pressing Enter returns the intended default.
| ShowDefaultValue = false, | |
| ShowDefaultValue = false, | |
| DefaultValue = defaultValue, |
| // Use [Y/n] or [y/N] convention where the capitalized letter indicates the default value. | ||
| var yesChoice = defaultValue ? "Y" : "y"; | ||
| var noChoice = defaultValue ? "n" : "N"; | ||
| var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]"; | ||
|
|
||
| var prompt = new ConfirmationPrompt(fullPromptText) | ||
| { | ||
| ShowChoices = false, | ||
| ShowDefaultValue = false, | ||
| }; | ||
|
|
||
| var result = await MessageConsole.PromptAsync(prompt, cancellationToken); |
There was a problem hiding this comment.
This change alters interactive prompt rendering/behavior but there are no tests validating the new [Y/n] formatting or the default-value semantics (Enter should select the configured default). Consider adding a focused unit test around ConfirmAsync similar to the existing ConsoleInteractionServiceTests patterns to prevent regressions.
CLI confirmation prompts showed default values as
[y/n] (y):— a non-standard format. The convention is to capitalize the default choice:[Y/n].Before:
Perform updates? [y/n] (y):After:
Perform updates? [Y/n]:Changes
ConsoleInteractionService.ConfirmAsync: ReplaceIAnsiConsole.ConfirmAsync(which renders Spectre's[y/n] (y)format) with aConfirmationPromptthat hasShowChoices = falseandShowDefaultValue = false, and manually prepend[Y/n]or[y/N]to the prompt text based ondefaultValue.Checklist
⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.