Skip to main content

TuiRunner

Struct TuiRunner 

Source
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

Source

pub fn new(agent: AgentCore) -> TuiRunner

Create a new TuiRunner from an AgentCore.

Source

pub fn agent_mut(&mut self) -> &mut AgentCore

Get a mutable reference to the underlying AgentCore.

Source

pub fn agent(&self) -> &AgentCore

Get a reference to the underlying AgentCore.

Source

pub fn set_conversation_factory<F>(&mut self, factory: F) -> &mut TuiRunner
where F: Fn() -> Box<dyn ConversationView> + Send + Sync + 'static,

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.

Source

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

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.

Source

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

Set a custom key handler for the TUI.

This allows full control over key handling behavior.

Source

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

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>(&mut self, handler: H) -> &mut TuiRunner
where H: ExitHandler,

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_commands( &mut self, commands: Vec<Box<dyn SlashCommand>>, ) -> &mut TuiRunner

Set the slash commands for this agent.

If not called, uses the default command set.

Source

pub fn set_command_extension<T>(&mut self, ext: T) -> &mut TuiRunner
where T: Any + Send + 'static,

Set extension data available to custom commands.

Commands can access this via ctx.extension::<T>().

Source

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

Register a widget with the agent.

Widgets are registered before calling run() and will be available in the TUI application.

Source

pub fn set_status_bar<W>(&mut self, status_bar: W) -> &mut TuiRunner
where W: Widget,

Set a custom status bar widget to replace the default.

Source

pub fn hide_status_bar(&mut self) -> &mut TuiRunner

Hide the default status bar.

Source

pub fn run(self) -> Result<(), Error>

Run the agent with the TUI.

This is the main entry point for running an agent with TUI. It:

  1. Starts background tasks (controller, input router)
  2. Creates an App with the configured settings
  3. Wires up all channels and registries
  4. Creates an initial session if LLM providers are configured
  5. Runs the TUI event loop
  6. Shuts down cleanly when the user quits

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