diff --git a/patches/app-name.diff b/patches/app-name.diff new file mode 100644 index 000000000000..5675d1646098 --- /dev/null +++ b/patches/app-name.diff @@ -0,0 +1,46 @@ +Apply --app-name to VS Code web page titles + +VS Code's `${appName}` title variable comes from `productService.nameLong` in the +web client. code-server already injects per-request product configuration into +VS Code's web bootstrap, so set `nameShort`/`nameLong` from the existing +`--app-name` CLI arg there. + +This keeps the patch minimal and makes browser tab titles honor `--app-name` +without changing unrelated product metadata. + +Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts ++++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts +@@ -24,6 +24,7 @@ export const serverOptions: OptionDescri + 'disable-getting-started-override': { type: 'boolean' }, + 'locale': { type: 'string' }, + 'link-protection-trusted-domains': { type: 'string[]' }, ++ 'app-name': { type: 'string' }, + + /* ----- server setup ----- */ + +@@ -120,6 +121,7 @@ export interface ServerParsedArgs { + 'disable-getting-started-override'?: boolean, + 'locale'?: string + 'link-protection-trusted-domains'?: string[], ++ 'app-name'?: string, + + /* ----- server setup ----- */ + +Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts +=================================================================== +--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts ++++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts +@@ -366,8 +366,11 @@ export class WebClientServer { + linkProtectionTrustedDomains.push(...this._productService.linkProtectionTrustedDomains); + } + ++ const appName = this._environmentService.args['app-name']; + const productConfiguration: Partial> = { + codeServerVersion: this._productService.codeServerVersion, ++ nameShort: appName, ++ nameLong: appName, + rootEndpoint: rootBase, + updateEndpoint: !this._environmentService.args['disable-update-check'] ? rootBase + '/update/check' : undefined, + logoutEndpoint: this._environmentService.args['auth'] && this._environmentService.args['auth'] !== "none" ? rootBase + '/logout' : undefined, diff --git a/patches/series b/patches/series index 3935786a69b6..6f438da313bf 100644 --- a/patches/series +++ b/patches/series @@ -23,3 +23,4 @@ display-language.diff trusted-domains.diff signature-verification.diff copilot.diff +app-name.diff diff --git a/test/unit/node/routes/vscode.test.ts b/test/unit/node/routes/vscode.test.ts index a5a4fb72da7a..5ae1827f630a 100644 --- a/test/unit/node/routes/vscode.test.ts +++ b/test/unit/node/routes/vscode.test.ts @@ -27,4 +27,16 @@ describe("vscode", () => { }) }).rejects.toThrow() }) + + it("should apply app-name to the VS Code product configuration", async () => { + const appName = "testnäme" + codeServer = await integration.setup(["--auth=none", `--app-name=${appName}`], "") + + const resp = await codeServer.fetch("/vscode") + const htmlContent = await resp.text() + + expect(resp.status).toBe(200) + expect(htmlContent).toContain(`"nameShort":"${appName}"`) + expect(htmlContent).toContain(`"nameLong":"${appName}"`) + }) })