From 9ab176f488f5da100984a005688f041d49e06bdb Mon Sep 17 00:00:00 2001 From: Benjamin Carlsson Date: Fri, 21 Aug 2026 05:29:08 +0000 Subject: [PATCH] Limit pending input preview wrapping work (#39864) ## Why Pending input previews display at most three wrapped rows, but previously wrapped every logical line before truncating the result. This made rendering do unnecessary work for very large multiline inputs. ## What changed Limit pending steers, rejected steers, and queued follow-up inputs to four source lines before wrapping: three for the preview and one to detect overflow and render the ellipsis. ## Testing Keep multiline preview coverage for queued messages and pending steers, including blank lines near the truncation boundary. GitOrigin-RevId: 4c300b13532983ff9c3bdfbd62d6ca722ea3a5aa --- .../src/bottom_pane/pending_input_preview.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/codex-rs/tui/src/bottom_pane/pending_input_preview.rs b/codex-rs/tui/src/bottom_pane/pending_input_preview.rs index e4a49a55a8..8700323cf6 100644 --- a/codex-rs/tui/src/bottom_pane/pending_input_preview.rs +++ b/codex-rs/tui/src/bottom_pane/pending_input_preview.rs @@ -100,7 +100,10 @@ impl PendingInputPreview { for steer in &self.pending_steers { let wrapped = adaptive_wrap_lines( - steer.lines().map(|line| Line::from(line.dim())), + steer + .lines() + .take(PREVIEW_LINE_LIMIT + 1) + .map(|line| Line::from(line.dim())), RtOptions::new(width as usize) .initial_indent(Line::from(" ↳ ".dim())) .subsequent_indent(Line::from(" ")), @@ -121,7 +124,10 @@ impl PendingInputPreview { for steer in &self.rejected_steers { let wrapped = adaptive_wrap_lines( - steer.lines().map(|line| Line::from(line.dim())), + steer + .lines() + .take(PREVIEW_LINE_LIMIT + 1) + .map(|line| Line::from(line.dim())), RtOptions::new(width as usize) .initial_indent(Line::from(" ↳ ".dim())) .subsequent_indent(Line::from(" ")), @@ -138,7 +144,10 @@ impl PendingInputPreview { for message in &self.queued_messages { let wrapped = adaptive_wrap_lines( - message.lines().map(|line| Line::from(line.dim().italic())), + message + .lines() + .take(PREVIEW_LINE_LIMIT + 1) + .map(|line| Line::from(line.dim().italic())), RtOptions::new(width as usize) .initial_indent(Line::from(" ↳ ".dim())) .subsequent_indent(Line::from(" ")), @@ -282,7 +291,7 @@ mod tests { let mut queue = PendingInputPreview::new(); queue .queued_messages - .push("This is\na message\nwith many\nlines".to_string()); + .push("This is\na message\nwith many\n\nlines".to_string()); let width = 40; let height = queue.desired_height(width); let mut buf = Buffer::empty(Rect::new(0, 0, width, height)); @@ -376,7 +385,7 @@ mod tests { let mut queue = PendingInputPreview::new(); queue .pending_steers - .push("First line\nSecond line\nThird line\nFourth line".to_string()); + .push("First line\nSecond line\nThird line\n\nFourth line".to_string()); let width = 48; let height = queue.desired_height(width); let mut buf = Buffer::empty(Rect::new(0, 0, width, height));