UserInteractionRegistry

Struct UserInteractionRegistry 

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

Registry for managing pending user interactions.

This registry tracks tools that are blocked waiting for user input and provides methods for the UI to query and respond to these interactions.

Implementations§

Source§

impl UserInteractionRegistry

Source

pub fn new(event_tx: Sender<ControllerEvent>) -> Self

Create a new UserInteractionRegistry.

§Arguments
  • event_tx - Channel to send events when interactions are registered.
Source

pub async fn register( &self, tool_use_id: String, session_id: i64, request: AskUserQuestionsRequest, turn_id: Option<TurnId>, ) -> Result<Receiver<AskUserQuestionsResponse>, UserInteractionError>

Register a pending interaction and get a receiver to await on.

This is called by the AskUserQuestionsTool when it starts executing. The tool will await on the returned receiver until the UI responds.

§Arguments
  • tool_use_id - Unique ID for this tool use request.
  • session_id - Session that requested the interaction.
  • request - The questions to ask the user.
  • turn_id - Optional turn ID for this interaction.
§Returns

A oneshot receiver that will receive the user’s response.

Source

pub async fn respond( &self, tool_use_id: &str, response: AskUserQuestionsResponse, ) -> Result<(), UserInteractionError>

Respond to a pending interaction.

This is called by the UI when the user has answered the questions.

§Arguments
  • tool_use_id - ID of the tool use to respond to.
  • response - The user’s answers.
§Returns

Ok(()) if the response was sent successfully, or an error.

Source

pub async fn cancel( &self, tool_use_id: &str, ) -> Result<(), UserInteractionError>

Cancel a pending interaction (user declined to answer).

This is called by the UI when the user presses Escape to close the question panel without answering.

§Arguments
  • tool_use_id - ID of the tool use to cancel.
§Returns

Ok(()) if the interaction was found and cancelled, or NotFound error.

Source

pub async fn pending_for_session( &self, session_id: i64, ) -> Vec<PendingQuestionInfo>

Get all pending interactions for a session.

This is called by the UI when switching sessions to display any pending questions for that session.

§Arguments
  • session_id - Session ID to query.
§Returns

List of pending question information for the session.

Source

pub async fn cancel_session(&self, session_id: i64)

Cancel all pending interactions for a session.

This is called when a session is destroyed. It drops the senders, which will cause the awaiting tools to receive a RecvError.

§Arguments
  • session_id - Session ID to cancel.
Source

pub async fn has_pending(&self, session_id: i64) -> bool

Check if there are any pending interactions for a session.

§Arguments
  • session_id - Session ID to check.
§Returns

True if there are pending interactions.

Source

pub async fn pending_count(&self) -> usize

Get the count of pending interactions.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more