@@ -24,6 +24,7 @@ import type { GitStatus } from '../../git/models/status';
2424import type { GitWorktree } from '../../git/models/worktree' ;
2525import { getOpenedWorktreesByBranch , groupWorktreesByBranch } from '../../git/models/worktree' ;
2626import type { Subscription } from '../../plus/gk/account/subscription' ;
27+ import { isSubscriptionStatePaidOrTrial } from '../../plus/gk/account/subscription' ;
2728import type { SubscriptionChangeEvent } from '../../plus/gk/account/subscriptionService' ;
2829import { getLaunchpadSummary } from '../../plus/launchpad/utils' ;
2930import type { ShowInCommitGraphCommandArgs } from '../../plus/webviews/graph/protocol' ;
@@ -446,12 +447,16 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
446447 }
447448 }
448449
449- private onSubscriptionChanged ( e : SubscriptionChangeEvent ) {
450- void this . notifyDidChangeSubscription ( e . current ) ;
450+ private async onSubscriptionChanged ( e : SubscriptionChangeEvent ) {
451+ await this . notifyDidChangeSubscription ( e . current ) ;
452+
453+ if ( isSubscriptionStatePaidOrTrial ( e . current . state ) !== isSubscriptionStatePaidOrTrial ( e . previous . state ) ) {
454+ this . onOverviewRepoChanged ( 'repo' ) ;
455+ }
451456 }
452457
453458 private async getState ( subscription ?: Subscription ) : Promise < State > {
454- const subResult = await this . getSubscription ( subscription ) ;
459+ const subResult = await this . getSubscriptionState ( subscription ) ;
455460
456461 return {
457462 ...this . host . baseWebviewState ,
@@ -504,7 +509,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
504509 branchesAndWorktrees ,
505510 this . container ,
506511 this . _overviewBranchFilter ,
507- forceWip ? { forceActive : true } : undefined ,
512+ {
513+ forceActive : forceWip ? true : undefined ,
514+ isPro : await this . isSubscriptionPro ( ) ,
515+ } ,
508516 ) ;
509517 this . _invalidateOverview = undefined ;
510518 if ( overviewBranches == null ) return undefined ;
@@ -683,8 +691,28 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
683691 return this . _hostedIntegrationConnected ;
684692 }
685693
694+ private _subscription : Subscription | undefined ;
686695 private async getSubscription ( subscription ?: Subscription ) {
687- subscription ??= await this . container . subscription . getSubscription ( true ) ;
696+ if ( subscription != null ) {
697+ this . _subscription = subscription ;
698+ } else if ( this . _subscription != null ) {
699+ subscription = this . _subscription ;
700+ } else {
701+ this . _subscription = subscription = await this . container . subscription . getSubscription ( true ) ;
702+ }
703+
704+ return this . _subscription ;
705+ }
706+
707+ private async isSubscriptionPro ( ) {
708+ const subscription = await this . getSubscription ( ) ;
709+ if ( subscription == null ) return false ;
710+
711+ return isSubscriptionStatePaidOrTrial ( subscription . state ) ;
712+ }
713+
714+ private async getSubscriptionState ( subscription ?: Subscription ) {
715+ subscription = await this . getSubscription ( subscription ) ;
688716
689717 let avatar ;
690718 if ( subscription . account ?. email ) {
@@ -755,7 +783,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
755783 }
756784
757785 private async notifyDidChangeSubscription ( subscription ?: Subscription ) {
758- const subResult = await this . getSubscription ( subscription ) ;
786+ const subResult = await this . getSubscriptionState ( subscription ) ;
759787
760788 void this . host . notify ( DidChangeSubscription , {
761789 subscription : subResult . subscription ,
@@ -902,7 +930,7 @@ async function getOverviewBranches(
902930 branchesData : RepositoryBranchData ,
903931 container : Container ,
904932 filters : OverviewFilters ,
905- options ?: { forceActive ?: boolean } ,
933+ options ?: { forceActive ?: boolean ; isPro ?: boolean } ,
906934) : Promise < GetOverviewBranches | undefined > {
907935 const { branches, worktreesByBranch } = branchesData ;
908936 if ( branches . length === 0 ) return undefined ;
@@ -928,7 +956,14 @@ async function getOverviewBranches(
928956 const timestamp = branch . date ?. getTime ( ) ;
929957 if ( branch . current || wt ?. opened ) {
930958 const forceOptions = options ?. forceActive ? { force : true } : undefined ;
931- prPromises . set ( branch . id , branch . getAssociatedPullRequest ( { avatarSize : 16 } ) ) ;
959+ if ( options ?. isPro !== false ) {
960+ prPromises . set ( branch . id , branch . getAssociatedPullRequest ( { avatarSize : 16 } ) ) ;
961+ contributorPromises . set (
962+ branch . id ,
963+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
964+ ) ;
965+ }
966+
932967 if ( wt != null ) {
933968 statusPromises . set ( branch . id , wt . getStatus ( forceOptions ) ) ;
934969 } else {
@@ -937,7 +972,6 @@ async function getOverviewBranches(
937972 }
938973 statusPromises . set ( branch . id , repoStatusPromise ) ;
939974 }
940- contributorPromises . set ( branch . id , container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ) ;
941975
942976 overviewBranches . active . push ( {
943977 id : branch . id ,
@@ -954,11 +988,17 @@ async function getOverviewBranches(
954988 }
955989
956990 if ( timestamp != null && timestamp > recentThreshold ) {
957- prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
991+ if ( options ?. isPro !== false ) {
992+ prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
993+ contributorPromises . set (
994+ branch . id ,
995+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
996+ ) ;
997+ }
998+
958999 if ( wt != null ) {
9591000 statusPromises . set ( branch . id , wt . getStatus ( ) ) ;
9601001 }
961- contributorPromises . set ( branch . id , container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ) ;
9621002
9631003 overviewBranches . recent . push ( {
9641004 id : branch . id ,
@@ -998,16 +1038,20 @@ async function getOverviewBranches(
9981038 ? { name : wt . name , uri : wt . uri . toString ( ) }
9991039 : undefined ;
10001040
1001- if ( ! branch . upstream ?. missing ) {
1002- prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
1041+ if ( options ?. isPro !== false ) {
1042+ if ( ! branch . upstream ?. missing ) {
1043+ prPromises . set ( branch . id , branch . getAssociatedPullRequest ( ) ) ;
1044+ }
1045+
1046+ contributorPromises . set (
1047+ branch . id ,
1048+ container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
1049+ ) ;
10031050 }
1051+
10041052 if ( wt != null ) {
10051053 statusPromises . set ( branch . id , wt . getStatus ( ) ) ;
10061054 }
1007- contributorPromises . set (
1008- branch . id ,
1009- container . git . getBranchContributorOverview ( branch . repoPath , branch . ref ) ,
1010- ) ;
10111055
10121056 overviewBranches . stale . push ( {
10131057 id : branch . id ,
0 commit comments