Skip to content

Commit 2cefa37

Browse files
committed
fix: wrap long exec lines in transcript overlay (#7454)
1 parent de08c73 commit 2cefa37

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

codex-rs/tui/src/exec_cell/render.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ impl HistoryCell for ExecCell {
219219

220220
if let Some(output) = call.output.as_ref() {
221221
if !call.is_unified_exec_interaction() {
222-
lines.extend(output.formatted_output.lines().map(ansi_escape_line));
222+
let wrap_width = width.max(1) as usize;
223+
let wrap_opts = RtOptions::new(wrap_width);
224+
for unwrapped in output.formatted_output.lines().map(ansi_escape_line) {
225+
let wrapped = word_wrap_line(&unwrapped, wrap_opts.clone());
226+
push_owned_lines(&wrapped, &mut lines);
227+
}
223228
}
224229
let duration = call
225230
.duration

codex-rs/tui/src/pager_overlay.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,49 @@ mod tests {
748748
assert_snapshot!("transcript_overlay_apply_patch_scroll_vt100", snapshot);
749749
}
750750

751+
#[test]
752+
fn transcript_overlay_wraps_long_exec_output_lines() {
753+
let marker = "Z";
754+
let long_line = marker.repeat(200);
755+
756+
let mut exec_cell = crate::exec_cell::new_active_exec_command(
757+
"exec-long".into(),
758+
vec!["bash".into(), "-lc".into(), "echo long".into()],
759+
vec![ParsedCommand::Unknown {
760+
cmd: "echo long".into(),
761+
}],
762+
ExecCommandSource::Agent,
763+
None,
764+
false,
765+
);
766+
exec_cell.complete_call(
767+
"exec-long",
768+
CommandOutput {
769+
exit_code: 0,
770+
aggregated_output: format!("{long_line}\n"),
771+
formatted_output: long_line,
772+
},
773+
Duration::from_millis(10),
774+
);
775+
let exec_cell: Arc<dyn HistoryCell> = Arc::new(exec_cell);
776+
777+
let mut overlay = TranscriptOverlay::new(vec![exec_cell]);
778+
let area = Rect::new(0, 0, 20, 10);
779+
let mut buf = Buffer::empty(area);
780+
781+
overlay.render(area, &mut buf);
782+
let rendered = buffer_to_text(&buf, area);
783+
784+
let wrapped_lines = rendered
785+
.lines()
786+
.filter(|line| line.contains(marker))
787+
.count();
788+
assert!(
789+
wrapped_lines >= 2,
790+
"expected long exec output to wrap into multiple lines in transcript overlay, got:\n{rendered}"
791+
);
792+
}
793+
751794
#[test]
752795
fn transcript_overlay_keeps_scroll_pinned_at_bottom() {
753796
let mut overlay = TranscriptOverlay::new(

0 commit comments

Comments
 (0)