Lightweight coding agent that runs in your terminal
Rust
Clamp session headers to narrow terminal widths (#34775)
Eric Traut730ec920032b
diff --git a/codex-rs/tui/src/history_cell/session.rs b/codex-rs/tui/src/history_cell/session.rsindex 695efc30f9..b4a2ca050d 100644--- a/codex-rs/tui/src/history_cell/session.rs+++ b/codex-rs/tui/src/history_cell/session.rs@@ -1,6 +1,7 @@//! Session headers, onboarding guidance, and transcript cards.use super::*;+use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;pub(crate) const SESSION_HEADER_MAX_INNER_WIDTH: usize = 56; // Just an eyeballed value@@ -390,6 +391,10 @@ impl HistoryCell for SessionHeaderHistoryCell {]));}+ let lines = lines+ .into_iter()+ .map(|line| truncate_line_with_ellipsis_if_overflow(line, inner_width))+ .collect();with_border(lines)}diff --git a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__session_header_clamps_to_narrow_width.snap b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__session_header_clamps_to_narrow_width.snapnew file mode 100644index 0000000000..2baf486e51--- /dev/null+++ b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__session_header_clamps_to_narrow_width.snap@@ -0,0 +1,11 @@+---+source: tui/src/history_cell/tests.rs+expression: "render_lines(&lines).join(\"\\n\")"+---+╭──────────────────────────────────────────╮+│ >_ OpenAI Codex (vtest) │+│ │+│ model: gpt-5.6-sol xhigh fast … │+│ directory: project │+│ permissions: YOLO mode │+╰──────────────────────────────────────────╯diff --git a/codex-rs/tui/src/history_cell/tests.rs b/codex-rs/tui/src/history_cell/tests.rsindex 6dbf016769..565055e35d 100644--- a/codex-rs/tui/src/history_cell/tests.rs+++ b/codex-rs/tui/src/history_cell/tests.rs@@ -6,6 +6,7 @@ use crate::exec_cell::ExecCall;use crate::exec_cell::ExecCell;use crate::legacy_core::config::Config;use crate::legacy_core::config::ConfigBuilder;+use crate::line_truncation::line_width;use crate::session_state::ThreadSessionState;use crate::wrapping::word_wrap_lines;use codex_app_server_protocol::AskForApproval;@@ -1568,6 +1569,25 @@ fn session_header_hides_fast_status_when_disabled() {assert!(!model_line.contains("fast"));}+#[test]+fn session_header_clamps_to_narrow_width() {+ const WIDTH: u16 = 44;+ let cell = SessionHeaderHistoryCell::new(+ "gpt-5.6-sol".to_string(),+ Some(ReasoningEffortConfig::XHigh),+ /*show_fast_status*/ true,+ PathBuf::from("project"),+ "test",+ )+ .with_yolo_mode(/*yolo_mode*/ true);++ let lines = cell.display_lines(WIDTH);+ let widths = lines.iter().map(line_width).collect::<Vec<_>>();++ assert_eq!(widths, vec![usize::from(WIDTH); lines.len()]);+ insta::assert_snapshot!(render_lines(&lines).join("\n"));+}+#[test]#[cfg_attr(target_os = "windows",