389
390
constructor(
392
>
@IProductService productService: IProductService,
393
>
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
394
>
@IContextKeyService private readonly contextKeyService: IContextKeyService,
395
>
@IConfigurationService private readonly configurationService: IConfigurationService,
396
>
@ITelemetryService private readonly telemetryService: ITelemetryService,
397
>
@ILogService private readonly logService: ILogService,
398
>
@IStorageService private readonly storageService: IStorageService,
399
>
) {
400
>
super();
401
>
402
>
const cachedUBB = this.storageService.getBoolean(ChatEntitlementService.CACHED_UBB_STORAGE_KEY, StorageScope.PROFILE);
403
>
this._quotas = cachedUBB !== undefined ? { usageBasedBilling: cachedUBB } : {};
404
>
405
>
this.chatQuotaExceededContextKey = ChatEntitlementContextKeys.chatQuotaExceeded.bindTo(this.contextKeyService);
406
>
this.completionsQuotaExceededContextKey = ChatEntitlementContextKeys.completionsQuotaExceeded.bindTo(this.contextKeyService);
407
>
408
>
this.anonymousContextKey = ChatEntitlementContextKeys.chatAnonymous.bindTo(this.contextKeyService);
409
>
this.anonymousContextKey.set(this.anonymous);
410
>
411
>
// Only apply the workbench-side default if no other source (e.g. the Copilot extension)
412
>
// has already set this key; binding would otherwise reset it to the declared default.
413
>
if (this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.clientByokEnabled.key) === undefined) {
414
>
ChatEntitlementContextKeys.clientByokEnabled.bindTo(this.contextKeyService);
415
>
}
416
>
417
>
this.onDidChangeEntitlement = Event.map(
418
>
Event.filter(
419
>
this.contextKeyService.onDidChangeContext, e => e.affectsSome(new Set([
420
ChatEntitlementContextKeys.Entitlement.planEdu.key,
421
ChatEntitlementContextKeys.Entitlement.planPro.key,