Add dashboard browser setting for VS Code extension#14684
Add dashboard browser setting for VS Code extension#14684adamint merged 8 commits intomicrosoft: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 -- 14684Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14684" |
There was a problem hiding this comment.
Pull request overview
This pull request adds VS Code extension settings to control which browser opens the Aspire dashboard during debugging and whether to automatically close it when debugging ends. The implementation consolidates dashboard lifecycle management in AspireDebugSession and uses VS Code's debug session parent-child relationships to enable auto-closing for browser debug sessions.
Changes:
- Added
aspire.dashboardBrowsersetting with options for external browser (default), Chrome, Edge, or Firefox debug sessions - Added
aspire.closeDashboardOnDebugEndsetting (default: true) to automatically close debug browser tabs when debugging stops - Moved dashboard opening logic from
vscode.env.openExternaltoAspireDebugSession.openDashboard()method - Added localization strings for new settings and dashboard name
- Included unrelated schema refactoring (flattening experimentalPolyglot settings and removing internal staging overrides)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/package.json | Defines two new VS Code settings: dashboardBrowser (enum) and closeDashboardOnDebugEnd (boolean) |
| extension/package.nls.json | Adds localized descriptions for the new settings and their enum values |
| extension/loc/xlf/aspire-vscode.xlf | Contains localization strings for the new settings |
| extension/src/loc/strings.ts | Exports new aspireDashboard localized string used as debug session name |
| extension/src/debugger/AspireDebugSession.ts | Implements openDashboard() and closeDashboard() methods with support for launching browsers as child debug sessions |
| extension/src/server/interactionService.ts | Updates dashboard auto-launch to use new browser type setting; adds no-op closeDashboard() interface method |
| extension/schemas/aspire-settings.schema.json | Flattens experimentalPolyglot properties and removes internal staging override settings (unrelated to dashboard feature) |
| extension/schemas/aspire-global-settings.schema.json | Same schema changes as aspire-settings.schema.json for global settings |
|
|
||
| export type DashboardBrowserType = 'openExternalBrowser' | 'debugChrome' | 'debugEdge' | 'debugFirefox'; | ||
| import AspireDcpServer, { generateDcpIdPrefix } from "../dcp/AspireDcpServer"; |
There was a problem hiding this comment.
The export statement for DashboardBrowserType is placed between import statements. By convention, all import statements should be grouped together at the top of the file, followed by type definitions and other exports. Consider moving the export type declaration after all imports (after line 19) for better code organization and consistency with typical TypeScript/JavaScript conventions.
Add settings to control which browser opens the Aspire dashboard during debugging and whether to close it when debugging ends: - aspire.dashboardBrowser: Choose between opening in default external browser (default), Chrome debug session, Edge debug session, or Firefox debug session - aspire.closeDashboardOnDebugEnd: Automatically close the dashboard browser tab when debugging ends (works with debug browser options) Debug browser sessions are launched as child sessions of the Aspire debug session, so they automatically close when the parent session ends. Dashboard lifecycle management is consolidated in AspireDebugSession.
d12bf1a to
1076d66
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
||
| /** | ||
| * Opens the dashboard URL in the specified browser. | ||
| * For debugChrome/debugEdge/debugFirefox, launches as a child debug session that auto-closes with the Aspire debug session. |
There was a problem hiding this comment.
This is probably a dumb question, but why would a user want to debug the dashboard?
There was a problem hiding this comment.
It ties the lifetime of the dashboard window to the Aspire debug session by opening a controlled browser window. It's what VS does with the aspire dashboard
There was a problem hiding this comment.
Does the user have to configure something themselves to get this to work? In VS it just happens AFAICT
There was a problem hiding this comment.
Currently yes because the default is to open the external browser. I could change the default to debugChrome? But we don't know that Chrome is installed. What do you think
There was a problem hiding this comment.
Actually, dev kit has the same behavior we do (launching the external browser). I think we should keep that approach
IEvangelist
left a comment
There was a problem hiding this comment.
Also, we should really clean up all the imports. Ideally (even though it's documented in the VS Code extensions docs), imports should only ever import a named export, never * as {blah}, while it can be noisier it's far more performant.
| const aspireConfig = vscode.workspace.getConfiguration('aspire'); | ||
| const shouldClose = aspireConfig.get<boolean>('closeDashboardOnDebugEnd', true); |
There was a problem hiding this comment.
In VS Code extensions I've written, I always end up creating a config class that reads the config and exposes property values the class as a service. Then you simply import the config class (and it implicitly reads from keys) - eliminating duplicated hardcoded strings throughout the code. This is an abstraction I'd strongly recommend.
There was a problem hiding this comment.
That's a good idea! I will follow this up with a clean up
* Add dashboard browser setting for VS Code extension Add settings to control which browser opens the Aspire dashboard during debugging and whether to close it when debugging ends: - aspire.dashboardBrowser: Choose between opening in default external browser (default), Chrome debug session, Edge debug session, or Firefox debug session - aspire.closeDashboardOnDebugEnd: Automatically close the dashboard browser tab when debugging ends (works with debug browser options) Debug browser sessions are launched as child sessions of the Aspire debug session, so they automatically close when the parent session ends. Dashboard lifecycle management is consolidated in AspireDebugSession. * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extension/src/server/interactionService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update extension/src/debugger/AspireDebugSession.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert auto-generated schema changes * Move DashboardBrowserType export after all imports --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description
Adds two new VS Code extension settings to control which browser opens the Aspire dashboard during debugging and whether to automatically close it when debugging ends. Fixes #12910
New Settings
aspire.dashboardBrowser: Choose which browser to use when auto-launching the Aspire dashboard:openExternalBrowser(default) — Opens in the system's default browser viavscode.env.openExternaldebugChrome— Opens in a Chrome debug session (usespwa-chrome)debugEdge— Opens in an Edge debug session (usespwa-msedge)debugFirefox— Opens in a Firefox debug session (requires the Firefox Debugger extension)aspire.closeDashboardOnDebugEnd(default:true): Automatically close the dashboard browser tab when the Aspire debug session ends. Works with the debug browser options (Chrome, Edge, Firefox), which are launched as child debug sessions that close when the parent session stops.Implementation Details
AspireDebugSessionparentSessionto bind their lifecycle to the Aspire debug sessionChecklist
aspire.devissue: