Align user history message prefix width (#3467)

<img width="798" height="340" alt="image"
src="https://github.com/user-attachments/assets/fdd63f40-9c94-4e3a-bce5-2d2f333a384f"
/>
This commit is contained in:
Ahmed Ibrahim
2025-09-14 16:51:08 -04:00
committed by GitHub
parent d701eb32d7
commit 7e1543f5d8
18 changed files with 56 additions and 39 deletions

View File

@@ -7,6 +7,7 @@ use crate::render::line_utils::prefix_lines;
use crate::render::line_utils::push_owned_lines;
use crate::slash_command::SlashCommand;
use crate::text_formatting::format_and_truncate_tool_result;
use crate::ui_consts::LIVE_PREFIX_COLS;
use crate::wrapping::RtOptions;
use crate::wrapping::word_wrap_line;
use crate::wrapping::word_wrap_lines;
@@ -106,7 +107,7 @@ impl HistoryCell for UserHistoryCell {
let mut lines: Vec<Line<'static>> = Vec::new();
// Wrap the content first, then prefix each wrapped line with the marker.
let wrap_width = width.saturating_sub(1); // account for the ▌ prefix
let wrap_width = width.saturating_sub(LIVE_PREFIX_COLS); // account for the ▌ prefix and trailing space
let wrapped = textwrap::wrap(
&self.message,
textwrap::Options::new(wrap_width as usize)
@@ -114,7 +115,7 @@ impl HistoryCell for UserHistoryCell {
);
for line in wrapped {
lines.push(vec!["".cyan().dim(), line.to_string().dim()].into());
lines.push(vec![" ".cyan().dim(), line.to_string().dim()].into());
}
lines
}
@@ -644,25 +645,25 @@ pub(crate) fn new_session_info(
]));
lines.push(Line::from("".dim()));
lines.push(Line::from(
" To get started, describe a task or try one of these commands:".dim(),
" To get started, describe a task or try one of these commands:".dim(),
));
lines.push(Line::from("".dim()));
if !has_agents_md {
lines.push(Line::from(vec![
" /init".bold(),
" /init".bold(),
format!(" - {}", SlashCommand::Init.description()).dim(),
]));
}
lines.push(Line::from(vec![
" /status".bold(),
" /status".bold(),
format!(" - {}", SlashCommand::Status.description()).dim(),
]));
lines.push(Line::from(vec![
" /approvals".bold(),
" /approvals".bold(),
format!(" - {}", SlashCommand::Approvals.description()).dim(),
]));
lines.push(Line::from(vec![
" /model".bold(),
" /model".bold(),
format!(" - {}", SlashCommand::Model.description()).dim(),
]));
PlainHistoryCell { lines }
@@ -1785,7 +1786,7 @@ mod tests {
message: msg.to_string(),
};
// Small width to force wrapping more clearly. Effective wrap width is width-1 due to the ▌ prefix.
// Small width to force wrapping more clearly. Effective wrap width is width-2 due to the ▌ prefix and trailing space.
let width: u16 = 12;
let lines = cell.display_lines(width);
let rendered = render_lines(&lines).join("\n");