Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix apply patch when only one file is rendered (#2468)

Ahmed Ibrahim0d6678936f83
diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs
index c7e9ad5b03..3bb5d42f9f 100644
--- a/codex-rs/tui/src/chatwidget/tests.rs
+++ b/codex-rs/tui/src/chatwidget/tests.rs
@@ -695,7 +695,7 @@ fn apply_patch_request_shows_diff_summary() {
// Per-file summary line should include the file path and counts
assert!(
- blob.contains("README.md (+2 -0)"),
+ blob.contains("README.md"),
"missing per-file diff summary: {blob:?}"
);
}
diff --git a/codex-rs/tui/src/diff_render.rs b/codex-rs/tui/src/diff_render.rs
index 24efefef46..aaa7617d91 100644
--- a/codex-rs/tui/src/diff_render.rs
+++ b/codex-rs/tui/src/diff_render.rs
@@ -130,17 +130,20 @@ pub(crate) fn create_diff_summary(
for (idx, f) in files.iter().enumerate() {
let mut spans: Vec<RtSpan<'static>> = Vec::new();
spans.push(RtSpan::raw(f.display_path.clone()));
- spans.push(RtSpan::raw(" ("));
- spans.push(RtSpan::styled(
- format!("+{}", f.added),
- Style::default().fg(Color::Green),
- ));
- spans.push(RtSpan::raw(" "));
- spans.push(RtSpan::styled(
- format!("-{}", f.removed),
- Style::default().fg(Color::Red),
- ));
- spans.push(RtSpan::raw(")"));
+ // Show per-file +/- counts only when there are multiple files
+ if file_count > 1 {
+ spans.push(RtSpan::raw(" ("));
+ spans.push(RtSpan::styled(
+ format!("+{}", f.added),
+ Style::default().fg(Color::Green),
+ ));
+ spans.push(RtSpan::raw(" "));
+ spans.push(RtSpan::styled(
+ format!("-{}", f.removed),
+ Style::default().fg(Color::Red),
+ ));
+ spans.push(RtSpan::raw(")"));
+ }
let mut line = RtLine::from(spans);
let prefix = if idx == 0 { " └ " } else { " " };
diff --git a/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__add_details.snap b/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__add_details.snap
index f86d2fb93a..143113fb68 100644
--- a/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__add_details.snap
+++ b/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__add_details.snap
@@ -3,7 +3,7 @@ source: tui/src/diff_render.rs
expression: terminal.backend()
---
"proposed patch to 1 file (+2 -0) "
-" └ README.md (+2 -0) "
+" └ README.md "
" 1 +first line "
" 2 +second line "
" "
diff --git a/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__update_details_with_rename.snap b/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__update_details_with_rename.snap
index 76151409ef..9a73c0c32b 100644
--- a/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__update_details_with_rename.snap
+++ b/codex-rs/tui/src/snapshots/codex_tui__diff_render__tests__update_details_with_rename.snap
@@ -4,7 +4,7 @@ assertion_line: 380
expression: terminal.backend()
---
"proposed patch to 1 file (+1 -1) "
-" └ src/lib.rs → src/lib_new.rs (+1 -1) "
+" └ src/lib.rs → src/lib_new.rs "
" 1 line one "
" 2 -line two "
" 2 +line two changed "