@@ -10,7 +10,7 @@ import { extensionLogOutputChannel } from '../utils/logging';
1010import { AspireExtendedDebugConfiguration , EnvVar } from '../dcp/types' ;
1111import { AnsiColors , AspireTerminal } from '../utils/AspireTerminalProvider' ;
1212import { AspireDebugSession } from '../debugger/AspireDebugSession' ;
13- import type { DashboardBrowserType , DashboardLaunchBehavior } from '../debugger/AspireDebugSession' ;
13+ import type { DashboardLaunchBehavior } from '../debugger/AspireDebugSession' ;
1414import { isDirectory } from '../utils/io' ;
1515
1616export interface IInteractionService {
@@ -44,6 +44,11 @@ export interface IInteractionService {
4444
4545type CSLogLevel = 'Trace' | 'Debug' | 'Information' | 'Warn' | 'Error' | 'Critical' ;
4646const dashboardDefaultChangedNotificationKey = 'aspire.dashboardBrowser.defaultChangedNotification.v1' ;
47+ type DashboardLaunchBehaviorSource = 'debugConfiguration' | 'globalConfiguration' | 'legacyConfiguration' | 'default' ;
48+ type ResolvedDashboardLaunchBehavior = {
49+ behavior : DashboardLaunchBehavior ;
50+ source : DashboardLaunchBehaviorSource ;
51+ } ;
4752
4853// Support both PascalCase (old) and camelCase (new) for backwards compatibility
4954// with different versions of the CLI/AppHost.
@@ -132,15 +137,6 @@ function getConfiguredDashboardLaunchBehavior(aspireConfig: vscode.WorkspaceConf
132137 return normalizeDashboardLaunchBehavior ( configuredValue ) ;
133138}
134139
135- function hasConfiguredDashboardLaunchBehavior ( aspireConfig : vscode . WorkspaceConfiguration ) : boolean {
136- const dashboardBrowserInspection = aspireConfig . inspect < unknown > ( 'dashboardBrowser' ) ;
137- const dashboardBrowserConfigured = dashboardBrowserInspection ?. workspaceFolderValue !== undefined
138- || dashboardBrowserInspection ?. workspaceValue !== undefined
139- || dashboardBrowserInspection ?. globalValue !== undefined ;
140-
141- return dashboardBrowserConfigured || getConfiguredLegacyDashboardLaunchBehavior ( aspireConfig ) !== undefined ;
142- }
143-
144140// Support both PascalCase (old) and camelCase (new) for backwards compatibility.
145141// DisplayLineState is serialized with ModelContextProtocol.McpJsonUtilities.DefaultOptions
146142// which changed to camelCase in version 0.2.0+
@@ -412,17 +408,17 @@ export class InteractionService implements IInteractionService {
412408 const aspireConfig = vscode . workspace . getConfiguration ( 'aspire' ) ;
413409 const dashboardLaunchBehavior = this . getDashboardLaunchBehavior ( aspireConfig ) ;
414410
415- if ( dashboardLaunchBehavior === 'none' ) {
416- await this . showDashboardDefaultChangedNotificationIfNeeded ( aspireConfig ) ;
411+ if ( dashboardLaunchBehavior . behavior === 'none' ) {
412+ await this . showDashboardDefaultChangedNotificationIfNeeded ( dashboardLaunchBehavior . source ) ;
417413 return ;
418414 }
419415
420- if ( dashboardLaunchBehavior !== 'notification' ) {
416+ if ( dashboardLaunchBehavior . behavior !== 'notification' ) {
421417 // Open the dashboard URL in the configured browser. Prefer codespaces URL if available.
422418 const urlToOpen = codespacesUrl || baseUrl ;
423419 const debugSession = this . _getAspireDebugSession ( ) ;
424420 if ( debugSession ) {
425- await debugSession . openDashboard ( urlToOpen , dashboardLaunchBehavior ) ;
421+ await debugSession . openDashboard ( urlToOpen , dashboardLaunchBehavior . behavior ) ;
426422 }
427423 return ;
428424 }
@@ -457,61 +453,80 @@ export class InteractionService implements IInteractionService {
457453 vscode . env . openExternal ( vscode . Uri . parse ( codespacesUrl ) ) ;
458454 }
459455 else if ( selected . title === settingsLabel ) {
460- vscode . commands . executeCommand ( 'workbench.action.openSettings' , 'aspire.dashboardBrowser' ) ;
456+ this . openDashboardLaunchBehaviorSettings ( dashboardLaunchBehavior . source ) ;
461457 }
462458 } ) ;
463459 } , 1000 ) ;
464460 }
465461
466- private getDashboardLaunchBehavior ( aspireConfig : vscode . WorkspaceConfiguration ) : DashboardLaunchBehavior {
462+ private getDashboardLaunchBehavior ( aspireConfig : vscode . WorkspaceConfiguration ) : ResolvedDashboardLaunchBehavior {
467463 const debugSession = this . _getAspireDebugSession ( ) ;
468464 const debugConfigurationBehavior = normalizeDashboardLaunchBehavior ( debugSession ?. configuration . dashboardBrowser ) ;
469465 if ( debugConfigurationBehavior ) {
470- return debugConfigurationBehavior ;
466+ return { behavior : debugConfigurationBehavior , source : 'debugConfiguration' } ;
471467 }
472468
473469 const configuredGlobalBehavior = getConfiguredDashboardLaunchBehavior ( aspireConfig ) ;
474470 if ( configuredGlobalBehavior === 'none' || configuredGlobalBehavior === 'notification' ) {
475- return configuredGlobalBehavior ;
471+ return { behavior : configuredGlobalBehavior , source : 'globalConfiguration' } ;
476472 }
477473
478474 const legacyBehavior = getConfiguredLegacyDashboardLaunchBehavior ( aspireConfig ) ;
479475
480476 if ( legacyBehavior ) {
481477 if ( legacyBehavior === 'notification' || legacyBehavior === 'none' ) {
482- return legacyBehavior ;
478+ return { behavior : legacyBehavior , source : 'legacyConfiguration' } ;
483479 }
484480
485- return configuredGlobalBehavior ?? 'integratedBrowser' ;
481+ return {
482+ behavior : configuredGlobalBehavior ?? 'integratedBrowser' ,
483+ source : configuredGlobalBehavior ? 'globalConfiguration' : 'legacyConfiguration'
484+ } ;
486485 }
487486
488487 if ( configuredGlobalBehavior ) {
489- return configuredGlobalBehavior ;
488+ return { behavior : configuredGlobalBehavior , source : 'globalConfiguration' } ;
490489 }
491490
492- return normalizeDashboardLaunchBehavior ( aspireConfig . get < unknown > ( 'dashboardBrowser' , 'none' ) ) ?? 'none' ;
491+ return {
492+ behavior : normalizeDashboardLaunchBehavior ( aspireConfig . get < unknown > ( 'dashboardBrowser' , 'none' ) ) ?? 'none' ,
493+ source : 'default'
494+ } ;
493495 }
494496
495- private async showDashboardDefaultChangedNotificationIfNeeded ( aspireConfig : vscode . WorkspaceConfiguration ) : Promise < void > {
497+ private async showDashboardDefaultChangedNotificationIfNeeded ( source : DashboardLaunchBehaviorSource ) : Promise < void > {
496498 if ( ! this . _globalState || this . _globalState . get < boolean > ( dashboardDefaultChangedNotificationKey , false ) ) {
497499 return ;
498500 }
499501
500- if ( hasConfiguredDashboardLaunchBehavior ( aspireConfig ) ) {
502+ if ( source !== 'default' ) {
501503 return ;
502504 }
503505
504506 await this . _globalState . update ( dashboardDefaultChangedNotificationKey , true ) ;
505507 vscode . window . showInformationMessage ( dashboardLaunchBehaviorChanged , settingsLabel , changelogLabel ) . then ( selected => {
506508 if ( selected === settingsLabel ) {
507- vscode . commands . executeCommand ( 'workbench.action.openSettings' , 'aspire.dashboardBrowser' ) ;
509+ this . openDashboardLaunchBehaviorSettings ( source ) ;
508510 }
509511 else if ( selected === changelogLabel ) {
510512 vscode . env . openExternal ( vscode . Uri . parse ( 'https://github.com/microsoft/aspire/blob/main/extension/CHANGELOG.md' ) ) ;
511513 }
512514 } ) ;
513515 }
514516
517+ private openDashboardLaunchBehaviorSettings ( source : DashboardLaunchBehaviorSource ) : void {
518+ if ( source === 'debugConfiguration' ) {
519+ vscode . commands . executeCommand ( 'workbench.action.debug.configure' ) ;
520+ return ;
521+ }
522+
523+ vscode . commands . executeCommand (
524+ 'workbench.action.openSettings' ,
525+ source === 'legacyConfiguration'
526+ ? 'aspire.enableAspireDashboardAutoLaunch'
527+ : 'aspire.dashboardBrowser' ) ;
528+ }
529+
515530 async displayLines ( lines : ConsoleLine [ ] ) {
516531 this . clearProgressNotification ( ) ;
517532
0 commit comments