Skip to content

Commit 9ff3bf4

Browse files
authored
Merge branch 'main' into helm-priorityClassName
2 parents 467437a + 19f486b commit 9ff3bf4

9 files changed

+133
-18
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/vscode

.prettierrc.yaml

-11
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,3 @@ trailingComma: all
44
arrowParens: always
55
singleQuote: false
66
useTabs: false
7-
8-
overrides:
9-
# Attempt to keep VScode's existing code style intact.
10-
- files: "lib/vscode/**/*.ts"
11-
options:
12-
# No limit defined upstream.
13-
printWidth: 10000
14-
semi: true
15-
singleQuote: true
16-
useTabs: true
17-
arrowParens: avoid

ci/steps/brew-bump.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ main() {
2323
# Find the docs for bump-formula-pr here
2424
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
2525
local output
26-
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit 2>&1); then
26+
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit --message="PR opened by @${GITHUB_ACTOR}" 2>&1); then
2727
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
2828
echo "$VERSION is already submitted"
2929
exit 0

docs/CONTRIBUTING.md

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
- [Version updates to Code](#version-updates-to-code)
1111
- [Patching Code](#patching-code)
1212
- [Build](#build)
13+
- [Troubleshooting](#troubleshooting)
14+
- [I see "Forbidden access" when I load code-server in the browser](#i-see-forbidden-access-when-i-load-code-server-in-the-browser)
15+
- ["Can only have one anonymous define call per script"](#can-only-have-one-anonymous-define-call-per-script)
1316
- [Help](#help)
1417
- [Test](#test)
1518
- [Unit tests](#unit-tests)
@@ -156,6 +159,18 @@ yarn package
156159
> If you need your builds to support older distros, run the build commands
157160
> inside a Docker container with all the build requirements installed.
158161
162+
### Troubleshooting
163+
164+
#### I see "Forbidden access" when I load code-server in the browser
165+
166+
This means your patches didn't apply correctly. We have a patch to remove the auth from vanilla Code because we use our own.
167+
168+
Try popping off the patches with `quilt pop -a` and reapplying with `quilt push -a`.
169+
170+
### "Can only have one anonymous define call per script"
171+
172+
Code might be trying to use a dev or prod HTML in the wrong context. You can try re-running code-server and setting `VSCODE_DEV=1`.
173+
159174
### Help
160175

161176
If you get stuck or need help, you can always start a new GitHub Discussion [here](https://github.com/coder/code-server/discussions). One of the maintainers will respond and help you out.

patches/base-path.diff

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
8686
<link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">
8787

8888
</head>
89+
@@ -38,7 +38,7 @@
90+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
91+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
92+
<script>
93+
- const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
94+
+ const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
95+
Object.keys(self.webPackagePaths).map(function (key, index) {
96+
self.webPackagePaths[key] = `${baseUrl}/node_modules/${key}/${self.webPackagePaths[key]}`;
97+
});
8998
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
9099
===================================================================
91100
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts

patches/cli-window-open.diff

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Make opening files/folders from the terminal only open in the current instance
2+
3+
Previously they would open in every code-server tab/window.
4+
5+
To test:
6+
7+
1. Run code-server
8+
2. Open code-server
9+
3. Open terminal
10+
4. Open another code-server window
11+
5. Run code-server with a file or directory argument
12+
13+
The file or directory should only open from the instance attached to that
14+
terminal.
15+
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+
@@ -240,20 +240,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+
@@ -276,6 +276,7 @@ export class RemoteTerminalChannel exten
56+
});
57+
this._onExecuteCommand.fire({
58+
reqId,
59+
+ terminalId,
60+
commandId,
61+
commandArgs: serializedCommandArgs
62+
});
63+
Index: code-server/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
64+
===================================================================
65+
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts
66+
+++ 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 => {
69+
const reqId = e.reqId;
70+
const commandId = e.commandId;
71+
+ const terminalId = e.terminalId;
72+
if (!allowedCommands.includes(commandId)) {
73+
this._remoteTerminalChannel.sendCommandResult(reqId, true, 'Invalid remote cli command: ' + commandId);
74+
return;
75+
}
76+
+ if (typeof terminalId !== "undefined" && !this._ptys.has(terminalId)) {
77+
+ return
78+
+ }
79+
const commandArgs = e.commandArgs.map(arg => revive(arg));
80+
try {
81+
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/display-language.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
9191
+ return cb(undefined, result)
9292
+ }
9393
+ const path = nlsConfig['vs/nls']._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
94-
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/vscode-remote-resource?path=${encodeURIComponent(path)}`)
94+
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/../vscode-remote-resource?path=${encodeURIComponent(path)}`)
9595
+ .then((response) => response.json())
9696
+ .then((json) => {
9797
+ bundles[bundle] = json

patches/series

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ sourcemaps.diff
1919
disable-downloads.diff
2020
telemetry.diff
2121
display-language.diff
22+
cli-window-open.diff

src/node/wrapper.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,18 @@ export class ParentProcess extends Process {
292292
const child = this.spawn()
293293
this.child = child
294294

295-
// Log both to stdout and to the log directory.
295+
// Log child output to stdout/stderr and to the log directory.
296296
if (child.stdout) {
297-
child.stdout.pipe(this.logStdoutStream)
298-
child.stdout.pipe(process.stdout)
297+
child.stdout.on("data", (data) => {
298+
this.logStdoutStream.write(data)
299+
process.stdout.write(data)
300+
})
299301
}
300302
if (child.stderr) {
301-
child.stderr.pipe(this.logStderrStream)
302-
child.stderr.pipe(process.stderr)
303+
child.stderr.on("data", (data) => {
304+
this.logStderrStream.write(data)
305+
process.stderr.write(data)
306+
})
303307
}
304308

305309
this.logger.debug(`spawned inner process ${child.pid}`)

0 commit comments

Comments
 (0)