diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index c2aafdd522..2f6195fe9e 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -29,6 +29,7 @@ use std::collections::HashMap; use std::io::Cursor; use std::path::PathBuf; use std::time::Duration; +use textwrap::Options; use tracing::error; pub(crate) struct CommandOutput { @@ -223,7 +224,15 @@ impl HistoryCell { pub(crate) fn new_user_prompt(message: String) -> Self { let mut lines: Vec> = Vec::new(); lines.push(Line::from("user".cyan().bold())); - lines.extend(message.lines().map(|l| Line::from(l.to_string()))); + let width = 80; + lines.extend( + textwrap::wrap( + &message, + Options::new(width).wrap_algorithm(textwrap::WrapAlgorithm::FirstFit), + ) + .iter() + .map(|l| Line::from(l.to_string())), + ); lines.push(Line::from("")); HistoryCell::UserPrompt {