Display "Stopping Aspire..." immediately on CTRL+C#17652
Open
JamesNK wants to merge 1 commit into
Open
Conversation
- Introduce CommonCommandServices to consolidate BaseCommand dependencies - Move cancellation/termination handling from Program.Main into BaseCommand - Show 'Stopping Aspire...' after 200ms if handler hasn't completed post-cancellation - Add CancellationManager to CliStartupContext and DI container - Map CliExitCodes.Cancelled in CommandResult.FromExitCode - Change ConsoleCancellationManager.SetStartedHandler to accept Task (not Task<int>) - Add BaseCommand tests for cancellation message timing - Add 'using' to BuildServiceProvider() calls in CLI tests to fix file handle leaks
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17652Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17652" |
Member
Author
|
Too big/risky for 13.4. |
Contributor
|
❓ CLI E2E Tests unknown — 108 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26623717661 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the user presses CTRL+C, the CLI now displays "Stopping Aspire..." after a short 200ms delay if the command handler hasn't completed yet. This gives immediate user feedback that shutdown is in progress.
Changes
Core feature
Program.Maininto theSetActionlambda. Uses aTask.WhenAnyloop with a 200msTaskCompletionSourcetimer to show the stopping message if the handler is still running after cancellation.SetStartedHandlerto acceptTaskinstead ofTask<int>since BaseCommand now manages the exit code directly.CliExitCodes.CancelledtoCommandResult.Cancelled(exitCode).Refactoring
IFeatures,ICliUpdateNotifier,CliExecutionContext,IInteractionService,AspireCliTelemetry,ConsoleCancellationManager,ILoggerFactory). All commands now take a singleCommonCommandServicesparameter.CancellationManagerproperty so it flows through DI.WhenAnyat the top level since BaseCommand handles it.Test fixes
usingto allBuildServiceProvider()calls in CLI tests to fixFileLoggerProviderholding file handles.ConsoleCancellationManagerregistration to test DI setup.Task.Delay(Timeout.Infinite, ct)withAsyncTestHelpers.WaitForCancellationAsync(ct)for cleaner test code.Testing
All 3829 CLI tests pass (0 failures, 21 skipped).