Skip to content

Commit b95f5fd

Browse files
authored
chat - update isInternal entitlement properly (microsoft#261596)
1 parent 2d6f48e commit b95f5fd

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/vs/workbench/contrib/chat/common/chatContextKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export namespace ChatContextKeys {
7272
};
7373

7474
export const Entitlement = {
75-
internal: new RawContextKey<boolean>('chatEntitlementInternal', false, true), // True when user is a chat internal user.
75+
internal: new RawContextKey<boolean>('chatEntitlementInternal', false, true), // True when user is a chat internal user.
7676
signedOut: new RawContextKey<boolean>('chatEntitlementSignedOut', false, true), // True when user is signed out.
7777
canSignUp: new RawContextKey<boolean>('chatPlanCanSignUp', false, true), // True when user can sign up to be a chat free user.
7878
free: new RawContextKey<boolean>('chatPlanFree', false, true), // True when user is a chat free user.

src/vs/workbench/contrib/chat/common/chatEntitlementService.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ export class ChatEntitlementRequests extends Disposable {
728728

729729
private containsInternalOrgs(organizationLogins: string[]): boolean {
730730
const internalOrgs = ['github', 'microsoft'];
731+
731732
return organizationLogins.some(org => internalOrgs.includes(org));
732733
}
733734

@@ -772,7 +773,7 @@ export class ChatEntitlementRequests extends Disposable {
772773
private update(state: IEntitlements): void {
773774
this.state = state;
774775

775-
this.context.update({ entitlement: this.state.entitlement, isInternal: this.state.isInternal });
776+
this.context.update({ entitlement: this.state.entitlement, isInternal: !!this.state.isInternal });
776777

777778
if (state.quotas) {
778779
this.chatQuotasAccessor.acceptQuotas(state.quotas);
@@ -943,7 +944,7 @@ export class ChatEntitlementContext extends Disposable {
943944
private readonly businessContextKey: IContextKey<boolean>;
944945
private readonly enterpriseContextKey: IContextKey<boolean>;
945946

946-
private readonly internalContextKey: IContextKey<boolean>;
947+
private readonly isInternalContextKey: IContextKey<boolean>;
947948

948949
private readonly hiddenContext: IContextKey<boolean>;
949950
private readonly laterContext: IContextKey<boolean>;
@@ -976,7 +977,7 @@ export class ChatEntitlementContext extends Disposable {
976977
this.proPlusContextKey = ChatContextKeys.Entitlement.proPlus.bindTo(contextKeyService);
977978
this.businessContextKey = ChatContextKeys.Entitlement.business.bindTo(contextKeyService);
978979
this.enterpriseContextKey = ChatContextKeys.Entitlement.enterprise.bindTo(contextKeyService);
979-
this.internalContextKey = ChatContextKeys.Entitlement.internal.bindTo(contextKeyService);
980+
this.isInternalContextKey = ChatContextKeys.Entitlement.internal.bindTo(contextKeyService);
980981
this.hiddenContext = ChatContextKeys.Setup.hidden.bindTo(contextKeyService);
981982
this.laterContext = ChatContextKeys.Setup.later.bindTo(contextKeyService);
982983
this.installedContext = ChatContextKeys.Setup.installed.bindTo(contextKeyService);
@@ -1025,10 +1026,9 @@ export class ChatEntitlementContext extends Disposable {
10251026
update(context: { installed: boolean; disabled: boolean; untrusted: boolean }): Promise<void>;
10261027
update(context: { hidden: boolean }): Promise<void>;
10271028
update(context: { later: boolean }): Promise<void>;
1028-
update(context: { entitlement: ChatEntitlement; isInternal?: boolean }): Promise<void>;
1029+
update(context: { entitlement: ChatEntitlement; isInternal: boolean }): Promise<void>;
10291030
update(context: { installed?: boolean; disabled?: boolean; untrusted?: boolean; hidden?: boolean; later?: boolean; entitlement?: ChatEntitlement; isInternal?: boolean }): Promise<void> {
10301031
this.logService.trace(`[chat entitlement context] update(): ${JSON.stringify(context)}`);
1031-
this.state.isInternal = !!context.isInternal;
10321032

10331033
if (typeof context.installed === 'boolean' && typeof context.disabled === 'boolean' && typeof context.untrusted === 'boolean') {
10341034
this._state.installed = context.installed;
@@ -1050,6 +1050,7 @@ export class ChatEntitlementContext extends Disposable {
10501050

10511051
if (typeof context.entitlement === 'number') {
10521052
this._state.entitlement = context.entitlement;
1053+
this._state.isInternal = !!context.isInternal;
10531054

10541055
if (this._state.entitlement === ChatEntitlement.Free || isProUser(this._state.entitlement)) {
10551056
this._state.registered = true;
@@ -1082,7 +1083,7 @@ export class ChatEntitlementContext extends Disposable {
10821083
this.proPlusContextKey.set(this._state.entitlement === ChatEntitlement.ProPlus);
10831084
this.businessContextKey.set(this._state.entitlement === ChatEntitlement.Business);
10841085
this.enterpriseContextKey.set(this._state.entitlement === ChatEntitlement.Enterprise);
1085-
this.internalContextKey.set(this._state.isInternal);
1086+
this.isInternalContextKey.set(this._state.isInternal);
10861087
this.hiddenContext.set(!!this._state.hidden);
10871088
this.laterContext.set(!!this._state.later);
10881089
this.installedContext.set(!!this._state.installed);

0 commit comments

Comments
 (0)