Skip to content

collectTouchedFiles includes failed/declined fileChange items and omits move_path destinations #846

Open

Description

@adityajai119

Summary

collectTouchedFiles in plugins/codex/scripts/lib/codex.mjs derives touchedFiles (exposed by task --json and stored in jobs/<id>.json) from turnState.fileChanges. Currently it iterates over every completed fileChange notification item without checking fileChange.status, and only reads change.path.

Per the generated codex app-server v2 types (v2/ThreadItem.ts, v2/PatchApplyStatus.ts, v2/PatchChangeKind.ts):

  • fileChange.status is "inProgress" | "completed" | "failed" | "declined". When a patch fails to apply or is declined by sandbox/approval policy, item/completed still fires with status: "failed" or status: "declined", and collectTouchedFiles falsely reports those untouched paths in touchedFiles.
  • change.kind for moved/renamed files is { type: "update", move_path: string | null }. collectTouchedFiles records the old change.path but drops change.kind.move_path.

Reproduction

  1. Run codex-companion.mjs task --write --json against an app-server turn that emits:
    • an item/completed fileChange with status: "declined" or status: "failed" for src/untouched.js, and
    • an item/completed fileChange with status: "completed" and changes: [{ path: "src/old.js", kind: { type: "update", move_path: "src/new.js" }, diff: "" }].
  2. Inspect touchedFiles in the JSON output.

Actual

touchedFiles contains ["src/untouched.js", "src/old.js"] (includes the failed/declined patch target and omits "src/new.js").

Expected

touchedFiles should include only paths from fileChange items with status === "completed", and include change.kind.move_path when an update moves/renames a file (["src/old.js", "src/new.js"]).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions