Skip to content

Add Aspire status bar item to VS Code extension#14869

Merged
adamint merged 1 commit intodotnet:release/13.2from
adamint:dev/adamint/status-bar
Mar 3, 2026
Merged

Add Aspire status bar item to VS Code extension#14869
adamint merged 1 commit intodotnet:release/13.2from
adamint:dev/adamint/status-bar

Conversation

@adamint
Copy link
Member

@adamint adamint commented Mar 3, 2026

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

State Icon Text Color
No app hosts running $(circle-outline) "Aspire: Stopped" Default
Running (healthy) $(radio-tower) "Aspire: N app host, M/T resources" Default
Unhealthy resource $(warning) Same as running Warning background
Error in polling $(error) "Aspire: Error" Error background
  • Clicking the status bar item focuses the Aspire running app hosts panel.
  • Subscribes to the tree provider's existing onDidChangeTreeData event, so updates arrive every polling cycle (~3s) with zero additional overhead.
  • All strings are localized via package.nls.json and strings.ts.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings March 3, 2026 03:26
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14869

Or

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 AspireStatusBarProvider to render state (stopped/running/warning/error) in the status bar based on tree provider data.
  • Exposes appHosts and hasError getters (and exports related types) from AspireAppHostTreeProvider for 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') {
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
if (resource.stateStyle === 'error' || resource.state === 'FailedToStart' || resource.state === 'RuntimeUnhealthy') {
if (
resource.stateStyle === 'error' ||
resource.stateStyle === 'warning' ||
resource.state === 'FailedToStart' ||
resource.state === 'RuntimeUnhealthy'
) {

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +99
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);
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to 91
// Always poll for app host status — the status bar needs up-to-date data even
// when the tree view panel is hidden.
appHostTreeProvider.startPolling();

Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// 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);
}

Copilot uses AI. Check for mistakes.
@adamint adamint requested a review from maddymontaquila March 3, 2026 04:15
Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

Clean implementation — well-structured status bar provider, proper disposal, all strings localized. Always-on polling trade-off is reasonable for a status bar feature.

@adamint adamint merged commit 098531f into dotnet:release/13.2 Mar 3, 2026
351 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 3, 2026
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.

3 participants