@@ -616,7 +616,7 @@ class ChatSetup {
616
616
this . skipDialogOnce = true ;
617
617
}
618
618
619
- async run ( options ?: { disableChatViewReveal ?: boolean } ) : Promise < IChatSetupResult > {
619
+ async run ( options ?: { disableChatViewReveal ?: boolean ; forceSignInDialog ?: boolean } ) : Promise < IChatSetupResult > {
620
620
if ( this . pendingRun ) {
621
621
return this . pendingRun ;
622
622
}
@@ -630,7 +630,7 @@ class ChatSetup {
630
630
}
631
631
}
632
632
633
- private async doRun ( options ?: { disableChatViewReveal ?: boolean } ) : Promise < IChatSetupResult > {
633
+ private async doRun ( options ?: { disableChatViewReveal ?: boolean ; forceSignInDialog ?: boolean } ) : Promise < IChatSetupResult > {
634
634
this . context . update ( { later : false } ) ;
635
635
636
636
const dialogSkipped = this . skipDialogOnce ;
@@ -647,10 +647,10 @@ class ChatSetup {
647
647
}
648
648
649
649
let setupStrategy : ChatSetupStrategy ;
650
- if ( dialogSkipped || isProUser ( this . chatEntitlementService . entitlement ) || this . chatEntitlementService . entitlement === ChatEntitlement . Free ) {
650
+ if ( ! options ?. forceSignInDialog && ( dialogSkipped || isProUser ( this . chatEntitlementService . entitlement ) || this . chatEntitlementService . entitlement === ChatEntitlement . Free ) ) {
651
651
setupStrategy = ChatSetupStrategy . DefaultSetup ; // existing pro/free users setup without a dialog
652
652
} else {
653
- setupStrategy = await this . showDialog ( ) ;
653
+ setupStrategy = await this . showDialog ( options ) ;
654
654
}
655
655
656
656
if ( setupStrategy === ChatSetupStrategy . DefaultSetup && ChatEntitlementRequests . providerId ( this . configurationService ) === defaultChat . provider . enterprise . id ) {
@@ -694,15 +694,15 @@ class ChatSetup {
694
694
return { success, dialogSkipped } ;
695
695
}
696
696
697
- private async showDialog ( ) : Promise < ChatSetupStrategy > {
697
+ private async showDialog ( options ?: { forceSignInDialog ?: boolean } ) : Promise < ChatSetupStrategy > {
698
698
const disposables = new DisposableStore ( ) ;
699
699
700
700
const dialogVariant = this . configurationService . getValue < 'default' | 'apple' | unknown > ( 'chat.setup.signInDialogVariant' ) ;
701
- const buttons = this . getButtons ( dialogVariant ) ;
701
+ const buttons = this . getButtons ( dialogVariant , options ) ;
702
702
703
703
const dialog = disposables . add ( new Dialog (
704
704
this . layoutService . activeContainer ,
705
- this . getDialogTitle ( ) ,
705
+ this . getDialogTitle ( options ) ,
706
706
buttons . map ( button => button [ 0 ] ) ,
707
707
createWorkbenchDialogOptions ( {
708
708
type : 'none' ,
@@ -723,12 +723,12 @@ class ChatSetup {
723
723
return buttons [ button ] ?. [ 1 ] ?? ChatSetupStrategy . Canceled ;
724
724
}
725
725
726
- private getButtons ( variant : 'default' | 'apple' | unknown ) : Array < [ string , ChatSetupStrategy , { styleButton ?: ( button : IButton ) => void } | undefined ] > {
726
+ private getButtons ( variant : 'default' | 'apple' | unknown , options ?: { forceSignInDialog ?: boolean } ) : Array < [ string , ChatSetupStrategy , { styleButton ?: ( button : IButton ) => void } | undefined ] > {
727
727
type ContinueWithButton = [ string , ChatSetupStrategy , { styleButton ?: ( button : IButton ) => void } | undefined ] ;
728
728
const styleButton = ( ...classes : string [ ] ) => ( { styleButton : ( button : IButton ) => button . element . classList . add ( ...classes ) } ) ;
729
729
730
730
let buttons : Array < ContinueWithButton > ;
731
- if ( this . context . state . entitlement === ChatEntitlement . Unknown ) {
731
+ if ( this . context . state . entitlement === ChatEntitlement . Unknown || options ?. forceSignInDialog ) {
732
732
const defaultProviderButton : ContinueWithButton = [ localize ( 'continueWith' , "Continue with {0}" , defaultChat . provider . default . name ) , ChatSetupStrategy . SetupWithoutEnterpriseProvider , styleButton ( 'continue-button' , 'default' ) ] ;
733
733
const defaultProviderLink : ContinueWithButton = [ defaultProviderButton [ 0 ] , defaultProviderButton [ 1 ] , styleButton ( 'link-button' ) ] ;
734
734
@@ -762,8 +762,8 @@ class ChatSetup {
762
762
return buttons ;
763
763
}
764
764
765
- private getDialogTitle ( ) : string {
766
- if ( this . context . state . entitlement === ChatEntitlement . Unknown ) {
765
+ private getDialogTitle ( options ?: { forceSignInDialog ?: boolean } ) : string {
766
+ if ( this . context . state . entitlement === ChatEntitlement . Unknown || options ?. forceSignInDialog ) {
767
767
return localize ( 'signIn' , "Sign in to use Copilot" ) ;
768
768
}
769
769
@@ -882,7 +882,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
882
882
} ) ;
883
883
}
884
884
885
- override async run ( accessor : ServicesAccessor , mode : ChatModeKind ) : Promise < boolean > {
885
+ override async run ( accessor : ServicesAccessor , mode ? : ChatModeKind , options ?: { forceSignInDialog ?: boolean } ) : Promise < boolean > {
886
886
const viewsService = accessor . get ( IViewsService ) ;
887
887
const layoutService = accessor . get ( IWorkbenchLayoutService ) ;
888
888
const instantiationService = accessor . get ( IInstantiationService ) ;
@@ -898,7 +898,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
898
898
}
899
899
900
900
const setup = ChatSetup . getInstance ( instantiationService , context , controller ) ;
901
- const { success } = await setup . run ( ) ;
901
+ const { success } = await setup . run ( options ) ;
902
902
if ( success === false && ! lifecycleService . willShutdown ) {
903
903
const { confirmed } = await dialogService . confirm ( {
904
904
type : Severity . Error ,
@@ -907,14 +907,33 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
907
907
} ) ;
908
908
909
909
if ( confirmed ) {
910
- return Boolean ( await commandService . executeCommand ( CHAT_SETUP_ACTION_ID , mode ) ) ;
910
+ return Boolean ( await commandService . executeCommand ( CHAT_SETUP_ACTION_ID , mode , options ) ) ;
911
911
}
912
912
}
913
913
914
914
return Boolean ( success ) ;
915
915
}
916
916
}
917
917
918
+ class ChatSetupTriggerForceSignInDialogAction extends Action2 {
919
+
920
+ constructor ( ) {
921
+ super ( {
922
+ id : 'workbench.action.chat.triggerSetupForceSignIn' ,
923
+ title : localize2 ( 'forceSignIn' , "Sign in to use Copilot" )
924
+ } ) ;
925
+ }
926
+
927
+ override async run ( accessor : ServicesAccessor ) : Promise < void > {
928
+ const commandService = accessor . get ( ICommandService ) ;
929
+ const telemetryService = accessor . get ( ITelemetryService ) ;
930
+
931
+ telemetryService . publicLog2 < WorkbenchActionExecutedEvent , WorkbenchActionExecutedClassification > ( 'workbenchActionExecuted' , { id : CHAT_SETUP_ACTION_ID , from : 'api' } ) ;
932
+
933
+ return commandService . executeCommand ( CHAT_SETUP_ACTION_ID , undefined , { forceSignInDialog : true } ) ;
934
+ }
935
+ }
936
+
918
937
class ChatSetupTriggerWithoutDialogAction extends Action2 {
919
938
920
939
constructor ( ) {
@@ -1105,6 +1124,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
1105
1124
}
1106
1125
1107
1126
registerAction2 ( ChatSetupTriggerAction ) ;
1127
+ registerAction2 ( ChatSetupTriggerForceSignInDialogAction ) ;
1108
1128
registerAction2 ( ChatSetupFromAccountsAction ) ;
1109
1129
registerAction2 ( ChatSetupTriggerWithoutDialogAction ) ;
1110
1130
registerAction2 ( ChatSetupHideAction ) ;
0 commit comments