chat - trigger commands to refresh tokens as needed (#235952)

This commit is contained in:
Benjamin Pasero
2024-12-12 15:19:37 +01:00
committed by GitHub
parent 091477e325
commit a212efb7a6
@@ -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');
}