ChatWidget

Struct ChatWidget 

Source
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: String

Current input

§scroll: usize

Scroll 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: bool

Whether streaming is currently active

§copy_operation: Option<CopyOperation>

Current copy operation with feedback

§show_action_menu: bool

Action menu visibility

§selected_action: Option<usize>

Selected action in menu

Implementations§

Source§

impl ChatWidget

Source

pub fn new() -> Self

Create a new chat widget

Source

pub fn start_streaming(&mut self)

Start streaming a new message

Source

pub fn append_token(&mut self, token: &str)

Append a token to the streaming message

Source

pub fn finish_streaming(&mut self) -> Option<Message>

Finish streaming and convert to a regular message

Source

pub fn update_streaming_animation(&mut self)

Update streaming animation

Source

pub fn get_streaming_display(&self) -> Option<String>

Get the current streaming message display text

Source

pub fn cancel_streaming(&mut self)

Cancel streaming

Source

pub fn add_message(&mut self, message: Message)

Add a message

Source

pub fn clear(&mut self)

Clear all messages

Source

pub fn update_actions(&mut self)

Update available actions for selected message

Source

pub fn execute_action(&mut self, action: MessageAction) -> Result<(), String>

Execute an action on the selected message

Source

pub fn visible_messages(&self, height: usize) -> Vec<&Message>

Get visible messages based on scroll

Source

pub fn scroll_up(&mut self)

Scroll up

Source

pub fn scroll_down(&mut self, height: usize)

Scroll down

Source

pub fn select_next(&mut self)

Select next message

Source

pub fn select_prev(&mut self)

Select previous message

Source

pub fn selected_message(&self) -> Option<&Message>

Get selected message

Source

pub fn toggle_action_menu(&mut self)

Toggle action menu visibility

Source

pub fn close_action_menu(&mut self)

Close action menu

Source

pub fn action_menu_up(&mut self)

Navigate action menu up

Source

pub fn action_menu_down(&mut self)

Navigate action menu down

Source

pub fn execute_action_by_shortcut(&mut self, key: char) -> Result<(), String>

Execute action by keyboard shortcut

Source

pub fn get_selected_action(&self) -> Option<MessageAction>

Get current action menu item

Source

pub fn execute_selected_action(&mut self) -> Result<(), String>

Execute selected action from menu

Source

pub fn update_copy_feedback(&mut self)

Update copy operation feedback

Source

pub fn get_copy_feedback(&self) -> Option<CopyFeedback>

Get current copy feedback if visible

Source

pub fn is_copy_feedback_visible(&self) -> bool

Check if copy feedback is visible

Trait Implementations§

Source§

impl Default for ChatWidget

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more