Skip to content

fix(tui): highlight user messages in transcript#1703

Closed
reidliu41 wants to merge 1 commit into
Hmbown:mainfrom
reidliu41:feat/user-message-contrast
Closed

fix(tui): highlight user messages in transcript#1703
reidliu41 wants to merge 1 commit into
Hmbown:mainfrom
reidliu41:feat/user-message-contrast

Conversation

@reidliu41
Copy link
Copy Markdown
Contributor

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.

image

Testing

  • cargo test --all-features
  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features

Checklist

  • Updated docs or comments as needed
  • Added or updated tests where relevant
  • Verified TUI behavior manually if UI changes

  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.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +2242 to +2244
for span in &mut line.spans {
span.style = span.style.bg(bg);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 23, 2026

This PR was opened before the v0.8.41 rebrand and is now stale. Feel free to rebase onto current main and reopen. 鲸鱼兄弟们等你 🐋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 用户消息在 TUI 中的视觉区分度不足

2 participants