diff --git a/src/vs/workbench/contrib/chat/browser/chatSetup.ts b/src/vs/workbench/contrib/chat/browser/chatSetup.ts index f8df3fb800007..2e4d60c931c4a 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts @@ -69,7 +69,7 @@ const defaultChat = { skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '', publicCodeMatchesUrl: product.defaultChatAgent?.publicCodeMatchesUrl ?? '', upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '', - providerId: product.defaultChatAgent?.providerId ?? '', + providerIds: [product.defaultChatAgent?.providerId ?? '', 'github-enterprise'], providerName: product.defaultChatAgent?.providerName ?? '', providerScopes: product.defaultChatAgent?.providerScopes ?? [[]], entitlementUrl: product.defaultChatAgent?.entitlementUrl ?? '', @@ -366,7 +366,8 @@ class ChatSetupRequests extends Disposable { @IRequestService private readonly requestService: IRequestService, @IChatQuotasService private readonly chatQuotasService: IChatQuotasService, @IDialogService private readonly dialogService: IDialogService, - @IOpenerService private readonly openerService: IOpenerService + @IOpenerService private readonly openerService: IOpenerService, + @IConfigurationService private readonly configurationService: IConfigurationService ) { super(); @@ -379,19 +380,19 @@ class ChatSetupRequests extends Disposable { this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.resolve())); this._register(this.authenticationService.onDidChangeSessions(e => { - if (e.providerId === defaultChat.providerId) { + if (defaultChat.providerIds.includes(e.providerId)) { this.resolve(); } })); this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => { - if (e.id === defaultChat.providerId) { + if (defaultChat.providerIds.includes(e.id)) { this.resolve(); } })); this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => { - if (e.id === defaultChat.providerId) { + if (defaultChat.providerIds.includes(e.id)) { this.resolve(); } })); @@ -438,9 +439,20 @@ class ChatSetupRequests extends Disposable { } private async findMatchingProviderSession(token: CancellationToken): Promise { - const sessions = await this.authenticationService.getSessions(defaultChat.providerId); - if (token.isCancellationRequested) { - return undefined; + let sessions: ReadonlyArray = []; + const authProviderConfigValue = this.configurationService.getValue('github.copilot.advanced.authProvider'); + if (authProviderConfigValue) { + sessions = await this.authenticationService.getSessions(authProviderConfigValue); + } else { + for (const providerId of defaultChat.providerIds) { + if (token.isCancellationRequested) { + return undefined; + } + sessions = await this.authenticationService.getSessions(providerId); + if (sessions.length) { + break; + } + } } for (const session of sessions) { @@ -787,7 +799,7 @@ class ChatSetupController extends Disposable { } if (!session) { - session = (await this.authenticationService.getSessions(defaultChat.providerId)).at(0); + session = (await this.authenticationService.getSessions(defaultChat.providerIds[0])).at(0); if (!session) { return; // unexpected } @@ -817,7 +829,7 @@ class ChatSetupController extends Disposable { try { showCopilotView(this.viewsService, this.layoutService); - session = await this.authenticationService.createSession(defaultChat.providerId, defaultChat.providerScopes[0]); + session = await this.authenticationService.createSession(defaultChat.providerIds[0], defaultChat.providerScopes[0]); entitlement = await this.requests.forceResolveEntitlement(session); } catch (error) { // noop