pub struct ChatMessage {
pub role: MessageRole,
pub content: String,
pub streaming: bool,
pub tool_name: Option<ToolName>,
pub diff_data: Option<DiffData>,
pub filter_stats: Option<String>,
pub kept_lines: Option<Vec<usize>>,
pub timestamp: String,
pub paste_line_count: Option<usize>,
}Expand description
A single entry in the TUI chat history buffer.
Carries the rendered text, role metadata, optional tool context, an inline diff, and a wall-clock timestamp for display.
§Examples
use zeph_tui::{ChatMessage, MessageRole};
let msg = ChatMessage::new(MessageRole::User, "Hello, agent!");
assert_eq!(msg.role, MessageRole::User);
assert_eq!(msg.content, "Hello, agent!");
assert!(!msg.streaming);Fields§
§role: MessageRoleRole that determines rendering style.
content: StringRendered text content of the message.
streaming: booltrue while the message is still being streamed from the LLM.
tool_name: Option<ToolName>Name of the tool that produced this message, if any.
diff_data: Option<DiffData>Inline diff attached to a tool-output message.
filter_stats: Option<String>Human-readable filter statistics (e.g. “kept 12/40 lines”).
kept_lines: Option<Vec<usize>>0-based line indices preserved by the output filter, used for highlighting in the diff widget.
timestamp: StringWall-clock time formatted as HH:MM when the message was created.
paste_line_count: Option<usize>Number of lines in the pasted content when this message was submitted
from a paste. Some(n) (n >= 2) enables collapsible display in the
chat renderer; None means normal display.
Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn new(role: MessageRole, content: impl Into<String>) -> Self
pub fn new(role: MessageRole, content: impl Into<String>) -> Self
Create a new non-streaming message with the current local time as timestamp.
§Examples
use zeph_tui::{ChatMessage, MessageRole};
let msg = ChatMessage::new(MessageRole::Assistant, "Done.");
assert_eq!(msg.role, MessageRole::Assistant);
assert!(!msg.streaming);Sourcepub fn streaming(self) -> Self
pub fn streaming(self) -> Self
Mark this message as actively streaming.
The chat widget renders a blinking cursor after the content while
streaming is true.
§Examples
use zeph_tui::{ChatMessage, MessageRole};
let msg = ChatMessage::new(MessageRole::Assistant, "").streaming();
assert!(msg.streaming);Sourcepub fn with_tool(self, name: ToolName) -> Self
pub fn with_tool(self, name: ToolName) -> Self
Attach a tool name to this message for display in the chat header.
§Examples
use zeph_tui::{ChatMessage, MessageRole};
let msg = ChatMessage::new(MessageRole::Tool, "output")
.with_tool(zeph_common::ToolName::new("bash"));
assert!(msg.tool_name.is_some());Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ChatMessage
impl RefUnwindSafe for ChatMessage
impl Send for ChatMessage
impl Sync for ChatMessage
impl Unpin for ChatMessage
impl UnsafeUnpin for ChatMessage
impl UnwindSafe for ChatMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request