Use a consistent borderless session header in the TUI (#48562)

## What changed

- Use the compact title, version, and directory layout for all session headers, including resume, fork, and clear-screen flows. Remove the boxed model row and retain the optional greeting and YOLO permissions indicator.
- Share title styling with the status card and honor the active render mode and wrapping policy when inserting a fresh header after clearing the screen.

## Testing

Update header and startup snapshots for the borderless layout, narrow widths, and halfwidth directory characters. Add assertions that clearing history preserves the raw header in raw output mode.

GitOrigin-RevId: 0b91c1ce6646f9d9d1954b1442936abe93bdcd3c
This commit is contained in:
Felipe Coury
2026-09-26 22:50:16 +00:00
committed by copyberry
parent 6a39914e37
commit e8fdbf1f7c
28 changed files with 135 additions and 442 deletions
+6 -6
View File
@@ -307,7 +307,8 @@ impl App {
width: u16,
version: &'static str,
) -> Vec<Line<'static>> {
self.clear_ui_header_cell(version).display_lines(width)
self.clear_ui_header_cell(version)
.display_lines_for_mode(width, self.chat_widget.history_render_mode())
}
/// Share the source-backed header between retained drawing and legacy terminal insertion.
@@ -318,10 +319,6 @@ impl App {
let mut header = history_cell::SessionHeaderHistoryCell::new(
self.chat_widget.model_display_name().to_string(),
self.chat_widget.current_reasoning_effort(),
self.chat_widget.should_show_fast_status(
self.chat_widget.current_model(),
self.chat_widget.current_service_tier(),
),
self.config.cwd.to_path_buf(),
version,
)
@@ -355,7 +352,10 @@ impl App {
.history_wrap_width(tui.terminal.last_known_screen_size.width);
let header_lines = self.clear_ui_header_lines(width);
if !header_lines.is_empty() {
tui.insert_history_lines(header_lines);
tui.insert_history_lines_with_wrap_policy(
header_lines,
self.history_line_wrap_policy(),
);
self.has_emitted_history_lines = true;
}
}
+5
View File
@@ -53,6 +53,11 @@ async fn owned_clear_resets_navigation_and_retains_one_fresh_header() -> Result<
app.transcript_cells[0].display_lines(/*width*/ 80),
app.clear_ui_header_lines(/*width*/ 80),
);
app.chat_widget.set_raw_output_mode(/*enabled*/ true);
assert_eq!(
app.transcript_cells[0].raw_lines(),
app.clear_ui_header_lines(/*width*/ 80),
);
assert!(app.transcript_view.is_following());
assert!(tui.pending_history_lines_for_test().is_empty());
tui.set_owned_screen(/*owned*/ false)?;
@@ -1,14 +1,11 @@
---
source: tui/src/app/tests.rs
assertion_line: 6350
assertion_line: 6513
expression: rendered
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-test /model to change │
│ directory: <thread cwd> │
╰────────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
<thread cwd>
› Next thread prompt
+6 -45
View File
@@ -4731,13 +4731,7 @@ async fn thread_read_session_state_does_not_reuse_primary_permission_profile() {
app.enqueue_primary_thread_session(session, Vec::new())
.await
.expect("switch to read thread");
let header =
lines_to_single_string(&app.clear_ui_header_lines_with_version(/*width*/ 80, "<VERSION>"));
let model_line = header
.lines()
.find(|line| line.contains("model:"))
.expect("rendered model line");
assert_app_snapshot!("thread_read_model_after_switch", model_line);
assert_eq!(app.chat_widget.current_model(), "server-reported-model");
}
#[test]
@@ -5936,7 +5930,9 @@ async fn ctrl_l_clears_owned_history_and_preserves_the_draft() -> Result<()> {
.is::<history_cell::SessionHeaderHistoryCell>()
);
let header = lines_to_single_string(&app.transcript_cells[0].display_lines(/*width*/ 80));
assert!(header.contains("gpt-test"));
assert!(header.contains("OpenAI Codex"));
let raw_header = lines_to_single_string(&app.transcript_cells[0].raw_lines());
assert!(raw_header.contains("gpt-test"));
assert!(!header.contains("old transcript row"));
assert_eq!(
app.chat_widget.composer_text_with_pending(),
@@ -5948,41 +5944,6 @@ async fn ctrl_l_clears_owned_history_and_preserves_the_draft() -> Result<()> {
Ok(())
}
#[tokio::test]
#[cfg_attr(
target_os = "windows",
ignore = "snapshot path rendering differs on Windows"
)]
async fn clear_ui_header_shows_fast_status_for_fast_capable_models() {
let mut app = make_test_app().await;
app.config.cwd = test_path_buf("/tmp/project").abs();
app.chat_widget.set_model("gpt-5.4");
set_fast_mode_test_catalog(&mut app.chat_widget);
app.chat_widget
.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
app.chat_widget.set_service_tier(Some(
codex_protocol::config_types::ServiceTier::Fast
.request_value()
.to_string(),
));
set_chatgpt_auth(&mut app.chat_widget);
set_fast_mode_test_catalog(&mut app.chat_widget);
let rendered = app
.clear_ui_header_lines_with_version(/*width*/ 80, "<VERSION>")
.iter()
.map(|line| {
line.spans
.iter()
.map(|span| span.content.as_ref())
.collect::<String>()
})
.collect::<Vec<_>>()
.join("\n");
assert_app_snapshot!("clear_ui_header_fast_status_fast_capable_models", rendered);
}
async fn make_test_app() -> Box<App> {
let (mut chat_widget, app_event_tx, _rx, _op_rx) = make_chatwidget_manual_with_sender().await;
let test_codex_home = chat_widget.test_codex_home.take();
@@ -6539,8 +6500,8 @@ async fn app_server_thread_replacement_clears_previous_transcript_before_replay(
.iter()
.map(|line| {
let text = rendered_line_text(line);
if text.contains("│ directory: ") {
"│ directory: <thread cwd> │".to_string()
if text.trim() == test_path_buf("/tmp/next").display().to_string() {
" <thread cwd>".to_string()
} else {
text
}
@@ -1,14 +1,11 @@
---
source: tui/src/app/tests/realtime_requests.rs
assertion_line: 645
assertion_line: 889
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-test /model to change │
│ directory: /tmp/project │
╰────────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
/tmp/project
To get started, describe a task or try one of these commands:
@@ -1,14 +1,11 @@
---
source: tui/src/app/tests/realtime_requests.rs
assertion_line: 1023
assertion_line: 1093
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-test /model to change │
│ directory: /tmp/project │
╰────────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
/tmp/project
To get started, describe a task or try one of these commands:
@@ -1,5 +1,6 @@
---
source: tui/src/app/tests/realtime_requests.rs
assertion_line: 479
expression: "normalize_voice_snapshot_directory(&format!(\"Other task:\\n{other_ui}\\nRestored owner:\\n{}\\n{rendered}\",\nrender_bottom_popup(&app.chat_widget, 80)), &app.config.cwd,)"
---
Other task:
@@ -13,12 +14,9 @@ Restored owner:
› Ask Codex to do anything
gpt-test default · /tmp/project
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-test /model to change │
│ directory: /tmp/project │
╰────────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
/tmp/project
To get started, describe a task or try one of these commands:
@@ -1,14 +1,11 @@
---
source: tui/src/app/tests/realtime_requests.rs
assertion_line: 561
assertion_line: 716
expression: "normalize_voice_snapshot_directory(&rendered, &app.config.cwd)"
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-test /model to change │
│ directory: /tmp/project │
╰────────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
/tmp/project
To get started, describe a task or try one of these commands:
+1 -5
View File
@@ -158,7 +158,6 @@ use crossterm::event::KeyEventKind;
use crossterm::event::KeyModifiers;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::Modifier;
use ratatui::style::Style;
use ratatui::style::Stylize;
use ratatui::text::Line;
@@ -1485,13 +1484,10 @@ impl ChatWidget {
/// Build a placeholder header cell while the session is configuring.
fn placeholder_session_header_cell(config: &Config) -> Box<dyn HistoryCell> {
let placeholder_style = Style::default().add_modifier(Modifier::DIM | Modifier::ITALIC);
Box::new(
history_cell::SessionHeaderHistoryCell::new_with_style(
history_cell::SessionHeaderHistoryCell::new(
DEFAULT_MODEL_DISPLAY_NAME.to_string(),
placeholder_style,
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
config.cwd.to_path_buf(),
CODEX_CLI_VERSION,
)
@@ -386,7 +386,7 @@ async fn initial_session_header_starts_at_the_top_of_the_viewport() {
let header = frame
.content
.chunks(usize::from(frame.area.width))
.take(/*n*/ 6)
.take(/*n*/ 3)
.map(|row| {
row.iter()
.map(ratatui::buffer::Cell::symbol)
@@ -399,15 +399,10 @@ async fn initial_session_header_starts_at_the_top_of_the_viewport() {
.replace(crate::version::CODEX_CLI_VERSION, "<VERSION>");
let cwd = widget.config.cwd.as_path().display().to_string();
let normalized_cwd = format!("{:<width$}", "/tmp/project", width = cwd.len());
insta::assert_snapshot!(header.replace(&cwd, &normalized_cwd), @r"
╭───────────────────────────────────────╮
│ >_ OpenAI Codex (v<VERSION>) │
│ │
│ model: loading /model to change │
│ directory: /tmp/project │
╰───────────────────────────────────────╯
insta::assert_snapshot!(header.replace(&cwd, "/tmp/project"), @r"
>_ OpenAI Codex (v<VERSION>)
/tmp/project
");
}
+20 -148
View File
@@ -10,21 +10,6 @@ use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
use crate::style::accent_color;
use crate::width::display_width;
pub(crate) const SESSION_HEADER_MAX_INNER_WIDTH: usize = 56; // Just an eyeballed value
pub(crate) fn card_inner_width(width: u16, max_inner_width: usize) -> Option<usize> {
if width < 4 {
return None;
}
let inner_width = std::cmp::min(width.saturating_sub(4) as usize, max_inner_width);
Some(inner_width)
}
/// Render `lines` inside a border sized to the widest span in the content.
pub(crate) fn with_border(lines: Vec<Line<'static>>) -> Vec<Line<'static>> {
with_border_internal(lines, /*forced_inner_width*/ None)
}
/// Render `lines` inside a border whose inner width is at least `inner_width`.
///
/// This is useful when callers have already clamped their content to a
@@ -33,18 +18,9 @@ pub(crate) fn with_border(lines: Vec<Line<'static>>) -> Vec<Line<'static>> {
pub(crate) fn with_border_with_inner_width(
lines: Vec<Line<'static>>,
inner_width: usize,
) -> Vec<Line<'static>> {
with_border_internal(lines, Some(inner_width))
}
fn with_border_internal(
lines: Vec<Line<'static>>,
forced_inner_width: Option<usize>,
) -> Vec<Line<'static>> {
let max_line_width = lines.iter().map(line_width).max().unwrap_or(0);
let content_width = forced_inner_width
.unwrap_or(max_line_width)
.max(max_line_width);
let content_width = inner_width.max(max_line_width);
let mut out = Vec::with_capacity(lines.len() + 2);
let border_inner_width = content_width + 2;
@@ -68,6 +44,15 @@ fn with_border_internal(
out
}
/// Brand title shared by the session header and the status card; each owns its own indentation.
pub(crate) fn codex_title(version: &str) -> Vec<Span<'static>> {
vec![
">_ ".fg(accent_color()),
"OpenAI Codex".bold(),
format!(" (v{version})").dim(),
]
}
#[derive(Debug)]
struct TooltipHistoryCell {
tip: String,
@@ -210,11 +195,10 @@ pub(crate) fn new_session_info(
auth_plan: Option<PlanType>,
show_fast_status: bool,
) -> SessionInfoCell {
// Header box rendered as history (so it appears at the very top)
// Header rendered as history (so it appears at the very top).
let header = SessionHeaderHistoryCell::new(
model_display_name.to_string(),
session.reasoning_effort.clone(),
show_fast_status,
config.cwd.to_path_buf(),
CODEX_CLI_VERSION,
)
@@ -308,9 +292,7 @@ pub(crate) fn has_yolo_permissions(
pub(crate) struct SessionHeaderHistoryCell {
version: &'static str,
model: String,
model_style: Style,
reasoning_effort: Option<ReasoningEffortConfig>,
show_fast_status: bool,
directory: PathBuf,
yolo_mode: bool,
greeting: Arc<OnceLock<Greeting>>,
@@ -320,34 +302,13 @@ impl SessionHeaderHistoryCell {
pub(crate) fn new(
model: String,
reasoning_effort: Option<ReasoningEffortConfig>,
show_fast_status: bool,
directory: PathBuf,
version: &'static str,
) -> Self {
Self::new_with_style(
model,
Style::default(),
reasoning_effort,
show_fast_status,
directory,
version,
)
}
pub(crate) fn new_with_style(
model: String,
model_style: Style,
reasoning_effort: Option<ReasoningEffortConfig>,
show_fast_status: bool,
directory: PathBuf,
version: &'static str,
) -> Self {
Self {
version,
model,
model_style,
reasoning_effort,
show_fast_status,
directory,
yolo_mode: false,
greeting: Default::default(),
@@ -394,19 +355,13 @@ impl SessionHeaderHistoryCell {
}
impl HistoryCell for SessionHeaderHistoryCell {
fn compact_hyperlink_lines(&self, width: u16) -> Vec<HyperlinkLine> {
if self.greeting.get().is_none() {
return self.display_hyperlink_lines(width);
}
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
let width = usize::from(width);
let mut title = vec![" ".into()];
title.extend(codex_title(self.version));
let mut lines = vec![
Line::default(),
Line::from(vec![
" ".into(),
">_ ".fg(accent_color()),
"OpenAI Codex".bold(),
format!(" (v{})", self.version).dim(),
]),
Line::from(title),
Line::from(vec![
" ".into(),
self.format_directory(Some(width.saturating_sub(/*rhs*/ 5)))
@@ -426,99 +381,16 @@ impl HistoryCell for SessionHeaderHistoryCell {
Line::from(vec![" ".into(), greeting.phrase.fg(accent_color())]),
]);
}
plain_hyperlink_lines(
lines
.into_iter()
.map(|line| truncate_line_with_ellipsis_if_overflow(line, width))
.collect(),
)
}
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
if self.greeting.get().is_some() {
return visible_lines(self.compact_hyperlink_lines(width));
}
let Some(inner_width) = card_inner_width(width, SESSION_HEADER_MAX_INNER_WIDTH) else {
return Vec::new();
};
let make_row = |spans: Vec<Span<'static>>| Line::from(spans);
// Title line rendered inside the box: ">_ OpenAI Codex (vX)"
let title_spans: Vec<Span<'static>> = vec![
Span::from(">_ ").dim(),
Span::from("OpenAI Codex").bold(),
Span::from(" ").dim(),
Span::from(format!("(v{})", self.version)).dim(),
];
const CHANGE_MODEL_HINT_COMMAND: &str = "/model";
const CHANGE_MODEL_HINT_EXPLANATION: &str = " to change";
const DIR_LABEL: &str = "directory:";
const PERMISSIONS_LABEL: &str = "permissions:";
let label_width = if self.yolo_mode {
DIR_LABEL.len().max(PERMISSIONS_LABEL.len())
} else {
DIR_LABEL.len()
};
let model_label = format!(
"{model_label:<label_width$}",
model_label = "model:",
label_width = label_width
);
let reasoning_label = self.reasoning_label();
let model_spans: Vec<Span<'static>> = {
let mut spans = vec![
Span::from(format!("{model_label} ")).dim(),
Span::styled(self.model.clone(), self.model_style),
];
if let Some(reasoning) = reasoning_label {
spans.push(Span::from(" "));
spans.push(Span::from(reasoning.to_owned()));
}
if self.show_fast_status {
spans.push(" ".into());
spans.push(Span::styled("fast", self.model_style.magenta()));
}
spans.push(" ".dim());
spans.push(CHANGE_MODEL_HINT_COMMAND.fg(accent_color()));
spans.push(CHANGE_MODEL_HINT_EXPLANATION.dim());
spans
};
let dir_label = format!("{DIR_LABEL:<label_width$}");
let dir_prefix = format!("{dir_label} ");
let dir_prefix_width = display_width(dir_prefix.as_str());
let dir_max_width = inner_width.saturating_sub(dir_prefix_width);
let dir = self.format_directory(Some(dir_max_width));
let dir_spans = vec![Span::from(dir_prefix).dim(), Span::from(dir)];
let mut lines = vec![
make_row(title_spans),
make_row(Vec::new()),
make_row(model_spans),
make_row(dir_spans),
];
if self.yolo_mode {
let permissions_label = format!("{PERMISSIONS_LABEL:<label_width$}");
lines.push(make_row(vec![
Span::from(format!("{permissions_label} ")).dim(),
"YOLO mode".magenta().bold(),
]));
}
let lines = lines
lines
.into_iter()
.map(|line| truncate_line_with_ellipsis_if_overflow(line, inner_width))
.collect();
with_border(lines)
.map(|line| truncate_line_with_ellipsis_if_overflow(line, width))
.collect()
}
fn raw_lines(&self) -> Vec<Line<'static>> {
if self.greeting.get().is_some() {
return visible_lines(self.compact_hyperlink_lines(u16::MAX))
return self
.display_lines(u16::MAX)
.into_iter()
.map(|line| Line::from(line.to_string()))
.collect();
@@ -1,11 +1,9 @@
---
source: tui/src/history_cell/tests.rs
assertion_line: 1867
expression: "render_lines(&lines).join(\"\\n\")"
---
╭──────────────────────────────────────────╮
│ >_ OpenAI Codex (vtest) │
│ │
│ model: gpt-5.6-sol xhigh fast … │
│ directory: project │
│ permissions: YOLO mode │
╰──────────────────────────────────────────╯
>_ OpenAI Codex (vtest)
project
permissions: YOLO mode
@@ -1,27 +1,48 @@
---
source: tui/src/history_cell/tests.rs
assertion_line: 1908
assertion_line: 1903
expression: "format!(\"{buf:?}\")"
---
Buffer {
area: Rect { x: 0, y: 0, width: 42, height: 6 },
area: Rect { x: 0, y: 0, width: 42, height: 3 },
content: [
"╭────────────────────────────────────────╮",
"│ >_ OpenAI Codex (vtest) │",
"│ │",
"│ model: gpt-5 /model to change │",
"│ directory: …パガパガパガパガパ-project │", // hidden by multi-width symbols: [(15, " "), (17, " "), (19, " "), (21, " "), (23, " "), (25, " "), (27, " "), (29, " "), (31, " ")]
"╰────────────────────────────────────────╯",
" ",
" >_ OpenAI Codex (vtest) ",
" …ガパガパガパガパガパガパガパ-project", // hidden by multi-width symbols: [(7, " "), (9, " "), (11, " "), (13, " "), (15, " "), (17, " "), (19, " "), (21, " "), (23, " "), (25, " "), (27, " "), (29, " "), (31, " "), (33, " ")]
],
styles: [
x: 0, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 0, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 5, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD,
x: 17, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 13, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 18, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 21, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 27, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 13, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 40, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 25, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 5, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 7, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 8, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 9, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 10, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 11, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 12, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 13, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 14, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 15, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 16, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 17, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 18, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 19, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 20, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 21, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 22, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 23, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 24, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 25, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 26, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 27, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 28, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 29, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 30, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 31, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 32, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 33, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 34, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
]
}
@@ -1,38 +0,0 @@
---
source: tui/src/history_cell/tests.rs
assertion_line: 1889
expression: "format!(\"{buf:?}\")"
---
Buffer {
area: Rect { x: 0, y: 0, width: 80, height: 6 },
content: [
"╭───────────────────────────────────────────╮ ",
"│ >_ OpenAI Codex (vtest) │ ",
"│ │ ",
"│ model: gpt-5-ガ-パ /model to change │ ", // hidden by multi-width symbols: [(20, " "), (23, " ")]
"│ directory: project │ ",
"╰───────────────────────────────────────────╯ ",
],
styles: [
x: 0, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 0, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 5, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD,
x: 17, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 1, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 2, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 13, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 24, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 27, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 33, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 13, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 20, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 4, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 45, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
]
}
@@ -1,11 +1,9 @@
---
source: tui/src/history_cell.rs
source: tui/src/history_cell/tests.rs
assertion_line: 1885
expression: rendered
---
╭───────────────────────────────────────╮
│ >_ OpenAI Codex (vtest) │
│ │
│ model: gpt-5 /model to change │
│ directory: /tmp/project │
│ permissions: YOLO mode │
╰───────────────────────────────────────╯
>_ OpenAI Codex (vtest)
/tmp/project
permissions: YOLO mode
@@ -1,12 +1,10 @@
---
source: tui/src/history_cell.rs
source: tui/src/history_cell/tests.rs
assertion_line: 778
expression: rendered
---
╭─────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-5 /model to change │
│ directory: /tmp/project │
╰─────────────────────────────────────╯
>_ OpenAI Codex (v0.0.0)
/tmp/project
Tip: Model just became available
+1 -63
View File
@@ -1849,53 +1849,12 @@ fn completed_mcp_tool_call_multiple_outputs_inline_snapshot() {
insta::assert_snapshot!(rendered);
}
#[test]
fn session_header_includes_reasoning_level_when_present() {
let cell = SessionHeaderHistoryCell::new(
"gpt-4o".to_string(),
Some(ReasoningEffortConfig::High),
/*show_fast_status*/ true,
std::env::temp_dir(),
"test",
);
let lines = render_lines(&cell.display_lines(/*width*/ 80));
let model_line = lines
.iter()
.find(|line| line.contains("model:"))
.expect("model line");
assert!(model_line.contains("gpt-4o high fast"));
assert!(model_line.contains("/model to change"));
}
#[test]
fn session_header_hides_fast_status_when_disabled() {
let cell = SessionHeaderHistoryCell::new(
"gpt-4o".to_string(),
Some(ReasoningEffortConfig::High),
/*show_fast_status*/ false,
std::env::temp_dir(),
"test",
);
let lines = render_lines(&cell.display_lines(/*width*/ 80));
let model_line = lines
.iter()
.find(|line| line.contains("model:"))
.expect("model line");
assert!(model_line.contains("gpt-4o high"));
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",
)
@@ -1904,7 +1863,7 @@ fn session_header_clamps_to_narrow_width() {
let lines = cell.display_lines(WIDTH);
let widths = lines.iter().map(line_width).collect::<Vec<_>>();
assert_eq!(widths, vec![usize::from(WIDTH); lines.len()]);
assert!(widths.iter().all(|width| *width <= usize::from(WIDTH)));
insta::assert_snapshot!(render_lines(&lines).join("\n"));
}
@@ -1917,7 +1876,6 @@ fn session_header_indicates_yolo_mode() {
let cell = SessionHeaderHistoryCell::new(
"gpt-5".to_string(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
test_path_buf("/tmp/project").abs().to_path_buf(),
"test",
)
@@ -1927,31 +1885,11 @@ fn session_header_indicates_yolo_mode() {
insta::assert_snapshot!(rendered);
}
#[test]
fn session_header_aligns_halfwidth_sound_marks() {
let cell: Box<dyn HistoryCell> = Box::new(SessionHeaderHistoryCell::new(
"gpt-5-ガ-パ".to_string(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
PathBuf::from("project"),
"test",
));
let width = 80;
let height = cell.desired_height(width);
let area = Rect::new(0, 0, width, height);
let mut buf = Buffer::empty(area);
cell.render(area, &mut buf);
insta::assert_snapshot!("session_header_halfwidth_sound_marks", format!("{buf:?}"));
}
#[test]
fn session_header_truncates_halfwidth_directory() {
let cell: Box<dyn HistoryCell> = Box::new(SessionHeaderHistoryCell::new(
"gpt-5".to_string(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
PathBuf::from("ガパガパガパガパガパガパガパガパ-project"),
"test",
));
@@ -518,7 +518,6 @@ fn transcript_overlay_absorbs_older_tail_into_live_without_duplicate_cells() {
let header: Arc<dyn HistoryCell> = Arc::new(history_cell::SessionHeaderHistoryCell::new(
"test model".to_owned(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
std::path::PathBuf::from("/project"),
"test",
));
@@ -1,10 +1,8 @@
---
source: tui/src/app.rs
source: tui/src/app/tests.rs
assertion_line: 5874
expression: rendered
---
╭─────────────────────────────────────────────╮
│ >_ OpenAI Codex (v<VERSION>) │
│ │
│ model: gpt-test high /model to change │
│ directory: /tmp/project │
╰─────────────────────────────────────────────╯
>_ OpenAI Codex (v<VERSION>)
/tmp/project
@@ -1,10 +0,0 @@
---
source: tui/src/app.rs
expression: rendered
---
╭────────────────────────────────────────────────────╮
│ >_ OpenAI Codex (v<VERSION>) │
│ │
│ model: gpt-5.4 xhigh fast /model to change │
│ directory: /tmp/project │
╰────────────────────────────────────────────────────╯
@@ -1,5 +0,0 @@
---
source: tui/src/app/tests.rs
expression: model_line
---
│ model: server-reported-model /model to change │
@@ -1,6 +1,6 @@
---
source: tui/src/startup_draft_tests.rs
assertion_line: 148
assertion_line: 154
expression: "snapshots.join(\"\\n---\\n\")"
---
empty (48 columns):
@@ -19,8 +19,6 @@ resuming (48 columns):
>_ OpenAI Codex (v<VERSION>)
loading
Pull up a prompt.
Resuming session…
› Ask Codex to do anything
@@ -31,8 +29,6 @@ forking (48 columns):
>_ OpenAI Codex (v<VERSION>)
loading
Pull up a prompt.
Forking session…
› draft while loading
+1 -6
View File
@@ -11,8 +11,6 @@ use tokio::time::Instant;
use crossterm::SynchronizedUpdate;
use ratatui::layout::Size;
use ratatui::style::Modifier;
use ratatui::style::Style;
use ratatui::style::Stylize;
use tokio::sync::mpsc::UnboundedReceiver;
use tokio::sync::mpsc::unbounded_channel;
@@ -468,17 +466,14 @@ impl StartupDraftPump {
}
fn startup_session_header(config: Option<&Config>) -> Box<dyn HistoryCell> {
let placeholder_style = Style::default().add_modifier(Modifier::DIM | Modifier::ITALIC);
let directory = config.map_or_else(
|| PathBuf::from("loading"),
|config| config.cwd.to_path_buf(),
);
Box::new(
history_cell::SessionHeaderHistoryCell::new_with_style(
history_cell::SessionHeaderHistoryCell::new(
"loading".to_string(),
placeholder_style,
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
directory,
CODEX_CLI_VERSION,
)
+2 -14
View File
@@ -17,7 +17,6 @@ use crate::bottom_pane::CommandPopupPlacement;
use crate::bottom_pane::ComposerRenderOptions;
use crate::render::renderable::Renderable;
use crate::render::renderable::RenderableItem;
use crate::terminal_hyperlinks::HyperlinkLine;
use crate::terminal_hyperlinks::HyperlinkParagraph;
pub(super) struct OwnedStartupLayout<'a> {
@@ -41,17 +40,6 @@ impl<'a> OwnedStartupLayout<'a> {
}
}
fn header_lines(&self, width: u16) -> Vec<HyperlinkLine> {
match self.pump.session_action {
StartupDraftSessionAction::New | StartupDraftSessionAction::NewFromCommandCenter => {
self.pump.header.compact_hyperlink_lines(width)
}
StartupDraftSessionAction::Resume | StartupDraftSessionAction::Fork => {
self.pump.header.display_hyperlink_lines(width)
}
}
}
pub(super) fn bottom_area(&self, area: Rect) -> Rect {
let height = self.bottom.desired_height(area.width).min(area.height);
Rect {
@@ -65,7 +53,7 @@ impl<'a> OwnedStartupLayout<'a> {
impl Renderable for OwnedStartupLayout<'_> {
fn render(&self, area: Rect, buf: &mut Buffer) {
let bottom = self.bottom_area(area);
let lines = self.header_lines(area.width);
let lines = self.pump.header.display_hyperlink_lines(area.width);
let paragraph = HyperlinkParagraph::new(&lines, Style::default());
let header = Rect {
height: u16::try_from(paragraph.line_count(area.width))
@@ -111,7 +99,7 @@ impl Renderable for OwnedStartupLayout<'_> {
}
fn desired_height(&self, width: u16) -> u16 {
let lines = self.header_lines(width);
let lines = self.pump.header.display_hyperlink_lines(width);
u16::try_from(HyperlinkParagraph::new(&lines, Style::default()).line_count(width))
.unwrap_or(u16::MAX)
.saturating_add(self.bottom.desired_height(width))
+8 -1
View File
@@ -74,7 +74,6 @@ pub(crate) fn startup_test_pump_with_input(text: &str) -> StartupDraftPump {
#[test]
fn startup_draft_renders_full_empty_and_multiline_composer_frames() {
let mut pump = startup_test_pump(std::iter::empty());
let mut snapshots = Vec::new();
for (label, width, text, session_action) in [
@@ -99,7 +98,15 @@ fn startup_draft_renders_full_empty_and_multiline_composer_frames() {
StartupDraftSessionAction::New,
),
] {
let mut pump = startup_test_pump(std::iter::empty());
pump.session_action = session_action;
// Resume and fork have no fresh-thread greeting. Exercise the real initial state.
if matches!(
session_action,
StartupDraftSessionAction::Resume | StartupDraftSessionAction::Fork
) {
pump.header = startup_session_header(/*config*/ None);
}
pump.bottom_pane
.set_composer_text(text.to_string(), Vec::new(), Vec::new());
let renderable =
+3 -6
View File
@@ -734,12 +734,9 @@ fn status_approval_label(
impl StatusHistoryCell {
fn content_lines(&self, width: u16) -> Vec<Line<'static>> {
let mut lines: Vec<Line<'static>> = Vec::new();
lines.push(Line::from(vec![
Span::from(format!("{}>_ ", FieldFormatter::INDENT)).dim(),
Span::from("OpenAI Codex").bold(),
Span::from(" ").dim(),
Span::from(format!("(v{CODEX_CLI_VERSION})")).dim(),
]));
let mut title = vec![FieldFormatter::INDENT.into()];
title.extend(crate::history_cell::codex_title(CODEX_CLI_VERSION));
lines.push(Line::from(title));
let available_inner_width = usize::from(width.saturating_sub(4));
if available_inner_width == 0 {
@@ -500,7 +500,6 @@ fn search_scans_a_page_inserted_after_the_retained_session_header() {
Arc::new(crate::history_cell::SessionHeaderHistoryCell::new(
"test model".to_string(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
std::path::PathBuf::from("/project"),
"test",
));
@@ -69,7 +69,6 @@ fn startup_warning_keeps_first_visible_header_in_place() {
Arc::new(crate::history_cell::SessionHeaderHistoryCell::new(
"gpt-test".into(),
/*reasoning_effort*/ None,
/*show_fast_status*/ false,
crate::test_support::test_path_buf("/project"),
"test",
));