Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/vs/workbench/contrib/chat/common/chatEntitlementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { IProductService } from '../../../../platform/product/common/productServ
import { asText, IRequestService } from '../../../../platform/request/common/request.js';
import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
import { ITelemetryService, TelemetryLevel } from '../../../../platform/telemetry/common/telemetry.js';
import { AuthenticationSession, IAuthenticationExtensionsService, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { AuthenticationSession, AuthenticationSessionAccount, IAuthenticationExtensionsService, IAuthenticationService } from '../../../services/authentication/common/authentication.js';
import { IWorkbenchExtensionEnablementService } from '../../../services/extensionManagement/common/extensionManagement.js';
import { IExtension, IExtensionsWorkbenchService } from '../../extensions/common/extensions.js';
import { ChatContextKeys } from './chatContextKeys.js';
Expand Down Expand Up @@ -465,8 +465,17 @@ export class ChatEntitlementRequests extends Disposable {
}

private async doGetSessions(providerId: string): Promise<readonly AuthenticationSession[]> {
const preferredAccountName = this.authenticationExtensionsService.getAccountPreference(defaultChat.chatExtensionId, providerId) ?? this.authenticationExtensionsService.getAccountPreference(defaultChat.extensionId, providerId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practice, chat and completions are tied together, via a package.json config, but this doesn't really hurt.

let preferredAccount: AuthenticationSessionAccount | undefined;
for (const account of await this.authenticationService.getAccounts(providerId)) {
if (account.label === preferredAccountName) {
preferredAccount = account;
break;
}
}

try {
return await this.authenticationService.getSessions(providerId);
return await this.authenticationService.getSessions(providerId, undefined, preferredAccount);
} catch (error) {
// ignore - errors can throw if a provider is not registered
}
Expand Down
Loading