Skip to content

Commit 4e32b01

Browse files
authored
chat - begin installation earlier (microsoft#252925)
1 parent 6ccdb0f commit 4e32b01

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,13 +1233,13 @@ class ChatSetupController extends Disposable {
12331233
let session: AuthenticationSession | undefined;
12341234
let entitlement: ChatEntitlement | undefined;
12351235

1236+
const installation = this.doInstall();
1237+
12361238
// Entitlement Unknown or `forceSignIn`: we need to sign-in user
12371239
if (this.context.state.entitlement === ChatEntitlement.Unknown || options.forceSignIn) {
12381240
this.setStep(ChatSetupStep.SigningIn);
12391241
const result = await this.signIn({ useAlternateProvider: options.useAlternateProvider });
12401242
if (!result.session) {
1241-
this.doInstall(); // still install the extension in the background to remind the user to sign-in eventually
1242-
12431243
this.telemetryService.publicLog2<InstallChatEvent, InstallChatClassification>('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', installDuration: watch.elapsed(), signUpErrorCode: undefined });
12441244
return undefined; // treat as cancelled because signing in already triggers an error dialog
12451245
}
@@ -1258,7 +1258,7 @@ class ChatSetupController extends Disposable {
12581258

12591259
// Install
12601260
this.setStep(ChatSetupStep.Installing);
1261-
success = await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch);
1261+
success = await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch, installation);
12621262
} finally {
12631263
this.setStep(ChatSetupStep.Initial);
12641264
this.context.resume();
@@ -1292,7 +1292,7 @@ class ChatSetupController extends Disposable {
12921292
return { session, entitlement: entitlements?.entitlement };
12931293
}
12941294

1295-
private async install(session: AuthenticationSession | undefined, entitlement: ChatEntitlement, providerId: string, watch: StopWatch): Promise<ChatSetupResultValue> {
1295+
private async install(session: AuthenticationSession | undefined, entitlement: ChatEntitlement, providerId: string, watch: StopWatch, installation: Promise<void>): Promise<ChatSetupResultValue> {
12961296
const wasRunning = this.context.state.installed && !this.context.state.disabled;
12971297
let signUpResult: boolean | { errorCode: number } | undefined = undefined;
12981298

@@ -1323,7 +1323,7 @@ class ChatSetupController extends Disposable {
13231323
}
13241324
}
13251325

1326-
await this.doInstallWithRetry();
1326+
await this.doInstallWithRetry(installation);
13271327
} catch (error) {
13281328
this.logService.error(`[chat setup] install: error ${error}`);
13291329
this.telemetryService.publicLog2<InstallChatEvent, InstallChatClassification>('commandCenter.chatInstall', { installResult: isCancellationError(error) ? 'cancelled' : 'failedInstall', installDuration: watch.elapsed(), signUpErrorCode: undefined });
@@ -1341,10 +1341,10 @@ class ChatSetupController extends Disposable {
13411341
return true;
13421342
}
13431343

1344-
private async doInstallWithRetry(): Promise<void> {
1344+
private async doInstallWithRetry(installation: Promise<void>): Promise<void> {
13451345
let error: Error | undefined;
13461346
try {
1347-
await this.doInstall();
1347+
await installation;
13481348
} catch (e) {
13491349
this.logService.error(`[chat setup] install: error ${error}`);
13501350
error = e;
@@ -1360,7 +1360,7 @@ class ChatSetupController extends Disposable {
13601360
});
13611361

13621362
if (confirmed) {
1363-
return this.doInstallWithRetry();
1363+
return this.doInstallWithRetry(this.doInstall());
13641364
}
13651365
}
13661366

0 commit comments

Comments
 (0)