pub struct ChatState {
pub messages: Vec<ChatMessage>,
pub input: String,
pub streaming: bool,
pub system_prompt_sent: bool,
/* private fields */
}Expand description
Chat state for the agent conversation.
Fields§
§messages: Vec<ChatMessage>All messages in the conversation history.
input: StringThe current text input from the user (not yet sent).
streaming: boolWhether the agent is currently streaming a response.
system_prompt_sent: boolWhether the system guidance has been sent with the first prompt.
Implementations§
Source§impl ChatState
impl ChatState
Sourcepub fn handle_update(&mut self, update: SessionUpdate)
pub fn handle_update(&mut self, update: SessionUpdate)
Process an incoming SessionUpdate from the agent, updating chat
state accordingly.
Non-chunk updates automatically flush any accumulated agent text buffer so that the complete message is recorded before tool calls or other events.
Sourcepub fn flush_agent_message(&mut self)
pub fn flush_agent_message(&mut self)
Flush the agent text buffer into a completed ChatMessage::Agent
message and reset streaming state.
Also extracts any fenced bash/sh code blocks and appends them as
ChatMessage::CommandSuggestion entries so the UI can offer
“Run in terminal” buttons.
Sourcepub fn streaming_text(&self) -> &str
pub fn streaming_text(&self) -> &str
Returns the current in-progress streaming text (not yet flushed).
Sourcepub fn add_user_message(&mut self, text: String)
pub fn add_user_message(&mut self, text: String)
Add a user message to the conversation.
Flushes any pending agent text first so messages stay interleaved.
Sourcepub fn add_system_message(&mut self, text: String)
pub fn add_system_message(&mut self, text: String)
Add a system message to the conversation.
Sourcepub fn add_command_suggestion(&mut self, command: String)
pub fn add_command_suggestion(&mut self, command: String)
Add a command suggestion to the conversation.
Sourcepub fn add_auto_approved(&mut self, description: String)
pub fn add_auto_approved(&mut self, description: String)
Add an auto-approved tool call notice to the conversation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatState
impl RefUnwindSafe for ChatState
impl Send for ChatState
impl Sync for ChatState
impl Unpin for ChatState
impl UnsafeUnpin for ChatState
impl UnwindSafe for ChatState
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> 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> 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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().