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
38 changes: 24 additions & 14 deletions src/vs/workbench/services/accounts/common/defaultAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,26 +231,36 @@ export class DefaultAccountManagementContribution extends Disposable implements
return {};
}

const chatContext = await this.requestService.request({
type: 'GET',
url: tokenEntitlementsUrl,
disableCache: true,
headers: {
'Authorization': `Bearer ${accessToken}`
try {
const chatContext = await this.requestService.request({
type: 'GET',
url: tokenEntitlementsUrl,
disableCache: true,
headers: {
'Authorization': `Bearer ${accessToken}`
}
}, CancellationToken.None);

const chatData = await asJson<ITokenEntitlementsResponse>(chatContext);
if (chatData) {
return {
// Editor preview features are disabled if the flag is present and set to 0
chat_preview_features_enabled: this.extractFromToken(chatData.token, 'editor_preview_features') !== '0',
};
}
}, CancellationToken.None);

const chatData = await asJson<ITokenEntitlementsResponse>(chatContext);
if (chatData) {
return {
// Editor preview features are disabled if the flag is present and set to 0
chat_preview_features_enabled: this.extractFromToken(chatData.token, 'editor_preview_features') !== '0',
};
this.logService.error('Failed to fetch token entitlements', 'No data returned');
} catch (error) {
this.logService.error('Failed to fetch token entitlements', getErrorMessage(error));
}

return {};
}

private async getChatEntitlements(accessToken: string, chatEntitlementsUrl: string): Promise<Partial<IChatEntitlementsResponse>> {
if (!chatEntitlementsUrl) {
return {};
}

try {
const context = await this.requestService.request({
type: 'GET',
Expand Down
Loading