-
Notifications
You must be signed in to change notification settings - Fork 816
Add Aspire status bar item to VS Code extension #14869
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,3 +85,21 @@ export const cliNotAvailable = vscode.l10n.t('Aspire CLI is not available on PAT | |
| export const cliFoundAtDefaultPath = (path: string) => vscode.l10n.t('Aspire CLI found at {0}. The extension will use this path.', path); | ||
| export const selectDirectoryTitle = vscode.l10n.t('Select directory'); | ||
| export const selectFileTitle = vscode.l10n.t('Select file'); | ||
|
|
||
| // Status bar strings | ||
| export const statusBarStopped = vscode.l10n.t('Aspire: Stopped'); | ||
| export const statusBarError = vscode.l10n.t('Aspire: Error'); | ||
| 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); | ||
| } | ||
|
Comment on lines
+92
to
+99
|
||
| export const statusBarTooltipStopped = vscode.l10n.t('No Aspire apphosts running. Click to open the Aspire panel.'); | ||
| export const statusBarTooltipError = vscode.l10n.t('Error fetching Aspire apphost status. Click to open the Aspire panel.'); | ||
| export const statusBarTooltipRunning = (appHostCount: number) => | ||
| appHostCount === 1 | ||
| ? vscode.l10n.t('{0} Aspire apphost running. Click to open the Aspire panel.', appHostCount) | ||
| : vscode.l10n.t('{0} Aspire apphosts running. Click to open the Aspire panel.', appHostCount); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||
| import * as vscode from 'vscode'; | ||||||||||||||||
| import { AspireAppHostTreeProvider, type AppHostDisplayInfo } from './AspireAppHostTreeProvider'; | ||||||||||||||||
| import { | ||||||||||||||||
| statusBarRunning, | ||||||||||||||||
| statusBarStopped, | ||||||||||||||||
| statusBarError, | ||||||||||||||||
| statusBarTooltipRunning, | ||||||||||||||||
| statusBarTooltipStopped, | ||||||||||||||||
| statusBarTooltipError, | ||||||||||||||||
| } from '../loc/strings'; | ||||||||||||||||
|
|
||||||||||||||||
| const runningStates = new Set(['Running', 'Active']); | ||||||||||||||||
|
|
||||||||||||||||
| function countResources(appHosts: readonly AppHostDisplayInfo[]): { total: number; running: number } { | ||||||||||||||||
| let total = 0; | ||||||||||||||||
| let running = 0; | ||||||||||||||||
| for (const appHost of appHosts) { | ||||||||||||||||
| if (appHost.resources) { | ||||||||||||||||
| for (const resource of appHost.resources) { | ||||||||||||||||
| total++; | ||||||||||||||||
| if (resource.state !== null && runningStates.has(resource.state)) { | ||||||||||||||||
| running++; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| return { total, running }; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function hasUnhealthyResource(appHosts: readonly AppHostDisplayInfo[]): boolean { | ||||||||||||||||
| for (const appHost of appHosts) { | ||||||||||||||||
| if (appHost.resources) { | ||||||||||||||||
| for (const resource of appHost.resources) { | ||||||||||||||||
| if (resource.stateStyle === 'error' || resource.state === 'FailedToStart' || resource.state === 'RuntimeUnhealthy') { | ||||||||||||||||
|
||||||||||||||||
| if (resource.stateStyle === 'error' || resource.state === 'FailedToStart' || resource.state === 'RuntimeUnhealthy') { | |
| if ( | |
| resource.stateStyle === 'error' || | |
| resource.stateStyle === 'warning' || | |
| resource.state === 'FailedToStart' || | |
| resource.state === 'RuntimeUnhealthy' | |
| ) { |
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.
Polling is now started unconditionally on activation. Since the extension activates on many workspaces (e.g.,
workspaceContains:**/*.csproj), this will spawnaspire psevery ~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.