Skip to main content

AssistantMessageComponent

Struct AssistantMessageComponent 

Source
pub struct AssistantMessageComponent { /* private fields */ }
Expand description

Component that renders a complete assistant message.

Mirrors TypeScript AssistantMessageComponent class. Content is rebuilt from AssistantBlocks on every update_blocks (and the legacy update_text), keeping thinking + text in order with TS-faithful spacing.

Implementations§

Source§

impl AssistantMessageComponent

Source

pub fn new(options: AssistantMessageOptions) -> Self

Create a new assistant message component.

Source

pub fn set_markdown_transformer( &self, transformer: Option<Arc<dyn Fn(&str) -> String + Send + Sync>>, )

B5e: install a markdown transformer applied to raw assistant text before the Markdown renderer styles it. The closure is Send + Sync so it is safe across the streaming-drain + render threads. Idempotent against rebuild_content: callers may set it before the first update_blocks or swap it on a /reload; either way the next rebuild re-applies it. A None value clears the transform (identity) — used on a reload that unregisters all markdown transformers.

On a transform CHANGE, the last blocks are rebuilt so the new transform is reflected immediately (mirrors set_hide_thinking/set_output_pad).

Source

pub fn default() -> Self

Create with default options.

Source

pub fn update_blocks(&self, blocks: &[AssistantBlock])

Update the content from a flat block list. Mirrors the TS updateContent ordering + spacing: text blocks render as markdown, runs of consecutive thinking blocks coalesce into one dim-italic markdown section (joined with \n\n), and a blank line separates a thinking run from a following visible block. When hide_thinking is set, each thinking run collapses to a single dim label line.

Source

pub fn update_text(&self, text: &str)

Update the content with assistant message text.

Convenience for callers that have only text (the legacy path). The block-aware [update_blocks] supersedes this where thinking blocks are available; both share the rebuild path.

Source

pub fn update_error(&self, error: &str, stop_reason: &str)

Update with error message.

Source

pub fn set_hide_thinking(&self, hide: bool)

Set hide thinking option. Rebuilds the last content so the toggle is reflected immediately (mirrors the TS setter).

Source

pub fn set_hidden_thinking_label(&self, label: &str)

Set hidden thinking label. Rebuilds the last content (mirrors TS).

Source

pub fn set_output_pad(&self, pad: usize)

Set output padding. Rebuilds the last content (mirrors TS).

Source

pub fn has_tool_calls(&self) -> bool

Check if has tool calls.

Source

pub fn markdown_transformer( &self, ) -> Option<Arc<dyn Fn(&str) -> String + Send + Sync>>

The currently installed markdown transformer (B5e), if any. The host reads this to carry an existing transform into a fresh component (e.g. after a /reload) so the new component renders with the same plugin transformer without the host re-querying the registry.

Source

pub fn set_streaming(&self, streaming: bool)

Set streaming state.

Trait Implementations§

Source§

impl Component for AssistantMessageComponent

Source§

fn render(&self, width: usize) -> Vec<String>

Render the component to lines for the given viewport width. Read more
Source§

fn invalidate(&self)

Invalidate any cached rendering state. Called when theme changes or when component needs to re-render from scratch.
Source§

fn as_any(&self) -> &dyn Any

Downcast to Any for runtime type checking. This enables the layout system to check for LayoutNodeProvider.
Source§

fn handle_input(&self, _data: &str) -> bool

Optional handler for keyboard input when component has focus. Read more
Source§

fn wants_key_release(&self) -> bool

If true, component receives key release events (Kitty protocol). Default is false - release events are filtered out.

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.