fix(tui): highlight user messages in transcript#1703
Conversation
Render user messages with a full-row background in the live transcript so they are easier to distinguish from assistant output. Keep transcript/export rendering free of visual padding and cover the behavior with regression tests.
There was a problem hiding this comment.
Code Review
This pull request introduces a highlighted background for user messages in the TUI history by adding render_user_message and apply_user_message_background helper functions. These changes ensure user messages are visually distinct and can optionally be padded to the full width of the terminal. Feedback was provided regarding the manual application of background styles to individual spans in apply_user_message_background, noting that it is redundant due to ratatui's style inheritance and could interfere with specific styling for elements like inline code blocks.
| for span in &mut line.spans { | ||
| span.style = span.style.bg(bg); | ||
| } |
There was a problem hiding this comment.
Explicitly setting the background on every span is redundant because ratatui's Line rendering logic automatically patches the line's style onto its spans during render.
More importantly, this loop overwrites any specific background styling applied by the markdown renderer (such as for inline code blocks). Removing this loop allows nested elements to maintain their own background contrast while still inheriting the message-wide highlight from line.style where they don't specify one.
|
This PR was opened before the v0.8.41 rebrand and is now stale. Feel free to rebase onto current |
Summary
Fixes #1672
User messages were too visually close to assistant output in the transcript, making longer conversations harder to scan. This updates the user-message render path to use a clearer green marker and full-row background highlight in the live TUI.
The transcript/export path keeps the same plain text shape without visual padding, so copy/export behavior is not polluted by trailing spaces.
Testing
cargo test --all-featurescargo fmt --all -- --checkcargo clippy --all-targets --all-featuresChecklist