Repository navigation
Fix CLI Ctrl+C/SIGTERM shutdown: responsive cancellation and double-signal bug - #17588
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17588Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17588" |
There was a problem hiding this comment.
Pull request overview
Improves Aspire CLI termination responsiveness when users press Ctrl+C during run/AppHost startup, aiming to avoid multi-second waits and provide a “second signal” forced termination path.
Changes:
- Refactors
ConsoleCancellationManagerso the first signal triggers non-blocking cancellation and schedules forced termination asynchronously; subsequent signals trigger immediate forced-termination signaling. - Threads the command cancellation token into
RunCommand.CancelAppHostStartupAsyncso its startup-cancellation wait exits promptly on Ctrl+C. - Adds unit coverage for the cancellation manager behavior and a regression test ensuring
runexits promptly when cancelled during the startup-timeout cancellation path.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/ConsoleCancellationManagerTests.cs | Adds tests for first/second signal behavior, async timeout forcing, and non-blocking cancel. |
| tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs | Adds regression test to ensure Ctrl+C cancels out of the startup-cancellation timeout promptly. |
| src/Aspire.Cli/Program.cs | Wires a logger into cancellation handling for diagnostics. |
| src/Aspire.Cli/ConsoleCancellationManager.cs | Makes signal handling non-blocking; adds async forced-termination timeout and second-signal behavior; adds logging hook. |
| src/Aspire.Cli/Commands/RunCommand.cs | Passes the command cancellation token through to WaitAsync during startup cancellation. |
06a5d7d to
754458f
Compare
PR Testing ReportPR Information
CLI Version Verification
Test Scenarios ExecutedScenario 1: Normal Start and StopObjective: Verify basic Steps:
Observations:
Scenario 2: ConsoleCancellationManager Unit TestsObjective: Verify all signal handling logic — first signal cooperative cancellation, second signal force-kill, timeout behavior Tests executed:
Scenario 3: Ctrl+C During Startup TimeoutObjective: Verify that when Ctrl+C fires during AppHost startup, the CLI exits promptly rather than blocking for the full 5-second Test: Observations:
Scenario 4: Startup Timeout Regression TestsObjective: Ensure existing startup timeout behavior is preserved Tests executed:
Summary
Overall Result✅ PR VERIFIED — All 13 targeted tests pass. The normal start/stop lifecycle works correctly. Signal handling changes are well-covered by unit tests that directly exercise the |
|
Tried this, still takes forever (5 seconds is forever): Screen.Recording.2026-05-28.104823.mp4It also feels like forever because there's no feedback. |
|
David Fowler (@davidfowl) |
|
This is purely for the CLI itself, nothing to do with graceful shutdown of resources, which happens when you stop a resource from the dashboard or cli, but isn't graceful in the debugger in VS. |
but it should be supported... We should be able to trigger a stop cmd that would send a sigterm to a resource when testing our distributed app.. You should at least rename KnownRessourcesCommand to Kill instead of Stop.. since this is what you truly are doing.. killing the process |
aspire resource stop. Lets not use this pr to discuss feature requests though |
|
Will this fix #17625? |
- Make ConsoleCancellationManager.Cancel() non-blocking so Ctrl+C handler returns immediately - Pass cancellation token through to WaitAsync in CancelAppHostStartupAsync so Ctrl+C exits promptly instead of waiting for the full 5s timeout - Support second Ctrl+C for immediate force exit (Environment.Exit) - Add logging support to ConsoleCancellationManager via SetLogger() - Add comprehensive unit tests for ConsoleCancellationManager - Add integration test for RunCommand cancellation during startup timeout Fixes #17569
Replace WaitForSuccessPromptAsync with WaitForSuccessPromptFailFastAsync across all CLI E2E tests. The fail-fast variant detects error prompts immediately and throws instead of hanging for up to 500s waiting for a success prompt that will never arrive. This prevents 10+ minute CI timeouts when a command fails with a non-zero exit code.
- Fix ConsoleCancellationManager double-signal bug: move Console.CancelKeyPress to else branch so it only registers on platforms without PosixSignalRegistration. Previously both handlers fired for the same SIGINT, causing immediate force-kill. - Add SIGQUIT/Ctrl+Break registration for Windows parity. - Remove old WaitForSuccessPromptAsync (no fail-fast) and rename WaitForSuccessPromptFailFastAsync to WaitForSuccessPromptAsync. - Remove duplicate RunCommandFailFastAsync (identical to RunCommandAsync).
|
/backport to release/13.4 |
|
Started backporting to |
|
James Newton-King (@JamesNK) backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix CLI Ctrl+C shutdown taking too long during AppHost startup
Applying: Fix review comments: volatile logger, accurate comments, clearer warning
Applying: Clean up
Applying: Use WaitForSuccessPromptFailFastAsync in CLI E2E tests
Using index info to reconstruct a base tree...
M tests/Aspire.Cli.EndToEnd.Tests/AgentCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/AgentMcpLogsTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/CertificatesCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ChannelUpdateWorkflowTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ConfigHealingTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ConfigMigrationTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DashboardRunTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DescribeCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DocsCommandE2ETests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DoctorCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/DotnetToolSmokeTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs
M tests/Aspire.Cli.EndToEnd.Tests/JavaCodegenValidationTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/JavaEmptyAppHostTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotApphostDirectoryTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/JavaScriptPublishTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/KubernetesDeployTypeScriptTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/KubernetesDeployWithHelmChartTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishRequiresExternalEndpointTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ListStepsTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/LogLevelTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/LogsCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/MultipleAppHostTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/NewWithAgentInitTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/OtelLogsTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/PodmanDeploymentTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ProjectReferenceTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/PsCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/PythonReactTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/ResourceCommandTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/SecretDotNetAppHostTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/SecretTypeScriptAppHostTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/StagingChannelTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptCodegenValidationTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptEmptyAppHostTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptLegacyAppHostTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotApphostDirectoryTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPublishTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptReusablePackageTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptSqlServerNativeAssetsBundleTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterSmokeTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/UpdateChannelNuGetConfigOrderingTests.cs
M tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs
Falling back to patching base and 3-way merge...
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/AgentCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/AgentCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/AgentMcpLogsTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/BannerTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/CentralPackageManagementTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/CertificatesCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/CertificatesCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ChannelUpdateWorkflowTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ConfigHealingTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ConfigMigrationTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/ConfigMigrationTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DashboardRunTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/DashboardRunTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DescribeCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/DescribeCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DockerDeploymentTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DocsCommandE2ETests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/DocsCommandE2ETests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DoctorCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/DoctorCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/DotnetToolSmokeTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/DotnetToolSmokeTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JavaCodegenValidationTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JavaEmptyAppHostTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotApphostDirectoryTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotApphostDirectoryTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/JavaPolyglotTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JavaScriptPublishTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/JavaScriptPublishTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/JsReactTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/KubernetesDeployTypeScriptTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/KubernetesDeployWithHelmChartTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishRequiresExternalEndpointTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishRequiresExternalEndpointTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/KubernetesPublishTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ListStepsTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/LocalConfigMigrationTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/LogLevelTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/LogLevelTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/LogsCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/LogsCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/MultipleAppHostTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/MultipleAppHostTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/NewWithAgentInitTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/NewWithAgentInitTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/OtelLogsTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/PodmanDeploymentTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ProjectReferenceTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/ProjectReferenceTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/PsCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/PsCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/PythonReactTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/ResourceCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/ResourceCommandTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/SecretDotNetAppHostTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/SecretDotNetAppHostTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/SecretTypeScriptAppHostTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/SecretTypeScriptAppHostTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/SmokeTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/StagingChannelTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/StagingChannelTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/StopNonInteractiveTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptCodegenValidationTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptEmptyAppHostTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptLegacyAppHostTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotApphostDirectoryTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotApphostDirectoryTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPolyglotTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPublishTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/TypeScriptPublishTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptReusablePackageTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptSqlServerNativeAssetsBundleTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterSmokeTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/TypeScriptStarterTemplateTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/UpdateChannelNuGetConfigOrderingTests.cs
Auto-merging tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs
CONFLICT (content): Merge conflict in tests/Aspire.Cli.EndToEnd.Tests/WaitCommandTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0004 Use WaitForSuccessPromptFailFastAsync in CLI E2E tests
Error: The process '/usr/bin/git' failed with exit code 128 |
- Add 'Stopping the AppHost' section explaining graceful shutdown - Document that a second Ctrl+C forces immediate termination - Note that Ctrl+C during startup cancels immediately Documents changes from microsoft/aspire#17588 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pull request created: #1119
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1119 targeting Added a new Stopping the AppHost section to
Note This draft PR needs human review before merging. |
…romptAsync rename Per davidfowl's review: we own the Aspire skills bundle and write its contents, so the defense-in-depth ValidateSkillName check is modelling the wrong threat. Drop the validator, its helpers, the reserved-device list, the now-unused System.Text using, and the unit tests that exercised it. Also rename the AgentCommandTests call site of WaitForSuccessPromptFailFastAsync to WaitForSuccessPromptAsync to match the consolidated helper that landed on main in #17588 (the FailFast variant was folded back into the canonical WaitForSuccessPromptAsync). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add TerminalRun IAsyncDisposable for consistent CLI E2E diagnostics capture (#17576) * Fix CLI Ctrl+C/SIGTERM shutdown: responsive cancellation and double-signal bug (#17588) * Fix CLI Ctrl+C shutdown taking too long during AppHost startup - Make ConsoleCancellationManager.Cancel() non-blocking so Ctrl+C handler returns immediately - Pass cancellation token through to WaitAsync in CancelAppHostStartupAsync so Ctrl+C exits promptly instead of waiting for the full 5s timeout - Support second Ctrl+C for immediate force exit (Environment.Exit) - Add logging support to ConsoleCancellationManager via SetLogger() - Add comprehensive unit tests for ConsoleCancellationManager - Add integration test for RunCommand cancellation during startup timeout Fixes #17569 * Fix review comments: volatile logger, accurate comments, clearer warning * Clean up * Use WaitForSuccessPromptFailFastAsync in CLI E2E tests Replace WaitForSuccessPromptAsync with WaitForSuccessPromptFailFastAsync across all CLI E2E tests. The fail-fast variant detects error prompts immediately and throws instead of hanging for up to 500s waiting for a success prompt that will never arrive. This prevents 10+ minute CI timeouts when a command fails with a non-zero exit code. * Fix double-signal bug and consolidate test helpers - Fix ConsoleCancellationManager double-signal bug: move Console.CancelKeyPress to else branch so it only registers on platforms without PosixSignalRegistration. Previously both handlers fired for the same SIGINT, causing immediate force-kill. - Add SIGQUIT/Ctrl+Break registration for Windows parity. - Remove old WaitForSuccessPromptAsync (no fail-fast) and rename WaitForSuccessPromptFailFastAsync to WaitForSuccessPromptAsync. - Remove duplicate RunCommandFailFastAsync (identical to RunCommandAsync). * Fix stale comment and restrict SIGQUIT to Windows only * Remove unused legacy builder methods and update E2E skill docs * Don't force when debugging * More logging
* Load Aspire skills catalog from bundle manifest
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address Aspire skill catalog review feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Harden dynamic Aspire skill catalog
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Trim bundle skill descriptions, sort alphabetically, silence bundle-unavailable warning
- Extract just the first sentence (after stripping the leading bold `**TYPE SKILL**` tag) for bundle skill descriptions shown in the agent init selection prompt so the list stays readable.
- Sort the merged skill catalog deterministically by name (OrdinalIgnoreCase) so prompt ordering is stable regardless of manifest order.
- When the Aspire skills bundle is unavailable (network failure, version mismatch, etc.), silently fall back to the CLI-defined skills instead of surfacing a user-visible warning. The installer already logs the underlying cause at debug, and the equivalent `LogWarning` paths on the corrupt-bundle catch blocks are demoted to `LogDebug` to match.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Trust embedded and cached Aspire skills bundles regardless of supports range
The embedded Aspire skills bundle ships inside the CLI binary as the
trusted last-resort fallback, and the on-disk cache is populated by this
installer itself. Both sources are gated by bundle version (the cache
directory is version-keyed), so the bundle manifest's supports range
should only gate fresh downloads from GitHub.
Previously, a prerelease CLI build whose version fell outside the
embedded snapshot's stamped range (e.g., a 13.5.x dogfood build paired
with a snapshot supporting '>=13.4.0 <13.5.0') would reject the embedded
bundle on every offline invocation, leaving the user with only the
CLI-defined PlaywrightCli and DotnetInspect skills.
Add a skipCompatibilityCheck parameter to AspireSkillsBundle.LoadAsync,
plumb it through CacheArchiveAsync, and apply it to the embedded install
and cache-load paths. The GitHub-download path keeps strict validation
because we don't otherwise know what we're getting.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Replace AgentInitSkillDefaultMode enum with predicate + add coverage
The default-skill selection in agent init was driven by a two-value enum
(AgentInitSkillDefaultMode) whose IncludeAspireify member named a specific
skill. That locks the design into a named set: every time a caller needs a
different default-selection rule, the enum has to grow another member.
Replace the enum with an optional Func<SkillDefinition, bool>? predicate
parameter on AgentInitCommand.PromptAndChainAsync. Semantics:
- null -> trust the bundle author's SkillDefinition.IsDefault as-is
(what 'aspire init' wants so aspireify chains into the flow)
- non-null -> caller decides which skills are pre-selected
The 'aspireify is one-time wiring' decision moves to the two call sites
that need it ('aspire new' and standalone 'aspire agent init') via an
internal AgentInitCommand.ExcludeAspireifyFromDefaults helper method.
No new enum values are needed when future contexts emerge.
Drops the dead IsDefaultSkill helper and the enum type. No user-visible
behavior change beyond what the predicate expresses.
Tests:
- Rename PromptAndChainAsync_WithIncludeAspireifyDefault_SelectsAspireify
to PromptAndChainAsync_WithoutPredicateOverride_PreSelectsBundleDefaultsIncludingAspireify
to match the new contract (no override = trust bundle's IsDefault).
- Add PromptAndChainAsync_WithExcludeAspireifyPredicate_DoesNotPreSelectAspireify
to lock in the predicate-based override path.
- Add AgentInitCommand_NonInteractive_WithAllBundleSkillNames_InstallsEverySkillSurfacedByBundle
as a regression guard: passing every bundle skill name to --skills must
materialize all six SKILL.md files (aspire-init, aspire-monitoring,
aspire-orchestration were invisible before this PR).
- Add AgentInitCommand_NonInteractive_WithExplicitBundleSkillName_InstallsBundleSkill
proving bundle-only names are selectable via --skills now that the
catalog comes from the manifest.
- Extend the Hex1b cache fixture to seed all six bundle skills and add
AgentInitCommand_NonInteractive_WithAllSkills_InstallsEverySkillSurfacedByBundle
as a full-stack regression guard against the original report.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Make catalog tests resilient to future bundle skill additions
Adding a skill to the bundle (or to the test fixture) no longer requires
mirroring the change in test assertions:
- Integration test now derives the skill list from the bundle's manifest
via IAspireSkillsInstaller, so --skills and the install assertions are
data-driven against whatever the fake produces.
- Hex1b regression test now narrows to the bundle-only skill names
(aspire-init/-monitoring/-orchestration) that the original bug hid.
Future bundle additions don't widen this scope; the test stays a
focused snapshot of the original regression.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Gate Aspire skills remote fetch behind aspireSkillsRemoteFetchEnabled feature
13.4 ships with the GitHub bundle fetch path disabled; users get the embedded snapshot only. Setting features:aspireSkillsRemoteFetchEnabled to true re-enables the GitHub release acquisition and sigstore provenance verification path. The cache lookup and embedded fallback are unaffected, so cached bundles still load without network access.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address self-review observations on bundle skill catalog
- Fix 1: SimplifyDescription only strips leading -/: when a **TYPE** prefix was actually trimmed; preserves descriptions like `-Quickly do X.` and `:memo notes`.
- Fix 2: ValidateSkillName adds explicit char.IsControl() check so U+0001..U+001F / U+0085 are rejected on Linux/macOS where Path.GetInvalidFileNameChars only returns { 0, / }.
- Fix 3: rename ExcludeAspireifyFromDefaults -> ExcludeOneTimeSetupSkillsFromDefaults backed by a single OneTimeSetupSkillNames set so future bundle bootstrap skills do not silently start auto-selecting.
- Fix 4: ResolveAvailableSkillsAsync now returns the bundle install failure message and AgentInitCommand surfaces it before MatchChoicesOrThrow when --skills names a non-CLI skill the bundle was expected to provide.
- Fix 5: ValidateSkillName also rejects empty strings, NFC-incorrect names, and Windows reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9 with or without extension) to match the PR description.
- Comment 5.1: ThrowNonInteractiveInvalidValue strips Spectre markup from each formatted choice so [[bold]]/[[dim]] tokens do not leak verbatim.
- Comment 5.2: PromptForSelectionsAsync gains an optional bindingChoices parameter; the MCP applicator (UX-only prompt item) is now excluded from --skills non-interactive validation.
Adds regression tests for the SimplifyDescription edge case and a parameterized rejection theory covering control chars, NFC, and Windows reserved names.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add regression tests for --skills rejection message
Adds two ConsoleInteractionService tests covering the rejection-message behaviors flagged by the PR testing report:
- OmitsItemsOutsideBindingChoices: items present in the visible multi-select prompt but excluded from bindingChoices (e.g. the MCP applicator entry) must not appear in the non-interactive Available values list.
- StripsSpectreMarkupFromChoiceLabels: [bold]/[dim] tokens from choice formatters used by the interactive prompt must be stripped before the plain-text rejection message is printed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Remove bundle skill-name validation and follow main's WaitForSuccessPromptAsync rename
Per davidfowl's review: we own the Aspire skills bundle and write its
contents, so the defense-in-depth ValidateSkillName check is modelling the
wrong threat. Drop the validator, its helpers, the reserved-device list,
the now-unused System.Text using, and the unit tests that exercised it.
Also rename the AgentCommandTests call site of WaitForSuccessPromptFailFastAsync
to WaitForSuccessPromptAsync to match the consolidated helper that landed
on main in #17588 (the FailFast variant was folded back into the canonical
WaitForSuccessPromptAsync).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Default all bundle skills to on in install prompt
Bundle-sourced skills (aspire, aspireify, aspire-deployment, aspire-init,
aspire-monitoring, aspire-orchestration) are now uniformly pre-selected in
the agent-init install prompt instead of respecting per-skill IsDefault
from the manifest. The CLI is the source of truth for the installable
catalog; bundle authors no longer opt in per skill via the manifest.
ExcludeOneTimeSetupSkillsFromDefaults continues to strip aspireify from
'aspire new' and standalone 'aspire agent init' flows.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Mark AspireSkillsRemoteFetchEnabled feature flag as preview
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pulls in microsoft#17701 (Fix TypeScript deadlock repro E2E test) so PR GitHub Actions can complete. Main has been broken for PR events since microsoft#17575 added a test calling RunCommandFailFastAsync which microsoft#17588 renamed to RunCommandAsync. microsoft#17701 updates the call sites. No infra changes from this branch are affected by this merge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Fixes the CLI's Ctrl+C/SIGTERM handling to be responsive during all phases and prevents a double-signal bug that caused immediate force-kill instead of graceful shutdown.
Problems Fixed
Sluggish Ctrl+C during AppHost startup: When a user pressed Ctrl+C during AppHost startup (before the AppHost connects back to the CLI), the CLI would wait for the full 5-second startup timeout before exiting.
Double-signal bug causing force-kill: Both
PosixSignalRegistration(SIGINT)andConsole.CancelKeyPresswere registered simultaneously. On Linux, when SIGINT arrives both handlers fire for the same signal, each callingCancel(), so_cancelCalledreaches 2 immediately — triggering the force-kill path instead of graceful shutdown.No way to force-exit: If graceful shutdown was taking too long, there was no mechanism for a second Ctrl+C to force immediate termination.
Changes
src/Aspire.Cli/ConsoleCancellationManager.cs(new file in this PR):CancellationTokenSourceProcessTerminationCompletionSourceConsole.CancelKeyPressis now only registered on platforms withoutPosixSignalRegistration(Android, iOS, tvOS, Browser) — eliminates the double-signal bugSetLogger()for diagnostic observability andSetStartedHandler()for timeout trackingsrc/Aspire.Cli/Program.cs:ConsoleCancellationManagerearly in startup and wires it through the command pipelineTask.WhenAny(handlerTask, processTerminationCompletionSource.Task)so forced termination is observed immediatelysrc/Aspire.Cli/Commands/RunCommand.cs:CancelAppHostStartupAsyncnow receives the cancellation token and passes it toWaitAsync, so the startup-timeout wait exits immediately on Ctrl+Ctests/Aspire.Cli.Tests/ConsoleCancellationManagerTests.cs(new):tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs:tests/Shared/Hex1bAutomatorTestHelpers.cs:WaitForSuccessPromptAsync(which would hang on errors instead of failing fast)WaitForSuccessPromptFailFastAsync→WaitForSuccessPromptAsync(now the only variant, always fails fast on ERR prompts)RunCommandFailFastAsync(was identical toRunCommandAsync)E2E test files (59 files):
WaitForSuccessPromptFailFastAsync→WaitForSuccessPromptAsyncRunCommandFailFastAsync→RunCommandAsyncFixes #17569
Checklist