@devries-cameron20 / t3code-1 / commits / 69f8f59b51
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Windows PowerShell terminal reads native UTF-8 output correctly (#37376)

Julius Marminge committed Nov 15, 2026 at 15:00 UTC 69f8f59b5185d892d4df612df1f7eca8671fcc03
2 files changed +14 -4
apps/server/src/terminal/Manager.test.ts
+9 -3
@@ -61,6 +61,12 @@ vi.mock("effect/SynchronizedRef", async (importOriginal) => {
61
62 // The server omits DOM types, which include TypeScript's WebAssembly declarations.
63
64 +const POWERSHELL_ARGS = [
65 + "-NoLogo",
66 + "-NoExit",
67 + "-Command",
68 + "[Console]::OutputEncoding = $OutputEncoding = [System.Text.UTF8Encoding]::new()",
69 +];
70 const encodeUnknownJson = Schema.encodeUnknownSync(Schema.fromJsonString(Schema.Unknown));
71
72 class FakePtyProcess implements PtyAdapter.PtyProcess {
@@ -2295,8 +2301,8 @@ it.layer(
2301 "pwsh.exe",
2302 "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
2303 ]);
2298 - expect(ptyAdapter.spawnInputs[1]?.args).toEqual(["-NoLogo"]);
2299 - expect(ptyAdapter.spawnInputs[2]?.args).toEqual(["-NoLogo"]);
2304 + expect(ptyAdapter.spawnInputs[1]?.args).toEqual(POWERSHELL_ARGS);
2305 + expect(ptyAdapter.spawnInputs[2]?.args).toEqual(POWERSHELL_ARGS);
2306 }),
2307 );
2308
@@ -2733,7 +2739,7 @@ it.layer(
2739 ["win32", "C:\\Program Files\\Git\\bin\\bash.exe", undefined],
2740 ["darwin", "/bin/zsh", ["-o", "nopromptsp"]],
2741 ["linux", "/bin/zsh", ["-o", "nopromptsp"]],
2736 - ["win32", "pwsh.exe", ["-NoLogo"]],
2742 + ["win32", "pwsh.exe", POWERSHELL_ARGS],
2743 ] as const) {
2744 const { manager, ptyAdapter } = yield* createManager(5, {
2745 shellResolver: () => shell,
apps/server/src/terminal/Manager.ts
+5 -1
@@ -588,6 +588,10 @@ function joinWindowsPath(...parts: ReadonlyArray<string>): string {
588 .join("\\");
589 }
590
591 +// PowerShell decodes native output with the console code page (often OEM 437), mangling UTF-8.
592 +const POWERSHELL_UTF8_SETUP =
593 + "[Console]::OutputEncoding = $OutputEncoding = [System.Text.UTF8Encoding]::new()";
594 +
595 function shellCandidateFromCommand(
596 command: string | null,
597 platform: NodeJS.Platform,
@@ -595,7 +599,7 @@ function shellCandidateFromCommand(
599 if (!command || command.length === 0) return null;
600 const shellName = basenameForPlatform(command, platform).toLowerCase();
601 if (platform === "win32" && (shellName === "pwsh.exe" || shellName === "powershell.exe")) {
598 - return { shell: command, args: ["-NoLogo"] };
602 + return { shell: command, args: ["-NoLogo", "-NoExit", "-Command", POWERSHELL_UTF8_SETUP] };
603 }
604 if (platform !== "win32" && shellName === "zsh") {
605 return { shell: command, args: ["-o", "nopromptsp"] };