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
impl AssistantMessageComponent
Sourcepub fn new(options: AssistantMessageOptions) -> Self
pub fn new(options: AssistantMessageOptions) -> Self
Create a new assistant message component.
Sourcepub fn set_markdown_transformer(
&self,
transformer: Option<Arc<dyn Fn(&str) -> String + Send + Sync>>,
)
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).
Sourcepub fn update_blocks(&self, blocks: &[AssistantBlock])
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.
Sourcepub fn update_text(&self, text: &str)
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.
Sourcepub fn update_error(&self, error: &str, stop_reason: &str)
pub fn update_error(&self, error: &str, stop_reason: &str)
Update with error message.
Sourcepub fn set_hide_thinking(&self, hide: bool)
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).
Set hidden thinking label. Rebuilds the last content (mirrors TS).
Sourcepub fn set_output_pad(&self, pad: usize)
pub fn set_output_pad(&self, pad: usize)
Set output padding. Rebuilds the last content (mirrors TS).
Sourcepub fn has_tool_calls(&self) -> bool
pub fn has_tool_calls(&self) -> bool
Check if has tool calls.
Sourcepub fn markdown_transformer(
&self,
) -> Option<Arc<dyn Fn(&str) -> String + Send + Sync>>
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.
Sourcepub fn set_streaming(&self, streaming: bool)
pub fn set_streaming(&self, streaming: bool)
Set streaming state.