Skip to content

Commit 9676fe6

Browse files
committed
update patches for vs 1.71.0
the cli fix seems to be fixed in upstream, the telemtry patch requires (again) some fixing and adjustments.
1 parent 9c40709 commit 9676fe6

8 files changed

+73
-110
lines changed

patches/cli-window-open.diff

+3-65
Original file line numberDiff line numberDiff line change
@@ -13,62 +13,15 @@ To test:
1313
The file or directory should only open from the instance attached to that
1414
terminal.
1515

16-
Index: code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
17-
===================================================================
18-
--- code-server.orig/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
19-
+++ code-server/lib/vscode/src/vs/server/node/remoteTerminalChannel.ts
20-
@@ -89,7 +89,7 @@ export class RemoteTerminalChannel exten
21-
uriTransformer: IURITransformer;
22-
}>();
23-
24-
- private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; commandId: string; commandArgs: any[] }>());
25-
+ private readonly _onExecuteCommand = this._register(new Emitter<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>());
26-
readonly onExecuteCommand = this._onExecuteCommand.event;
27-
28-
constructor(
29-
@@ -241,20 +241,20 @@ export class RemoteTerminalChannel exten
30-
const ipcHandlePath = createRandomIPCHandle();
31-
env.VSCODE_IPC_HOOK_CLI = ipcHandlePath;
32-
const commandsExecuter: ICommandsExecuter = {
33-
- executeCommand: <T>(id: string, ...args: any[]): Promise<T> => this._executeCommand(id, args, uriTransformer)
34-
+ executeCommand: <T>(commandId: string, ...args: any[]): Promise<T> => this._executeCommand(terminalId, commandId, args, uriTransformer)
35-
};
36-
const cliServer = new CLIServerBase(commandsExecuter, this._logService, ipcHandlePath);
37-
38-
- const id = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
39-
- this._ptyService.onProcessExit(e => e.id === id && cliServer.dispose());
40-
+ const terminalId = await this._ptyService.createProcess(shellLaunchConfig, initialCwd, args.cols, args.rows, args.unicodeVersion, env, baseEnv, args.options, args.shouldPersistTerminal, args.workspaceId, args.workspaceName);
41-
+ this._ptyService.onProcessExit(e => e.id === terminalId && cliServer.dispose());
42-
43-
return {
44-
- persistentTerminalId: id,
45-
+ persistentTerminalId: terminalId,
46-
resolvedShellLaunchConfig: shellLaunchConfig
47-
};
48-
}
49-
50-
- private _executeCommand<T>(commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
51-
+ private _executeCommand<T>(terminalId: number, commandId: string, commandArgs: any[], uriTransformer: IURITransformer): Promise<T> {
52-
let resolve!: (data: any) => void;
53-
let reject!: (err: any) => void;
54-
const result = new Promise<T>((_resolve, _reject) => {
55-
@@ -277,6 +277,7 @@ export class RemoteTerminalChannel exten
56-
});
57-
this._onExecuteCommand.fire({
58-
reqId,
59-
+ terminalId,
60-
commandId,
61-
commandArgs: serializedCommandArgs
62-
});
6316
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
6417
===================================================================
6518
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
6619
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
67-
@@ -94,10 +94,14 @@ class RemoteTerminalBackend extends Base
68-
this._remoteTerminalChannel.onExecuteCommand(async e => {
20+
@@ -99,10 +99,14 @@ class RemoteTerminalBackend extends Base
21+
}
6922
const reqId = e.reqId;
7023
const commandId = e.commandId;
71-
+ const terminalId = e.terminalId;
24+
+ const terminalId = e.persistentProcessId;
7225
if (!allowedCommands.includes(commandId)) {
7326
this._remoteTerminalChannel.sendCommandResult(reqId, true, 'Invalid remote cli command: ' + commandId);
7427
return;
@@ -79,18 +32,3 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTe
7932
const commandArgs = e.commandArgs.map(arg => revive(arg));
8033
try {
8134
const result = await this._commandService.executeCommand(e.commandId, ...commandArgs);
82-
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
83-
===================================================================
84-
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
85-
+++ code-server/lib/vscode/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts
86-
@@ -88,8 +88,8 @@ export class RemoteTerminalChannelClient
87-
get onProcessOrphanQuestion(): Event<{ id: number }> {
88-
return this._channel.listen<{ id: number }>('$onProcessOrphanQuestion');
89-
}
90-
- get onExecuteCommand(): Event<{ reqId: number; commandId: string; commandArgs: any[] }> {
91-
- return this._channel.listen<{ reqId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
92-
+ get onExecuteCommand(): Event<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }> {
93-
+ return this._channel.listen<{ reqId: number; terminalId: number; commandId: string; commandArgs: any[] }>('$onExecuteCommand');
94-
}
95-
get onDidRequestDetach(): Event<{ requestId: number; workspaceId: string; instanceId: number }> {
96-
return this._channel.listen<{ requestId: number; workspaceId: string; instanceId: number }>('$onDidRequestDetach');

patches/disable-builtin-ext-update.diff

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens
77
===================================================================
88
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
99
+++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
10-
@@ -237,6 +237,10 @@ export class Extension implements IExten
10+
@@ -236,6 +236,10 @@ export class Extension implements IExten
1111
if (this.type === ExtensionType.System && this.productService.quality === 'stable') {
1212
return false;
1313
}
@@ -18,7 +18,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens
1818
if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) {
1919
return false;
2020
}
21-
@@ -1122,6 +1126,10 @@ export class ExtensionsWorkbenchService
21+
@@ -1121,6 +1125,10 @@ export class ExtensionsWorkbenchService
2222
// Skip if check updates only for builtin extensions and current extension is not builtin.
2323
continue;
2424
}

patches/heartbeat.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Index: code-server/lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts
1515

1616
export const enum SocketDiagnosticsEventType {
1717
Created = 'created',
18-
@@ -829,6 +830,19 @@ export class PersistentProtocol implemen
18+
@@ -849,6 +850,19 @@ export class PersistentProtocol implemen
1919
this._socketDisposables.push(this._socketWriter);
2020
this._socketReader = new ProtocolReader(this._socket);
2121
this._socketDisposables.push(this._socketReader);

patches/insecure-notification.diff

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
2727
) {
2828
super();
2929
}
30-
@@ -42,5 +45,32 @@ export class CodeServerClient extends Di
30+
@@ -42,5 +45,31 @@ export class CodeServerClient extends Di
3131
}
3232
});
3333
}
@@ -49,7 +49,6 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/client.ts
4949
+ class: undefined,
5050
+ enabled: true,
5151
+ checked: true,
52-
+ dispose: () => undefined,
5352
+ run: () => {
5453
+ return Promise.resolve();
5554
+ },

patches/proposed-api.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensions/common/abstra
99
===================================================================
1010
--- code-server.orig/lib/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.ts
1111
+++ code-server/lib/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.ts
12-
@@ -1460,7 +1460,7 @@ class ProposedApiController {
12+
@@ -1458,7 +1458,7 @@ class ProposedApiController {
1313

1414
this._envEnabledExtensions = new Set((_environmentService.extensionEnabledProposedApi ?? []).map(id => ExtensionIdentifier.toKey(id)));
1515

patches/proxy-uri.diff

+14-14
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ Index: code-server/lib/vscode/src/vs/platform/remote/browser/remoteAuthorityReso
3535
import { getRemoteServerRootPath, parseAuthorityWithOptionalPort } from 'vs/platform/remote/common/remoteHosts';
3636

3737
export class RemoteAuthorityResolverService extends Disposable implements IRemoteAuthorityResolverService {
38-
@@ -22,7 +22,7 @@ export class RemoteAuthorityResolverServ
39-
private readonly _connectionToken: string | undefined;
38+
@@ -23,7 +23,7 @@ export class RemoteAuthorityResolverServ
39+
private readonly _connectionToken: Promise<string> | string | undefined;
4040
private readonly _connectionTokens: Map<string, string>;
4141

42-
- constructor(@IProductService productService: IProductService, connectionToken: string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined) {
43-
+ constructor(@IProductService productService: IProductService, connectionToken: string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined, private readonly proxyEndpointTemplate?: string) {
42+
- constructor(@IProductService productService: IProductService, connectionToken: Promise<string> | string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined) {
43+
+ constructor(@IProductService productService: IProductService, connectionToken: Promise<string> | string | undefined, resourceUriProvider: ((uri: URI) => URI) | undefined, private readonly proxyEndpointTemplate?: string) {
4444
super();
45-
this._cache = new Map<string, ResolverResult>();
4645
this._connectionToken = connectionToken;
47-
@@ -62,9 +62,14 @@ export class RemoteAuthorityResolverServ
46+
this._connectionTokens = new Map<string, string>();
47+
@@ -61,9 +61,14 @@ export class RemoteAuthorityResolverServ
4848

49-
private _doResolveAuthority(authority: string): ResolverResult {
50-
const connectionToken = this._connectionTokens.get(authority) || this._connectionToken;
49+
private async _doResolveAuthority(authority: string): Promise<ResolverResult> {
50+
const connectionToken = await Promise.resolve(this._connectionTokens.get(authority) || this._connectionToken);
5151
+ let options: ResolvedOptions | undefined;
5252
+ if (this.proxyEndpointTemplate) {
5353
+ const proxyUrl = new URL(this.proxyEndpointTemplate, window.location.href);
5454
+ options = { extensionHostEnv: { VSCODE_PROXY_URI: decodeURIComponent(proxyUrl.toString()) }}
5555
+ }
5656
const defaultPort = (/^https:/.test(window.location.href) ? 443 : 80);
5757
const { host, port } = parseAuthorityWithOptionalPort(authority, defaultPort);
58-
- return { authority: { authority, host: host, port: port, connectionToken } };
59-
+ return { authority: { authority, host: host, port: port, connectionToken }, options };
60-
}
61-
62-
_clearResolvedAuthority(authority: string): void {
58+
- const result: ResolverResult = { authority: { authority, host: host, port: port, connectionToken } };
59+
+ const result: ResolverResult = { authority: { authority, host: host, port: port, connectionToken }, options };
60+
RemoteAuthorities.set(authority, result.authority.host, result.authority.port);
61+
this._cache.set(authority, result);
62+
this._onDidChangeConnectionData.fire();
6363
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
6464
===================================================================
6565
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
@@ -76,7 +76,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.main.ts
7676
===================================================================
7777
--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.main.ts
7878
+++ code-server/lib/vscode/src/vs/workbench/browser/web.main.ts
79-
@@ -239,7 +239,7 @@ export class BrowserMain extends Disposa
79+
@@ -247,7 +247,7 @@ export class BrowserMain extends Disposa
8080

8181
// Remote
8282
const connectionToken = environmentService.options.connectionToken || getCookieValue(connectionTokenCookieName);

patches/sourcemaps.diff

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js
1010
===================================================================
1111
--- code-server.orig/lib/vscode/build/gulpfile.reh.js
1212
+++ code-server/lib/vscode/build/gulpfile.reh.js
13-
@@ -194,8 +194,7 @@ function packageTask(type, platform, arc
13+
@@ -196,8 +196,7 @@ function packageTask(type, platform, arc
1414

1515
const src = gulp.src(sourceFolderName + '/**', { base: '.' })
1616
.pipe(rename(function (path) { path.dirname = path.dirname.replace(new RegExp('^' + sourceFolderName), 'out'); }))
@@ -20,7 +20,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js
2020

2121
const workspaceExtensionPoints = ['debuggers', 'jsonValidation'];
2222
const isUIExtension = (manifest) => {
23-
@@ -234,9 +233,9 @@ function packageTask(type, platform, arc
23+
@@ -236,9 +235,9 @@ function packageTask(type, platform, arc
2424
.map(name => `.build/extensions/${name}/**`);
2525

2626
const extensions = gulp.src(extensionPaths, { base: '.build', dot: true });
@@ -32,7 +32,7 @@ Index: code-server/lib/vscode/build/gulpfile.reh.js
3232

3333
let version = packageJson.version;
3434
const quality = product.quality;
35-
@@ -371,7 +370,7 @@ function tweakProductForServerWeb(produc
35+
@@ -373,7 +372,7 @@ function tweakProductForServerWeb(produc
3636
const minifyTask = task.define(`minify-vscode-${type}`, task.series(
3737
optimizeTask,
3838
util.rimraf(`out-vscode-${type}-min`),

patches/telemetry.diff

+48-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Add support for telemetry endpoint
22

3+
Contains some fixes included in https://github.com/microsoft/vscode/commit/b108bc8294ce920fcf2ee8d53f97c3bcf3316e1c
4+
35
Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
46
===================================================================
57
--- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts
@@ -86,12 +88,45 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
8688
===================================================================
8789
--- code-server.orig/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
8890
+++ code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/telemetryService.ts
89-
@@ -38,26 +38,30 @@ export class TelemetryService extends Di
91+
@@ -15,7 +15,7 @@ import { ClassifiedEvent, IGDPRProperty,
92+
import { ITelemetryData, ITelemetryInfo, ITelemetryService, TelemetryLevel, TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry';
93+
import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogAppender';
94+
import { ITelemetryServiceConfig, TelemetryService as BaseTelemetryService } from 'vs/platform/telemetry/common/telemetryService';
95+
-import { isInternalTelemetry, ITelemetryAppender, NullTelemetryService, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
96+
+import { getTelemetryLevel, isInternalTelemetry, ITelemetryAppender, NullTelemetryService, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
97+
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
98+
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
99+
import { resolveWorkbenchCommonProperties } from 'vs/workbench/services/telemetry/browser/workbenchCommonProperties';
100+
@@ -24,7 +24,7 @@ export class TelemetryService extends Di
101+
102+
declare readonly _serviceBrand: undefined;
103+
104+
- private impl: ITelemetryService;
105+
+ private impl: ITelemetryService = NullTelemetryService;
106+
public readonly sendErrorTelemetry = true;
107+
108+
constructor(
109+
@@ -37,11 +37,7 @@ export class TelemetryService extends Di
90110
) {
91111
super();
92112

93113
- if (supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey) {
94-
+ if (supportsTelemetry(productService, environmentService)) {
114+
- this.impl = this.initializeService(environmentService, loggerService, configurationService, storageService, productService, remoteAgentService);
115+
- } else {
116+
- this.impl = NullTelemetryService;
117+
- }
118+
+ this.impl = this.initializeService(environmentService, loggerService, configurationService, storageService, productService, remoteAgentService);
119+
120+
// When the level changes it could change from off to on and we want to make sure telemetry is properly intialized
121+
this._register(configurationService.onDidChangeConfiguration(e => {
122+
@@ -64,23 +60,28 @@ export class TelemetryService extends Di
123+
productService: IProductService,
124+
remoteAgentService: IRemoteAgentService
125+
) {
126+
- const telemetrySupported = supportsTelemetry(productService, environmentService) && productService.aiConfig?.ariaKey;
127+
- if (telemetrySupported && this.impl === NullTelemetryService && this.telemetryLevel.value !== TelemetryLevel.NONE) {
128+
+ const telemetrySupported = supportsTelemetry(productService, environmentService);
129+
+ if (telemetrySupported && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE && this.impl === NullTelemetryService) {
95130
// If remote server is present send telemetry through that, else use the client side appender
96131
const appenders = [];
97132
const isInternal = isInternalTelemetry(productService, configurationService);
@@ -103,14 +138,6 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
103138
- commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
104139
- sendErrorTelemetry: this.sendErrorTelemetry,
105140
- };
106-
- this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
107-
-
108-
- if (getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
109-
- // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
110-
- // This is most likely due to ad blockers
111-
- fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
112-
- this.impl = NullTelemetryService;
113-
- });
114141
+ const telemetryProvider: ITelemetryAppender | undefined = remoteAgentService.getConnection() !== null ? { log: remoteAgentService.logTelemetry.bind(remoteAgentService), flush: remoteAgentService.flushTelemetry.bind(remoteAgentService) } : productService.aiConfig?.ariaKey ? new OneDataSystemWebAppender(isInternal, 'monacoworkbench', null, productService.aiConfig?.ariaKey) : undefined;
115142
+ if (telemetryProvider) {
116143
+ appenders.push(telemetryProvider);
@@ -120,20 +147,19 @@ Index: code-server/lib/vscode/src/vs/workbench/services/telemetry/browser/teleme
120147
+ commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, isInternal, environmentService.remoteAuthority, productService.embedderIdentifier, productService.removeTelemetryMachineId, environmentService.options && environmentService.options.resolveCommonTelemetryProperties),
121148
+ sendErrorTelemetry: this.sendErrorTelemetry,
122149
+ };
123-
+ this.impl = this._register(new BaseTelemetryService(config, configurationService, productService));
124150
+
125-
+ if (remoteAgentService.getConnection() === null && getTelemetryLevel(configurationService) !== TelemetryLevel.NONE) {
126-
+ // If we cannot fetch the endpoint it means it is down and we should not send any telemetry.
127-
+ // This is most likely due to ad blockers
128-
+ fetch(telemetryEndpointUrl, { method: 'POST' }).catch(err => {
129-
+ this.impl = NullTelemetryService;
130-
+ });
131-
+ }
151+
+ return this._register(new BaseTelemetryService(config, configurationService, productService));
132152
+ } else {
133-
+ this.impl = NullTelemetryService;
134-
}
135-
} else {
136-
this.impl = NullTelemetryService;
153+
+ return this.impl;
154+
+ }
155+
156+
- return this._register(new BaseTelemetryService(config, configurationService, productService));
157+
}
158+
- return NullTelemetryService;
159+
+ return this.impl;
160+
}
161+
162+
setExperimentProperty(name: string, value: string): void {
137163
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
138164
===================================================================
139165
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts

0 commit comments

Comments
 (0)