From fabdb6a30b49f79a7aba0f2ad9df9b399473380f Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 19 Dec 2024 11:13:25 +0100 Subject: [PATCH] Copilot not working in Remote windows (fix #236537) (#236552) * Copilot not working in Remote windows (fix #236537) * 2nd fix for #236537: install extension everywhere even when it is installed locally if `installEverywhere` is set --- src/vs/workbench/contrib/chat/browser/chatSetup.ts | 9 ++++----- .../extensions/browser/extensionsWorkbenchService.ts | 8 +++++--- .../common/extensionManagementService.ts | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatSetup.ts b/src/vs/workbench/contrib/chat/browser/chatSetup.ts index fb8166d10f085..f8df3fb800007 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSetup.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSetup.ts @@ -26,7 +26,6 @@ import { IConfigurationService } from '../../../../platform/configuration/common import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js'; import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js'; import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js'; -import { IExtensionManagementService } from '../../../../platform/extensionManagement/common/extensionManagement.js'; import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js'; import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js'; import { ILogService } from '../../../../platform/log/common/log.js'; @@ -1042,9 +1041,9 @@ class ChatSetupContext extends Disposable { @IStorageService private readonly storageService: IStorageService, @IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService, @IExtensionService private readonly extensionService: IExtensionService, - @IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService, @IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService, - @ILogService private readonly logService: ILogService + @ILogService private readonly logService: ILogService, + @IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService, ) { super(); @@ -1069,9 +1068,9 @@ class ChatSetupContext extends Disposable { } })); - const extensions = await this.extensionManagementService.getInstalled(); + const extensions = await this.extensionsWorkbenchService.queryLocal(); const defaultChatExtension = extensions.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId)); - this.update({ installed: !!defaultChatExtension && this.extensionEnablementService.isEnabled(defaultChatExtension) }); + this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) }); } update(context: { installed: boolean }): Promise; diff --git a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts index 1a862498873ed..56161211c9b07 100644 --- a/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ b/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts @@ -2368,8 +2368,9 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension if (extension?.isMalicious) { throw new Error(nls.localize('malicious', "This extension is reported to be problematic.")); } + // TODO: @sandy081 - Install the extension only on servers where it is not installed // Do not install if requested to enable and extension is already installed - if (!(installOptions.enable && extension?.local)) { + if (installOptions.installEverywhere || !(installOptions.enable && extension?.local)) { if (!installable) { if (!gallery) { const id = isString(arg) ? arg : (arg).identifier.id; @@ -2741,10 +2742,11 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension return this.extensionManagementService.installVSIX(vsix, manifest, installOptions); } - private installFromGallery(extension: IExtension, gallery: IGalleryExtension, installOptions?: InstallOptions): Promise { + private installFromGallery(extension: IExtension, gallery: IGalleryExtension, installOptions?: InstallExtensionOptions): Promise { installOptions = installOptions ?? {}; installOptions.pinned = extension.local?.pinned || !this.shouldAutoUpdateExtension(extension); - if (extension.local) { + // TODO: @sandy081 - Install the extension only on servers where it is not installed + if (!installOptions.installEverywhere && extension.local) { installOptions.productVersion = this.getProductVersion(); installOptions.operation = InstallOperation.Update; return this.extensionManagementService.updateFromGallery(gallery, extension.local, installOptions); diff --git a/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts b/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts index 6312b05fe32ab..0e7aa20db873b 100644 --- a/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts +++ b/src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts @@ -475,7 +475,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench installOptions = { ...(installOptions || {}), isMachineScoped }; } - if (installOptions.installEverywhere || (!installOptions.isMachineScoped && this.isExtensionsSyncEnabled())) { + if (!installOptions.isMachineScoped && this.isExtensionsSyncEnabled()) { if (this.extensionManagementServerService.localExtensionManagementServer && !servers.includes(this.extensionManagementServerService.localExtensionManagementServer) && await this.extensionManagementServerService.localExtensionManagementServer.extensionManagementService.canInstall(gallery) === true) { @@ -606,7 +606,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench } } - private async validateAndGetExtensionManagementServersToInstall(gallery: IGalleryExtension, installOptions?: InstallOptions): Promise { + private async validateAndGetExtensionManagementServersToInstall(gallery: IGalleryExtension, installOptions?: IWorkbenchInstallOptions): Promise { const manifest = await this.extensionGalleryService.getManifest(gallery, CancellationToken.None); if (!manifest) { @@ -615,8 +615,8 @@ export class ExtensionManagementService extends Disposable implements IWorkbench const servers: IExtensionManagementServer[] = []; - // Install Language pack on local and remote servers - if (isLanguagePackExtension(manifest)) { + // Install everywhere if asked to install everywhere or if the extension is a language pack + if (installOptions?.installEverywhere || isLanguagePackExtension(manifest)) { servers.push(...this.servers.filter(server => server !== this.extensionManagementServerService.webExtensionManagementServer)); } else { const server = this.getExtensionManagementServerToInstall(manifest);