Skip to content

Address apphost stdout review feedback#15298

Closed
sebastienros wants to merge 1 commit intorelease/13.2from
sebros/review-apphost-stdout
Closed

Address apphost stdout review feedback#15298
sebastienros wants to merge 1 commit intorelease/13.2from
sebros/review-apphost-stdout

Conversation

@sebastienros
Copy link
Copy Markdown
Contributor

@sebastienros sebastienros commented Mar 16, 2026

Description

Follow up on review feedback for the apphost stdout logging change.

This keeps the original behavior change intact while tightening the implementation details James called out during review:

  • replace string-based stdout/stderr tracking with an internal OutputLineStream enum
  • use shared ConsoleLogTypes constants for CLI-defined console log message types
  • add clarifying comments around nullable live callbacks, buffered replay behavior, and Process stream completion semantics

This is a low-risk cleanup on top of the existing apphost stdout work for aspire run in non-detached runs. There are no additional dependencies.

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
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings March 16, 2026 23:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 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 -- 15298

Or

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sebastienros sebastienros force-pushed the sebros/review-apphost-stdout branch from 54df8cc to c67113e Compare March 17, 2026 00:03
Copy link
Copy Markdown
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 aspire run observability by streaming AppHost stdout/stderr to the CLI console in real time (both .NET and guest runtimes), while also hardening related test automation and replacing stringly-typed stream identifiers with a typed enum.

Changes:

  • Add live output forwarding to console logs for .NET AppHost and guest AppHost processes during non-detached aspire run.
  • Introduce OutputLineStream (StdOut/StdErr) and propagate it through OutputCollector and IInteractionService.DisplayLines.
  • Add/adjust unit + end-to-end tests and update terminal automation to handle newer/older CLI template selection flows.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Shared/Hex1bAutomatorTestHelpers.cs Makes template selection automation resilient to new/old “Empty AppHost” prompts and language prompt flow differences.
tests/Aspire.Cli.Tests/Utils/OutputCollectorTests.cs Updates tests to use OutputLineStream and adds coverage for the new live output callback.
tests/Aspire.Cli.Tests/TestServices/TestInteractionService.cs Updates test interaction service to match the new DisplayLines signature using OutputLineStream.
tests/Aspire.Cli.Tests/TestServices/TestExtensionInteractionService.cs Updates extension test interaction service to match the new DisplayLines signature.
tests/Aspire.Cli.Tests/Templating/DotNetTemplateFactoryTests.cs Updates test stub interaction service for DisplayLines signature change.
tests/Aspire.Cli.Tests/Projects/ProcessGuestLauncherTests.cs Adds a unit test verifying ProcessGuestLauncher forwards stdout via live callback.
tests/Aspire.Cli.Tests/Projects/GuestRuntimeTests.cs Updates assertions to use typed stderr stream values.
tests/Aspire.Cli.Tests/Projects/ExtensionGuestLauncherTests.cs Updates test stub interaction service for DisplayLines signature change.
tests/Aspire.Cli.Tests/Interaction/ConsoleInteractionServiceTests.cs Updates tests to pass typed stdout/stderr tuples.
tests/Aspire.Cli.Tests/Commands/UpdateCommandTests.cs Updates wrapper interaction service to forward typed DisplayLines.
tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs Adds test asserting .NET AppHost stdout is forwarded into console logs during run.
tests/Aspire.Cli.Tests/Commands/PublishCommandPromptingIntegrationTests.cs Updates test stub interaction service for DisplayLines signature change.
tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs Updates test stub interaction service for DisplayLines signature change.
tests/Aspire.Cli.EndToEnd.Tests/AppHostConsoleLogTests.cs Adds E2E coverage ensuring AppHost console output is visible during interactive aspire run (C# and TypeScript).
src/Aspire.Cli/Utils/OutputCollector.cs Adds OutputLineStream, replaces string stream markers with typed enum, and introduces optional live output callback.
src/Aspire.Cli/Projects/ProcessGuestLauncher.cs Adds live output callback plumbing and waits for redirected streams to drain after process exit.
src/Aspire.Cli/Projects/GuestRuntime.cs Allows passing a live output callback into the default launcher for interactive run flows.
src/Aspire.Cli/Projects/GuestAppHostProject.cs Streams guest AppHost output live to console logs and avoids replaying buffered output when live streaming is enabled.
src/Aspire.Cli/Projects/DotNetAppHostProject.cs Streams .NET AppHost output live to console logs via OutputCollector callback.
src/Aspire.Cli/Interaction/IInteractionService.cs Updates DisplayLines signature to use OutputLineStream and clarifies console log type semantics.
src/Aspire.Cli/Interaction/ExtensionInteractionService.cs Updates DisplayLines to translate OutputLineStream back to "stdout"/"stderr" for backchannel payloads.
src/Aspire.Cli/Interaction/ConsoleLogTypes.cs Introduces constants for CLI-emitted console log semantic types.
src/Aspire.Cli/Interaction/ConsoleInteractionService.cs Switches console log styling from string literals to ConsoleLogTypes constants and updates DisplayLines for OutputLineStream.

Comment on lines 103 to 105
await process.WaitForExitAsync(cancellationToken);
// Wait for the redirected streams to finish draining so no trailing lines are lost.
await Task.WhenAll(stdoutCompleted.Task, stderrCompleted.Task).WaitAsync(cancellationToken);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, might be worth having a timeout just in case something goes wrong.

Comment on lines 103 to 105
await process.WaitForExitAsync(cancellationToken);
// Wait for the redirected streams to finish draining so no trailing lines are lost.
await Task.WhenAll(stdoutCompleted.Task, stderrCompleted.Task).WaitAsync(cancellationToken);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, might be worth having a timeout just in case something goes wrong.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit c67113e:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ 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
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
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
Run_ShowsDotNetAppHostConsoleOutput ▶️ View Recording
Run_ShowsTypeScriptAppHostConsoleOutput ❌ Upload failed
SecretCrudOnDotNetAppHost ❌ Upload failed
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ❌ Upload failed
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23171817240

@JamesNK
Copy link
Copy Markdown
Member

JamesNK commented Mar 17, 2026

apphost stdout is being reverted for a different fix. Improvements in this PR have been added to #15307

@JamesNK JamesNK closed this Mar 17, 2026
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 17, 2026
@sebastienros
Copy link
Copy Markdown
Contributor Author

Thanks @JamesNK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants