Skip to content

Commit db0f534

Browse files
committed
introduce sessionId
1 parent 1b67671 commit db0f534

6 files changed

Lines changed: 12 additions & 15 deletions

File tree

src/vs/code/electron-main/window.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
635635

636636
// Set window ID
637637
windowConfiguration.windowId = this._win.id;
638+
windowConfiguration.sessionId = `window:${this._win.id}`;
638639
windowConfiguration.logLevel = this.logService.getLevel();
639640

640641
// Set zoomlevel

src/vs/platform/menubar/electron-main/menubar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ export class Menubar {
551551
label: this.mnemonicLabel(nls.localize('miCheckForUpdates', "Check for &&Updates...")), click: () => setTimeout(() => {
552552
this.reportMenuActionTelemetry('CheckForUpdate');
553553

554-
const focusedWindow = BrowserWindow.getFocusedWindow();
555-
const context = focusedWindow ? { windowId: focusedWindow.id } : null;
554+
const window = this.windowsMainService.getLastActiveWindow();
555+
const context = window?.config?.sessionId;
556556
this.updateService.checkForUpdates(context);
557557
}, 0)
558558
})];

src/vs/platform/windows/common/windows.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ export interface IAddFoldersRequest {
220220

221221
export interface IWindowConfiguration extends ParsedArgs {
222222
machineId: string;
223-
windowId: number;
223+
windowId: number; // TODO: should we deprecate this in favor of sessionId?
224+
sessionId: string;
224225
logLevel: LogLevel;
225226

226227
mainPid: number;

src/vs/workbench/browser/parts/titlebar/menubarControl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ export class CustomMenubarControl extends MenubarControl {
293293
@IThemeService private readonly themeService: IThemeService,
294294
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
295295
@IHostService protected readonly hostService: IHostService,
296+
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService,
296297
@optional(IElectronService) private readonly electronService: IElectronService,
297298
@optional(IElectronEnvironmentService) private readonly electronEnvironmentService: IElectronEnvironmentService
298299
) {
@@ -444,9 +445,8 @@ export class CustomMenubarControl extends MenubarControl {
444445
return null;
445446

446447
case StateType.Idle:
447-
const context = `window:${this.electronEnvironmentService ? this.electronEnvironmentService.windowId : 'any'}`;
448448
return new Action('update.check', nls.localize({ key: 'checkForUpdates', comment: ['&& denotes a mnemonic'] }, "Check for &&Updates..."), undefined, true, () =>
449-
this.updateService.checkForUpdates(context));
449+
this.updateService.checkForUpdates(this.workbenchEnvironmentService.configuration.sessionId));
450450

451451
case StateType.CheckingForUpdates:
452452
return new Action('update.checking', nls.localize('checkingForUpdates', "Checking for Updates..."), undefined, false);

src/vs/workbench/contrib/update/browser/update.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Action } from 'vs/base/common/actions';
99
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
1010
import { URI } from 'vs/base/common/uri';
1111
import { IActivityService, NumberBadge, IBadge, ProgressBadge } from 'vs/workbench/services/activity/common/activity';
12-
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
12+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import { GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity';
1414
import { IOpenerService } from 'vs/platform/opener/common/opener';
1515
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
@@ -30,10 +30,6 @@ import { ShowCurrentReleaseNotesActionId } from 'vs/workbench/contrib/update/com
3030
import { IHostService } from 'vs/workbench/services/host/browser/host';
3131
import { IProductService } from 'vs/platform/product/common/productService';
3232

33-
// TODO@Joao layer breaker
34-
// tslint:disable-next-line: layering
35-
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
36-
3733
const CONTEXT_UPDATE_STATE = new RawContextKey<string>('updateState', StateType.Uninitialized);
3834

3935
let releaseNotesManager: ReleaseNotesManager | undefined = undefined;
@@ -171,8 +167,6 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
171167
private readonly badgeDisposable = this._register(new MutableDisposable());
172168
private updateStateContextKey: IContextKey<string>;
173169

174-
private context = `window:${this.electronEnvironmentService ? this.electronEnvironmentService.windowId : 'any'}`;
175-
176170
constructor(
177171
@IStorageService private readonly storageService: IStorageService,
178172
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -182,7 +176,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
182176
@IActivityService private readonly activityService: IActivityService,
183177
@IContextKeyService private readonly contextKeyService: IContextKeyService,
184178
@IProductService private readonly productService: IProductService,
185-
@optional(IElectronEnvironmentService) private readonly electronEnvironmentService: IElectronEnvironmentService
179+
@IWorkbenchEnvironmentService private readonly workbenchEnvironmentService: IWorkbenchEnvironmentService
186180
) {
187181
super();
188182
this.state = updateService.state;
@@ -218,7 +212,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
218212
case StateType.Idle:
219213
if (state.error) {
220214
this.onError(state.error);
221-
} else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.context) {
215+
} else if (this.state.type === StateType.CheckingForUpdates && this.state.context === this.workbenchEnvironmentService.configuration.sessionId) {
222216
this.onUpdateNotAvailable();
223217
}
224218
break;
@@ -401,7 +395,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
401395
}
402396

403397
private registerGlobalActivityActions(): void {
404-
CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.context));
398+
CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(this.workbenchEnvironmentService.configuration.sessionId));
405399
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
406400
group: '6_update',
407401
command: {

src/vs/workbench/services/environment/browser/environmentService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
2424

2525
machineId!: string;
2626
windowId!: number;
27+
sessionId!: string;
2728
logLevel!: LogLevel;
2829

2930
mainPid!: number;

0 commit comments

Comments
 (0)