Skip to content

Commit 7f37b1e

Browse files
Include checking for github-enterprise (microsoft#237993)
* Include checking for `github-enterprise` So that we hide the setup view for GHE.com users after they install Copilot & sign in. Note: this behavior still isn't great if they haven't yet installed Copilot, but to keep this candidate small, we're just focused on fixing the case for when they have Copilot installed already. * Check setting
1 parent 91fbddd commit 7f37b1e

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

src/vs/workbench/contrib/chat/browser/chatSetup.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const defaultChat = {
6969
skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '',
7070
publicCodeMatchesUrl: product.defaultChatAgent?.publicCodeMatchesUrl ?? '',
7171
upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '',
72-
providerId: product.defaultChatAgent?.providerId ?? '',
72+
providerIds: [product.defaultChatAgent?.providerId ?? '', 'github-enterprise'],
7373
providerName: product.defaultChatAgent?.providerName ?? '',
7474
providerScopes: product.defaultChatAgent?.providerScopes ?? [[]],
7575
entitlementUrl: product.defaultChatAgent?.entitlementUrl ?? '',
@@ -366,7 +366,8 @@ class ChatSetupRequests extends Disposable {
366366
@IRequestService private readonly requestService: IRequestService,
367367
@IChatQuotasService private readonly chatQuotasService: IChatQuotasService,
368368
@IDialogService private readonly dialogService: IDialogService,
369-
@IOpenerService private readonly openerService: IOpenerService
369+
@IOpenerService private readonly openerService: IOpenerService,
370+
@IConfigurationService private readonly configurationService: IConfigurationService
370371
) {
371372
super();
372373

@@ -379,19 +380,19 @@ class ChatSetupRequests extends Disposable {
379380
this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.resolve()));
380381

381382
this._register(this.authenticationService.onDidChangeSessions(e => {
382-
if (e.providerId === defaultChat.providerId) {
383+
if (defaultChat.providerIds.includes(e.providerId)) {
383384
this.resolve();
384385
}
385386
}));
386387

387388
this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => {
388-
if (e.id === defaultChat.providerId) {
389+
if (defaultChat.providerIds.includes(e.id)) {
389390
this.resolve();
390391
}
391392
}));
392393

393394
this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => {
394-
if (e.id === defaultChat.providerId) {
395+
if (defaultChat.providerIds.includes(e.id)) {
395396
this.resolve();
396397
}
397398
}));
@@ -438,9 +439,20 @@ class ChatSetupRequests extends Disposable {
438439
}
439440

440441
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+
}
444456
}
445457

446458
for (const session of sessions) {
@@ -787,7 +799,7 @@ class ChatSetupController extends Disposable {
787799
}
788800

789801
if (!session) {
790-
session = (await this.authenticationService.getSessions(defaultChat.providerId)).at(0);
802+
session = (await this.authenticationService.getSessions(defaultChat.providerIds[0])).at(0);
791803
if (!session) {
792804
return; // unexpected
793805
}
@@ -817,7 +829,7 @@ class ChatSetupController extends Disposable {
817829
try {
818830
showCopilotView(this.viewsService, this.layoutService);
819831

820-
session = await this.authenticationService.createSession(defaultChat.providerId, defaultChat.providerScopes[0]);
832+
session = await this.authenticationService.createSession(defaultChat.providerIds[0], defaultChat.providerScopes[0]);
821833
entitlement = await this.requests.forceResolveEntitlement(session);
822834
} catch (error) {
823835
// noop

0 commit comments

Comments
 (0)