App

Struct App 

Source
pub struct App {
    pub should_quit: bool,
    pub waiting_for_response: bool,
    pub widgets: HashMap<&'static str, Box<dyn Widget>>,
    pub widget_priority_order: Vec<&'static str>,
    pub filtered_commands: Vec<&'static SlashCommand>,
    /* private fields */
}

Fields§

§should_quit: bool§waiting_for_response: bool

Whether we’re waiting for a response (set immediately on submit, before streaming starts)

§widgets: HashMap<&'static str, Box<dyn Widget>>

Registered widgets (keyed by ID)

§widget_priority_order: Vec<&'static str>

Cached sorted priority order for key event handling

§filtered_commands: Vec<&'static SlashCommand>

Filtered slash commands for the popup (used by SlashPopup widget)

Implementations§

Source§

impl App

Source

pub fn new() -> Self

Source

pub fn with_config(config: AppConfig) -> Self

Source

pub fn register_widget<W: Widget>(&mut self, widget: W)

Register a widget with the app

The widget will be stored and used for key handling and rendering. Widgets are identified by their ID and stored in a priority order.

Source

pub fn rebuild_priority_order(&mut self)

Rebuild the priority order cache after widget registration

Source

pub fn widget<W: Widget + 'static>(&self, id: &str) -> Option<&W>

Get a widget by ID

Source

pub fn widget_mut<W: Widget + 'static>(&mut self, id: &str) -> Option<&mut W>

Get a widget by ID (mutable)

Source

pub fn has_widget(&self, id: &str) -> bool

Check if a widget is registered

Source

pub fn agent_name(&self) -> &str

Get the agent name

Source

pub fn version(&self) -> &str

Get the agent version

Source

pub fn set_to_controller(&mut self, tx: ToControllerTx)

Set the channel for sending messages to the controller

Source

pub fn set_from_controller(&mut self, rx: FromControllerRx)

Set the channel for receiving messages from the controller

Source

pub fn set_controller(&mut self, controller: Arc<LLMController>)

Set the controller reference for session management

Source

pub fn set_llm_registry(&mut self, registry: LLMRegistry)

Set the LLM provider registry

Source

pub fn set_runtime_handle(&mut self, handle: Handle)

Set the tokio runtime handle

Source

pub fn set_user_interaction_registry( &mut self, registry: Arc<UserInteractionRegistry>, )

Set the user interaction registry

Source

pub fn set_permission_registry(&mut self, registry: Arc<PermissionRegistry>)

Set the permission registry

Source

pub fn set_session_id(&mut self, id: i64)

Set the session ID

Source

pub fn set_model_name(&mut self, name: impl Into<String>)

Set the model name

Source

pub fn set_context_limit(&mut self, limit: i32)

Set the context limit

Source

pub fn set_layout(&mut self, template: LayoutTemplate)

Set the layout template

Source

pub fn set_key_handler<H: KeyHandler>(&mut self, handler: H)

Set a custom key handler.

This allows full control over key handling behavior. For simpler customization, use [set_key_bindings] instead.

Source

pub fn set_key_handler_boxed(&mut self, handler: Box<dyn KeyHandler>)

Set a boxed key handler directly.

This is useful when you have a Box<dyn KeyHandler> already.

Source

pub fn set_key_bindings(&mut self, bindings: KeyBindings)

Set custom key bindings using the default handler.

This is a simpler alternative to [set_key_handler] when you only need to change which keys trigger which actions.

Source

pub fn set_exit_handler<H: ExitHandler>(&mut self, handler: H)

Set an exit handler for cleanup before quitting.

The exit handler’s on_exit() method is called when the user confirms exit. If it returns false, the exit is cancelled.

Source

pub fn set_exit_handler_boxed(&mut self, handler: Box<dyn ExitHandler>)

Set a boxed exit handler directly.

Source

pub fn submit_message(&mut self)

Source

pub fn interrupt_request(&mut self)

Interrupt the current LLM request

Source

pub fn switch_session(&mut self, session_id: i64)

Switch to a different session by ID

Source

pub fn add_session(&mut self, info: SessionInfo)

Add a session to the sessions list

Source

pub fn scroll_up(&mut self)

Source

pub fn scroll_down(&mut self)

Source

pub fn run(&mut self) -> Result<()>

Trait Implementations§

Source§

impl Default for App

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for App

§

impl !RefUnwindSafe for App

§

impl Send for App

§

impl !Sync for App

§

impl Unpin for App

§

impl !UnwindSafe for App

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