Add Aspire status bar item to VS Code extension#14869
Add Aspire status bar item to VS Code extension#14869adamint merged 1 commit intodotnet:release/13.2from
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14869Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14869" |
There was a problem hiding this comment.
Pull request overview
Adds a persistent VS Code status bar item for the Aspire extension, reflecting the current running app host/resource state by reusing the existing running app hosts tree provider’s polling + change events.
Changes:
- Introduces
AspireStatusBarProviderto render state (stopped/running/warning/error) in the status bar based on tree provider data. - Exposes
appHostsandhasErrorgetters (and exports related types) fromAspireAppHostTreeProviderfor reuse by the status bar provider. - Starts polling unconditionally so status updates continue even when the Aspire view is hidden; adds localized strings and package NLS entries for the status bar text/tooltips.
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 |
|---|---|
| extension/src/views/AspireStatusBarProvider.ts | New status bar provider that derives summary state from app host/resource data. |
| extension/src/views/AspireAppHostTreeProvider.ts | Exposes app host data/error state for consumers (status bar) and exports JSON/type interfaces. |
| extension/src/loc/strings.ts | Adds status bar strings/tooltips and formatting helpers. |
| extension/src/extension.ts | Wires up the status bar provider and changes polling to always-on. |
| extension/package.nls.json | Adds new localized string entries for the status bar feature. |
| for (const appHost of appHosts) { | ||
| if (appHost.resources) { | ||
| for (const resource of appHost.resources) { | ||
| if (resource.stateStyle === 'error' || resource.state === 'FailedToStart' || resource.state === 'RuntimeUnhealthy') { |
There was a problem hiding this comment.
hasUnhealthyResource treats only stateStyle === 'error' (or specific states) as unhealthy. The tree view already uses stateStyle === 'warning' to render a warning icon for Running/Active resources; those cases currently won’t trigger the status bar’s warning icon/background. Consider including stateStyle === 'warning' in the unhealthy check so the status bar reflects degraded resources consistently.
| if (resource.stateStyle === 'error' || resource.state === 'FailedToStart' || resource.state === 'RuntimeUnhealthy') { | |
| if ( | |
| resource.stateStyle === 'error' || | |
| resource.stateStyle === 'warning' || | |
| resource.state === 'FailedToStart' || | |
| resource.state === 'RuntimeUnhealthy' | |
| ) { |
| export function statusBarRunning(appHostCount: number, runningResources: number, totalResources: number): string { | ||
| if (totalResources === 0) { | ||
| return appHostCount === 1 | ||
| ? vscode.l10n.t('Aspire: {0} apphost', appHostCount) | ||
| : vscode.l10n.t('Aspire: {0} apphosts', appHostCount); | ||
| } | ||
| return vscode.l10n.t('Aspire: {0}/{1} running', runningResources, totalResources); | ||
| } |
There was a problem hiding this comment.
The status bar running text currently resolves to only a resource count ("Aspire: {running}/{total} running") and omits the app host count. This doesn’t match the PR description/table, which says the running text should include both the number of app hosts and the resource counts (e.g., "Aspire: N app host, M/T resources"). Either update the implementation/strings to match the described UX, or adjust the PR description to reflect the actual text.
| // Always poll for app host status — the status bar needs up-to-date data even | ||
| // when the tree view panel is hidden. | ||
| appHostTreeProvider.startPolling(); | ||
|
|
There was a problem hiding this comment.
Polling is now started unconditionally on activation. Since the extension activates on many workspaces (e.g., workspaceContains:**/*.csproj), this will spawn aspire ps every ~3s even when the Aspire view isn’t used, which can add background CPU/process overhead. Consider introducing a slower interval/backoff when there are no running app hosts (or when the CLI is missing), or re-introducing a visibility-based gate with a separate lightweight refresh strategy for the status bar.
| // Always poll for app host status — the status bar needs up-to-date data even | |
| // when the tree view panel is hidden. | |
| appHostTreeProvider.startPolling(); | |
| // Lazily start polling for app host status to avoid background overhead in | |
| // workspaces where the Aspire view is never used. | |
| let pollingStarted = false; | |
| const ensurePollingStarted = () => { | |
| if (!pollingStarted) { | |
| pollingStarted = true; | |
| appHostTreeProvider.startPolling(); | |
| } | |
| }; | |
| // If the Aspire tree view is already visible, start polling immediately. | |
| if (appHostTreeView.visible) { | |
| ensurePollingStarted(); | |
| } else { | |
| // Otherwise, wait until the view is first shown before starting polling. | |
| const visibilityDisposable = appHostTreeView.onDidChangeVisibility(e => { | |
| if (e.visible) { | |
| ensurePollingStarted(); | |
| visibilityDisposable.dispose(); | |
| } | |
| }); | |
| context.subscriptions.push(visibilityDisposable); | |
| } |
mitchdenny
left a comment
There was a problem hiding this comment.
Clean implementation — well-structured status bar provider, proper disposal, all strings localized. Always-on polling trade-off is reasonable for a status bar feature.
Description
Adds a persistent status bar item to the Aspire VS Code extension that shows the current state of running app hosts and their resources at a glance, without needing to open the Aspire panel.
Status bar states
$(circle-outline)$(radio-tower)$(warning)$(error)onDidChangeTreeDataevent, so updates arrive every polling cycle (~3s) with zero additional overhead.package.nls.jsonandstrings.ts.Checklist