VS Code extension: Auto-restore on workspace open and config change#15546
VS Code extension: Auto-restore on workspace open and config change#15546adamint wants to merge 4 commits intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15546Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15546" |
There was a problem hiding this comment.
Pull request overview
Adds an auto-restore mechanism to the VS Code extension so aspire restore is run automatically to keep integration packages in sync with aspire.config.json, reducing editor squiggles after branch switches/config edits.
Changes:
- Introduces
AspirePackageRestoreProviderto runaspire restoreon workspace open and onaspire.config.jsonchanges (with a concurrency cap and status bar progress). - Adds the
aspire.enableAutoRestoresetting (defaulttrue) plus localized strings for restore progress and results. - Updates TypeScript playground
aspire.config.jsonfiles and refreshes generated AppHost.modulesoutputs.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| playground/TypeScriptApps/RpsArena/aspire.config.json | Moves package versions to 13.2.0 and removes daily SDK/channel fields. |
| playground/TypeScriptApps/AzureFunctionsSample/aspire.config.json | Adds appHost metadata and moves package versions to 13.2.0. |
| playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts | Updates generated transport layer (cancellation, marshalling, connection/auth flow). |
| playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts | Updates generated base SDK types (ReferenceExpression enhancements, transport value serialization). |
| playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash | Updates codegen hash to reflect regenerated modules. |
| extension/src/utils/settings.ts | Adds accessor for enableAutoRestore. |
| extension/src/utils/AspirePackageRestoreProvider.ts | New provider that runs/monitors aspire restore and shows status bar progress. |
| extension/src/loc/strings.ts | Adds localized runtime strings for restore progress/results. |
| extension/src/extension.ts | Wires up the new auto-restore provider during activation. |
| extension/package.nls.json | Adds localized description for the new setting and restore messages. |
| extension/package.json | Defines the new aspire.enableAutoRestore configuration setting. |
| extension/loc/xlf/aspire-vscode.xlf | Adds localization units for new strings/setting description. |
playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts
Outdated
Show resolved
Hide resolved
…g restores, separate errors, fix timeout leak, handle unhandled promise
…s-15546 # Conflicts: # playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/.codegen-hash # playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/aspire.ts # playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/base.ts # playground/TypeScriptApps/AzureFunctionsSample/AppHost/.modules/transport.ts
| "Aspire.Hosting.Python": "13.3.0-preview.1.26167.8", | ||
| "Aspire.Hosting.PostgreSQL": "13.3.0-preview.1.26167.8", | ||
| "Aspire.Hosting.JavaScript": "13.3.0-preview.1.26167.8" | ||
| "Aspire.Hosting.Python": "13.2.0", | ||
| "Aspire.Hosting.PostgreSQL": "13.2.0", | ||
| "Aspire.Hosting.JavaScript": "13.2.0" |
There was a problem hiding this comment.
Shouldn't be using the latest main builds? What effect would this change have?
| "aspire-vscode.strings.selectFileTitle": "Select file", | ||
| "aspire-vscode.strings.enterPipelineStep": "Enter the pipeline step to execute", | ||
| "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0}...", | ||
| "aspire-vscode.strings.runningAspireRestoreProgress": "Running aspire restore ({0}/{1} projects)...", |
There was a problem hiding this comment.
| "aspire-vscode.strings.runningAspireRestoreProgress": "Running aspire restore ({0}/{1} projects)...", | |
| "aspire-vscode.strings.runningAspireRestoreProgress": "Running aspire restore ({0}/{1} projects ...", |
| "aspire-vscode.strings.selectDirectoryTitle": "Select directory", | ||
| "aspire-vscode.strings.selectFileTitle": "Select file", | ||
| "aspire-vscode.strings.enterPipelineStep": "Enter the pipeline step to execute", | ||
| "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0}...", |
There was a problem hiding this comment.
| "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0}...", | |
| "aspire-vscode.strings.runningAspireRestore": "Running aspire restore on {0} ...", |
| for (const proc of this._childProcesses) { | ||
| proc.kill(); | ||
| } | ||
| this._childProcesses.clear(); | ||
| for (const timeout of this._timeouts) { | ||
| clearTimeout(timeout); | ||
| } | ||
| this._timeouts.clear(); | ||
| for (const d of this._disposables) { | ||
| d.dispose(); | ||
| } | ||
| this._disposables.length = 0; |
There was a problem hiding this comment.
I'm a TS noob. Do we need to handle exceptions here like if killing a process fails?
| 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 runningAspireRestore = (configPath: string) => vscode.l10n.t('Running aspire restore on {0}...', configPath); | ||
| export const runningAspireRestoreProgress = (completed: number, total: number) => vscode.l10n.t('Running aspire restore ({0}/{1} projects)...', completed, total); |
There was a problem hiding this comment.
| export const runningAspireRestoreProgress = (completed: number, total: number) => vscode.l10n.t('Running aspire restore ({0}/{1} projects)...', completed, total); | |
| export const runningAspireRestoreProgress = (completed: number, total: number) => vscode.l10n.t('Running aspire restore ({0}/{1} projects ...', completed, total); |
| export const cliNotAvailable = vscode.l10n.t('Aspire CLI is not available on PATH. Please install it and restart VS Code.'); | ||
| 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 runningAspireRestore = (configPath: string) => vscode.l10n.t('Running aspire restore on {0}...', configPath); |
There was a problem hiding this comment.
| export const runningAspireRestore = (configPath: string) => vscode.l10n.t('Running aspire restore on {0}...', configPath); | |
| export const runningAspireRestore = (configPath: string) => vscode.l10n.t('Running aspire restore on {0} ...', configPath); |
| if (!getEnableAutoRestore()) { | ||
| return; | ||
| } | ||
| if (this._active.size === 0) { |
There was a problem hiding this comment.
Do we need to worry about _onChanged getting called multiple times in parallel?
| const hideTimeout = setTimeout(() => { | ||
| this._timeouts.delete(hideTimeout); | ||
| if (this._active.size === 0) { this._statusBarItem.hide(); } | ||
| }, 5000); |
There was a problem hiding this comment.
5000 - should this be a const from somewhere?
Description
Adds automatic
aspire restoreexecution in the VS Code extension to keep integration packages in sync withaspire.config.json.Problem: When switching git branches that have different Aspire integrations configured, the editor shows squiggly errors until you manually run
aspire restore. This is a common friction point during development.Solution: The new
AspirePackageRestoreProviderautomatically runsaspire restore:aspire.config.jsonfiles found in the workspaceFileSystemWatchermonitorsaspire.config.jsonfiles; when content actually changes (e.g., branch switch, manual edit), it runs restoreI tested this using:
Checklist