@@ -42,7 +42,7 @@ import { IProgressService, ProgressLocation } from '../../../../platform/progres
42
42
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js' ;
43
43
import { Registry } from '../../../../platform/registry/common/platform.js' ;
44
44
import { ITelemetryService , TelemetryLevel } from '../../../../platform/telemetry/common/telemetry.js' ;
45
- import { IWorkspaceTrustRequestService } from '../../../../platform/workspace/common/workspaceTrust.js' ;
45
+ import { IWorkspaceTrustManagementService , IWorkspaceTrustRequestService } from '../../../../platform/workspace/common/workspaceTrust.js' ;
46
46
import { IWorkbenchContribution } from '../../../common/contributions.js' ;
47
47
import { IViewDescriptorService , ViewContainerLocation } from '../../../common/views.js' ;
48
48
import { IActivityService , ProgressBadge } from '../../../services/activity/common/activity.js' ;
@@ -191,6 +191,7 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
191
191
}
192
192
193
193
private static readonly SETUP_NEEDED_MESSAGE = new MarkdownString ( localize ( 'settingUpCopilotNeeded' , "You need to set up Copilot and be signed in to use Chat." ) ) ;
194
+ private static readonly TRUST_NEEDED_MESSAGE = new MarkdownString ( localize ( 'trustNeeded' , "You need to trust this workspace to use Chat." ) ) ;
194
195
195
196
private readonly _onUnresolvableError = this . _register ( new Emitter < void > ( ) ) ;
196
197
readonly onUnresolvableError = this . _onUnresolvableError . event ;
@@ -205,7 +206,8 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
205
206
@ILogService private readonly logService : ILogService ,
206
207
@IConfigurationService private readonly configurationService : IConfigurationService ,
207
208
@ITelemetryService private readonly telemetryService : ITelemetryService ,
208
- @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService
209
+ @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService ,
210
+ @IWorkspaceTrustManagementService private readonly workspaceTrustManagementService : IWorkspaceTrustManagementService
209
211
) {
210
212
super ( ) ;
211
213
}
@@ -439,7 +441,7 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
439
441
else {
440
442
progress ( {
441
443
kind : 'markdownContent' ,
442
- content : SetupAgent . SETUP_NEEDED_MESSAGE ,
444
+ content : this . workspaceTrustManagementService . isWorkspaceTrusted ( ) ? SetupAgent . SETUP_NEEDED_MESSAGE : SetupAgent . TRUST_NEEDED_MESSAGE
443
445
} ) ;
444
446
}
445
447
@@ -590,7 +592,7 @@ class ChatSetup {
590
592
let instance = ChatSetup . instance ;
591
593
if ( ! instance ) {
592
594
instance = ChatSetup . instance = instantiationService . invokeFunction ( accessor => {
593
- return new ChatSetup ( context , controller , instantiationService , accessor . get ( ITelemetryService ) , accessor . get ( IWorkbenchLayoutService ) , accessor . get ( IKeybindingService ) , accessor . get ( IChatEntitlementService ) as ChatEntitlementService , accessor . get ( ILogService ) , accessor . get ( IConfigurationService ) , accessor . get ( IViewsService ) , accessor . get ( IOpenerService ) ) ;
595
+ return new ChatSetup ( context , controller , instantiationService , accessor . get ( ITelemetryService ) , accessor . get ( IWorkbenchLayoutService ) , accessor . get ( IKeybindingService ) , accessor . get ( IChatEntitlementService ) as ChatEntitlementService , accessor . get ( ILogService ) , accessor . get ( IConfigurationService ) , accessor . get ( IViewsService ) , accessor . get ( IOpenerService ) , accessor . get ( IWorkspaceTrustRequestService ) ) ;
594
596
} ) ;
595
597
}
596
598
@@ -613,6 +615,7 @@ class ChatSetup {
613
615
@IConfigurationService private readonly configurationService : IConfigurationService ,
614
616
@IViewsService private readonly viewsService : IViewsService ,
615
617
@IOpenerService private readonly openerService : IOpenerService ,
618
+ @IWorkspaceTrustRequestService private readonly workspaceTrustRequestService : IWorkspaceTrustRequestService
616
619
) { }
617
620
618
621
skipDialog ( ) : void {
@@ -639,6 +642,16 @@ class ChatSetup {
639
642
const dialogSkipped = this . skipDialogOnce ;
640
643
this . skipDialogOnce = false ;
641
644
645
+ const trusted = await this . workspaceTrustRequestService . requestWorkspaceTrust ( {
646
+ message : localize ( 'copilotWorkspaceTrust' , "Copilot is currently only supported in trusted workspaces." )
647
+ } ) ;
648
+ if ( ! trusted ) {
649
+ this . context . update ( { later : true } ) ;
650
+ this . telemetryService . publicLog2 < InstallChatEvent , InstallChatClassification > ( 'commandCenter.chatInstall' , { installResult : 'failedNotTrusted' , installDuration : 0 , signUpErrorCode : undefined } ) ;
651
+
652
+ return { dialogSkipped, success : undefined /* canceled */ } ;
653
+ }
654
+
642
655
let setupStrategy : ChatSetupStrategy ;
643
656
if ( dialogSkipped || isProUser ( this . chatEntitlementService . entitlement ) || this . chatEntitlementService . entitlement === ChatEntitlement . Free ) {
644
657
setupStrategy = ChatSetupStrategy . DefaultSetup ; // existing pro/free users setup without a dialog
@@ -1186,7 +1199,6 @@ class ChatSetupController extends Disposable {
1186
1199
@IProgressService private readonly progressService : IProgressService ,
1187
1200
@IActivityService private readonly activityService : IActivityService ,
1188
1201
@ICommandService private readonly commandService : ICommandService ,
1189
- @IWorkspaceTrustRequestService private readonly workspaceTrustRequestService : IWorkspaceTrustRequestService ,
1190
1202
@IDialogService private readonly dialogService : IDialogService ,
1191
1203
@IConfigurationService private readonly configurationService : IConfigurationService ,
1192
1204
@ILifecycleService private readonly lifecycleService : ILifecycleService ,
@@ -1252,15 +1264,7 @@ class ChatSetupController extends Disposable {
1252
1264
entitlement = result . entitlement ;
1253
1265
}
1254
1266
1255
- const trusted = await this . workspaceTrustRequestService . requestWorkspaceTrust ( {
1256
- message : localize ( 'copilotWorkspaceTrust' , "Copilot is currently only supported in trusted workspaces." )
1257
- } ) ;
1258
- if ( ! trusted ) {
1259
- this . telemetryService . publicLog2 < InstallChatEvent , InstallChatClassification > ( 'commandCenter.chatInstall' , { installResult : 'failedNotTrusted' , installDuration : watch . elapsed ( ) , signUpErrorCode : undefined } ) ;
1260
- return false ;
1261
- }
1262
-
1263
- // Install
1267
+ // Await Install
1264
1268
this . setStep ( ChatSetupStep . Installing ) ;
1265
1269
success = await this . install ( session , entitlement ?? this . context . state . entitlement , providerId , watch , installation ) ;
1266
1270
} finally {
0 commit comments