@@ -60,7 +60,7 @@ import type { Subscription } from '../../plus/gk/models/subscription';
6060import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService' ;
6161import { isMcpBannerEnabled , mcpExtensionRegistrationAllowed } from '../../plus/gk/utils/-webview/mcp.utils' ;
6262import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils' ;
63- import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils' ;
63+ import { getCommunitySubscription , isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils' ;
6464import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService' ;
6565import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService' ;
6666import { providersMetadata } from '../../plus/integrations/providers/models' ;
@@ -84,6 +84,8 @@ import { debug, log } from '../../system/decorators/log';
8484import type { Deferrable } from '../../system/function/debounce' ;
8585import { debounce } from '../../system/function/debounce' ;
8686import { filterMap } from '../../system/iterable' ;
87+ import { getLoggableName , Logger } from '../../system/logger' ;
88+ import { startLogScope } from '../../system/logger.scope' ;
8789import { getSettledValue } from '../../system/promise' ;
8890import { SubscriptionManager } from '../../system/subscriptionManager' ;
8991import type { UriTypes } from '../../uris/deepLinks/deepLink' ;
@@ -113,6 +115,7 @@ import type {
113115 OverviewRepository ,
114116 OverviewStaleThreshold ,
115117 State ,
118+ SubscriptionState ,
116119} from './protocol' ;
117120import {
118121 ChangeOverviewRepositoryCommand ,
@@ -884,15 +887,32 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
884887 }
885888
886889 private async getState ( subscription ?: Subscription ) : Promise < State > {
887- const [ subResult , integrationResult , aiModelResult , aiAllAccessBannerCollapsed ] = await Promise . allSettled ( [
888- this . getSubscriptionState ( subscription ) ,
889- this . getIntegrationStates ( true ) ,
890- this . container . ai . getModel ( { silent : true } , { source : 'home' } ) ,
891- this . getAiAllAccessBannerCollapsed ( ) ,
892- ] ) ;
890+ const [ subscriptionResult , integrationResult , aiModelResult , aiAllAccessBannerCollapsed ] =
891+ await Promise . allSettled ( [
892+ this . getSubscriptionState ( subscription ) ,
893+ this . getIntegrationStates ( true ) ,
894+ this . container . ai . getModel ( { silent : true } , { source : 'home' } ) ,
895+ this . getAiAllAccessBannerCollapsed ( ) ,
896+ ] ) ;
893897
894- if ( subResult . status === 'rejected' ) {
895- throw subResult . reason ;
898+ // Handle subscription rejection gracefully by falling back to community subscription
899+ let subscriptionState : SubscriptionState ;
900+ if ( subscriptionResult . status === 'fulfilled' ) {
901+ subscriptionState = subscriptionResult . value ;
902+ } else {
903+ using scope = startLogScope ( `${ getLoggableName ( this ) } .getState(${ Logger . toLoggable ( subscription ) } )` , false ) ;
904+ Logger . error ( subscriptionResult . reason , scope , 'Failed to get subscription state' ) ;
905+
906+ this . container . telemetry . sendEvent ( 'home/failed' , {
907+ reason : 'subscription' ,
908+ error : String ( subscriptionResult . reason ) ,
909+ } ) ;
910+
911+ subscriptionState = {
912+ subscription : getCommunitySubscription ( ) ,
913+ avatar : `${ this . host . getWebRoot ( ) ?? '' } /media/gitlens-logo.webp` ,
914+ organizationsCount : 0 ,
915+ } ;
896916 }
897917
898918 const integrations = getSettledValue ( integrationResult ) ?? [ ] ;
@@ -904,9 +924,9 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
904924 discovering : this . _discovering != null ,
905925 repositories : this . getRepositoriesState ( ) ,
906926 webroot : this . host . getWebRoot ( ) ,
907- subscription : subResult . value . subscription ,
908- avatar : subResult . value . avatar ,
909- organizationsCount : subResult . value . organizationsCount ,
927+ subscription : subscriptionState . subscription ,
928+ avatar : subscriptionState . avatar ,
929+ organizationsCount : subscriptionState . organizationsCount ,
910930 orgSettings : this . getOrgSettings ( ) ,
911931 aiEnabled : this . getAiEnabled ( ) ,
912932 experimentalComposerEnabled : this . getExperimentalComposerEnabled ( ) ,
@@ -1281,7 +1301,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
12811301 return isSubscriptionTrialOrPaidFromState ( subscription . state ) ;
12821302 }
12831303
1284- private async getSubscriptionState ( subscription ?: Subscription ) {
1304+ private async getSubscriptionState ( subscription ?: Subscription ) : Promise < SubscriptionState > {
12851305 subscription = await this . getSubscription ( subscription ) ;
12861306 this . _etagSubscription = this . container . subscription . etag ;
12871307
0 commit comments