Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/codex/scripts/lib/codex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@ function describeStartedItem(state, item) {
phase: looksLikeVerificationCommand(item.command) ? "verifying" : "running"
};
case "fileChange":
return { message: `Applying ${item.changes.length} file change(s).`, phase: "editing" };
return {
message: `Applying ${Array.isArray(item.changes) ? item.changes.length : 0} file change(s).`,
phase: "editing"
};
case "mcpToolCall":
return { message: `Calling ${item.server}/${item.tool}.`, phase: "investigating" };
case "dynamicToolCall":
Expand Down
7 changes: 7 additions & 0 deletions tests/fake-codex-fixture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,13 @@ rl.on("line", (line) => {
}

const items = [
...(BEHAVIOR === "file-change-started-without-changes"
? [
{
started: { type: "fileChange", id: "fc_" + turnId }
}
]
: []),
...(BEHAVIOR === "with-reasoning"
? [
{
Expand Down
19 changes: 19 additions & 0 deletions tests/runtime.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ test("task runs when the active provider does not require OpenAI login", () => {
assert.match(result.stdout, /Handled the requested task/);
});

test("task survives fileChange started items that omit changes", () => {
const repo = makeTempDir();
const binDir = makeTempDir();
installFakeCodex(binDir, "file-change-started-without-changes");
initGitRepo(repo);
fs.writeFileSync(path.join(repo, "README.md"), "hello\n");
run("git", ["add", "README.md"], { cwd: repo });
run("git", ["commit", "-m", "init"], { cwd: repo });

const result = run("node", [SCRIPT, "task", "apply the patch"], {
cwd: repo,
env: buildEnv(binDir)
});

assert.equal(result.status, 0, result.stderr);
assert.match(result.stdout, /Handled the requested task/);
assert.doesNotMatch(result.stderr, /Cannot read properties of undefined/);
});

test("task runs without auth preflight so Codex can refresh an expired session", () => {
const repo = makeTempDir();
const binDir = makeTempDir();
Expand Down