Lightweight coding agent that runs in your terminal
Rust
fix: ensure resume args precede image args (#10709)
cryptonerdcn1dc06b6ffcc8
diff --git a/sdk/typescript/src/exec.ts b/sdk/typescript/src/exec.tsindex d569106c84..6f8048e5e4 100644--- a/sdk/typescript/src/exec.ts+++ b/sdk/typescript/src/exec.ts@@ -115,16 +115,16 @@ export class CodexExec {commandArgs.push("--config", `approval_policy="${args.approvalPolicy}"`);}+ if (args.threadId) {+ commandArgs.push("resume", args.threadId);+ }+if (args.images?.length) {for (const image of args.images) {commandArgs.push("--image", image);}}- if (args.threadId) {- commandArgs.push("resume", args.threadId);- }-const env: Record<string, string> = {};if (this.envOverride) {Object.assign(env, this.envOverride);diff --git a/sdk/typescript/tests/exec.test.ts b/sdk/typescript/tests/exec.test.tsindex 9c4b6c2530..7ef52d72e1 100644--- a/sdk/typescript/tests/exec.test.ts+++ b/sdk/typescript/tests/exec.test.ts@@ -67,4 +67,30 @@ describe("CodexExec", () => {expect(result.error.message).toMatch(/Codex Exec exited/);}});++ it("places resume args before image args", async () => {+ const { CodexExec } = await import("../src/exec");+ spawnMock.mockClear();+ const child = new FakeChildProcess();+ spawnMock.mockReturnValue(child as unknown as child_process.ChildProcess);++ setImmediate(() => {+ child.stdout.end();+ child.stderr.end();+ child.emit("exit", 0, null);+ });++ const exec = new CodexExec("codex");+ for await (const _ of exec.run({ input: "hi", images: ["img.png"], threadId: "thread-id" })) {+ // no-op+ }++ const commandArgs = spawnMock.mock.calls[0]?.[1] as string[] | undefined;+ expect(commandArgs).toBeDefined();+ const resumeIndex = commandArgs!.indexOf("resume");+ const imageIndex = commandArgs!.indexOf("--image");+ expect(resumeIndex).toBeGreaterThan(-1);+ expect(imageIndex).toBeGreaterThan(-1);+ expect(resumeIndex).toBeLessThan(imageIndex);+ });});