pub struct TermUi {
pub(crate) term: Option<DefaultTerminal>,
pub(crate) events: EventStream,
pub(crate) agents: UiAgents,
pub(crate) input_area: TextArea<'static>,
pub(crate) queued_prompts: VecDeque<String>,
pub(crate) processing: bool,
pub(crate) pending_permissions: VecDeque<(String, Sender<Result<(), String>>)>,
pub(crate) app_name: String,
pub(crate) creation: Instant,
}Expand description
UI state for WorkBuddy
Fields§
§term: Option<DefaultTerminal>ratatui terminal object
Always set, except during rendering, because for some reason ratatui needs ownership access
to this. (Well, “for some reason” is that it found it clever to have a term.do(|x| ...)
pattern for rendering, so if we want access to self in that callback, we cannot have
term stored here.)
events: EventStreamProduces terminal events, asynchronously
agents: UiAgentsAll agents currently running
input_area: TextArea<'static>User message input widget
queued_prompts: VecDeque<String>Messages that are queued for sending
processing: boolWhether a prompt iteration is currently being processed (from PromptSubmitted
until AwaitingPrompt); the input title is not bolded while processing
pending_permissions: VecDeque<(String, Sender<Result<(), String>>)>Tool calls awaiting a permission decision from the user, oldest first.
Only the first one is shown; the rest wait their turn.
app_name: StringThe application name to use e.g. for notifications
creation: InstantWhen the object was created, purely for visual purposes
Implementations§
Source§impl TermUi
impl TermUi
Sourcepub fn new(
app_name: &str,
agent: &Agent,
chat_history: Arc<Mutex<ChatHistory>>,
) -> Self
pub fn new( app_name: &str, agent: &Agent, chat_history: Arc<Mutex<ChatHistory>>, ) -> Self
Create the term state with chat_history, for agent, with the application name
app_name (e.g. for notifications).
Sourcepub(crate) fn scroll_up(&mut self, lines: usize)
pub(crate) fn scroll_up(&mut self, lines: usize)
Scroll the active view up by the given number of lines.
Sourcepub(crate) fn scroll_down(&mut self, lines: usize)
pub(crate) fn scroll_down(&mut self, lines: usize)
Scroll the active view down by the given number of lines.
Sourcepub(crate) fn handle_key_event(
&mut self,
event: KeyEvent,
) -> Result<Option<Event>>
pub(crate) fn handle_key_event( &mut self, event: KeyEvent, ) -> Result<Option<Event>>
Handle the given keyboard event.
Sourcepub(crate) fn handle_mouse_event(
&mut self,
event: MouseEvent,
) -> Result<Option<Event>>
pub(crate) fn handle_mouse_event( &mut self, event: MouseEvent, ) -> Result<Option<Event>>
Handle the given mouse event.
Sourcepub(crate) fn handle_paste_event(
&mut self,
text: String,
) -> Result<Option<Event>>
pub(crate) fn handle_paste_event( &mut self, text: String, ) -> Result<Option<Event>>
Handle clipboard pasting.
Sourcepub(crate) fn input_block(processing: bool) -> Block<'static>
pub(crate) fn input_block(processing: bool) -> Block<'static>
The input field’s block: the title is bolded while the agent awaits a prompt, and not bolded while a request is being processed.
Sourcepub(crate) fn send_osc99_notification(&self, title: &str, body: Option<&str>)
pub(crate) fn send_osc99_notification(&self, title: &str, body: Option<&str>)
Send a terminal (OSC 99) notification with the given title and optional body.
Under tmux (detected via $TERM) the OSC 99 messages are wrapped in tmux’s
passthrough envelope (which requires allow-passthrough on); otherwise the
messages are sent bare.
The title and body are trimmed, and newlines, tabs, semicolons and other ASCII control characters are replaced or dropped, since they would corrupt the OSC 99 payload; both are truncated to 200 characters.
Sourcepub(crate) fn notify_prompt_done(&self, response: Option<String>)
pub(crate) fn notify_prompt_done(&self, response: Option<String>)
Raise a terminal notification that the response is ready and the agent is awaiting a new prompt.
Sourcepub(crate) fn render(&mut self, frame: &mut Frame<'_>)
pub(crate) fn render(&mut self, frame: &mut Frame<'_>)
Render the current state onto the screen.
Sourcepub(crate) fn render_permission_popup(
frame: &mut Frame<'_>,
area: Rect,
prompt: &str,
)
pub(crate) fn render_permission_popup( frame: &mut Frame<'_>, area: Rect, prompt: &str, )
Render the given permission request as a popup centered on the screen, on top of the main layout.
The popup is 80% of the terminal’s width (at most) and as tall as its wrapped prompt requires (at most the terminal’s height), and clears the area it covers, so that nothing from the main layout shows through.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TermUi
impl !RefUnwindSafe for TermUi
impl !Sync for TermUi
impl !UnwindSafe for TermUi
impl Send for TermUi
impl Unpin for TermUi
impl UnsafeUnpin for TermUi
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
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more