pub struct TuiRunner { /* private fields */ }Expand description
TUI configuration that extends AgentCore with TUI-specific settings.
This struct holds all TUI-related configuration that would otherwise
need to be stored on AgentCore. Use TuiRunner::new() to create one
from an AgentCore, configure it, then call run().
Implementations§
Source§impl TuiRunner
impl TuiRunner
Sourcepub fn agent_mut(&mut self) -> &mut AgentCore
pub fn agent_mut(&mut self) -> &mut AgentCore
Get a mutable reference to the underlying AgentCore.
Sourcepub fn set_conversation_factory<F>(&mut self, factory: F) -> &mut Self
pub fn set_conversation_factory<F>(&mut self, factory: F) -> &mut Self
Set the conversation view factory.
The factory is called to create conversation views when sessions are created or cleared. This allows customizing the chat view with custom welcome screens, title renderers, etc.
Sourcepub fn set_layout(&mut self, template: LayoutTemplate) -> &mut Self
pub fn set_layout(&mut self, template: LayoutTemplate) -> &mut Self
Set the layout template for the TUI.
This allows customizing how widgets are arranged in the terminal. If not set, the default Standard layout with panels is used.
Sourcepub fn set_key_handler<H: KeyHandler>(&mut self, handler: H) -> &mut Self
pub fn set_key_handler<H: KeyHandler>(&mut self, handler: H) -> &mut Self
Set a custom key handler for the TUI.
This allows full control over key handling behavior.
Sourcepub fn set_key_bindings(&mut self, bindings: KeyBindings) -> &mut Self
pub fn set_key_bindings(&mut self, bindings: KeyBindings) -> &mut Self
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) -> &mut Self
pub fn set_exit_handler<H: ExitHandler>(&mut self, handler: H) -> &mut Self
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_commands(
&mut self,
commands: Vec<Box<dyn SlashCommand>>,
) -> &mut Self
pub fn set_commands( &mut self, commands: Vec<Box<dyn SlashCommand>>, ) -> &mut Self
Set the slash commands for this agent.
If not called, uses the default command set.
Sourcepub fn set_command_extension<T: Any + Send + 'static>(
&mut self,
ext: T,
) -> &mut Self
pub fn set_command_extension<T: Any + Send + 'static>( &mut self, ext: T, ) -> &mut Self
Set extension data available to custom commands.
Commands can access this via ctx.extension::<T>().
Sourcepub fn register_widget<W: Widget>(&mut self, widget: W) -> &mut Self
pub fn register_widget<W: Widget>(&mut self, widget: W) -> &mut Self
Register a widget with the agent.
Widgets are registered before calling run() and will be available
in the TUI application.
Sourcepub fn set_status_bar<W: Widget>(&mut self, status_bar: W) -> &mut Self
pub fn set_status_bar<W: Widget>(&mut self, status_bar: W) -> &mut Self
Set a custom status bar widget to replace the default.
Sourcepub fn hide_status_bar(&mut self) -> &mut Self
pub fn hide_status_bar(&mut self) -> &mut Self
Hide the default status bar.
Sourcepub fn run(self) -> Result<()>
pub fn run(self) -> Result<()>
Run the agent with the TUI.
This is the main entry point for running an agent with TUI. It:
- Starts background tasks (controller, input router)
- Creates an App with the configured settings
- Wires up all channels and registries
- Creates an initial session if LLM providers are configured
- Runs the TUI event loop
- Shuts down cleanly when the user quits
Auto Trait Implementations§
impl !Freeze for TuiRunner
impl !RefUnwindSafe for TuiRunner
impl Send for TuiRunner
impl !Sync for TuiRunner
impl Unpin for TuiRunner
impl !UnwindSafe for TuiRunner
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