Skip to content

Commit 2103b64

Browse files
jonathandunnecode-asher
authored andcommitted
fix: apply --app-name to web page titles
1 parent 2114937 commit 2103b64

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

patches/app-name.diff

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Apply --app-name to VS Code web page titles
2+
3+
VS Code's `${appName}` title variable comes from `productService.nameLong` in the
4+
web client. code-server already injects per-request product configuration into
5+
VS Code's web bootstrap, so set `nameShort`/`nameLong` from the existing
6+
`--app-name` CLI arg there.
7+
8+
This keeps the patch minimal and makes browser tab titles honor `--app-name`
9+
without changing unrelated product metadata.
10+
11+
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
12+
===================================================================
13+
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
14+
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
15+
@@ -333,8 +333,11 @@ export class WebClientServer {
16+
scopes: [['user:email'], ['repo']]
17+
} : undefined;
18+
19+
+ const appName = this._environmentService.args['app-name'];
20+
const productConfiguration = {
21+
embedderIdentifier: 'server-distro',
22+
+ nameShort: appName,
23+
+ nameLong: appName,
24+
extensionsGallery: this._webExtensionResourceUrlTemplate && this._productService.extensionsGallery ? {
25+
...this._productService.extensionsGallery,
26+
resourceUrlTemplate: this._webExtensionResourceUrlTemplate.with({

patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ display-language.diff
2323
trusted-domains.diff
2424
signature-verification.diff
2525
copilot.diff
26+
app-name.diff

test/unit/node/routes/vscode.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,16 @@ describe("vscode", () => {
2727
})
2828
}).rejects.toThrow()
2929
})
30+
31+
it("should apply app-name to the VS Code product configuration", async () => {
32+
const appName = "testnäme"
33+
codeServer = await integration.setup(["--auth=none", `--app-name=${appName}`], "")
34+
35+
const resp = await codeServer.fetch("/vscode")
36+
const htmlContent = await resp.text()
37+
38+
expect(resp.status).toBe(200)
39+
expect(htmlContent).toContain(`\"nameShort\":\"${appName}\"`)
40+
expect(htmlContent).toContain(`\"nameLong\":\"${appName}\"`)
41+
})
3042
})

0 commit comments

Comments
 (0)