Skip to content

Suppress animated banner auto-display in CI/non-interactive environments#14792

Merged
radical merged 2 commits intomainfrom
copilot/update-aspire-cli-banner-display
Feb 28, 2026
Merged

Suppress animated banner auto-display in CI/non-interactive environments#14792
radical merged 2 commits intomainfrom
copilot/update-aspire-cli-banner-display

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Description

The CLI animated banner was unconditionally shown on first run, including in CI pipelines and non-interactive environments where it pollutes logs. Gate the auto-first-run banner on ICliHostEnvironment.SupportsInteractiveOutput, which already detects CI (via CI, GITHUB_ACTIONS, TF_BUILD, etc.), --non-interactive, and ASPIRE_NON_INTERACTIVE. Explicit --banner continues to work regardless of interactivity.

Changes

  • src/Aspire.Cli/Program.csDisplayFirstTimeUseNoticeIfNeededAsync: resolve ICliHostEnvironment from DI and add SupportsInteractiveOutput guard to the first-run banner path only (explicit --banner path is unguarded):

    // Before
    if (showBanner || (isFirstRun && !noLogo))
    
    // After
    var hostEnvironment = serviceProvider.GetRequiredService<ICliHostEnvironment>();
    if (showBanner || (isFirstRun && !noLogo && hostEnvironment.SupportsInteractiveOutput))
  • tests/Aspire.Cli.Tests/Commands/RootCommandTests.cs — Two new unit tests:

    • FirstTimeUseNotice_BannerNotDisplayedInNonInteractiveEnvironment: first run + non-interactive → banner suppressed, sentinel still created
    • Banner_DisplayedWithExplicitBannerFlag_InNonInteractiveEnvironment: --banner → banner shown even when non-interactive

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
Original prompt

Goal

In dotnet/aspire, update the Aspire CLI first-run experience so the animated banner is only auto-shown when running in an interactive environment (suitable for TTY/local use) and is suppressed in CI/non-interactive environments.

Background / Current Behavior

  • The CLI currently auto-shows the animated banner on first run by default (unless suppressed by --nologo or informational commands), via:
    • src/Aspire.Cli/Program.cs method DisplayFirstTimeUseNoticeIfNeededAsync.
  • The animation is implemented in:
    • src/Aspire.Cli/Interaction/BannerService.cs.
  • The repo already has a pattern for detecting CI/non-interactive environments via:
    • src/Aspire.Cli/Utils/CliHostEnvironment.cs (ICliHostEnvironment with SupportsInteractiveOutput, SupportsInteractiveInput, plus CI env var detection and ASPIRE_NON_INTERACTIVE).

Required Change

  1. Modify the banner auto-display logic so the banner is only shown automatically on first run when the host supports interactive output.

    • Use the existing ICliHostEnvironment.SupportsInteractiveOutput capability.
    • Keep --banner behavior: If the user explicitly passes --banner, still show the banner even in non-interactive environments (unless the current logic already prevents it via other flags).
    • Preserve existing suppression behavior via --nologo, configuration CliConfigNames.NoLogo, and informational commands.
  2. Update tests accordingly.

    • Add/adjust unit tests in tests/Aspire.Cli.Tests/Commands/RootCommandTests.cs (or appropriate existing test file) to cover:
      • First run + non-interactive output => banner NOT shown.
      • Explicit --banner still shows banner regardless of interactivity.
    • If E2E tests in tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs depend on the old behavior, update them to match the new behavior. Prefer modifying E2E tests to explicitly request --banner when they need it, and/or configure the test environment as interactive where appropriate.

Implementation Notes

  • The change should happen in Program.DisplayFirstTimeUseNoticeIfNeededAsync:
    • Resolve ICliHostEnvironment from DI.
    • Gate the auto-first-run banner path on hostEnvironment.SupportsInteractiveOutput.
    • Do not gate the explicit --banner path.

Acceptance Criteria

  • In CI/non-interactive environments, the animated banner is not shown automatically on first run.
  • In interactive environments, the banner remains auto-shown on first run.
  • aspire --banner still shows the banner.
  • All tests pass.

References

  • Current banner decision logic:
    • src/Aspire.Cli/Program.cs (DisplayFirstTimeUseNoticeIfNeededAsync)
  • Interactive/CI detection pattern:
    • src/Aspire.Cli/Utils/CliHostEnvironment.cs
  • Banner animation:
    • src/Aspire.Cli/Interaction/BannerService.cs
  • Existing tests:
    • tests/Aspire.Cli.Tests/Commands/RootCommandTests.cs
    • tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… run

Co-authored-by: radical <1472+radical@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Aspire CLI first-run experience for banner display Suppress animated banner auto-display in CI/non-interactive environments Feb 28, 2026
@github-actions
Copy link
Contributor

🚀 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 -- 14792

Or

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

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 improves the Aspire CLI first-run experience by preventing the animated banner from auto-displaying in CI and other non-interactive environments, reducing log noise while preserving the ability to explicitly request the banner.

Changes:

  • Gate the auto first-run banner display on ICliHostEnvironment.SupportsInteractiveOutput (explicit --banner remains unaffected).
  • Add unit tests to verify the banner is suppressed on first run in non-interactive environments and still shows when --banner is explicitly provided.

Reviewed changes

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

File Description
src/Aspire.Cli/Program.cs Adds ICliHostEnvironment.SupportsInteractiveOutput guard for the auto-first-run banner path.
tests/Aspire.Cli.Tests/Commands/RootCommandTests.cs Adds unit tests for non-interactive suppression and explicit --banner behavior.
Comments suppressed due to low confidence (1)

src/Aspire.Cli/Program.cs:487

  • ICliHostEnvironment is resolved unconditionally here, even when showBanner is true (explicit --banner) or when banner output is otherwise suppressed. Since constructing CliHostEnvironment can involve environment/ANSI detection in some modes, consider resolving it only when the auto-first-run banner path is being evaluated (e.g., inline it into the conditional and rely on short-circuiting), so --banner doesn’t pay this cost.
        var hostEnvironment = serviceProvider.GetRequiredService<ICliHostEnvironment>();

        // Show banner if explicitly requested OR on first run (unless suppressed by noLogo or non-interactive output)
        if (showBanner || (isFirstRun && !noLogo && hostEnvironment.SupportsInteractiveOutput))

@radical radical merged commit b374204 into main Feb 28, 2026
349 checks passed
@radical radical deleted the copilot/update-aspire-cli-banner-display branch February 28, 2026 04:24
@dotnet-policy-service dotnet-policy-service bot added this to the 13.3 milestone Feb 28, 2026
@davidfowl
Copy link
Member

@copilot backport this chane to release/13.2

@davidfowl
Copy link
Member

/backport to release/13.2

@github-actions
Copy link
Contributor

Started backporting to release/13.2: https://github.com/dotnet/aspire/actions/runs/22526559590

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.

5 participants