diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index d4320215cb93edc1ff11392d222172c1539792c2..dd38f9a8a248e4755a5da63cab41b2bd6abbc5d3 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -635,6 +635,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { // Set window ID windowConfiguration.windowId = this._win.id; + windowConfiguration.sessionId = `window:${this._win.id}`; windowConfiguration.logLevel = this.logService.getLevel(); // Set zoomlevel diff --git a/src/vs/platform/menubar/electron-main/menubar.ts b/src/vs/platform/menubar/electron-main/menubar.ts index 36380eef934bf5fb2087bd3f1bff518815ee8940..ed1e8ef64cce4eed82e80cb37d0cf6a854e5de48 100644 --- a/src/vs/platform/menubar/electron-main/menubar.ts +++ b/src/vs/platform/menubar/electron-main/menubar.ts @@ -551,8 +551,8 @@ export class Menubar { label: this.mnemonicLabel(nls.localize('miCheckForUpdates', "Check for &&Updates...")), click: () => setTimeout(() => { this.reportMenuActionTelemetry('CheckForUpdate'); - const focusedWindow = BrowserWindow.getFocusedWindow(); - const context = focusedWindow ? { windowId: focusedWindow.id } : null; + const window = this.windowsMainService.getLastActiveWindow(); + const context = window?.config?.sessionId; this.updateService.checkForUpdates(context); }, 0) })]; diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index db5a976d33e330309332d4250afd21457c9722c0..9e06f26b86dae866d52d59664ba29ea66fed5ba1 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -220,7 +220,8 @@ export interface IAddFoldersRequest { export interface IWindowConfiguration extends ParsedArgs { machineId: string; - windowId: number; + windowId: number; // TODO: should we deprecate this in favor of sessionId? + sessionId: string; logLevel: LogLevel; mainPid: number; diff --git a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts index a35ad251f855a64f497d076a741fe1e261c6a1a5..dac036e01dcb546754d75a9c82436c41b1d87f26 100644 --- a/src/vs/workbench/browser/parts/titlebar/menubarControl.ts +++ b/src/vs/workbench/browser/parts/titlebar/menubarControl.ts @@ -293,6 +293,7 @@ export class CustomMenubarControl extends MenubarControl { @IThemeService private readonly themeService: IThemeService, @IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService, @IHostService protected readonly hostService: IHostService, + @IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService, @optional(IElectronService) private readonly electronService: IElectronService, @optional(IElectronEnvironmentService) private readonly electronEnvironmentService: IElectronEnvironmentService ) { @@ -444,9 +445,8 @@ export class CustomMenubarControl extends MenubarControl { return null; case StateType.Idle: - const context = `window:${this.electronEnvironmentService ? this.electronEnvironmentService.windowId : 'any'}`; return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () => - this.updateService.checkForUpdates(context)); + this.updateService.checkForUpdates(this.workbenchEnvironmentService.configuration.sessionId)); case StateType.CheckingForUpdates: return new Action('update.checking', nls.localize('checkingForUpdates', "Checking for Updates..."), undefined, false); diff --git a/src/vs/workbench/contrib/update/browser/update.ts b/src/vs/workbench/contrib/update/browser/update.ts index 00b74f5f3213e348b5b413a4fa5b043d28f059f8..0245d46aa5b49317f7fb95003f478bde1867d1c8 100644 --- a/src/vs/workbench/contrib/update/browser/update.ts +++ b/src/vs/workbench/contrib/update/browser/update.ts @@ -9,7 +9,7 @@ import { Action } from 'vs/base/common/actions'; import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; import { IActivityService, NumberBadge, IBadge, ProgressBadge } from 'vs/workbench/services/activity/common/activity'; -import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; @@ -30,10 +30,6 @@ import { ShowCurrentReleaseNotesActionId } from 'vs/workbench/contrib/update/com import { IHostService } from 'vs/workbench/services/host/browser/host'; import { IProductService } from 'vs/platform/product/common/productService'; -// TODO@Joao layer breaker -// tslint:disable-next-line: layering -import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService'; - const CONTEXT_UPDATE_STATE = new RawContextKey('updateState', StateType.Uninitialized); let releaseNotesManager: ReleaseNotesManager | undefined = undefined; @@ -171,8 +167,6 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu private readonly badgeDisposable = this._register(new MutableDisposable()); private updateStateContextKey: IContextKey; - private context = `window:${this.electronEnvironmentService ? this.electronEnvironmentService.windowId : 'any'}`; - constructor( @IStorageService private readonly storageService: IStorageService, @IInstantiationService private readonly instantiationService: IInstantiationService, @@ -182,7 +176,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu @IActivityService private readonly activityService: IActivityService, @IContextKeyService private readonly contextKeyService: IContextKeyService, @IProductService private readonly productService: IProductService, - @optional(IElectronEnvironmentService) private readonly electronEnvironmentService: IElectronEnvironmentService + @IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService ) { super(); this.state = updateService.state; @@ -218,7 +212,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu case StateType.Idle: if (state.error) { this.onError(state.error); - } else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.context) { + } else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.workbenchEnvironmentService.configuration.sessionId) { this.onUpdateNotAvailable(); } break; @@ -401,7 +395,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu } private registerGlobalActivityActions(): void { - CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.context)); + CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.workbenchEnvironmentService.configuration.sessionId)); MenuRegistry.appendMenuItem(MenuId.GlobalActivity, { group: '6_update', command: { diff --git a/src/vs/workbench/services/environment/browser/environmentService.ts b/src/vs/workbench/services/environment/browser/environmentService.ts index 614a9294c9c5a5a441675aee9467ecd98246c98a..643c3ab320c363e9c3d4e923407812740032e802 100644 --- a/src/vs/workbench/services/environment/browser/environmentService.ts +++ b/src/vs/workbench/services/environment/browser/environmentService.ts @@ -43,6 +43,7 @@ export class BrowserWindowConfiguration implements IWindowConfiguration { readonly machineId = generateUuid(); windowId!: number; + sessionId!: string; logLevel!: LogLevel; mainPid!: number;