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: boolWhether 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
impl App
pub fn new() -> Self
pub fn with_config(config: AppConfig) -> Self
Sourcepub fn register_widget<W: Widget>(&mut self, widget: W)
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.
Sourcepub fn rebuild_priority_order(&mut self)
pub fn rebuild_priority_order(&mut self)
Rebuild the priority order cache after widget registration
Sourcepub fn widget_mut<W: Widget + 'static>(&mut self, id: &str) -> Option<&mut W>
pub fn widget_mut<W: Widget + 'static>(&mut self, id: &str) -> Option<&mut W>
Get a widget by ID (mutable)
Sourcepub fn has_widget(&self, id: &str) -> bool
pub fn has_widget(&self, id: &str) -> bool
Check if a widget is registered
Sourcepub fn agent_name(&self) -> &str
pub fn agent_name(&self) -> &str
Get the agent name
Sourcepub fn set_to_controller(&mut self, tx: ToControllerTx)
pub fn set_to_controller(&mut self, tx: ToControllerTx)
Set the channel for sending messages to the controller
Sourcepub fn set_from_controller(&mut self, rx: FromControllerRx)
pub fn set_from_controller(&mut self, rx: FromControllerRx)
Set the channel for receiving messages from the controller
Sourcepub fn set_controller(&mut self, controller: Arc<LLMController>)
pub fn set_controller(&mut self, controller: Arc<LLMController>)
Set the controller reference for session management
Sourcepub fn set_llm_registry(&mut self, registry: LLMRegistry)
pub fn set_llm_registry(&mut self, registry: LLMRegistry)
Set the LLM provider registry
Sourcepub fn set_runtime_handle(&mut self, handle: Handle)
pub fn set_runtime_handle(&mut self, handle: Handle)
Set the tokio runtime handle
Sourcepub fn set_user_interaction_registry(
&mut self,
registry: Arc<UserInteractionRegistry>,
)
pub fn set_user_interaction_registry( &mut self, registry: Arc<UserInteractionRegistry>, )
Set the user interaction registry
Sourcepub fn set_permission_registry(&mut self, registry: Arc<PermissionRegistry>)
pub fn set_permission_registry(&mut self, registry: Arc<PermissionRegistry>)
Set the permission registry
Sourcepub fn set_session_id(&mut self, id: i64)
pub fn set_session_id(&mut self, id: i64)
Set the session ID
Sourcepub fn set_model_name(&mut self, name: impl Into<String>)
pub fn set_model_name(&mut self, name: impl Into<String>)
Set the model name
Sourcepub fn set_context_limit(&mut self, limit: i32)
pub fn set_context_limit(&mut self, limit: i32)
Set the context limit
Sourcepub fn set_layout(&mut self, template: LayoutTemplate)
pub fn set_layout(&mut self, template: LayoutTemplate)
Set the layout template
Sourcepub fn set_key_handler<H: KeyHandler>(&mut self, handler: H)
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.
Sourcepub fn set_key_handler_boxed(&mut self, handler: Box<dyn KeyHandler>)
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.
Sourcepub fn set_key_bindings(&mut self, bindings: KeyBindings)
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.
Sourcepub fn set_exit_handler<H: ExitHandler>(&mut self, handler: H)
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.
Sourcepub fn set_exit_handler_boxed(&mut self, handler: Box<dyn ExitHandler>)
pub fn set_exit_handler_boxed(&mut self, handler: Box<dyn ExitHandler>)
Set a boxed exit handler directly.
pub fn submit_message(&mut self)
Sourcepub fn interrupt_request(&mut self)
pub fn interrupt_request(&mut self)
Interrupt the current LLM request
Sourcepub fn switch_session(&mut self, session_id: i64)
pub fn switch_session(&mut self, session_id: i64)
Switch to a different session by ID
Sourcepub fn add_session(&mut self, info: SessionInfo)
pub fn add_session(&mut self, info: SessionInfo)
Add a session to the sessions list
pub fn scroll_up(&mut self)
pub fn scroll_down(&mut self)
pub fn run(&mut self) -> Result<()>
Trait Implementations§
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> 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> 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