@@ -103,6 +103,9 @@ export interface IChatEntitlementService {
103103
104104 readonly entitlement : ChatEntitlement ;
105105 readonly isInternal : boolean ;
106+ readonly sku : string | undefined ;
107+ readonly isGitHubInternal : boolean ;
108+ readonly isMicrosoftInternal : boolean ;
106109
107110 readonly onDidChangeQuotaExceeded : Event < void > ;
108111 readonly onDidChangeQuotaRemaining : Event < void > ;
@@ -179,7 +182,11 @@ export class ChatEntitlementService extends Disposable implements IChatEntitleme
179182 ChatContextKeys . Entitlement . proPlus . key ,
180183 ChatContextKeys . Entitlement . free . key ,
181184 ChatContextKeys . Entitlement . canSignUp . key ,
182- ChatContextKeys . Entitlement . signedOut . key
185+ ChatContextKeys . Entitlement . signedOut . key ,
186+ ChatContextKeys . Entitlement . internal . key ,
187+ ChatContextKeys . Entitlement . gitHubInternal . key ,
188+ ChatContextKeys . Entitlement . microsoftInternal . key ,
189+ ChatContextKeys . Entitlement . sku . key
183190 ] ) ) , this . _store
184191 ) , ( ) => { } , this . _store
185192 ) ;
@@ -246,6 +253,18 @@ export class ChatEntitlementService extends Disposable implements IChatEntitleme
246253 return this . contextKeyService . getContextKeyValue < boolean > ( ChatContextKeys . Entitlement . internal . key ) === true ;
247254 }
248255
256+ get isGitHubInternal ( ) : boolean {
257+ return this . contextKeyService . getContextKeyValue < boolean > ( ChatContextKeys . Entitlement . gitHubInternal . key ) === true ;
258+ }
259+
260+ get isMicrosoftInternal ( ) : boolean {
261+ return this . contextKeyService . getContextKeyValue < boolean > ( ChatContextKeys . Entitlement . microsoftInternal . key ) === true ;
262+ }
263+
264+ get sku ( ) : string | undefined {
265+ return this . contextKeyService . getContextKeyValue < string > ( ChatContextKeys . Entitlement . sku . key ) ;
266+ }
267+
249268 //#endregion
250269
251270 //#region --- Quotas
@@ -406,6 +425,9 @@ interface IEntitlementsResponse extends ILegacyQuotaSnapshotResponse {
406425interface IEntitlements {
407426 readonly entitlement : ChatEntitlement ;
408427 readonly isInternal ?: boolean ;
428+ readonly isGitHubInternal ?: boolean ;
429+ readonly isMicrosoftInternal ?: boolean ;
430+ readonly sku ?: string ;
409431 readonly quotas ?: IQuotas ;
410432}
411433
@@ -651,8 +673,11 @@ export class ChatEntitlementRequests extends Disposable {
651673
652674 const entitlements : IEntitlements = {
653675 entitlement,
654- isInternal : this . containsInternalOrgs ( entitlementsResponse . organization_login_list ) ,
655- quotas : this . toQuotas ( entitlementsResponse )
676+ isInternal : this . containsInternalOrgs ( entitlementsResponse . organization_login_list , [ 'github' , 'microsoft' ] ) ,
677+ isGitHubInternal : this . containsInternalOrgs ( entitlementsResponse . organization_login_list , [ 'github' ] ) ,
678+ isMicrosoftInternal : this . containsInternalOrgs ( entitlementsResponse . organization_login_list , [ 'microsoft' ] ) ,
679+ quotas : this . toQuotas ( entitlementsResponse ) ,
680+ sku : entitlementsResponse . access_type_sku
656681 } ;
657682
658683 this . logService . trace ( `[chat entitlement]: resolved to ${ entitlements . entitlement } , quotas: ${ JSON . stringify ( entitlements . quotas ) } ` ) ;
@@ -740,9 +765,7 @@ export class ChatEntitlementRequests extends Disposable {
740765 return quotas ;
741766 }
742767
743- private containsInternalOrgs ( organizationLogins : string [ ] ) : boolean {
744- const internalOrgs = [ 'github' , 'microsoft' ] ;
745-
768+ private containsInternalOrgs ( organizationLogins : string [ ] , internalOrgs : string [ ] ) : boolean {
746769 return organizationLogins . some ( org => internalOrgs . includes ( org ) ) ;
747770 }
748771
@@ -787,7 +810,7 @@ export class ChatEntitlementRequests extends Disposable {
787810 private update ( state : IEntitlements ) : void {
788811 this . state = state ;
789812
790- this . context . update ( { entitlement : this . state . entitlement , isInternal : ! ! this . state . isInternal } ) ;
813+ this . context . update ( { entitlement : this . state . entitlement , isInternal : ! ! this . state . isInternal , isGitHubInternal : ! ! this . state . isGitHubInternal , isMicrosoftInternal : ! ! this . state . isMicrosoftInternal , sku : this . state . sku } ) ;
791814
792815 if ( state . quotas ) {
793816 this . chatQuotasAccessor . acceptQuotas ( state . quotas ) ;
@@ -942,11 +965,26 @@ export interface IChatEntitlementContextState extends IChatSentiment {
942965 */
943966 entitlement : ChatEntitlement ;
944967
968+ /**
969+ * User's last known or resolved raw SKU type.
970+ */
971+ sku : string | undefined ;
972+
945973 /**
946974 * User is an internal chat user.
947975 */
948976 isInternal : boolean ;
949977
978+ /**
979+ * User is a GitHub internal user.
980+ */
981+ isGitHubInternal : boolean ;
982+
983+ /**
984+ * User is a Microsoft internal user.
985+ */
986+ isMicrosoftInternal : boolean ;
987+
950988 /**
951989 * User is or was a registered Chat user.
952990 */
@@ -968,6 +1006,9 @@ export class ChatEntitlementContext extends Disposable {
9681006 private readonly enterpriseContextKey : IContextKey < boolean > ;
9691007
9701008 private readonly isInternalContextKey : IContextKey < boolean > ;
1009+ private readonly isGitHubInternalContextKey : IContextKey < boolean > ;
1010+ private readonly isMicrosoftInternalContextKey : IContextKey < boolean > ;
1011+ private readonly skuContextKey : IContextKey < string | undefined > ;
9711012
9721013 private readonly hiddenContext : IContextKey < boolean > ;
9731014 private readonly laterContext : IContextKey < boolean > ;
@@ -1002,13 +1043,16 @@ export class ChatEntitlementContext extends Disposable {
10021043 this . businessContextKey = ChatContextKeys . Entitlement . business . bindTo ( contextKeyService ) ;
10031044 this . enterpriseContextKey = ChatContextKeys . Entitlement . enterprise . bindTo ( contextKeyService ) ;
10041045 this . isInternalContextKey = ChatContextKeys . Entitlement . internal . bindTo ( contextKeyService ) ;
1046+ this . isGitHubInternalContextKey = ChatContextKeys . Entitlement . gitHubInternal . bindTo ( contextKeyService ) ;
1047+ this . isMicrosoftInternalContextKey = ChatContextKeys . Entitlement . microsoftInternal . bindTo ( contextKeyService ) ;
1048+ this . skuContextKey = ChatContextKeys . Entitlement . sku . bindTo ( contextKeyService ) ;
10051049 this . hiddenContext = ChatContextKeys . Setup . hidden . bindTo ( contextKeyService ) ;
10061050 this . laterContext = ChatContextKeys . Setup . later . bindTo ( contextKeyService ) ;
10071051 this . installedContext = ChatContextKeys . Setup . installed . bindTo ( contextKeyService ) ;
10081052 this . disabledContext = ChatContextKeys . Setup . disabled . bindTo ( contextKeyService ) ;
10091053 this . untrustedContext = ChatContextKeys . Setup . untrusted . bindTo ( contextKeyService ) ;
10101054
1011- this . _state = this . storageService . getObject < IChatEntitlementContextState > ( ChatEntitlementContext . CHAT_ENTITLEMENT_CONTEXT_STORAGE_KEY , StorageScope . PROFILE ) ?? { entitlement : ChatEntitlement . Unknown , isInternal : false } ;
1055+ this . _state = this . storageService . getObject < IChatEntitlementContextState > ( ChatEntitlementContext . CHAT_ENTITLEMENT_CONTEXT_STORAGE_KEY , StorageScope . PROFILE ) ?? { entitlement : ChatEntitlement . Unknown , isInternal : false , isGitHubInternal : false , isMicrosoftInternal : false , sku : undefined } ;
10121056
10131057 this . checkExtensionInstallation ( ) ;
10141058 this . updateContextSync ( ) ;
@@ -1069,8 +1113,8 @@ export class ChatEntitlementContext extends Disposable {
10691113 update ( context : { installed : boolean ; disabled : boolean ; untrusted : boolean } ) : Promise < void > ;
10701114 update ( context : { hidden : false } ) : Promise < void > ; // legacy UI state from before we had a setting to hide, keep around to still support users who used this
10711115 update ( context : { later : boolean } ) : Promise < void > ;
1072- update ( context : { entitlement : ChatEntitlement ; isInternal : boolean } ) : Promise < void > ;
1073- update ( context : { installed ?: boolean ; disabled ?: boolean ; untrusted ?: boolean ; hidden ?: false ; later ?: boolean ; entitlement ?: ChatEntitlement ; isInternal ?: boolean } ) : Promise < void > {
1116+ update ( context : { entitlement : ChatEntitlement ; isInternal : boolean ; isGitHubInternal : boolean ; isMicrosoftInternal : boolean ; sku : string | undefined } ) : Promise < void > ;
1117+ update ( context : { installed ?: boolean ; disabled ?: boolean ; untrusted ?: boolean ; hidden ?: false ; later ?: boolean ; entitlement ?: ChatEntitlement ; isInternal ?: boolean ; isGitHubInternal ?: boolean ; isMicrosoftInternal ?: boolean ; sku ?: string } ) : Promise < void > {
10741118 this . logService . trace ( `[chat entitlement context] update(): ${ JSON . stringify ( context ) } ` ) ;
10751119
10761120 if ( typeof context . installed === 'boolean' && typeof context . disabled === 'boolean' && typeof context . untrusted === 'boolean' ) {
@@ -1094,6 +1138,9 @@ export class ChatEntitlementContext extends Disposable {
10941138 if ( typeof context . entitlement === 'number' ) {
10951139 this . _state . entitlement = context . entitlement ;
10961140 this . _state . isInternal = ! ! context . isInternal ;
1141+ this . _state . isGitHubInternal = ! ! context . isGitHubInternal ;
1142+ this . _state . isMicrosoftInternal = ! ! context . isMicrosoftInternal ;
1143+ this . _state . sku = context . sku ;
10971144
10981145 if ( this . _state . entitlement === ChatEntitlement . Free || isProUser ( this . _state . entitlement ) ) {
10991146 this . _state . registered = true ;
@@ -1129,6 +1176,9 @@ export class ChatEntitlementContext extends Disposable {
11291176 this . businessContextKey . set ( state . entitlement === ChatEntitlement . Business ) ;
11301177 this . enterpriseContextKey . set ( state . entitlement === ChatEntitlement . Enterprise ) ;
11311178 this . isInternalContextKey . set ( state . isInternal ) ;
1179+ this . isGitHubInternalContextKey . set ( state . isGitHubInternal ) ;
1180+ this . isMicrosoftInternalContextKey . set ( state . isMicrosoftInternal ) ;
1181+ this . skuContextKey . set ( state . sku ) ;
11321182 this . hiddenContext . set ( ! ! state . hidden ) ;
11331183 this . laterContext . set ( ! ! state . later ) ;
11341184 this . installedContext . set ( ! ! state . installed ) ;
0 commit comments