Fix Codex process spawning and health checks on Windows
- Run Codex-related child processes with `shell` on Windows for reliable command execution - Switch provider auth probe to `codex login status` and update health-check expectations - Use Node PTY on Windows instead of Bun PTY in server runtime setup
This commit is contained in:
1 parent
9db54c9b19
commit
0a12333448
7 files changed
+20
-37
No files matched your search
@@ -185,6 +185,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
...(codexHomePath ? { CODEX_HOME: codexHomePath } : {}),
|
||||
},
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
const output = readline.createInterface({ input: child.stdout });
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
|
||||
],
|
||||
{
|
||||
cwd,
|
||||
shell: process.platform === "win32",
|
||||
stdin: {
|
||||
stream: Stream.make(new TextEncoder().encode(prompt)),
|
||||
},
|
||||
|
||||
@@ -230,6 +230,7 @@ export const launchDetached = (launch: EditorLaunch) =>
|
||||
child = spawn(launch.command, [...launch.args], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
} catch (error) {
|
||||
return resume(
|
||||
|
||||
@@ -112,6 +112,7 @@ export async function runProcess(
|
||||
cwd: options.cwd,
|
||||
env: options.env,
|
||||
stdio: "pipe",
|
||||
shell: process.platform === "win32",
|
||||
});
|
||||
|
||||
let stdout = "";
|
||||
|
||||
@@ -22,8 +22,8 @@ describe("checkProviderStatusesOnStartup", () => {
|
||||
if (args.join(" ") === "--version") {
|
||||
return result({ stdout: "codex 1.0.0\n" });
|
||||
}
|
||||
if (args.join(" ") === "auth status --json") {
|
||||
return result({ stdout: '{"authenticated":true}\n' });
|
||||
if (args.join(" ") === "login status") {
|
||||
return result({ stdout: "Logged in\n" });
|
||||
}
|
||||
throw new Error(`Unexpected command: ${args.join(" ")}`);
|
||||
});
|
||||
@@ -59,7 +59,7 @@ describe("checkProviderStatusesOnStartup", () => {
|
||||
if (args.join(" ") === "--version") {
|
||||
return result({ stdout: "codex 1.0.0\n" });
|
||||
}
|
||||
if (args.join(" ") === "auth status --json") {
|
||||
if (args.join(" ") === "login status") {
|
||||
return result({
|
||||
code: 1,
|
||||
stderr: "Not logged in. Run codex login.",
|
||||
@@ -79,14 +79,15 @@ describe("checkProviderStatusesOnStartup", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns unauthenticated when auth probe JSON array includes authenticated=false", async () => {
|
||||
it("returns unauthenticated when login status output includes 'not logged in'", async () => {
|
||||
const status = await checkProviderStatusesOnStartup(async (_command, args) => {
|
||||
if (args.join(" ") === "--version") {
|
||||
return result({ stdout: "codex 1.0.0\n" });
|
||||
}
|
||||
if (args.join(" ") === "auth status --json") {
|
||||
if (args.join(" ") === "login status") {
|
||||
return result({
|
||||
stdout: '[{"authenticated":false}]\n',
|
||||
code: 1,
|
||||
stdout: "Not logged in\n",
|
||||
});
|
||||
}
|
||||
throw new Error(`Unexpected command: ${args.join(" ")}`);
|
||||
@@ -103,41 +104,15 @@ describe("checkProviderStatusesOnStartup", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns warning when auth probe JSON array has no auth marker", async () => {
|
||||
it("returns warning when login status command is unsupported", async () => {
|
||||
const status = await checkProviderStatusesOnStartup(async (_command, args) => {
|
||||
if (args.join(" ") === "--version") {
|
||||
return result({ stdout: "codex 1.0.0\n" });
|
||||
}
|
||||
if (args.join(" ") === "auth status --json") {
|
||||
return result({
|
||||
code: 0,
|
||||
stdout: '[{"ok":true}]\n',
|
||||
});
|
||||
}
|
||||
throw new Error(`Unexpected command: ${args.join(" ")}`);
|
||||
});
|
||||
|
||||
expect(status).toEqual([
|
||||
expect.objectContaining({
|
||||
provider: "codex",
|
||||
status: "warning",
|
||||
available: true,
|
||||
authStatus: "unknown",
|
||||
message:
|
||||
"Could not verify Codex authentication status from JSON output (missing auth marker).",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("returns warning when auth status command is unsupported", async () => {
|
||||
const status = await checkProviderStatusesOnStartup(async (_command, args) => {
|
||||
if (args.join(" ") === "--version") {
|
||||
return result({ stdout: "codex 1.0.0\n" });
|
||||
}
|
||||
if (args.join(" ") === "auth status --json") {
|
||||
if (args.join(" ") === "login status") {
|
||||
return result({
|
||||
code: 2,
|
||||
stderr: "error: unknown command 'auth'",
|
||||
stderr: "error: unknown command 'login'",
|
||||
});
|
||||
}
|
||||
throw new Error(`Unexpected command: ${args.join(" ")}`);
|
||||
|
||||
@@ -223,7 +223,7 @@ async function checkCodexProviderStatus(run: CommandRunner): Promise<ServerProvi
|
||||
}
|
||||
|
||||
try {
|
||||
const auth = await run("codex", ["auth", "status", "--json"], {
|
||||
const auth = await run("codex", ["login", "status"], {
|
||||
timeoutMs: DEFAULT_TIMEOUT_MS,
|
||||
allowNonZeroExit: true,
|
||||
outputMode: "truncate",
|
||||
|
||||
@@ -105,7 +105,11 @@ export function makeServerRuntimeServicesLayer() {
|
||||
);
|
||||
|
||||
const terminalLayer = TerminalManagerLive.pipe(
|
||||
Layer.provide(typeof Bun !== "undefined" ? BunPtyAdapterLive : NodePtyAdapterLive),
|
||||
Layer.provide(
|
||||
typeof Bun !== "undefined" && process.platform !== "win32"
|
||||
? BunPtyAdapterLive
|
||||
: NodePtyAdapterLive,
|
||||
),
|
||||
);
|
||||
|
||||
const gitManagerLayer = GitManagerLive.pipe(
|
||||
|
||||
Reference in new issue
Block a user