@@ -11,6 +11,7 @@ import type { ExplainStashCommandArgs } from '../../commands/explainStash';
1111import type { ExplainWipCommandArgs } from '../../commands/explainWip' ;
1212import type { OpenPullRequestOnRemoteCommandArgs } from '../../commands/openPullRequestOnRemote' ;
1313import type { ContextKeys } from '../../constants.context' ;
14+ import { isSupportedCloudIntegrationId } from '../../constants.integrations' ;
1415import type { InspectTelemetryContext , Sources } from '../../constants.telemetry' ;
1516import type { Container } from '../../container' ;
1617import type { CommitSelectedEvent } from '../../eventBus' ;
@@ -47,7 +48,7 @@ import { confirmDraftStorage } from '../../plus/drafts/utils/-webview/drafts.uti
4748import type { Subscription } from '../../plus/gk/models/subscription' ;
4849import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService' ;
4950import { ensureAccount } from '../../plus/gk/utils/-webview/acount.utils' ;
50- import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService ' ;
51+ import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService ' ;
5152import { supportsCodeSuggest } from '../../plus/integrations/providers/models' ;
5253import { getEntityIdentifierInput } from '../../plus/integrations/providers/utils' ;
5354import {
@@ -213,7 +214,7 @@ export class CommitDetailsWebviewProvider
213214 configuration . onDidChangeAny ( this . onAnyConfigurationChanged , this ) ,
214215 onDidChangeContext ( this . onContextChanged , this ) ,
215216 this . container . subscription . onDidChange ( this . onSubscriptionChanged , this ) ,
216- container . integrations . onDidChangeConnectionState ( this . onIntegrationConnectionStateChanged , this ) ,
217+ container . integrations . onDidChangeConfiguredIntegrations ( this . onIntegrationsChanged , this ) ,
217218 ) ;
218219 }
219220
@@ -913,20 +914,27 @@ export class CommitDetailsWebviewProvider
913914 return this . _context . hasAccount ;
914915 }
915916
916- private async onIntegrationConnectionStateChanged ( e : ConnectionStateChangeEvent ) {
917- const isConnected = e . reason === 'connected' ;
918- if ( this . _context . hasIntegrationsConnected === isConnected ) return ;
917+ private async onIntegrationsChanged ( _e : ConfiguredIntegrationsChangeEvent ) {
918+ const previous = this . _context . hasIntegrationsConnected ;
919+ const current = await this . getHasIntegrationsConnected ( true ) ;
920+ if ( previous === current ) return ;
919921
920922 void this . host . notify ( DidChangeIntegrationsNotification , {
921- hasIntegrationsConnected : await this . getHasIntegrationsConnected ( true ) ,
923+ hasIntegrationsConnected : current ,
922924 } ) ;
923925 }
924926
925927 async getHasIntegrationsConnected ( force = false ) : Promise < boolean > {
926- if ( this . _context . hasIntegrationsConnected != null && ! force ) return this . _context . hasIntegrationsConnected ;
927-
928- const hasAny = ( await this . container . integrations . getConfigured ( ) ) . length > 0 ;
929- this . _context . hasIntegrationsConnected = hasAny ;
928+ if ( force || this . _context . hasIntegrationsConnected == null ) {
929+ const configured = await this . container . integrations . getConfigured ( ) ;
930+ if ( configured . length > 0 ) {
931+ this . _context . hasIntegrationsConnected = configured . some ( i =>
932+ isSupportedCloudIntegrationId ( i . integrationId ) ,
933+ ) ;
934+ } else {
935+ this . _context . hasIntegrationsConnected = false ;
936+ }
937+ }
930938
931939 return this . _context . hasIntegrationsConnected ;
932940 }
0 commit comments