@@ -936,20 +936,32 @@ export class AIProviderService implements Disposable {
936936 case AIErrorReason . NoEntitlement : {
937937 const sub = await this . container . subscription . getSubscription ( ) ;
938938
939- const plan = isSubscriptionPaid ( sub )
940- ? compareSubscriptionPlans ( sub . plan . actual . id , SubscriptionPlanId . Advanced ) <= 0
941- ? SubscriptionPlanId . Business
942- : SubscriptionPlanId . Advanced
943- : SubscriptionPlanId . Pro ;
944-
945- const upgrade = { title : `Upgrade to ${ getSubscriptionPlanTier ( plan ) } ` } ;
946- const result = await window . showErrorMessage (
947- 'You do not have the required entitlement to use this AI feature. Please upgrade your plan and try again.' ,
948- upgrade ,
949- ) ;
950-
951- if ( result === upgrade ) {
952- void this . container . subscription . upgrade ( plan , source ) ;
939+ if ( isSubscriptionPaid ( sub ) ) {
940+ const plan =
941+ compareSubscriptionPlans ( sub . plan . actual . id , SubscriptionPlanId . Advanced ) <= 0
942+ ? SubscriptionPlanId . Business
943+ : SubscriptionPlanId . Advanced ;
944+
945+ const upgrade = { title : `Upgrade to ${ getSubscriptionPlanTier ( plan ) } ` } ;
946+ const result = await window . showErrorMessage (
947+ "This AI feature isn't included in your current plan. Please upgrade and try again." ,
948+ upgrade ,
949+ ) ;
950+
951+ if ( result === upgrade ) {
952+ void this . container . subscription . manageSubscription ( source ) ;
953+ }
954+ } else {
955+ // Users without accounts would never get here since they would have been blocked by `ensureFeatureAccess`
956+ const upgrade = { title : 'Upgrade to Pro' } ;
957+ const result = await window . showErrorMessage (
958+ 'Please upgrade to GitLens Pro to access this AI feature and try again.' ,
959+ upgrade ,
960+ ) ;
961+
962+ if ( result === upgrade ) {
963+ void this . container . subscription . upgrade ( SubscriptionPlanId . Pro , source ) ;
964+ }
953965 }
954966
955967 return undefined ;
0 commit comments