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§
Sourcefn notify(&self, message: &str, kind: NotifyKind)
fn notify(&self, message: &str, kind: NotifyKind)
Shows a message.
Provided Methods§
Sourcefn notify_untyped(&self, message: &str)
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.
Sourcefn select(
&self,
_title: &str,
_options: Vec<String>,
_dialog: DialogOptions,
) -> BoxFuture<'static, Option<String>>
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.
Sourcefn input(
&self,
_title: &str,
_placeholder: Option<&str>,
_dialog: DialogOptions,
) -> BoxFuture<'static, Option<String>>
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.
Sourcefn confirm(
&self,
_title: &str,
_message: &str,
_dialog: DialogOptions,
) -> BoxFuture<'static, bool>
fn confirm( &self, _title: &str, _message: &str, _dialog: DialogOptions, ) -> BoxFuture<'static, bool>
Asks a yes or no question, resolving to false when cancelled.
Sourcefn editor(
&self,
_title: &str,
_prefill: Option<&str>,
) -> BoxFuture<'static, Option<String>>
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.
Sourcefn set_status(&self, _key: &str, _text: Option<&str>)
fn set_status(&self, _key: &str, _text: Option<&str>)
Sets the footer status key, or clears it.
Sourcefn set_widget(
&self,
_key: &str,
_widget: Option<Widget>,
_placement: Option<Placement>,
)
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.
Sourcefn set_header(&self, _component: Option<RemoteComponent>)
fn set_header(&self, _component: Option<RemoteComponent>)
Replaces the startup header, or restores the built-in one.
Sourcefn refresh_completions(&self)
fn refresh_completions(&self)
Completions an extension computed in the background are ready. The editor asks for its suggestions again.
Sourcefn set_working_message(&self, _message: Option<&str>)
fn set_working_message(&self, _message: Option<&str>)
Sets the message shown while the agent works, or restores the default.
Sourcefn set_working_visible(&self, _visible: bool)
fn set_working_visible(&self, _visible: bool)
Shows or hides the indicator shown while the agent works.
Sourcefn set_working_indicator(&self, _indicator: Option<WorkingIndicator>)
fn set_working_indicator(&self, _indicator: Option<WorkingIndicator>)
Sets the animation shown while the agent works, or restores the default spinner.
Sets the label of hidden thinking blocks, or restores the default.
Sourcefn set_editor_text(&self, _text: &str)
fn set_editor_text(&self, _text: &str)
Replaces the editor’s text.
Sourcefn paste_to_editor(&self, text: &str)
fn paste_to_editor(&self, text: &str)
Pastes into the editor as a terminal paste would.
Sourcefn editor_text(&self) -> String
fn editor_text(&self) -> String
The editor’s text.
Sourcefn shows_components(&self) -> bool
fn shows_components(&self) -> bool
Whether ExtensionUi::custom and component widgets are shown.
Sourcefn set_editor(&self, _editor: Option<RemoteComponent>, _embeds_status: bool)
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.
Sourcefn editor_changed(&self, _text: &str)
fn editor_changed(&self, _text: &str)
The extension’s editor now holds text, paste markers expanded.
Sourcefn editor_submit(&self, _text: &str)
fn editor_submit(&self, _text: &str)
The extension’s editor submitted text.
Sourcefn editor_action(&self, _action: &str)
fn editor_action(&self, _action: &str)
The extension’s editor asks for app action action, a key binding id
such as app.interrupt.
Sourcefn set_terminal_input(
&self,
_runtime: u64,
_listeners: Option<Arc<dyn ComponentHost>>,
)
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.
Sourcefn set_autocomplete(
&self,
_providers: Arc<dyn ComponentHost>,
_triggers: Vec<String>,
)
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.
Sourcefn suggestions(&self, _request: Value) -> BoxFuture<'static, Value>
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.
Sourcefn apply_completion(&self, _request: &Value) -> Value
fn apply_completion(&self, _request: &Value) -> Value
The built-in provider’s applyCompletion for {"lines", "cursorLine", "cursorCol", "item", "prefix"}: {"lines", "cursorLine", "cursorCol"}.
Sourcefn editor_shortcut(&self, _data: &str) -> bool
fn editor_shortcut(&self, _data: &str) -> bool
Whether raw input data is an extension shortcut, which then runs.
Sourcefn keybindings(&self) -> Value
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.
Sourcefn custom(&self, _component: RemoteComponent, _options: CustomOptions)
fn custom(&self, _component: RemoteComponent, _options: CustomOptions)
Shows component with keyboard focus until ExtensionUi::close.
Sourcefn close(&self, _component: RemoteComponent)
fn close(&self, _component: RemoteComponent)
Removes the custom component component.
Sourcefn drop_components(&self, _runtime: u64)
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.
Sourcefn mcp_manager(&self, _screen: McpScreen)
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.
Sourcefn request_render(&self)
fn request_render(&self)
Components changed and need rendering.
Sourcefn renderers_changed(&self)
fn renderers_changed(&self)
An extension registered transcript renderers or a Markdown transformer after its session started. What draws next uses them.
Sourcefn tools_expanded(&self) -> bool
fn tools_expanded(&self) -> bool
Whether tool output is expanded.
Sourcefn set_tools_expanded(&self, _expanded: bool)
fn set_tools_expanded(&self, _expanded: bool)
Expands or collapses tool output.
Sourcefn terminal(&self) -> Option<Receiver<TerminalState>>
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.
What custom footers read: {"gitBranch", "statuses": [[key, text]], "providers"}.
Sourcefn theme(&self) -> Value
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.
Sourcefn get_theme(&self, _name: &str) -> Value
fn get_theme(&self, _name: &str) -> Value
The theme called name, as ExtensionUi::theme describes it, or
Null when there is none.
Sourcefn all_themes(&self) -> Value
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".