Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions codex-rs/tui/src/history_cell/session.rs
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 │
╰──────────────────────────────────────────╯
20 changes: 20 additions & 0 deletions codex-rs/tui/src/history_cell/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
Loading