From 318c78ca3c9f7ed3b4a6037ee6b0cf8f82e23582 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Mon, 4 Aug 2025 15:44:12 -0700 Subject: [PATCH] wrap user message --- codex-rs/tui/src/history_cell.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 {