Skip to content

Commit 74683d4

Browse files
authored
Copilot setup failed message: Could have more information regarding why it failed (fix microsoft#253242) (microsoft#253618)
1 parent 7b36e11 commit 74683d4

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/vs/workbench/contrib/chat/browser/chatSetup.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { IProgressService, ProgressLocation } from '../../../../platform/progres
4242
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
4343
import { Registry } from '../../../../platform/registry/common/platform.js';
4444
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';
4646
import { IWorkbenchContribution } from '../../../common/contributions.js';
4747
import { IViewDescriptorService, ViewContainerLocation } from '../../../common/views.js';
4848
import { IActivityService, ProgressBadge } from '../../../services/activity/common/activity.js';
@@ -191,6 +191,7 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
191191
}
192192

193193
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."));
194195

195196
private readonly _onUnresolvableError = this._register(new Emitter<void>());
196197
readonly onUnresolvableError = this._onUnresolvableError.event;
@@ -205,7 +206,8 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
205206
@ILogService private readonly logService: ILogService,
206207
@IConfigurationService private readonly configurationService: IConfigurationService,
207208
@ITelemetryService private readonly telemetryService: ITelemetryService,
208-
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
209+
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
210+
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService
209211
) {
210212
super();
211213
}
@@ -439,7 +441,7 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
439441
else {
440442
progress({
441443
kind: 'markdownContent',
442-
content: SetupAgent.SETUP_NEEDED_MESSAGE,
444+
content: this.workspaceTrustManagementService.isWorkspaceTrusted() ? SetupAgent.SETUP_NEEDED_MESSAGE : SetupAgent.TRUST_NEEDED_MESSAGE
443445
});
444446
}
445447

@@ -590,7 +592,7 @@ class ChatSetup {
590592
let instance = ChatSetup.instance;
591593
if (!instance) {
592594
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));
594596
});
595597
}
596598

@@ -613,6 +615,7 @@ class ChatSetup {
613615
@IConfigurationService private readonly configurationService: IConfigurationService,
614616
@IViewsService private readonly viewsService: IViewsService,
615617
@IOpenerService private readonly openerService: IOpenerService,
618+
@IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService
616619
) { }
617620

618621
skipDialog(): void {
@@ -639,6 +642,16 @@ class ChatSetup {
639642
const dialogSkipped = this.skipDialogOnce;
640643
this.skipDialogOnce = false;
641644

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+
642655
let setupStrategy: ChatSetupStrategy;
643656
if (dialogSkipped || isProUser(this.chatEntitlementService.entitlement) || this.chatEntitlementService.entitlement === ChatEntitlement.Free) {
644657
setupStrategy = ChatSetupStrategy.DefaultSetup; // existing pro/free users setup without a dialog
@@ -1186,7 +1199,6 @@ class ChatSetupController extends Disposable {
11861199
@IProgressService private readonly progressService: IProgressService,
11871200
@IActivityService private readonly activityService: IActivityService,
11881201
@ICommandService private readonly commandService: ICommandService,
1189-
@IWorkspaceTrustRequestService private readonly workspaceTrustRequestService: IWorkspaceTrustRequestService,
11901202
@IDialogService private readonly dialogService: IDialogService,
11911203
@IConfigurationService private readonly configurationService: IConfigurationService,
11921204
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@@ -1252,15 +1264,7 @@ class ChatSetupController extends Disposable {
12521264
entitlement = result.entitlement;
12531265
}
12541266

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
12641268
this.setStep(ChatSetupStep.Installing);
12651269
success = await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch, installation);
12661270
} finally {

0 commit comments

Comments
 (0)