@devries-cameron20 / t3code Mirror · read-only / commits / b0b7b38da1
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 05:00 UTC

fix(server): detect localized Windows command errors (#2152)

Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>

Raul Pereira da Silva committed Apr 23, 2026 at 01:42 UTC b0b7b38da1dc4b19833d13f84eb907b1e2adfb63
2 files changed +33 -2
apps/server/src/processRunner.test.ts
+19 -1
@@ -1,6 +1,6 @@
1 import { describe, expect, it } from "vitest";
2
3 -import { runProcess } from "./processRunner.ts";
3 +import { isWindowsCommandNotFound, runProcess } from "./processRunner.ts";
4
5 describe("runProcess", () => {
6 it("fails when output exceeds max buffer in default mode", async () => {
@@ -21,3 +21,21 @@ describe("runProcess", () => {
21 expect(result.stderrTruncated).toBe(false);
22 });
23 });
24 +
25 +describe("isWindowsCommandNotFound", () => {
26 + it("matches the localized German cmd.exe error text", () => {
27 + const originalPlatform = process.platform;
28 + Object.defineProperty(process, "platform", { value: "win32", configurable: true });
29 +
30 + try {
31 + expect(
32 + isWindowsCommandNotFound(
33 + 1,
34 + "wird nicht als interner oder externer Befehl, betriebsfahiges Programm oder Batch-Datei erkannt",
35 + ),
36 + ).toBe(true);
37 + } finally {
38 + Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });
39 + }
40 + });
41 +});
apps/server/src/processRunner.ts
+14 -1
@@ -37,10 +37,23 @@ function normalizeSpawnError(command: string, args: readonly string[], error: un
37 return new Error(`Failed to run ${commandLabel(command, args)}: ${error.message}`);
38 }
39
40 +const WINDOWS_COMMAND_NOT_FOUND_PATTERNS = [
41 + /is not recognized as an internal or external command/i,
42 + /n.o . reconhecido como um comando interno/i,
43 + /non . riconosciuto come comando interno o esterno/i,
44 + /n.est pas reconnu en tant que commande interne/i,
45 + /no se reconoce como un comando interno o externo/i,
46 + /wird nicht als interner oder externer befehl/i,
47 +] as const;
48 +
49 +function hasWindowsCommandNotFoundMessage(output: string): boolean {
50 + return WINDOWS_COMMAND_NOT_FOUND_PATTERNS.some((pattern) => pattern.test(output));
51 +}
52 +
53 export function isWindowsCommandNotFound(code: number | null, stderr: string): boolean {
54 if (process.platform !== "win32") return false;
55 if (code === 9009) return true;
43 - return /is not recognized as an internal or external command/i.test(stderr);
56 + return hasWindowsCommandNotFoundMessage(stderr);
57 }
58
59 function normalizeExitError(