Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Aspire.Cli/Interaction/ConsoleInteractionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,19 @@ public async Task<bool> ConfirmAsync(string promptText, bool defaultValue = true
}

MessageLogger.LogInformation("Confirm: {PromptText} (default: {DefaultValue})", promptText, defaultValue);
var result = await MessageConsole.ConfirmAsync(promptText, defaultValue, cancellationToken);

// 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}]";
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
var fullPromptText = $"{promptText} [{yesChoice}/{noChoice}]";
var fullPromptText = $"{promptText} [[{yesChoice}/{noChoice}]]";

Copilot uses AI. Check for mistakes.

var prompt = new ConfirmationPrompt(fullPromptText)
{
ShowChoices = false,
ShowDefaultValue = false,
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
ShowDefaultValue = false,
ShowDefaultValue = false,
DefaultValue = defaultValue,

Copilot uses AI. Check for mistakes.
};

var result = await MessageConsole.PromptAsync(prompt, cancellationToken);
Comment on lines +432 to +443
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
MessageLogger.LogInformation("Confirm result: {Result}", result);
return result;
}
Expand Down
Loading