pub struct AIChatView { /* private fields */ }Expand description
A scrolling conversation.
Implementations§
Source§impl AIChatView
impl AIChatView
pub fn new(cx: &mut Context<'_, Self>) -> Self
Sourcepub fn turns(self, turns: impl IntoIterator<Item = AITurn>) -> Self
pub fn turns(self, turns: impl IntoIterator<Item = AITurn>) -> Self
Seed the transcript — restoring a saved conversation.
Sourcepub fn empty_message(self, message: impl Into<SharedString>) -> Self
pub fn empty_message(self, message: impl Into<SharedString>) -> Self
What to show before anything has been said.
pub fn size(self, size: Size) -> Self
Sourcepub fn max_width(self, width: f32) -> Self
pub fn max_width(self, width: f32) -> Self
Cap the reading width and center it. Long lines are hard to read, and a transcript in a wide window is the usual way to get them.
Sourcepub fn virtualize(self, virtualize: bool) -> Self
pub fn virtualize(self, virtualize: bool) -> Self
Build every turn every frame, however long the conversation gets.
On by default, virtualizing means a turn scrolled more than a screen away is drawn as a spacer of the height it last measured, because building it means re-parsing its markdown — which is linear in the size of the whole transcript and lands on every frame. Turn it off if you need every turn’s element tree live at all times (an in-place find, a screenshot of the full history).
pub fn focus_handle(&self) -> FocusHandle
pub fn turn_count(&self) -> usize
pub fn all(&self) -> &[AITurn]
pub fn turn(&self, index: usize) -> Option<&AITurn>
Sourcepub fn update_turn(
&mut self,
index: usize,
edit: impl FnOnce(&mut AITurn),
cx: &mut Context<'_, Self>,
)
pub fn update_turn( &mut self, index: usize, edit: impl FnOnce(&mut AITurn), cx: &mut Context<'_, Self>, )
Edit a turn in place — attaching a tool result, marking an error.
Sourcepub fn push(&mut self, turn: AITurn, cx: &mut Context<'_, Self>) -> usize
pub fn push(&mut self, turn: AITurn, cx: &mut Context<'_, Self>) -> usize
Append a turn and return its index. Sending always re-attaches the view to the bottom: the user just acted, so they want to see the result.
Sourcepub fn begin_reply(&mut self, cx: &mut Context<'_, Self>) -> usize
pub fn begin_reply(&mut self, cx: &mut Context<'_, Self>) -> usize
Open an empty assistant turn to stream into, and return its index.
Sourcepub fn push_delta(&mut self, delta: &str, cx: &mut Context<'_, Self>)
pub fn push_delta(&mut self, delta: &str, cx: &mut Context<'_, Self>)
Append to the open assistant turn. Does nothing if none is open, so a late-arriving delta after a cancel can’t resurrect a finished turn.
Sourcepub fn push_reasoning(&mut self, delta: &str, cx: &mut Context<'_, Self>)
pub fn push_reasoning(&mut self, delta: &str, cx: &mut Context<'_, Self>)
Append to the open turn’s reasoning block.
Sourcepub fn fail_reply(
&mut self,
error: impl Into<String>,
cx: &mut Context<'_, Self>,
)
pub fn fail_reply( &mut self, error: impl Into<String>, cx: &mut Context<'_, Self>, )
Close the open turn with a failure. Whatever text arrived is kept — a truncated reply is still evidence of what went wrong.
Sourcepub fn set_pending(
&mut self,
label: Option<impl Into<SharedString>>,
cx: &mut Context<'_, Self>,
)
pub fn set_pending( &mut self, label: Option<impl Into<SharedString>>, cx: &mut Context<'_, Self>, )
Show a “working on it” line under the transcript.
Sourcepub fn scroll_to_bottom(&mut self, cx: &mut Context<'_, Self>)
pub fn scroll_to_bottom(&mut self, cx: &mut Context<'_, Self>)
Re-attach to the bottom and scroll there.
Sourcepub fn is_following(&self) -> bool
pub fn is_following(&self) -> bool
Whether new text is currently pulling the view down.
Trait Implementations§
impl EventEmitter<AIChatViewEvent> for AIChatView
Source§impl Render for AIChatView
impl Render for AIChatView
Auto Trait Implementations§
impl !RefUnwindSafe for AIChatView
impl !Send for AIChatView
impl !Sync for AIChatView
impl !UnwindSafe for AIChatView
impl Freeze for AIChatView
impl Unpin for AIChatView
impl UnsafeUnpin for AIChatView
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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