Skip to main content

ExtensionUi

Trait ExtensionUi 

Source
pub trait ExtensionUi: Send + Sync {
Show 47 methods // Required methods fn has_ui(&self) -> bool; fn notify(&self, message: &str, kind: NotifyKind); // Provided methods fn shutdown(&self) { ... } fn notify_untyped(&self, message: &str) { ... } fn select( &self, _title: &str, _options: Vec<String>, _dialog: DialogOptions, ) -> BoxFuture<'static, Option<String>> { ... } fn input( &self, _title: &str, _placeholder: Option<&str>, _dialog: DialogOptions, ) -> BoxFuture<'static, Option<String>> { ... } fn confirm( &self, _title: &str, _message: &str, _dialog: DialogOptions, ) -> BoxFuture<'static, bool> { ... } fn editor( &self, _title: &str, _prefill: Option<&str>, ) -> BoxFuture<'static, Option<String>> { ... } fn set_status(&self, _key: &str, _text: Option<&str>) { ... } fn set_widget( &self, _key: &str, _widget: Option<Widget>, _placement: Option<Placement>, ) { ... } fn set_footer(&self, _component: Option<RemoteComponent>) { ... } fn set_header(&self, _component: Option<RemoteComponent>) { ... } fn set_title(&self, _title: &str) { ... } fn refresh_completions(&self) { ... } fn set_working_message(&self, _message: Option<&str>) { ... } fn set_working_visible(&self, _visible: bool) { ... } fn set_working_indicator(&self, _indicator: Option<WorkingIndicator>) { ... } fn set_hidden_thinking_label(&self, _label: Option<&str>) { ... } fn set_editor_text(&self, _text: &str) { ... } fn paste_to_editor(&self, text: &str) { ... } fn editor_text(&self) -> String { ... } fn shows_components(&self) -> bool { ... } fn set_editor(&self, _editor: Option<RemoteComponent>, _embeds_status: bool) { ... } fn editor_changed(&self, _text: &str) { ... } fn editor_submit(&self, _text: &str) { ... } fn editor_action(&self, _action: &str) { ... } fn set_terminal_input( &self, _runtime: u64, _listeners: Option<Arc<dyn ComponentHost>>, ) { ... } fn set_autocomplete( &self, _providers: Arc<dyn ComponentHost>, _triggers: Vec<String>, ) { ... } fn suggestions(&self, _request: Value) -> BoxFuture<'static, Value> { ... } fn apply_completion(&self, _request: &Value) -> Value { ... } fn editor_shortcut(&self, _data: &str) -> bool { ... } fn keybindings(&self) -> Value { ... } fn custom(&self, _component: RemoteComponent, _options: CustomOptions) { ... } fn close(&self, _component: RemoteComponent) { ... } fn drop_components(&self, _runtime: u64) { ... } fn mcp_manager(&self, _screen: McpScreen) { ... } fn request_render(&self) { ... } fn renderers_changed(&self) { ... } fn tools_expanded(&self) -> bool { ... } fn set_tools_expanded(&self, _expanded: bool) { ... } fn terminal(&self) -> Option<Receiver<TerminalState>> { ... } fn footer_data(&self) -> Value { ... } fn theme(&self) -> Value { ... } fn get_theme(&self, _name: &str) -> Value { ... } fn all_themes(&self) -> Value { ... } fn set_theme(&self, _theme: &Value) -> Result<(), String> { ... } fn extension_error( &self, path: &str, _event: &str, error: &str, _stack: Option<&str>, ) { ... }
}
Expand description

pi’s ExtensionUIContext as a mode implements it. Dialogs a mode cannot show resolve as cancelled. Everything else does nothing by default.

Required Methods§

Source

fn has_ui(&self) -> bool

Whether a person can answer dialogs.

Source

fn notify(&self, message: &str, kind: NotifyKind)

Shows a message.

Provided Methods§

Source

fn shutdown(&self)

pi’s ctx.shutdown(): the mode exits once the agent is idle.

Source

fn notify_untyped(&self, message: &str)

Shows a message that names no kind. Hosts show it as information, and RPC forwards it without a kind, as pi does.

Source

fn select( &self, _title: &str, _options: Vec<String>, _dialog: DialogOptions, ) -> BoxFuture<'static, Option<String>>

Asks to pick one of options, resolving to None when cancelled.

Source

fn input( &self, _title: &str, _placeholder: Option<&str>, _dialog: DialogOptions, ) -> BoxFuture<'static, Option<String>>

Asks for a line of text, resolving to None when cancelled.

Source

fn confirm( &self, _title: &str, _message: &str, _dialog: DialogOptions, ) -> BoxFuture<'static, bool>

Asks a yes or no question, resolving to false when cancelled.

Source

fn editor( &self, _title: &str, _prefill: Option<&str>, ) -> BoxFuture<'static, Option<String>>

Asks for multi-line text starting from prefill, resolving to None when cancelled.

Source

fn set_status(&self, _key: &str, _text: Option<&str>)

Sets the footer status key, or clears it.

Source

fn set_widget( &self, _key: &str, _widget: Option<Widget>, _placement: Option<Placement>, )

Sets widget key, or removes it. Without a placement it goes above the editor.

Replaces the footer, or restores the built-in one.

Source

fn set_header(&self, _component: Option<RemoteComponent>)

Replaces the startup header, or restores the built-in one.

Source

fn set_title(&self, _title: &str)

Sets the terminal title.

Source

fn refresh_completions(&self)

Completions an extension computed in the background are ready. The editor asks for its suggestions again.

Source

fn set_working_message(&self, _message: Option<&str>)

Sets the message shown while the agent works, or restores the default.

Source

fn set_working_visible(&self, _visible: bool)

Shows or hides the indicator shown while the agent works.

Source

fn set_working_indicator(&self, _indicator: Option<WorkingIndicator>)

Sets the animation shown while the agent works, or restores the default spinner.

Source

fn set_hidden_thinking_label(&self, _label: Option<&str>)

Sets the label of hidden thinking blocks, or restores the default.

Source

fn set_editor_text(&self, _text: &str)

Replaces the editor’s text.

Source

fn paste_to_editor(&self, text: &str)

Pastes into the editor as a terminal paste would.

Source

fn editor_text(&self) -> String

The editor’s text.

Source

fn shows_components(&self) -> bool

Whether ExtensionUi::custom and component widgets are shown.

Source

fn set_editor(&self, _editor: Option<RemoteComponent>, _embeds_status: bool)

Replaces the editor with editor, or restores the built-in one. embeds_status when the editor shows the working status in its top border.

Source

fn editor_changed(&self, _text: &str)

The extension’s editor now holds text, paste markers expanded.

Source

fn editor_submit(&self, _text: &str)

The extension’s editor submitted text.

Source

fn editor_action(&self, _action: &str)

The extension’s editor asks for app action action, a key binding id such as app.interrupt.

Source

fn set_terminal_input( &self, _runtime: u64, _listeners: Option<Arc<dyn ComponentHost>>, )

Starts passing raw input through the onTerminalInput listeners of extension runtime runtime, which listeners runs, or stops with None. Runtimes’ listeners see input in the order they started.

Source

fn set_autocomplete( &self, _providers: Arc<dyn ComponentHost>, _triggers: Vec<String>, )

Completes through the providers composed with addAutocompleteProvider, which providers runs. triggers open completion too. They replace the providers of the runtime that set them before.

Source

fn suggestions(&self, _request: Value) -> BoxFuture<'static, Value>

What the built-in provider suggests for pi’s provider arguments request, {"lines", "cursorLine", "cursorCol", "force"} with UTF-16 columns: pi’s AutocompleteSuggestions, or Null.

Source

fn apply_completion(&self, _request: &Value) -> Value

The built-in provider’s applyCompletion for {"lines", "cursorLine", "cursorCol", "item", "prefix"}: {"lines", "cursorLine", "cursorCol"}.

Source

fn editor_shortcut(&self, _data: &str) -> bool

Whether raw input data is an extension shortcut, which then runs.

Source

fn keybindings(&self) -> Value

The key bindings components match keys against: {"kitty", "bindings": {id: [key]}, "actions": [id]}, where actions are the app actions an extension’s editor can ask for. Null keeps pi-tui’s defaults.

Source

fn custom(&self, _component: RemoteComponent, _options: CustomOptions)

Shows component with keyboard focus until ExtensionUi::close.

Source

fn close(&self, _component: RemoteComponent)

Removes the custom component component.

Source

fn drop_components(&self, _runtime: u64)

Removes the editor, widgets, footer and header that extension runtime runtime showed, which it lost when it restarted. The built-in editor, footer and header return.

Source

fn mcp_manager(&self, _screen: McpScreen)

Shows a screen of the /mcp manager with keyboard focus, opening the manager. McpScreen::Close closes it. Without the TUI the screen is dropped, which closes its menu.

Source

fn request_render(&self)

Components changed and need rendering.

Source

fn renderers_changed(&self)

An extension registered transcript renderers or a Markdown transformer after its session started. What draws next uses them.

Source

fn tools_expanded(&self) -> bool

Whether tool output is expanded.

Source

fn set_tools_expanded(&self, _expanded: bool)

Expands or collapses tool output.

Source

fn terminal(&self) -> Option<Receiver<TerminalState>>

The terminal’s state, kept current as it changes, or None without a terminal, as in print, JSON and RPC modes.

Source

fn footer_data(&self) -> Value

What custom footers read: {"gitBranch", "statuses": [[key, text]], "providers"}.

Source

fn theme(&self) -> Value

The theme as escape sequences, and the colors they come from: {"name", "mode", "fg": {token: sequence}, "bg": {token: sequence}, "dim": [token], "colors": {token: color}}. Null leaves text unstyled.

Source

fn get_theme(&self, _name: &str) -> Value

The theme called name, as ExtensionUi::theme describes it, or Null when there is none.

Source

fn all_themes(&self) -> Value

pi’s getAllThemes: the themes ExtensionUi::set_theme can switch to, as [{"name", "path"}] with no path for a theme without a file. Empty without a UI that switches themes, as in pi’s RPC mode.

Source

fn set_theme(&self, _theme: &Value) -> Result<(), String>

Switches to theme: a theme name, which is saved as /settings saves it, or a theme document {"name", "appearance", "colors"}, which is not saved. The error says why it could not.

Source

fn extension_error( &self, path: &str, _event: &str, error: &str, _stack: Option<&str>, )

A handler of extension path failed on event, with the error’s stack when the runtime gave one. By default it reports as print mode does.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§