Skip to content

Show discovered AppHosts in Aspire pane#17506

Merged
adamint merged 7 commits into
microsoft:mainfrom
ellahathaway:dev/ellahathaway/17458-aspire-pane-show-apphosts-on-disk
May 30, 2026
Merged

Show discovered AppHosts in Aspire pane#17506
adamint merged 7 commits into
microsoft:mainfrom
ellahathaway:dev/ellahathaway/17458-aspire-pane-show-apphosts-on-disk

Conversation

@ellahathaway
Copy link
Copy Markdown
Contributor

@ellahathaway ellahathaway commented May 26, 2026

PR Summary

What it does

Displays idle (non-running) AppHosts discovered via aspire ls in the VS Code Aspire pane tree view, with right-click Run/Debug/Open Source/Copy Path context menu actions.

Demo

aspire-discovered-apphost-demo.mp4

Key changes

File Change
AppHostLaunchService.ts (new) Centralized service for launching AppHosts — tracks "launching" state, fires events, used by both tree and editor providers
AspireAppHostTreeProvider.ts Multi-candidate tree rendering: idle AppHosts show as tree items; launching ones show a spinner + "Starting…" label
AppHostDataRepository.ts Exposes workspaceAppHostCandidatePaths from aspire ls output
AspireEditorCommandProvider.ts Uses AppHostLaunchService instead of inline launch logic
package.json New commands (runWorkspaceAppHost, debugWorkspaceAppHost, openAppHostSource, copyAppHostPath), menu contributions with when-clause regex patterns
strings.ts / package.nls.json Localized strings for new commands and labels
aspire-vscode.xlf Translation file updates

New tests

Test file Coverage
appHostLaunchService.test.ts (8 tests) launch() calls debug API with correct args; isLaunching()/clearLaunching() state tracking; onDidChangeLaunchingState event fires on launch and clear; no-op when already launching; concurrent launches of different AppHosts
appHostTreeView.test.ts (4 new tests) Non-running candidate renders as WorkspaceAppHostItem; multiple running AppHosts from ps appear in multi-candidate mode; resource commands resolve to the owning AppHost; describe resources used as fallback when ps resources are missing/empty
aspireEditorCommandProvider.test.ts (1 new test) Editor run command uses the resolved AppHost path from the discovery service (not just the active file)
packageManifest.test.ts (existing test fixed) Validates when-clause regex patterns correctly target running AppHost context items

Fixes #17458

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17506

Or

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

@ellahathaway ellahathaway changed the title Show discovered AppHosts in Aspire pane when none are running Show discovered AppHosts in Aspire pane May 27, 2026
@ellahathaway ellahathaway force-pushed the dev/ellahathaway/17458-aspire-pane-show-apphosts-on-disk branch from 687dd0e to 12997e9 Compare May 29, 2026 00:19
@adamint
Copy link
Copy Markdown
Member

adamint commented May 29, 2026

vs code extension tests failing?

@adamint
Copy link
Copy Markdown
Member

adamint commented May 29, 2026

image

Maybe workspace apphosts instead of idle apphosts? When there are no running apphosts, maybe we don't even need that parent at all and can show each apphost top-level.

Sporadically, I'm able to get to a bad state when hitting Run on an idle apphost in the context menu - nothing actually happens in the aspire terminal.

Instead of sending text to the aspire terminal, I would use the vscode.debug.startDebugging api to direct start a debug session.

@ellahathaway ellahathaway force-pushed the dev/ellahathaway/17458-aspire-pane-show-apphosts-on-disk branch from 12997e9 to 0d8fa08 Compare May 29, 2026 23:08
@ellahathaway
Copy link
Copy Markdown
Contributor Author

vs code extension tests failing?

Fixed!

@ellahathaway
Copy link
Copy Markdown
Contributor Author

Maybe workspace apphosts instead of idle apphosts? When there are no running apphosts, maybe we don't even need that parent at all and can show each apphost top-level.

Done

Sporadically, I'm able to get to a bad state when hitting Run on an idle apphost in the context menu - nothing actually happens in the aspire terminal.

I wasn't able to reproduce this issue with my recent changes. If you're still seeing this with the latest changes, could you share your setup/environment so I can try to repro?

Instead of sending text to the aspire terminal, I would use the vscode.debug.startDebugging api to direct start a debug session.

Done

@ellahathaway ellahathaway marked this pull request as ready for review May 29, 2026 23:21
@ellahathaway ellahathaway requested a review from adamint as a code owner May 29, 2026 23:21
Copilot AI review requested due to automatic review settings May 29, 2026 23:21
When an AppHost stops, the noAppHosts context key now considers
workspace candidates. This ensures the panel shows idle AppHosts
instead of the empty welcome view after a running AppHost is stopped.
@ellahathaway ellahathaway force-pushed the dev/ellahathaway/17458-aspire-pane-show-apphosts-on-disk branch from 733545a to 0e312f9 Compare May 30, 2026 00:09
ellahathaway and others added 2 commits May 29, 2026 17:25
The _updateWorkspaceContext change (0e312f9) added !hasWorkspaceCandidates
to the noAppHosts condition, meaning the panel stays visible when idle
AppHosts are discovered. Two tests asserted noAppHosts=true after describe
exit, but the legacy format candidate is treated as buildable (toAppHostCandidate
defaults null status to 'buildable'), so workspace candidates persist and
noAppHosts is correctly false.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint
Copy link
Copy Markdown
Member

adamint commented May 30, 2026

Pulled down the updated changes, I disagree with my prior statement about showing the apphosts at the top level, it doesn't look great. I made two UI changes -

  1. moved back under "Workspace AppHosts"
  2. indentation is different if a tree item is not collapsible, this made the workspace apphost indentation look bad. I added the context menu commands as children on workspace apphosts (collapsed by default), which should also help with discovery.
image

thank you!

Copy link
Copy Markdown
Member

@adamint adamint left a comment

Choose a reason for hiding this comment

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

Code review (Opus 4.7-xhigh + Opus 4.8 + GPT-5.5; all three reviewers independently agreed on finding #1). 6 issues total — 1 critical regression, 2 high-severity (stuck-state and unhandled rejection), 2 medium (data-flow correctness, command-palette gating), 1 low (context-menu regression on a transient state).

Comment thread extension/package.json
Comment thread extension/src/services/AppHostLaunchService.ts Outdated
Comment thread extension/src/views/AspireAppHostTreeProvider.ts Outdated
Comment thread extension/src/views/AspireAppHostTreeProvider.ts Outdated
Comment thread extension/package.json Outdated
Comment thread extension/package.json Outdated
Fix microsoft#1: Rename command IDs in package.json menus and walkthrough so
they target the new aspire-vscode.runAppHostCommand and
aspire-vscode.debugAppHostCommand registrations introduced in this PR.
Without this the editor title bar, explorer context menu, and Get
Started walkthrough Run/Debug buttons silently no-op.

Fix microsoft#2: Wrap vscode.debug.startDebugging in try/catch in
AppHostLaunchService.launch so a 'false' return value (debug adapter
rejected) or thrown error clears the launching state. Otherwise the
tree item is stuck showing the 'Starting...' spinner forever and the
user cannot retry.

Fix microsoft#3: Make AspireAppHostTreeProvider.runAppHost async and await
launch so launch failures surface via showErrorMessage instead of
being dropped as unhandled promise rejections.

Fix microsoft#4: In workspace mode with multiple candidate AppHost paths, match
running AppHosts to candidates by directory equivalence
(isMatchingAppHostPath) rather than exact path. This is the same
matching used elsewhere in AppHostDataRepository when correlating
'aspire ps' output to candidate paths, so canonicalization
differences (case, separators, trailing slashes) no longer cause a
running AppHost to display as idle.

Fix microsoft#5: Introduce aspire.noRunningAppHosts context key so the Open
Dashboard palette command is only enabled when at least one AppHost
is actually running. Previously the palette appeared when only idle
candidates were known and then silently no-oped.

Fix microsoft#6: Widen the workspaceResources contextValue regex in
package.json so the read-only 'Open AppHost Source' and 'Copy AppHost
Path' actions appear on bare 'workspaceResources' items, not only on
'workspaceResources:hasAppHost'. The destructive 'Stop AppHost' menu
remains gated on :hasAppHost.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint adamint enabled auto-merge (squash) May 30, 2026 04:13
@adamint adamint merged commit 768842c into microsoft:main May 30, 2026
614 of 619 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.5 milestone May 30, 2026
pull Bot pushed a commit to tooniez/aspire that referenced this pull request Jun 2, 2026
Brings 43 release-branch commits forward onto main now that 13.4.0 has shipped.
This PR replaces the original automated merge (microsoft#17804) which had to be closed so
that conflict resolution and post-merge cleanups could be made on a non-protected
branch.

Conflict resolution summary (33 files):

* Equivalent backports (took main's commit identity): ChannelUpdateWorkflowTests,
  LoggingHelpersTests, the four extension test files, AspireEditorCommandProvider,
  appHostDiscovery.

* Release-only forwards (preserved): microsoft#17732 / microsoft#17756 Foundry hosted-agent protocol
  selection and cross-compute-environment endpoint references, microsoft#17573 stabilize
  PrebuiltAppHostServer staging globalPackagesFolder path, microsoft#17743 staging-identity
  CLI darc feed routing.

* Main-only forwards (preserved): microsoft#17506 Show discovered AppHosts in Aspire pane,
  microsoft#17547 Localize Aspire skills metadata errors, microsoft#17801 VS Code v1.12.0, microsoft#17297
  Aspire CLI npm package release integration, microsoft#17576 TerminalRun IAsyncDisposable,
  microsoft#17721 / microsoft#17723 VS Code telemetry, microsoft#17671 ATS baseline fix (re-applied manually
  on top of Foundry source taken from release).

* Hybrid (manually spliced): docs/contributing.md - kept main's restructured
  layout and inserted release's staging-validation paragraph; HostedAgentBuilder-
  Extension - took release base then re-applied microsoft#17671 asHostedAgent rename;
  UpdateCommandTests - took main and injected microsoft#17743's
  OverrideCliInformationalVersionConfigKey block.

Post-merge cleanups included in this PR:

* eng/Versions.props: revert StabilizePackageVersion to false (was flipped to
  true on release/13.4 by microsoft#17520 for shipping 13.4.0; main must stay in preview
  mode).

* .github/workflows/generate-api-diffs.yml: retarget back to main (was pointed
  at release/13.4 by microsoft#17696 release prep).

* .github/workflows/backmerge-release.yml: update from release/13.3 to
  release/13.4 (was stale - missed the 13.4 release-time bump).

* .github/workflows/milestone-assignment.yml: audited - already correct
  (main -> 13.5, release/13.4 -> 13.4.x); no change.

This merge commit must be preserved - do not squash on merge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Display non-running app hosts in extension

2 participants