-
Notifications
You must be signed in to change notification settings - Fork 668
Fix dashboard UI to show no message for cancelled commands #10893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: davidfowl <[email protected]>
@copilot The dashboard UI is still showing a success message when the command returns cancelled. It shouldn't show any UI at all. |
When commands return cancelled results, the dashboard UI now: - Closes any existing "starting" toast - Shows no success or error message - Provides a silent cancellation experience as expected This fixes the issue where cancelled commands were incorrectly showing success messages in the dashboard UI. Co-authored-by: davidfowl <[email protected]>
Fixed in ad77f0b. The dashboard UI now specifically handles cancelled commands by closing any existing toast and not showing any success or error messages. When a command returns |
@JamesNK this works but now I'm wondering it if should say command cancelled. |
Screen.Recording.2025-08-09.at.10.31.39.PM.mov |
There was a problem hiding this 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 adds comprehensive cancellation support to command execution in Aspire, specifically addressing the issue where cancelled commands incorrectly displayed success messages in the dashboard UI. The solution introduces a new Canceled
property to ExecuteCommandResult
and updates the entire command execution pipeline to properly handle cancellations.
- Introduces
Canceled
property andCommandResults.Canceled()
factory method for clean cancellation handling - Updates command aggregation logic to distinguish between actual failures and user cancellations
- Fixes dashboard UI to show no messages when commands are cancelled, providing a silent cancellation experience
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/Aspire.Hosting/ApplicationModel/ResourceCommandAnnotation.cs | Adds Canceled property to ExecuteCommandResult and CommandResults.Canceled() factory method |
src/Aspire.Hosting/ApplicationModel/ResourceCommandService.cs | Updates aggregation logic to separate cancellations from failures and adds debug logging for cancelled commands |
src/Aspire.Hosting/Dashboard/DashboardServiceData.cs | Maps cancelled results to ExecuteCommandResultType.Canceled |
src/Aspire.Dashboard/Model/DashboardCommandExecutor.cs | Handles cancelled commands by closing toasts without showing messages |
src/Aspire.Hosting/api/Aspire.Hosting.cs | Updates generated API surface with new cancellation members |
tests/Aspire.Hosting.Tests/ResourceCommandServiceTests.cs | Adds comprehensive test coverage for cancellation scenarios |
if (!results[i].Success) | ||
{ | ||
failures.Add((names[i], results[i])); | ||
if (results[i].Canceled) | ||
{ | ||
cancellations.Add((names[i], results[i])); | ||
} | ||
else | ||
{ | ||
failures.Add((names[i], results[i])); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The nested if-else structure could be simplified using pattern matching or early returns to improve readability. Consider restructuring to handle Success, Canceled, and Failed cases more clearly.
if (!results[i].Success) | |
{ | |
failures.Add((names[i], results[i])); | |
if (results[i].Canceled) | |
{ | |
cancellations.Add((names[i], results[i])); | |
} | |
else | |
{ | |
failures.Add((names[i], results[i])); | |
} | |
} | |
var result = results[i]; | |
if (result.Success) | |
{ | |
// Do nothing, success case | |
continue; | |
} | |
else if (result.Canceled) | |
{ | |
cancellations.Add((names[i], result)); | |
} | |
else | |
{ | |
failures.Add((names[i], result)); | |
} |
Copilot uses AI. Check for mistakes.
This PR adds cancellation support to
ExecuteCommandResult
and fixes the dashboard UI to properly handle cancelled commands by showing no messages at all.Problem
When a command uses the interaction service and the dialog is dismissed, the dashboard UI was incorrectly showing a success message. There was no clean way to cancel commands without displaying unwanted messages to users.
Solution
Extended
ExecuteCommandResult
with:Canceled
property - A boolean flag indicating whether the command was canceled by the userCommandResults.Canceled()
factory method - Produces a canceled result withSuccess = false
andCanceled = true
ExecuteCommandResultType.Canceled
when commands are cancelledUsage Example
Key Fix
The critical issue was in
DashboardCommandExecutor.cs
where cancelled commands were falling through to the error handling logic and showing success messages. The fix specifically handlesResourceCommandResponseKind.Cancelled
by:Benefits
ExecuteCommandResultType.Canceled
This provides a much better user experience when users change their mind about executing commands, especially those that prompt for confirmation or input.
Fixes #10368.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.