Lightweight coding agent that runs in your terminal
Rust
tui: reserve 1 cell right margin for composer and user history (#5026)
Jeremy Rose9be704a934fb
diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rsindex 5b63a410bb..0d1395d51d 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs@@ -165,8 +165,9 @@ impl ChatComposer {.unwrap_or_else(|| footer_height(footer_props));let footer_spacing = Self::footer_spacing(footer_hint_height);let footer_total_height = footer_hint_height + footer_spacing;+ const COLS_WITH_MARGIN: u16 = LIVE_PREFIX_COLS + 1;self.textarea- .desired_height(width.saturating_sub(LIVE_PREFIX_COLS))+ .desired_height(width.saturating_sub(COLS_WITH_MARGIN))+ 2+ match &self.active_popup {ActivePopup::None => footer_total_height,@@ -197,7 +198,9 @@ impl ChatComposer {let [composer_rect, popup_rect] =Layout::vertical([Constraint::Min(1), popup_constraint]).areas(area);let mut textarea_rect = composer_rect;- textarea_rect.width = textarea_rect.width.saturating_sub(LIVE_PREFIX_COLS);+ textarea_rect.width = textarea_rect.width.saturating_sub(+ LIVE_PREFIX_COLS + 1, /* keep a one-column right margin for wrapping */+ );textarea_rect.x = textarea_rect.x.saturating_add(LIVE_PREFIX_COLS);[composer_rect, textarea_rect, popup_rect]}diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_1.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_1.snapindex 310c32b40c..52f96e8557 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_1.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_1.snap@@ -2,4 +2,4 @@source: tui/src/bottom_pane/mod.rsexpression: "render_snapshot(&pane, area1)"----› Ask Codex to do an+› Ask Codex to do adiff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_2.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_2.snapindex ea0beeedf3..964bf7ed87 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_2.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__status_hidden_when_height_too_small_height_2.snap@@ -3,4 +3,4 @@ source: tui/src/bottom_pane/mod.rsexpression: "render_snapshot(&pane, area2)"----› Ask Codex to do an+› Ask Codex to do adiff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rsindex 2cc0c3fd9e..fe37d5fa09 100644--- a/codex-rs/tui/src/history_cell.rs+++ b/codex-rs/tui/src/history_cell.rs@@ -114,7 +114,11 @@ impl HistoryCell for UserHistoryCell {fn display_lines(&self, width: u16) -> Vec<Line<'static>> {let mut lines: Vec<Line<'static>> = Vec::new();- let wrap_width = width.saturating_sub(LIVE_PREFIX_COLS);+ let wrap_width = width+ .saturating_sub(+ LIVE_PREFIX_COLS + 1, /* keep a one-column right margin for wrapping */+ )+ .max(1);let style = user_message_style();@@ -125,7 +129,8 @@ impl HistoryCell for UserHistoryCell {.map(|l| Line::from(l).style(style)).collect::<Vec<_>>(),// Wrap algorithm matches textarea.rs.- RtOptions::new(wrap_width as usize).wrap_algorithm(textwrap::WrapAlgorithm::FirstFit),+ RtOptions::new(usize::from(wrap_width))+ .wrap_algorithm(textwrap::WrapAlgorithm::FirstFit),);lines.push(Line::from("").style(style));diff --git a/codex-rs/tui/src/snapshots/codex_tui__history_cell__tests__user_history_cell_wraps_and_prefixes_each_line_snapshot.snap b/codex-rs/tui/src/snapshots/codex_tui__history_cell__tests__user_history_cell_wraps_and_prefixes_each_line_snapshot.snapindex 3fd59095ce..9870dddb06 100644--- a/codex-rs/tui/src/snapshots/codex_tui__history_cell__tests__user_history_cell_wraps_and_prefixes_each_line_snapshot.snap+++ b/codex-rs/tui/src/snapshots/codex_tui__history_cell__tests__user_history_cell_wraps_and_prefixes_each_line_snapshot.snap@@ -3,6 +3,6 @@ source: tui/src/history_cell.rsexpression: rendered---› one two- three four- five six- seven+ three+ four five+ six seven