pub struct ChatState {
pub messages: Vec<ChatMessage>,
pub list_state: ListState,
}Expand description
Shared chat panel state — messages list + scroll.
This is the core of any agent TUI: a scrollable list of messages with role-based coloring and prefix detection.
Fields§
§messages: Vec<ChatMessage>§list_state: ListStateImplementations§
Source§impl ChatState
impl ChatState
pub fn new() -> Self
pub fn push(&mut self, msg: String)
pub fn clear(&mut self)
pub fn scroll_to_bottom(&mut self)
Sourcepub fn toggle_expand(&mut self)
pub fn toggle_expand(&mut self)
Toggle expanded state of currently selected message.
Sourcepub fn replace_or_push(&mut self, prefix: &str, msg: String)
pub fn replace_or_push(&mut self, prefix: &str, msg: String)
Replace the last message if it starts with prefix, otherwise push new.
Sourcepub fn append_stream_chunk(&mut self, prefix: &str, chunk: &str)
pub fn append_stream_chunk(&mut self, prefix: &str, chunk: &str)
Append text to the last message that starts with prefix.
If no such message, push a new one with prefix + chunk.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatState
impl RefUnwindSafe for ChatState
impl Send for ChatState
impl Sync for ChatState
impl Unpin for ChatState
impl UnsafeUnpin for ChatState
impl UnwindSafe for ChatState
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more