Skip to content

fix(native-chat): list each file in a counted Codex diff - #48033

Closed
bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/48025-multifile-apply-patch-summary
Closed

bbingz wants to merge 2 commits into
stablyai:mainfrom
bbingz:fix/48025-multifile-apply-patch-summary

Conversation

@bbingz

@bbingz bbingz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

ELI5

When Codex edits two files in one step, the finished chat turn now lists both files. Before, that turn showed no changed-files summary at all.

What Changed

Before: a completed multi-file Codex edit was saved as one diff labeled 2 files, with the real names kept beside it. The chat summary only read the label, treated it as "not a file," and showed nothing.

After: the summary reads that file list and splits the joined diff on the blank line between files. One file's own hunks stay together. a.txt and b.txt show up with their own add/remove counts. A 2 files diff that has no file list still shows no card.

Why

The names were already on the journal row. Pairing hunks by count would attach a cut file's later hunk to the next path, so the split only accepts a blank line between files, which is what joining those diffs produces.

Linked Issue

Fixes #48025

Visual Proof

N/A. This is text in the completed-turn summary, not a layout change. I did not launch Orca. The unit test checks the file names and the +2 -2 / +1 -1 counts.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

src/shared/native-chat/tools/native-chat-file-count-diff.test.ts failed before the fix (files was undefined) and passed after it. Neighbor agent-message-preview-line.test.ts passed (12 tests total).

Also ran oxlint, oxfmt --check, and check-changed-code-quality.mjs --base origin/main (0 new findings). pnpm tc:web exited 0.

Did not run full pnpm lint, full pnpm test, pnpm build, or a live Codex chat.

Performance

None, because this only parses a completed multi-file diff when the turn summary is built. A one-file edit is unchanged.

Risk

Level: Low

A joined diff whose blank lines do not match the file list still shows no summary, which is the old behavior. A wrong split would list a hunk under the wrong name; the split refuses that shape. Revert the two commits to restore the missing summary. No saved data, wire, or platform branch changes.

AI Disclosure

Authored by Cursor Agent (Grok 4.7). Independent review: magpie-remote did not respond (HTTP 000), so OpenAI Codex via codex exec read-only reviewed the branch. Round 1 found findings and the split was tightened. Round 2 on 0fd79c82786 reported no actionable findings.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Open #42271 also touches codex-structured-item-translation.ts for review-mode items. This PR does not edit that file.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

A multi-file edit was stored as "N files" plus the real paths, but the summary dropped that list and rendered no changed files.
Matching hunk counts can assign a truncated file's later hunk to the next path, and a file-count label with no paths list still must not invent cards.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The diff projection now includes nonempty action paths. Native chat filters those paths and passes multiple valid paths to the patch parser. The parser splits a joined patch when the number of nonempty diff parts matches the number of paths, then parses each part. A test checks that the resulting summaries contain separate paths and change counts for two files.

Severity of issue fixed: Medium

Merge Risk: Low · up to 0fd79

Multi-file Codex patch summaries now list each file, but a rename on the last file would be shown as a plain edit. This is a small display issue that is easy to fix before or shortly after merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change and its scope: a counted Codex diff now lists each file in native chat. It matches the main change in the summary, which splits a multi-file Codex diff by its path list. It …
Description check Passed The description follows the template and fills most sections. It covers ELI5, What Changed, Why, a linked issue (Fixes #48025), Visual Proof (N/A with reason), Testing, Performance, Risk with level, A…
Linked Issues check Passed Issue #48025 requires a completed Native Chat turn to list a.txt and b.txt with +1 -1 each when one apply_patch updates both files. At the reviewed head, editFilesFromPatchText no longer returns null …
Out of Scope Changes check Passed All changed files serve the objective of #48025. The native-chat-edit-patch-files.ts change adds the counted-path split and the summary-only and truncation handling for it. The native-chat-edit-normal…
Full details: Title check

Explanation

The title names the change and its scope: a counted Codex diff now lists each file in native chat. It matches the main change in the summary, which splits a multi-file Codex diff by its path list. It uses the conventional commit form and avoids vague terms.

Full details: Description check

Explanation

The description follows the template and fills most sections. It covers ELI5, What Changed, Why, a linked issue (Fixes #48025), Visual Proof (N/A with reason), Testing, Performance, Risk with level, AI Disclosure, and the upstream boundary checkbox. Required gaps remain: the Testing checklist leaves the manual-test box unchecked, and the Performance section is one line that is acceptable. The final checklist item for lint, typecheck, test, and build is unchecked, though the author lists which checks ran. The Ensure-no-issues Notes section is template text. The description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #48025 requires a completed Native Chat turn to list a.txt and b.txt with +1 -1 each when one apply_patch updates both files. At the reviewed head, editFilesFromPatchText no longer returns null for a file-count path when countedPaths has at least two entries. filesForFileCountPath splits the joined diff with splitCountedFileDiffs. The split accepts only when the number of blank-line-separated parts equals paths.length, then pairs each part with its path and parses it as a single-file diff. editFilesFromToolPair passes input.paths through countedFilePaths, and the structured tool-call projection now forwards paths when present. The author reports that native-chat-file-count-diff.test.ts fails before the fix and passes after it, and that it asserts the names a.txt and b.txt with +2 -2 and +1 -1 counts. The two-call control path produces one-path diffs and is unchanged. Limitation: I did not run the test suite. The result relies on the diff-level code reading and the author's reported test results. The split depends on join('\n') producing a blank line between per-file diffs, which the code comment states.

Full details: Out of Scope Changes check

Explanation

All changed files serve the objective of #48025. The native-chat-edit-patch-files.ts change adds the counted-path split and the summary-only and truncation handling for it. The native-chat-edit-normalize.ts change forwards input.paths as countedPaths. The structured-agent-session-tool-call-block.ts change projects paths into the Diff tool-call input, which the normalizer needs. The test file covers the new behavior. No unrelated change was found. The PR description notes that the related open PR #42271 is not edited here, and no edits to codex-structured-item-translation.ts appear in the reviewed summary.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 28439c7c-141f-4f09-bdf6-36ba6d024c2d
Commits

Reviewing files that changed from the base of the PR and between f124b4b and 0fd79c8.

Files selected for processing: 4

  • src/shared/agent-session/view/messages/structured-agent-session-tool-call-block.ts
  • src/shared/native-chat/tools/native-chat-edit-normalize.ts
  • src/shared/native-chat/tools/native-chat-edit-patch-files.ts
  • src/shared/native-chat/tools/native-chat-file-count-diff.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

summaryOnly: boolean
): NativeChatEditFileSummary[] | null {
const bounded = stripBoundedTextMarker(patchText)
const body = splitMoveMarker(bounded.text).body

@coderabbitai coderabbitai Bot Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Preserve the final file's move marker.

If the second file's diff ends with Moved to: c.txt, this call removes the marker and discards movedTo. With paths ["a.txt", "b.txt"], recursive parsing then reports b.txt as edited instead of reporting its rename to c.txt.

Split bounded.text without removing the move marker. Let each recursive parser process its own marker. Ordinary updates will retain the same splitting behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gap is real on 0fd79c82786: filesForFileCountPath strips a final Moved to from the whole payload, so the last file stays an edit.

A local follow-up, e8144ebea4a, leaves that marker on the last blank-line part. I am not pushing it. #48038 is now open on the same issue and edits this same parser with a different split.

@bbingz

bbingz commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Fork verification for 0fd79c82786 finished.

unit full on bbingz/orca run https://github.com/bbingz/orca/actions/runs/45324149115 concluded success (24/24 Node 24 shards, typecheck, static analysis, code quality, and ratchets passed; e2e was skipped). Closing verification PR bbingz#86.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @bbingz for digging into this and for the fix! We landed the change for #48025 through #48038, which adds git headers per file on the Codex side, so the client never has to split on blank lines (add or delete content that contains blank lines could otherwise split in the wrong place). Your idea of carrying body.paths into the Diff call is in there too, as the check that the files match, and you're credited as a co-author on the commit. Closing this one in favor of #48038.

@nwparker nwparker closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex Native Chat omits the changed-files summary for a multi-file apply_patch

2 participants