Skip to content

Add dashboard browser setting for VS Code extension#14684

Merged
adamint merged 8 commits intomicrosoft:release/13.2from
adamint:dev/adamint/dashboard-browser-setting
Mar 4, 2026
Merged

Add dashboard browser setting for VS Code extension#14684
adamint merged 8 commits intomicrosoft:release/13.2from
adamint:dev/adamint/dashboard-browser-setting

Conversation

@adamint
Copy link
Member

@adamint adamint commented Feb 25, 2026

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 via vscode.env.openExternal
    • debugChrome — Opens in a Chrome debug session (uses pwa-chrome)
    • debugEdge — Opens in an Edge debug session (uses pwa-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

  • Dashboard lifecycle management (open/close) is consolidated in AspireDebugSession
  • Debug browser sessions use parentSession to bind their lifecycle to the Aspire debug session
  • All new user-facing strings are localized

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • No — These are VS Code extension settings and debug session orchestration that can't be meaningfully unit tested without real VS Code APIs. Existing interaction service tests continue to pass.
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings February 25, 2026 17:25
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 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 -- 14684

Or

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

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

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.dashboardBrowser setting with options for external browser (default), Chrome, Edge, or Firefox debug sessions
  • Added aspire.closeDashboardOnDebugEnd setting (default: true) to automatically close debug browser tabs when debugging stops
  • Moved dashboard opening logic from vscode.env.openExternal to AspireDebugSession.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

Comment on lines 7 to 9

export type DashboardBrowserType = 'openExternalBrowser' | 'debugChrome' | 'debugEdge' | 'debugFirefox';
import AspireDcpServer, { generateDcpIdPrefix } from "../dcp/AspireDcpServer";
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@adamint adamint changed the base branch from main to release/13.2 March 2, 2026 17:37
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.
@adamint adamint force-pushed the dev/adamint/dashboard-browser-setting branch from d12bf1a to 1076d66 Compare March 2, 2026 17:41
adamint and others added 4 commits March 2, 2026 12:43
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.
Copy link
Member

Choose a reason for hiding this comment

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

This is probably a dumb question, but why would a user want to debug the dashboard?

Copy link
Member Author

@adamint adamint Mar 2, 2026

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

Does the user have to configure something themselves to get this to work? In VS it just happens AFAICT

Copy link
Member Author

@adamint adamint Mar 2, 2026

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

What does VS do?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, dev kit has the same behavior we do (launching the external browser). I think we should keep that approach

Copy link
Member

@IEvangelist IEvangelist left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +373 to +374
const aspireConfig = vscode.workspace.getConfiguration('aspire');
const shouldClose = aspireConfig.get<boolean>('closeDashboardOnDebugEnd', true);
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea! I will follow this up with a clean up

@adamint adamint merged commit a8eed2d into microsoft:release/13.2 Mar 4, 2026
384 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Mar 4, 2026
Copilot AI pushed a commit that referenced this pull request Mar 10, 2026
* 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>
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.

VS Code Extension: Allow me to select the browser and close the browser when debug done

4 participants