Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 (#15681)

* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898

* Fixes and cleanup

* Distro

* Fix hygiene yarn

* delete no yarn lock changes file

* Fix hygiene

* Fix layer check

* Fix CI

* Skip lib checks

* Remove tests deleted in vs code

* Fix tests

* Distro

* Fix tests and add removed extension point

* Skip failing notebook tests for now

* Disable broken tests and cleanup build folder

* Update yarn.lock and fix smoke tests

* Bump sqlite

* fix contributed actions and file spacing

* Fix user data path

* Update yarn.locks

Co-authored-by: ADS Merger <karlb@microsoft.com>
This commit is contained in:
Charles Gagnon
2021-06-17 08:17:11 -07:00
committed by GitHub
parent fdcb97c7f7
commit 3cb2f552a6
2582 changed files with 124827 additions and 87099 deletions

View File

@@ -3,6 +3,8 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
// Since data sent through the service is serialized to JSON, functions will be lost, so Color objects
// should not be sent as their 'toString' method will be stripped. Instead convert to strings before sending.
export interface WindowStyles {
@@ -40,7 +42,7 @@ export interface IssueReporterStyles extends WindowStyles {
export interface IssueReporterExtensionData {
name: string;
publisher: string;
publisher: string | undefined;
version: string;
id: string;
isTheme: boolean;
@@ -67,9 +69,6 @@ export interface ISettingSearchResult {
score: number;
}
export interface IssueReporterFeatures {
}
export interface ProcessExplorerStyles extends WindowStyles {
hoverBackground?: string;
hoverForeground?: string;
@@ -78,7 +77,7 @@ export interface ProcessExplorerStyles extends WindowStyles {
export interface ProcessExplorerData extends WindowData {
pid: number;
styles: ProcessExplorerStyles;
platform: 'win32' | 'darwin' | 'linux';
platform: string;
applicationName: string;
}
@@ -88,3 +87,17 @@ export interface ICommonIssueService {
openProcessExplorer(data: ProcessExplorerData): Promise<void>;
getSystemStatus(): Promise<string>;
}
export interface IssueReporterWindowConfiguration extends ISandboxConfiguration {
disableExtensions: boolean;
data: IssueReporterData;
os: {
type: string;
arch: string;
release: string;
}
}
export interface ProcessExplorerWindowConfiguration extends ISandboxConfiguration {
data: ProcessExplorerData;
}

View File

@@ -4,16 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import * as os from 'os';
import { arch, release, type } from 'os';
import product from 'vs/platform/product/common/product';
import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
import { ICommonIssueService, IssueReporterData, IssueReporterFeatures, ProcessExplorerData } from 'vs/platform/issue/common/issue';
import { ICommonIssueService, IssueReporterWindowConfiguration, IssueReporterData, ProcessExplorerData, ProcessExplorerWindowConfiguration } from 'vs/platform/issue/common/issue';
import { BrowserWindow, ipcMain, screen, IpcMainEvent, Display } from 'electron';
import { ILaunchMainService } from 'vs/platform/launch/electron-main/launchMainService';
import { PerformanceInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { IDiagnosticsService } from 'vs/platform/diagnostics/node/diagnosticsService';
import { IDiagnosticsService, PerformanceInfo, isRemoteDiagnosticError } from 'vs/platform/diagnostics/common/diagnostics';
import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
import { isMacintosh, IProcessEnvironment } from 'vs/base/common/platform';
import { isMacintosh, IProcessEnvironment, browserCodeLoadingCacheStrategy } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowState } from 'vs/platform/windows/electron-main/windows';
import { listProcesses } from 'vs/base/node/ps';
@@ -22,66 +20,69 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import { zoomLevelToZoomFactor } from 'vs/platform/windows/common/windows';
import { FileAccess } from 'vs/base/common/network';
import { INativeHostMainService } from 'vs/platform/native/electron-main/nativeHostMainService';
const DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
import { IIPCObjectUrl, IProtocolMainService } from 'vs/platform/protocol/electron-main/protocol';
import { DisposableStore } from 'vs/base/common/lifecycle';
export const IIssueMainService = createDecorator<IIssueMainService>('issueMainService');
export interface IIssueMainService extends ICommonIssueService { }
export class IssueMainService implements ICommonIssueService {
declare readonly _serviceBrand: undefined;
_issueWindow: BrowserWindow | null = null;
_issueParentWindow: BrowserWindow | null = null;
_processExplorerWindow: BrowserWindow | null = null;
_processExplorerParentWindow: BrowserWindow | null = null;
private static readonly DEFAULT_BACKGROUND_COLOR = '#1E1E1E';
private issueReporterWindow: BrowserWindow | null = null;
private issueReporterParentWindow: BrowserWindow | null = null;
private processExplorerWindow: BrowserWindow | null = null;
private processExplorerParentWindow: BrowserWindow | null = null;
constructor(
private machineId: string,
private userEnv: IProcessEnvironment,
@IEnvironmentMainService private readonly environmentService: IEnvironmentMainService,
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
@ILaunchMainService private readonly launchMainService: ILaunchMainService,
@ILogService private readonly logService: ILogService,
@IDiagnosticsService private readonly diagnosticsService: IDiagnosticsService,
@IDialogMainService private readonly dialogMainService: IDialogMainService,
@INativeHostMainService private readonly nativeHostMainService: INativeHostMainService
@INativeHostMainService private readonly nativeHostMainService: INativeHostMainService,
@IProtocolMainService private readonly protocolMainService: IProtocolMainService
) {
this.registerListeners();
}
private registerListeners(): void {
ipcMain.on('vscode:issueSystemInfoRequest', async (event: IpcMainEvent) => {
Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })])
.then(result => {
const [info, remoteData] = result;
this.diagnosticsService.getSystemInfo(info, remoteData).then(msg => {
this.safeSend(event, 'vscode:issueSystemInfoResponse', msg);
});
});
ipcMain.on('vscode:issueSystemInfoRequest', async event => {
const [info, remoteData] = await Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })]);
const msg = await this.diagnosticsService.getSystemInfo(info, remoteData);
this.safeSend(event, 'vscode:issueSystemInfoResponse', msg);
});
ipcMain.on('vscode:listProcesses', async (event: IpcMainEvent) => {
ipcMain.on('vscode:listProcesses', async event => {
const processes = [];
try {
const mainPid = await this.launchMainService.getMainProcessId();
processes.push({ name: localize('local', "Local"), rootProcess: await listProcesses(mainPid) });
(await this.launchMainService.getRemoteDiagnostics({ includeProcesses: true }))
.forEach(data => {
if (isRemoteDiagnosticError(data)) {
const remoteDiagnostics = await this.launchMainService.getRemoteDiagnostics({ includeProcesses: true });
remoteDiagnostics.forEach(data => {
if (isRemoteDiagnosticError(data)) {
processes.push({
name: data.hostName,
rootProcess: data
});
} else {
if (data.processes) {
processes.push({
name: data.hostName,
rootProcess: data
rootProcess: data.processes
});
} else {
if (data.processes) {
processes.push({
name: data.hostName,
rootProcess: data.processes
});
}
}
});
}
});
} catch (e) {
this.logService.error(`Listing processes failed: ${e}`);
}
@@ -89,7 +90,7 @@ export class IssueMainService implements ICommonIssueService {
this.safeSend(event, 'vscode:listProcessesResponse', processes);
});
ipcMain.on('vscode:issueReporterClipboard', (event: IpcMainEvent) => {
ipcMain.on('vscode:issueReporterClipboard', async event => {
const messageOptions = {
message: localize('issueReporterWriteToClipboard', "There is too much data to send to GitHub directly. The data will be copied to the clipboard, please paste it into the GitHub issue page that is opened."),
type: 'warning',
@@ -99,21 +100,18 @@ export class IssueMainService implements ICommonIssueService {
]
};
if (this._issueWindow) {
this.dialogMainService.showMessageBox(messageOptions, this._issueWindow)
.then(result => {
this.safeSend(event, 'vscode:issueReporterClipboardResponse', result.response === 0);
});
if (this.issueReporterWindow) {
const result = await this.dialogMainService.showMessageBox(messageOptions, this.issueReporterWindow);
this.safeSend(event, 'vscode:issueReporterClipboardResponse', result.response === 0);
}
});
ipcMain.on('vscode:issuePerformanceInfoRequest', (event: IpcMainEvent) => {
this.getPerformanceInfo().then(msg => {
this.safeSend(event, 'vscode:issuePerformanceInfoResponse', msg);
});
ipcMain.on('vscode:issuePerformanceInfoRequest', async event => {
const performanceInfo = await this.getPerformanceInfo();
this.safeSend(event, 'vscode:issuePerformanceInfoResponse', performanceInfo);
});
ipcMain.on('vscode:issueReporterConfirmClose', () => {
ipcMain.on('vscode:issueReporterConfirmClose', async () => {
const messageOptions = {
message: localize('confirmCloseIssueReporter', "Your input will not be saved. Are you sure you want to close this window?"),
type: 'warning',
@@ -123,16 +121,14 @@ export class IssueMainService implements ICommonIssueService {
]
};
if (this._issueWindow) {
this.dialogMainService.showMessageBox(messageOptions, this._issueWindow)
.then(result => {
if (result.response === 0) {
if (this._issueWindow) {
this._issueWindow.destroy();
this._issueWindow = null;
}
}
});
if (this.issueReporterWindow) {
const result = await this.dialogMainService.showMessageBox(messageOptions, this.issueReporterWindow);
if (result.response === 0) {
if (this.issueReporterWindow) {
this.issueReporterWindow.destroy();
this.issueReporterWindow = null;
}
}
}
});
@@ -142,10 +138,10 @@ export class IssueMainService implements ICommonIssueService {
let parentWindow: BrowserWindow | null;
switch (from) {
case 'issueReporter':
parentWindow = this._issueParentWindow;
parentWindow = this.issueReporterParentWindow;
break;
case 'processExplorer':
parentWindow = this._processExplorerParentWindow;
parentWindow = this.processExplorerParentWindow;
break;
default:
throw new Error(`Unexpected command source: ${from}`);
@@ -160,22 +156,21 @@ export class IssueMainService implements ICommonIssueService {
this.nativeHostMainService.openExternal(undefined, arg);
});
ipcMain.on('vscode:closeIssueReporter', (event: IpcMainEvent) => {
if (this._issueWindow) {
this._issueWindow.close();
ipcMain.on('vscode:closeIssueReporter', event => {
if (this.issueReporterWindow) {
this.issueReporterWindow.close();
}
});
ipcMain.on('vscode:closeProcessExplorer', (event: IpcMainEvent) => {
if (this._processExplorerWindow) {
this._processExplorerWindow.close();
ipcMain.on('vscode:closeProcessExplorer', event => {
if (this.processExplorerWindow) {
this.processExplorerWindow.close();
}
});
ipcMain.on('vscode:windowsInfoRequest', (event: IpcMainEvent) => {
this.launchMainService.getMainProcessInfo().then(info => {
this.safeSend(event, 'vscode:windowsInfoResponse', info.windows);
});
ipcMain.on('vscode:windowsInfoRequest', async event => {
const mainProcessInfo = await this.launchMainService.getMainProcessInfo();
this.safeSend(event, 'vscode:windowsInfoResponse', mainProcessInfo.windows);
});
}
@@ -186,128 +181,138 @@ export class IssueMainService implements ICommonIssueService {
}
async openReporter(data: IssueReporterData): Promise<void> {
if (!this._issueWindow) {
this._issueParentWindow = BrowserWindow.getFocusedWindow();
if (this._issueParentWindow) {
const position = this.getWindowPosition(this._issueParentWindow, 700, 800);
if (!this.issueReporterWindow) {
this.issueReporterParentWindow = BrowserWindow.getFocusedWindow();
if (this.issueReporterParentWindow) {
const issueReporterDisposables = new DisposableStore();
this._issueWindow = new BrowserWindow({
fullscreen: false,
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
title: localize('issueReporter', "Issue Reporter"),
backgroundColor: data.styles.backgroundColor || DEFAULT_BACKGROUND_COLOR,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
v8CacheOptions: 'bypassHeatCheck',
enableWebSQL: false,
enableRemoteModule: false,
spellcheck: false,
nativeWindowOpen: true,
zoomFactor: zoomLevelToZoomFactor(data.zoomLevel),
sandbox: true,
contextIsolation: true
}
const issueReporterWindowConfigUrl = issueReporterDisposables.add(this.protocolMainService.createIPCObjectUrl<IssueReporterWindowConfiguration>());
const position = this.getWindowPosition(this.issueReporterParentWindow, 700, 800);
this.issueReporterWindow = this.createBrowserWindow(position, issueReporterWindowConfigUrl, data.styles.backgroundColor, localize('issueReporter', "Issue Reporter"), data.zoomLevel);
// Store into config object URL
issueReporterWindowConfigUrl.update({
appRoot: this.environmentMainService.appRoot,
windowId: this.issueReporterWindow.id,
userEnv: this.userEnv,
data,
disableExtensions: !!this.environmentMainService.disableExtensions,
os: {
type: type(),
arch: arch(),
release: release(),
},
product
});
this._issueWindow.setMenuBarVisibility(false); // workaround for now, until a menu is implemented
this.issueReporterWindow.loadURL(
FileAccess.asBrowserUri('vs/code/electron-sandbox/issue/issueReporter.html', require, true).toString(true)
);
// Modified when testing UI
const features: IssueReporterFeatures = {};
this.issueReporterWindow.on('close', () => {
this.issueReporterWindow = null;
this.logService.trace('issueService#openReporter: opening issue reporter');
this._issueWindow.loadURL(this.getIssueReporterPath(data, features));
issueReporterDisposables.dispose();
});
this._issueWindow.on('close', () => this._issueWindow = null);
this.issueReporterParentWindow.on('closed', () => {
if (this.issueReporterWindow) {
this.issueReporterWindow.close();
this.issueReporterWindow = null;
this._issueParentWindow.on('closed', () => {
if (this._issueWindow) {
this._issueWindow.close();
this._issueWindow = null;
issueReporterDisposables.dispose();
}
});
}
}
if (this._issueWindow) {
this._issueWindow.focus();
}
this.issueReporterWindow?.focus();
}
async openProcessExplorer(data: ProcessExplorerData): Promise<void> {
// Create as singleton
if (!this._processExplorerWindow) {
this._processExplorerParentWindow = BrowserWindow.getFocusedWindow();
if (this._processExplorerParentWindow) {
const position = this.getWindowPosition(this._processExplorerParentWindow, 800, 500);
this._processExplorerWindow = new BrowserWindow({
skipTaskbar: true,
resizable: true,
fullscreen: false,
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
backgroundColor: data.styles.backgroundColor,
title: localize('processExplorer', "Process Explorer"),
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
v8CacheOptions: 'bypassHeatCheck',
enableWebSQL: false,
enableRemoteModule: false,
spellcheck: false,
nativeWindowOpen: true,
zoomFactor: zoomLevelToZoomFactor(data.zoomLevel),
sandbox: true,
contextIsolation: true
}
if (!this.processExplorerWindow) {
this.processExplorerParentWindow = BrowserWindow.getFocusedWindow();
if (this.processExplorerParentWindow) {
const processExplorerDisposables = new DisposableStore();
const processExplorerWindowConfigUrl = processExplorerDisposables.add(this.protocolMainService.createIPCObjectUrl<ProcessExplorerWindowConfiguration>());
const position = this.getWindowPosition(this.processExplorerParentWindow, 800, 500);
this.processExplorerWindow = this.createBrowserWindow(position, processExplorerWindowConfigUrl, data.styles.backgroundColor, localize('processExplorer', "Process Explorer"), data.zoomLevel);
// Store into config object URL
processExplorerWindowConfigUrl.update({
appRoot: this.environmentMainService.appRoot,
windowId: this.processExplorerWindow.id,
userEnv: this.userEnv,
data,
product
});
this._processExplorerWindow.setMenuBarVisibility(false);
this.processExplorerWindow.loadURL(
FileAccess.asBrowserUri('vs/code/electron-sandbox/processExplorer/processExplorer.html', require, true).toString(true)
);
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
windowId: this._processExplorerWindow.id,
userEnv: this.userEnv,
machineId: this.machineId,
data
};
this.processExplorerWindow.on('close', () => {
this.processExplorerWindow = null;
processExplorerDisposables.dispose();
});
this._processExplorerWindow.loadURL(
toWindowUrl('vs/code/electron-sandbox/processExplorer/processExplorer.html', windowConfiguration));
this.processExplorerParentWindow.on('close', () => {
if (this.processExplorerWindow) {
this.processExplorerWindow.close();
this.processExplorerWindow = null;
this._processExplorerWindow.on('close', () => this._processExplorerWindow = null);
this._processExplorerParentWindow.on('close', () => {
if (this._processExplorerWindow) {
this._processExplorerWindow.close();
this._processExplorerWindow = null;
processExplorerDisposables.dispose();
}
});
}
}
// Focus
if (this._processExplorerWindow) {
this._processExplorerWindow.focus();
}
this.processExplorerWindow?.focus();
}
public async getSystemStatus(): Promise<string> {
return Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })])
.then(result => {
const [info, remoteData] = result;
return this.diagnosticsService.getDiagnostics(info, remoteData);
});
private createBrowserWindow<T>(position: IWindowState, ipcObjectUrl: IIPCObjectUrl<T>, backgroundColor: string | undefined, title: string, zoomLevel: number): BrowserWindow {
const window = new BrowserWindow({
fullscreen: false,
skipTaskbar: true,
resizable: true,
width: position.width,
height: position.height,
minWidth: 300,
minHeight: 200,
x: position.x,
y: position.y,
title,
backgroundColor: backgroundColor || IssueMainService.DEFAULT_BACKGROUND_COLOR,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */],
v8CacheOptions: browserCodeLoadingCacheStrategy,
enableWebSQL: false,
enableRemoteModule: false,
spellcheck: false,
nativeWindowOpen: true,
zoomFactor: zoomLevelToZoomFactor(zoomLevel),
sandbox: true,
contextIsolation: true
}
});
window.setMenuBarVisibility(false);
return window;
}
async getSystemStatus(): Promise<string> {
const [info, remoteData] = await Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })]);
return this.diagnosticsService.getDiagnostics(info, remoteData);
}
private getWindowPosition(parentWindow: BrowserWindow, defaultWidth: number, defaultHeight: number): IWindowState {
// We want the new window to open on the same display that the parent is in
let displayToUse: Display | undefined;
const displays = screen.getAllDisplays();
@@ -375,66 +380,14 @@ export class IssueMainService implements ICommonIssueService {
return state;
}
private getPerformanceInfo(): Promise<PerformanceInfo> {
return new Promise(async (resolve, reject) => {
Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true })])
.then(result => {
const [info, remoteData] = result;
this.diagnosticsService.getPerformanceInfo(info, remoteData)
.then(diagnosticInfo => {
resolve(diagnosticInfo);
})
.catch(err => {
this.logService.warn('issueService#getPerformanceInfo ', err.message);
reject(err);
});
});
});
}
private async getPerformanceInfo(): Promise<PerformanceInfo> {
try {
const [info, remoteData] = await Promise.all([this.launchMainService.getMainProcessInfo(), this.launchMainService.getRemoteDiagnostics({ includeProcesses: true, includeWorkspaceMetadata: true })]);
return await this.diagnosticsService.getPerformanceInfo(info, remoteData);
} catch (error) {
this.logService.warn('issueService#getPerformanceInfo ', error.message);
private getIssueReporterPath(data: IssueReporterData, features: IssueReporterFeatures): string {
if (!this._issueWindow) {
throw new Error('Issue window has been disposed');
}
const windowConfiguration = {
appRoot: this.environmentService.appRoot,
windowId: this._issueWindow.id,
machineId: this.machineId,
userEnv: this.userEnv,
data,
features,
disableExtensions: this.environmentService.disableExtensions,
os: {
type: os.type(),
arch: os.arch(),
release: os.release(),
},
product: {
nameShort: product.nameShort,
version: !!product.darwinUniversalAssetId ? `${product.version} (Universal)` : product.version,
commit: product.commit,
date: product.date,
reportIssueUrl: product.reportIssueUrl
}
};
return toWindowUrl('vs/code/electron-sandbox/issue/issueReporter.html', windowConfiguration);
}
}
function toWindowUrl<T>(modulePathToHtml: string, windowConfiguration: T): string {
const environment = parseArgs(process.argv, OPTIONS);
const config = Object.assign(environment, windowConfiguration);
for (const keyValue of Object.keys(config)) {
const key = keyValue as keyof typeof config;
if (config[key] === undefined || config[key] === null || config[key] === '') {
delete config[key]; // only send over properties that have a true value
throw error;
}
}
return FileAccess
.asBrowserUri(modulePathToHtml, require, true)
.with({ query: `config=${encodeURIComponent(JSON.stringify(config))}` })
.toString(true);
}