fix(tui): highlight user messages in cached transcript
Route user cells in the transcript cache through the existing user-message renderer. The live chat view renders through lines_with_copy_metadata(), which previously bypassed the user-message highlight path. As a result, submitted user prompts did not show the intended full-row background in the main transcript. Add a regression test for the transcript cache path.
This commit is contained in:
@@ -309,13 +309,9 @@ impl HistoryCell {
|
||||
options: TranscriptRenderOptions,
|
||||
) -> Vec<RenderedTranscriptLine> {
|
||||
match self {
|
||||
HistoryCell::User { content } => render_message_with_copy_metadata(
|
||||
USER_GLYPH,
|
||||
user_label_style(),
|
||||
user_body_style(),
|
||||
content,
|
||||
width,
|
||||
),
|
||||
HistoryCell::User { content } => {
|
||||
hard_break_copy_lines(render_user_message(content, width))
|
||||
}
|
||||
HistoryCell::Assistant { content, streaming } => render_message_with_copy_metadata(
|
||||
ASSISTANT_GLYPH,
|
||||
assistant_label_style_for(*streaming, options.low_motion),
|
||||
|
||||
@@ -554,6 +554,7 @@ fn truncate_spans_to_width(spans: Vec<Span<'static>>, max_width: usize) -> Vec<S
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::palette;
|
||||
use crate::tui::history::{ExecCell, ExecSource, HistoryCell, ToolCell, ToolStatus};
|
||||
|
||||
fn plain_lines(cache: &TranscriptViewCache) -> Vec<String> {
|
||||
@@ -595,6 +596,20 @@ mod tests {
|
||||
}))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache_renders_user_cells_with_highlight_background() {
|
||||
let cells = vec![user_cell("# literal user prompt")];
|
||||
let revisions = vec![1u64];
|
||||
|
||||
let mut cache = TranscriptViewCache::new();
|
||||
cache.ensure(&cells, &revisions, 40, TranscriptRenderOptions::default());
|
||||
|
||||
let lines = cache.lines();
|
||||
assert_eq!(lines[0].style.bg, Some(palette::SURFACE_ELEVATED));
|
||||
assert_eq!(lines[0].width(), 40);
|
||||
assert_eq!(plain_lines(&cache)[0].trim_end(), "▎ # literal user prompt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache_reuses_cells_when_revision_unchanged() {
|
||||
let cells = vec![
|
||||
|
||||
Reference in New Issue
Block a user