@@ -69,7 +69,7 @@ const defaultChat = {
69
69
skusDocumentationUrl : product . defaultChatAgent ?. skusDocumentationUrl ?? '' ,
70
70
publicCodeMatchesUrl : product . defaultChatAgent ?. publicCodeMatchesUrl ?? '' ,
71
71
upgradePlanUrl : product . defaultChatAgent ?. upgradePlanUrl ?? '' ,
72
- providerId : product . defaultChatAgent ?. providerId ?? '' ,
72
+ providerIds : [ product . defaultChatAgent ?. providerId ?? '' , 'github-enterprise' ] ,
73
73
providerName : product . defaultChatAgent ?. providerName ?? '' ,
74
74
providerScopes : product . defaultChatAgent ?. providerScopes ?? [ [ ] ] ,
75
75
entitlementUrl : product . defaultChatAgent ?. entitlementUrl ?? '' ,
@@ -366,7 +366,8 @@ class ChatSetupRequests extends Disposable {
366
366
@IRequestService private readonly requestService : IRequestService ,
367
367
@IChatQuotasService private readonly chatQuotasService : IChatQuotasService ,
368
368
@IDialogService private readonly dialogService : IDialogService ,
369
- @IOpenerService private readonly openerService : IOpenerService
369
+ @IOpenerService private readonly openerService : IOpenerService ,
370
+ @IConfigurationService private readonly configurationService : IConfigurationService
370
371
) {
371
372
super ( ) ;
372
373
@@ -379,19 +380,19 @@ class ChatSetupRequests extends Disposable {
379
380
this . _register ( this . authenticationService . onDidChangeDeclaredProviders ( ( ) => this . resolve ( ) ) ) ;
380
381
381
382
this . _register ( this . authenticationService . onDidChangeSessions ( e => {
382
- if ( e . providerId === defaultChat . providerId ) {
383
+ if ( defaultChat . providerIds . includes ( e . providerId ) ) {
383
384
this . resolve ( ) ;
384
385
}
385
386
} ) ) ;
386
387
387
388
this . _register ( this . authenticationService . onDidRegisterAuthenticationProvider ( e => {
388
- if ( e . id === defaultChat . providerId ) {
389
+ if ( defaultChat . providerIds . includes ( e . id ) ) {
389
390
this . resolve ( ) ;
390
391
}
391
392
} ) ) ;
392
393
393
394
this . _register ( this . authenticationService . onDidUnregisterAuthenticationProvider ( e => {
394
- if ( e . id === defaultChat . providerId ) {
395
+ if ( defaultChat . providerIds . includes ( e . id ) ) {
395
396
this . resolve ( ) ;
396
397
}
397
398
} ) ) ;
@@ -438,9 +439,20 @@ class ChatSetupRequests extends Disposable {
438
439
}
439
440
440
441
private async findMatchingProviderSession ( token : CancellationToken ) : Promise < AuthenticationSession | undefined > {
441
- const sessions = await this . authenticationService . getSessions ( defaultChat . providerId ) ;
442
- if ( token . isCancellationRequested ) {
443
- return undefined ;
442
+ let sessions : ReadonlyArray < AuthenticationSession > = [ ] ;
443
+ const authProviderConfigValue = this . configurationService . getValue < string | undefined > ( 'github.copilot.advanced.authProvider' ) ;
444
+ if ( authProviderConfigValue ) {
445
+ sessions = await this . authenticationService . getSessions ( authProviderConfigValue ) ;
446
+ } else {
447
+ for ( const providerId of defaultChat . providerIds ) {
448
+ if ( token . isCancellationRequested ) {
449
+ return undefined ;
450
+ }
451
+ sessions = await this . authenticationService . getSessions ( providerId ) ;
452
+ if ( sessions . length ) {
453
+ break ;
454
+ }
455
+ }
444
456
}
445
457
446
458
for ( const session of sessions ) {
@@ -787,7 +799,7 @@ class ChatSetupController extends Disposable {
787
799
}
788
800
789
801
if ( ! session ) {
790
- session = ( await this . authenticationService . getSessions ( defaultChat . providerId ) ) . at ( 0 ) ;
802
+ session = ( await this . authenticationService . getSessions ( defaultChat . providerIds [ 0 ] ) ) . at ( 0 ) ;
791
803
if ( ! session ) {
792
804
return ; // unexpected
793
805
}
@@ -817,7 +829,7 @@ class ChatSetupController extends Disposable {
817
829
try {
818
830
showCopilotView ( this . viewsService , this . layoutService ) ;
819
831
820
- session = await this . authenticationService . createSession ( defaultChat . providerId , defaultChat . providerScopes [ 0 ] ) ;
832
+ session = await this . authenticationService . createSession ( defaultChat . providerIds [ 0 ] , defaultChat . providerScopes [ 0 ] ) ;
821
833
entitlement = await this . requests . forceResolveEntitlement ( session ) ;
822
834
} catch ( error ) {
823
835
// noop
0 commit comments