pub struct ChatWidget {
pub messages: Vec<Message>,
pub input: String,
pub scroll: usize,
pub selected: Option<usize>,
pub available_actions: Vec<MessageAction>,
pub streaming_message: Option<StreamingMessage>,
pub is_streaming: bool,
pub copy_operation: Option<CopyOperation>,
pub show_action_menu: bool,
pub selected_action: Option<usize>,
}Expand description
Chat widget for displaying conversations
Fields§
§messages: Vec<Message>Messages in the chat
input: StringCurrent input
scroll: usizeScroll offset
selected: Option<usize>Selected message index
available_actions: Vec<MessageAction>Available actions for selected message
streaming_message: Option<StreamingMessage>Current streaming message (if any)
is_streaming: boolWhether streaming is currently active
copy_operation: Option<CopyOperation>Current copy operation with feedback
Action menu visibility
selected_action: Option<usize>Selected action in menu
Implementations§
Source§impl ChatWidget
impl ChatWidget
Sourcepub fn start_streaming(&mut self)
pub fn start_streaming(&mut self)
Start streaming a new message
Sourcepub fn append_token(&mut self, token: &str)
pub fn append_token(&mut self, token: &str)
Append a token to the streaming message
Sourcepub fn finish_streaming(&mut self) -> Option<Message>
pub fn finish_streaming(&mut self) -> Option<Message>
Finish streaming and convert to a regular message
Sourcepub fn update_streaming_animation(&mut self)
pub fn update_streaming_animation(&mut self)
Update streaming animation
Sourcepub fn get_streaming_display(&self) -> Option<String>
pub fn get_streaming_display(&self) -> Option<String>
Get the current streaming message display text
Sourcepub fn cancel_streaming(&mut self)
pub fn cancel_streaming(&mut self)
Cancel streaming
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a message
Sourcepub fn update_actions(&mut self)
pub fn update_actions(&mut self)
Update available actions for selected message
Sourcepub fn execute_action(&mut self, action: MessageAction) -> Result<(), String>
pub fn execute_action(&mut self, action: MessageAction) -> Result<(), String>
Execute an action on the selected message
Sourcepub fn visible_messages(&self, height: usize) -> Vec<&Message>
pub fn visible_messages(&self, height: usize) -> Vec<&Message>
Get visible messages based on scroll
Sourcepub fn scroll_down(&mut self, height: usize)
pub fn scroll_down(&mut self, height: usize)
Scroll down
Sourcepub fn select_next(&mut self)
pub fn select_next(&mut self)
Select next message
Sourcepub fn select_prev(&mut self)
pub fn select_prev(&mut self)
Select previous message
Sourcepub fn selected_message(&self) -> Option<&Message>
pub fn selected_message(&self) -> Option<&Message>
Get selected message
Toggle action menu visibility
Close action menu
Navigate action menu up
Navigate action menu down
Sourcepub fn execute_action_by_shortcut(&mut self, key: char) -> Result<(), String>
pub fn execute_action_by_shortcut(&mut self, key: char) -> Result<(), String>
Execute action by keyboard shortcut
Sourcepub fn get_selected_action(&self) -> Option<MessageAction>
pub fn get_selected_action(&self) -> Option<MessageAction>
Get current action menu item
Sourcepub fn execute_selected_action(&mut self) -> Result<(), String>
pub fn execute_selected_action(&mut self) -> Result<(), String>
Execute selected action from menu
Sourcepub fn update_copy_feedback(&mut self)
pub fn update_copy_feedback(&mut self)
Update copy operation feedback
Sourcepub fn get_copy_feedback(&self) -> Option<CopyFeedback>
pub fn get_copy_feedback(&self) -> Option<CopyFeedback>
Get current copy feedback if visible
Sourcepub fn is_copy_feedback_visible(&self) -> bool
pub fn is_copy_feedback_visible(&self) -> bool
Check if copy feedback is visible
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatWidget
impl RefUnwindSafe for ChatWidget
impl Send for ChatWidget
impl Sync for ChatWidget
impl Unpin for ChatWidget
impl UnwindSafe for ChatWidget
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> 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 more