Skip to content

Labels not properly show for PromptInputsAsync call with single InteractionInput in CLI #10465

@captainsafia

Description

@captainsafia

Root cause

PublishCommandBase.HandlePromptActivityAsync builds the prompt text like so:

var promptText = inputs.Count > 1
    ? $"{input.Label}: "
    : $"[bold]{activity.Data.StatusText}[/]";
  • For multi-input prompts (inputs.Count > 1) the label is displayed (input.Label).
  • For a single input the label is ignored, and only StatusText is shown.

Because PublishingActivityReporter uses StatusText for narrative context (e.g., “Configure deployment target”), not for the field label, the prompt becomes ambiguous.


Proposed fix

  1. Always prefer input.Label when it is provided, even for single inputs.
  2. For single-input prompts, prepend the bold header (StatusText) only when it is different from the label, avoiding duplication.
  3. Escape Spectre.Console markup in both StatusText and Label.

Illustrative helper:

private static string BuildPromptText(
    PublishingPromptInput input,
    int inputCount,
    string statusText)
{
    if (inputCount > 1)
        return $"{input.Label.EscapeMarkup()}: ";

    // Single-input path
    var header = statusText ?? string.Empty;
    var label  = input.Label ?? string.Empty;

    if (header.Equals(label, StringComparison.OrdinalIgnoreCase))
        return $"{label.EscapeMarkup()}: ";

    return $"[bold]{header.EscapeMarkup()}[/] {label.EscapeMarkup()}: ";
}

Acceptance criteria

  • A single-input prompt displays both context (StatusText) and the field label (Label), formatted as:
    <StatusText> <Label>: separated by a new line
  • If StatusText equals Label, the prompt shows only the label once.
  • Multi-input prompts remain unchanged.
  • Unit tests cover: single input, multi input, StatusText = Label, and Spectre markup escaping.

Tasks

  • Update PublishCommandBase.HandlePromptActivityAsync (or extract a helper) with the logic above.
  • Add/adjust unit tests in Aspire.Cli.Tests verifying correct console output.
  • Run dotnet test and ensure all publishing CLI tests pass.
  • (Optional) document the prompt behavior in the publishing CLI README.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions