diff --git a/codex-rs/tui/src/history_cell/session.rs b/codex-rs/tui/src/history_cell/session.rs index 973de150d1..bf9e46e04a 100644 --- a/codex-rs/tui/src/history_cell/session.rs +++ b/codex-rs/tui/src/history_cell/session.rs @@ -437,27 +437,30 @@ impl HistoryCell for SessionHeaderHistoryCell { let dir_label = format!("{DIR_LABEL: text_width) { - return with_border(text_lines); + return with_border(build_text_lines(inner_width)); } let logo_animation_tick = self.logo_animation_tick(); diff --git a/codex-rs/tui/src/history_cell/tests.rs b/codex-rs/tui/src/history_cell/tests.rs index f95da01286..7ef84d50a1 100644 --- a/codex-rs/tui/src/history_cell/tests.rs +++ b/codex-rs/tui/src/history_cell/tests.rs @@ -1499,18 +1499,38 @@ fn session_header_hides_fast_status_when_disabled() { #[test] fn session_header_hides_logo_when_text_would_not_fit() { + let directory = test_path_buf("/tmp/project/with/a/long/directory/name") + .abs() + .to_path_buf(); let cell = SessionHeaderHistoryCell::new( "gpt-4o".to_string(), Some(ReasoningEffortConfig::High), /*show_fast_status*/ true, - std::env::temp_dir(), + directory.clone(), "test", ); let rendered = render_lines(&cell.display_lines(/*width*/ 48)).join("\n"); + let inner_width = card_inner_width(/*width*/ 48, SESSION_HEADER_MAX_INNER_WIDTH) + .expect("session header should fit"); + let full_width_directory = SessionHeaderHistoryCell::format_directory_inner( + &directory, + /*max_width*/ Some(inner_width.saturating_sub("directory: ".len())), + ); + let logo_width_directory = SessionHeaderHistoryCell::format_directory_inner( + &directory, + /*max_width*/ + Some( + inner_width + .saturating_sub(codex_logo::WIDTH + codex_logo::GAP_WIDTH) + .saturating_sub("directory: ".len()), + ), + ); assert!(rendered.contains("OpenAI Codex")); assert!(!rendered.contains("⣿")); + assert!(rendered.contains(&full_width_directory)); + assert_ne!(full_width_directory, logo_width_directory); } #[tokio::test]