Stream aspire ls results in interactive mode#17113
Conversation
Stream discovered AppHost candidates in interactive table mode while preserving stable JSON output. Make cancellation more responsive by checking cancellation during discovery and terminating in-flight git processes when Ctrl+C is requested. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17113Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17113" |
There was a problem hiding this comment.
Pull request overview
This PR improves the aspire ls interactive experience by streaming discovered AppHost candidates into a live-updating display as validation completes, reducing the “blank/hung” feel in large repositories and making cancellation more responsive. It also adds cancellation checks to avoid expensive fallback work after Ctrl+C and ensures child git processes are terminated when cancellation is requested.
Changes:
- Add an optional progress callback to the AppHost discovery pipeline and use it to drive live updates in interactive
aspire ls. - Add cancellation checks in discovery and kill in-flight
gitchild processes on cancellation. - Update test fakes and CLI tests to cover live streaming and cancellation scenarios, and harden profiling-activity assertions for parallel test execution.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/TestServices/TestProjectLocator.cs | Extends test project locator to support progress-callback discovery. |
| tests/Aspire.Cli.Tests/TestServices/TestInteractionService.cs | Records renderables/live-renderables and cancellation display for new ls behaviors. |
| tests/Aspire.Cli.Tests/TestServices/NoProjectFileProjectLocator.cs | Updates signature to match new IProjectLocator optional progress callback. |
| tests/Aspire.Cli.Tests/Git/GitRepositoryTests.cs | Makes profiling-activity test resilient to parallel execution via unique session id filtering. |
| tests/Aspire.Cli.Tests/Commands/SecretCommandTests.cs | Updates test IProjectLocator implementation signature. |
| tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs | Updates test IProjectLocator implementations signature. |
| tests/Aspire.Cli.Tests/Commands/LsCommandTests.cs | Adds interactive streaming + cancellation tests; adjusts profiling assertions; updates JSON/table expectations. |
| tests/Aspire.Cli.Tests/Commands/ExtensionInternalCommandTests.cs | Updates test IProjectLocator implementations signature. |
| tests/Aspire.Cli.Tests/Commands/ExecCommandTests.cs | Updates test IProjectLocator implementations signature. |
| src/Aspire.Cli/Projects/ProjectLocator.cs | Adds optional onCandidateFound callback and reports validated candidates from parallel validation. |
| src/Aspire.Cli/Projects/AppHostCandidateFinder.cs | Adds early/late cancellation checks to avoid unnecessary enumeration/fallback work. |
| src/Aspire.Cli/Git/GitRepository.cs | Registers cancellation callback to terminate spawned git processes; reads stdout/stderr concurrently. |
| src/Aspire.Cli/Commands/LsCommand.cs | Implements live-updating interactive ls rendering via DisplayLiveAsync; refactors table building; adds cancellation handling. |
| src/Aspire.Cli/Commands/DashboardRunCommand.cs | Minor simplification of stderr callback wiring. |
Copilot's findings
Comments suppressed due to low confidence (2)
src/Aspire.Cli/Commands/LsCommand.cs:244
CandidateAppHostDisplayInfono longer includesRelativePath, which changes theaspire ls --format jsonpayload shape (previously tests validatedrelativePath). The PR description states machine-readable output remains stable, so this is either an unintended breaking change or the description/tests need updating. Consider keepingrelativePathin the JSON model (even if the interactive table no longer shows it) to preserve compatibility.
internal sealed class CandidateAppHostDisplayInfo
{
public required string Path { get; init; }
public required string Language { get; init; }
public required string Status { get; init; }
}
tests/Aspire.Cli.Tests/Commands/LsCommandTests.cs:132
- This test no longer validates the presence/value of
relativePathin the JSON output foraspire ls. If JSON output is intended to stay stable (per PR description), keep assertingRelativePathso a payload/schema regression is caught by tests.
var jsonOutput = string.Join(string.Empty, textWriter.Logs);
var candidateAppHosts = JsonSerializer.Deserialize(jsonOutput, JsonSourceGenerationContext.RelaxedEscaping.ListCandidateAppHostDisplayInfo);
Assert.NotNull(candidateAppHosts);
Assert.Collection(candidateAppHosts,
first =>
{
Assert.Equal(appHostPath1, first.Path);
Assert.Equal(KnownLanguageId.CSharp, first.Language);
Assert.Equal("buildable", first.Status);
},
second =>
{
Assert.Equal(appHostPath2, second.Path);
Assert.Equal(KnownLanguageId.TypeScript, second.Language);
Assert.Equal("possibly-unbuildable", second.Status);
});
- Files reviewed: 14/14 changed files
- Comments generated: 1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the summary. This is an overview rather than actionable feedback, so no changes are needed here. |
|
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
|
# Conflicts: # tests/Aspire.Cli.Tests/Git/GitRepositoryTests.cs
Add streaming JSON support for aspire ls, refactor project discovery to async streams, and document CLI machine-readable output formats. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The CLI no longer registers an exec command, so these stray tests only exercise parser errors and fail CI across all OSes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I ran this in aspire with Edit: Ah, and there is a type=complete at the end. So there is a mini-protocol here, not just writing JSON output line-by-line. That's different from what we do elsewhere where streaming with JSON is just the JSON content except LDJSON instead of one array. Why is this streaming different than other places? |
Replace the live interactive ls table with a dynamic status that reports directories searched and AppHosts found, then render the final table once discovery completes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # tests/Aspire.Cli.Tests/TestServices/TestInteractionService.cs
Emit one AppHost candidate per NDJSON line for aspire ls --format json --stream instead of using a custom event protocol. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@JamesNK accepted. There was not a good reason for I changed |
|
AI went off the rails 😄 |
Document that streaming JSON output emits content items as NDJSON instead of lifecycle protocol events. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Inject TimeProvider into LsCommand so interactive status refresh cadence can be validated with fake time. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JamesNK
left a comment
There was a problem hiding this comment.
Nice work — the streaming architecture (Channels → IAsyncEnumerable → NDJSON), interactive Spectre.Console spinner, and process kill-on-cancellation all look solid. Two minor notes left as inline comments (one dead resource string, one pre-existing _inStatus pattern).
Clean up dead resources, make AppHost candidate ordering culture-invariant, use file links for table paths, and fix status fallback state handling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks! Addressed both remaining notes in ca35295: removed the dead |
|
❓ CLI E2E Tests unknown — 94 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26168791131 |
Description
aspire lscould look blank in interactive terminals until the full workspace search completed, which made large repositories feel hung and made cancellation feel delayed. This change streams discovered AppHost candidates into the live table as validation completes, so users get visible progress while discovery continues.The implementation keeps machine-readable output stable:
--format json, debug output, and non-interactive output still emit one final payload after discovery. The discovery pipeline now accepts an optional progress callback, reports candidates safely from parallel validation, checks cancellation before expensive fallback work, and terminates in-flight childgitprocesses when Ctrl+C is requested because cancelingWaitForExitAsyncdoes not stop the process.User-facing usage
aspire ls aspire ls --format jsonValidation
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?