From a212efb7a6f3e6145c7e9a010c1fc2b13ec0099c Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 12 Dec 2024 15:19:37 +0100 Subject: [PATCH] chat - trigger commands to refresh tokens as needed (#235952) --- src/vs/workbench/contrib/chat/browser/chatSetup.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatSetup.ts b/src/vs/workbench/contrib/chat/browser/chatSetup.ts index 37544c7ec93..3af2ce5f98c 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts @@ -266,7 +266,7 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr const entitlement = await that.requests.forceResolveEntitlement(undefined); if (entitlement === ChatEntitlement.Pro) { - commandService.executeCommand('github.copilot.refreshToken'); // ugly, but we need to signal to the extension that entitlements changed + refreshTokens(commandService); } } } @@ -787,7 +787,7 @@ class ChatSetupController extends Disposable { installResult = isCancellationError(error) ? 'cancelled' : 'failedInstall'; } finally { if (wasInstalled && didSignUp) { - this.commandService.executeCommand('github.copilot.refreshToken'); // ugly, but we need to signal to the extension that sign-up happened + refreshTokens(this.commandService); } if (installResult === 'installed') { @@ -1088,3 +1088,9 @@ function showCopilotView(viewsService: IViewsService, layoutService: IWorkbenchL return showChatView(viewsService); } } + +function refreshTokens(commandService: ICommandService): void { + // ugly, but we need to signal to the extension that entitlements changed + commandService.executeCommand('github.copilot.signIn'); + commandService.executeCommand('github.copilot.refreshToken'); +}