Add, respect auto-open aspire dashboard setting. Open the first application url in dotnet projects if multiple are provided#12674
Conversation
…est priority) application url in dotnet projects
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12674Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12674" |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new configuration option aspire.enableAspireDashboardAutoLaunch to control whether the Aspire Dashboard automatically opens in the browser when debugging an Aspire apphost. When set to false, the dashboard won't auto-launch, and an informational message prompts the user to manually open it.
Key Changes
- Added new VS Code setting
aspire.enableAspireDashboardAutoLaunch(default:true) to control dashboard auto-launch behavior - Modified
displayDashboardUrlsto conditionally show info message based on the new setting - Updated
determineServerReadyActionto handle multiple URLs separated by semicolons by selecting the first URL - Conditional logic in dotnet debugger to respect the auto-launch setting for apphost projects
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/package.json | Added new boolean configuration property for dashboard auto-launch control |
| extension/package.nls.json | Added localization key for the new configuration description |
| extension/loc/xlf/aspire-vscode.xlf | Added localization translation unit for the new setting |
| extension/src/server/interactionService.ts | Added conditional logic to skip info message when auto-launch is enabled |
| extension/src/debugger/languages/dotnet.ts | Added conditional serverReadyAction based on auto-launch setting for apphost projects |
| extension/src/debugger/launchProfiles.ts | Enhanced URL handling to extract first URL from semicolon-separated list |
| extension/src/test/rpc/interactionServiceTests.test.ts | Updated tests to verify behavior with both auto-launch enabled and disabled |
| extension/src/test/launchProfiles.test.ts | Added test for semicolon-separated URL handling |
Comments suppressed due to low confidence (1)
extension/src/debugger/launchProfiles.ts:206
- This use of variable 'applicationUrl' always evaluates to true.
let uriFormat = applicationUrl && applicationUrl.includes(';') ? applicationUrl.split(';')[0] : applicationUrl;
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>
|
|
||
| if (launchOptions.isApphost) { | ||
| // The Aspire dashboard URL will be set as the apphost's application URL. Check if auto-launch is enabled | ||
| const enableDashboardAutoLaunch = vscode.workspace.getConfiguration('aspire').get<boolean>('enableAspireDashboardAutoLaunch', true); |
There was a problem hiding this comment.
Is there a way to have this check in a single spot? that way:
- We don't have duplicate code
- how expensive is this check?
There was a problem hiding this comment.
Sure, I can put getters for getConfiguration calls into workspace.ts!
There was a problem hiding this comment.
I looked into this more and it doesn’t seem like that’s a common pattern in most extensions. I may keep for now? If the amount of settings grows we may benefit from some sort of setting manager
| const enableDashboardAutoLaunch = vscode.workspace.getConfiguration('aspire').get<boolean>('enableAspireDashboardAutoLaunch', true); | ||
|
|
||
| if (enableDashboardAutoLaunch) { | ||
| debugConfiguration.serverReadyAction = determineServerReadyAction(baseProfile?.launchBrowser, baseProfile?.applicationUrl); |
There was a problem hiding this comment.
(nit) is there a way to refactor the logic so we only need to set debugConfiguration.serverReadyAction in a single spot?
There was a problem hiding this comment.
It's definitely possible, but seemingly not without computing enableDashboardAutoLaunch even when it is not necessary or having a variable at the scope of enableDashboardAutoLaunch that serverReadyAction is then set to
Description
I noticed yesterday that server ready actions weren't working as I'd expect when there are multiple URLs in the
applicationUrlsproperty. The first should be opened. After a question from Tommaso, I also investigated and found that the dashboard was not auto-opening because of the same issue.To allow opting out of launching the dashboard, I added a new VS Code setting (
aspire.enableAspireDashboardAutoLaunch), which istrueby default. Iftrue, the launch aspire dashboard informational message no longer appears, as it would be redundant.cc @tommasodotNET
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate