pub struct ChatView { /* private fields */ }Expand description
Chat message display widget with streaming and tool execution support.
Implementations§
Source§impl ChatView
impl ChatView
Sourcepub fn with_config(config: ChatViewConfig) -> ChatView
pub fn with_config(config: ChatViewConfig) -> ChatView
Create a new ChatView with custom configuration
Sourcepub fn config(&self) -> &ChatViewConfig
pub fn config(&self) -> &ChatViewConfig
Get the current configuration
Sourcepub fn set_config(&mut self, config: ChatViewConfig)
pub fn set_config(&mut self, config: ChatViewConfig)
Set a new configuration
Sourcepub fn with_title(self, title: impl Into<String>) -> ChatView
pub fn with_title(self, title: impl Into<String>) -> ChatView
Set the title displayed in the title bar
Sourcepub fn with_initial_content(
self,
render: Box<dyn Fn(&mut Frame<'_>, Rect, &Theme) + Sync + Send>,
) -> ChatView
pub fn with_initial_content( self, render: Box<dyn Fn(&mut Frame<'_>, Rect, &Theme) + Sync + Send>, ) -> ChatView
Set custom initial content renderer (shown when no messages)
Provide a closure for full ratatui control over what to display when the chat has no messages yet.
Sourcepub fn with_title_renderer<F>(self, render: F) -> ChatView
pub fn with_title_renderer<F>(self, render: F) -> ChatView
Set custom title bar renderer
The function receives the current title and theme, and returns (left_title, right_title) as ratatui Lines.
Sourcepub fn set_title(&mut self, title: impl Into<String>)
pub fn set_title(&mut self, title: impl Into<String>)
Set the title displayed in the title bar (mutable setter)
Sourcepub fn step_spinner(&mut self)
pub fn step_spinner(&mut self)
Advance the spinner animation
Sourcepub fn add_user_message(&mut self, content: String)
pub fn add_user_message(&mut self, content: String)
Add a user message (does not force scroll - caller should handle that)
Sourcepub fn add_assistant_message(&mut self, content: String)
pub fn add_assistant_message(&mut self, content: String)
Add an assistant message (complete)
Sourcepub fn add_system_message(&mut self, content: String)
pub fn add_system_message(&mut self, content: String)
Add a system message (ignores empty messages)
Sourcepub fn add_tool_message(
&mut self,
tool_use_id: &str,
display_name: &str,
display_title: &str,
)
pub fn add_tool_message( &mut self, tool_use_id: &str, display_name: &str, display_title: &str, )
Add a tool execution message
Sourcepub fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus)
pub fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus)
Update a tool message status by tool_use_id - O(1) lookup
Sourcepub fn enable_auto_scroll(&mut self)
pub fn enable_auto_scroll(&mut self)
Re-enable auto-scroll and scroll to bottom (call when user submits a message)
Sourcepub fn append_streaming(&mut self, text: &str)
pub fn append_streaming(&mut self, text: &str)
Append text to the streaming buffer
Sourcepub fn complete_streaming(&mut self)
pub fn complete_streaming(&mut self)
Complete the streaming response and add as assistant message
Sourcepub fn discard_streaming(&mut self)
pub fn discard_streaming(&mut self)
Discard the streaming buffer without saving (used on cancel)
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Check if currently streaming
pub fn scroll_up(&mut self)
pub fn scroll_down(&mut self)
pub fn render_chat( &mut self, frame: &mut Frame<'_>, area: Rect, pending_status: Option<&str>, )
Trait Implementations§
Source§impl ConversationView for ChatView
impl ConversationView for ChatView
Source§fn add_user_message(&mut self, content: String)
fn add_user_message(&mut self, content: String)
Source§fn add_assistant_message(&mut self, content: String)
fn add_assistant_message(&mut self, content: String)
Source§fn add_system_message(&mut self, content: String)
fn add_system_message(&mut self, content: String)
Source§fn append_streaming(&mut self, text: &str)
fn append_streaming(&mut self, text: &str)
Source§fn complete_streaming(&mut self)
fn complete_streaming(&mut self)
Source§fn discard_streaming(&mut self)
fn discard_streaming(&mut self)
Source§fn is_streaming(&self) -> bool
fn is_streaming(&self) -> bool
Source§fn add_tool_message(
&mut self,
tool_use_id: &str,
display_name: &str,
display_title: &str,
)
fn add_tool_message( &mut self, tool_use_id: &str, display_name: &str, display_title: &str, )
Source§fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus)
fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus)
Source§fn scroll_down(&mut self)
fn scroll_down(&mut self)
Source§fn enable_auto_scroll(&mut self)
fn enable_auto_scroll(&mut self)
Source§fn render(
&mut self,
frame: &mut Frame<'_>,
area: Rect,
_theme: &Theme,
pending_status: Option<&str>,
)
fn render( &mut self, frame: &mut Frame<'_>, area: Rect, _theme: &Theme, pending_status: Option<&str>, )
Source§fn step_spinner(&mut self)
fn step_spinner(&mut self)
Source§fn save_state(&self) -> Box<dyn Any + Send>
fn save_state(&self) -> Box<dyn Any + Send>
Source§impl Widget for ChatView
impl Widget for ChatView
Source§fn handle_key(
&mut self,
_key: KeyEvent,
_ctx: &WidgetKeyContext<'_>,
) -> WidgetKeyResult
fn handle_key( &mut self, _key: KeyEvent, _ctx: &WidgetKeyContext<'_>, ) -> WidgetKeyResult
Source§fn required_height(&self, _available: u16) -> u16
fn required_height(&self, _available: u16) -> u16
Source§fn blocks_input(&self) -> bool
fn blocks_input(&self) -> bool
Source§fn is_overlay(&self) -> bool
fn is_overlay(&self) -> bool
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Auto Trait Implementations§
impl Freeze for ChatView
impl !RefUnwindSafe for ChatView
impl Send for ChatView
impl Sync for ChatView
impl Unpin for ChatView
impl !UnwindSafe for ChatView
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