Skip to content

Commit fabdb6a

Browse files
authored
Copilot not working in Remote windows (fix microsoft#236537) (microsoft#236552)
* Copilot not working in Remote windows (fix microsoft#236537) * 2nd fix for microsoft#236537: install extension everywhere even when it is installed locally if `installEverywhere` is set
1 parent 820447a commit fabdb6a

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { IConfigurationService } from '../../../../platform/configuration/common
2626
import { ContextKeyExpr, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
2727
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js';
2828
import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
29-
import { IExtensionManagementService } from '../../../../platform/extensionManagement/common/extensionManagement.js';
3029
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
3130
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
3231
import { ILogService } from '../../../../platform/log/common/log.js';
@@ -1042,9 +1041,9 @@ class ChatSetupContext extends Disposable {
10421041
@IStorageService private readonly storageService: IStorageService,
10431042
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
10441043
@IExtensionService private readonly extensionService: IExtensionService,
1045-
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
10461044
@IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
1047-
@ILogService private readonly logService: ILogService
1045+
@ILogService private readonly logService: ILogService,
1046+
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
10481047
) {
10491048
super();
10501049

@@ -1069,9 +1068,9 @@ class ChatSetupContext extends Disposable {
10691068
}
10701069
}));
10711070

1072-
const extensions = await this.extensionManagementService.getInstalled();
1071+
const extensions = await this.extensionsWorkbenchService.queryLocal();
10731072
const defaultChatExtension = extensions.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId));
1074-
this.update({ installed: !!defaultChatExtension && this.extensionEnablementService.isEnabled(defaultChatExtension) });
1073+
this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) });
10751074
}
10761075

10771076
update(context: { installed: boolean }): Promise<void>;

src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,8 +2368,9 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
23682368
if (extension?.isMalicious) {
23692369
throw new Error(nls.localize('malicious', "This extension is reported to be problematic."));
23702370
}
2371+
// TODO: @sandy081 - Install the extension only on servers where it is not installed
23712372
// Do not install if requested to enable and extension is already installed
2372-
if (!(installOptions.enable && extension?.local)) {
2373+
if (installOptions.installEverywhere || !(installOptions.enable && extension?.local)) {
23732374
if (!installable) {
23742375
if (!gallery) {
23752376
const id = isString(arg) ? arg : (<IExtension>arg).identifier.id;
@@ -2741,10 +2742,11 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
27412742
return this.extensionManagementService.installVSIX(vsix, manifest, installOptions);
27422743
}
27432744

2744-
private installFromGallery(extension: IExtension, gallery: IGalleryExtension, installOptions?: InstallOptions): Promise<ILocalExtension> {
2745+
private installFromGallery(extension: IExtension, gallery: IGalleryExtension, installOptions?: InstallExtensionOptions): Promise<ILocalExtension> {
27452746
installOptions = installOptions ?? {};
27462747
installOptions.pinned = extension.local?.pinned || !this.shouldAutoUpdateExtension(extension);
2747-
if (extension.local) {
2748+
// TODO: @sandy081 - Install the extension only on servers where it is not installed
2749+
if (!installOptions.installEverywhere && extension.local) {
27482750
installOptions.productVersion = this.getProductVersion();
27492751
installOptions.operation = InstallOperation.Update;
27502752
return this.extensionManagementService.updateFromGallery(gallery, extension.local, installOptions);

src/vs/workbench/services/extensionManagement/common/extensionManagementService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
475475
installOptions = { ...(installOptions || {}), isMachineScoped };
476476
}
477477

478-
if (installOptions.installEverywhere || (!installOptions.isMachineScoped && this.isExtensionsSyncEnabled())) {
478+
if (!installOptions.isMachineScoped && this.isExtensionsSyncEnabled()) {
479479
if (this.extensionManagementServerService.localExtensionManagementServer
480480
&& !servers.includes(this.extensionManagementServerService.localExtensionManagementServer)
481481
&& await this.extensionManagementServerService.localExtensionManagementServer.extensionManagementService.canInstall(gallery) === true) {
@@ -606,7 +606,7 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
606606
}
607607
}
608608

609-
private async validateAndGetExtensionManagementServersToInstall(gallery: IGalleryExtension, installOptions?: InstallOptions): Promise<IExtensionManagementServer[]> {
609+
private async validateAndGetExtensionManagementServersToInstall(gallery: IGalleryExtension, installOptions?: IWorkbenchInstallOptions): Promise<IExtensionManagementServer[]> {
610610

611611
const manifest = await this.extensionGalleryService.getManifest(gallery, CancellationToken.None);
612612
if (!manifest) {
@@ -615,8 +615,8 @@ export class ExtensionManagementService extends Disposable implements IWorkbench
615615

616616
const servers: IExtensionManagementServer[] = [];
617617

618-
// Install Language pack on local and remote servers
619-
if (isLanguagePackExtension(manifest)) {
618+
// Install everywhere if asked to install everywhere or if the extension is a language pack
619+
if (installOptions?.installEverywhere || isLanguagePackExtension(manifest)) {
620620
servers.push(...this.servers.filter(server => server !== this.extensionManagementServerService.webExtensionManagementServer));
621621
} else {
622622
const server = this.getExtensionManagementServerToInstall(manifest);

0 commit comments

Comments
 (0)