Skip to main content

SessionHost

Trait SessionHost 

Source
pub trait SessionHost:
    Send
    + Sync
    + 'static {
Show 35 methods // Required methods fn snapshot(&self) -> SessionSnapshot; fn subscribe(&self) -> EventSubscription; fn partial_rx(&self) -> Receiver<Option<Arc<AssistantMessage>>>; fn prompt( &self, text: &str, opts: PromptOptions, ) -> BoxFuture<'_, Result<(), String>>; fn steer(&self, text: &str) -> BoxFuture<'_, Result<(), String>>; fn follow_up(&self, text: &str) -> BoxFuture<'_, Result<(), String>>; fn abort(&self) -> BoxFuture<'static, Result<(), String>>; fn compact( &self, instructions: Option<&str>, ) -> BoxFuture<'_, Result<(), String>>; fn cycle_thinking_level(&self) -> BoxFuture<'_, Result<(), String>>; fn cycle_model(&self, forward: bool) -> BoxFuture<'_, Result<(), String>>; fn reload(&self) -> BoxFuture<'_, Result<(), String>>; fn messages(&self) -> Vec<AgentMessage>; fn get_model_entries( &self, ) -> BoxFuture<'_, Result<Vec<ModelSelectorEntry>, String>>; fn get_session_entries( &self, ) -> BoxFuture<'_, Result<Vec<SessionPickerEntry>, String>>; fn get_tree_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>; fn get_fork_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>; fn get_trust_entries( &self, ) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>; fn get_auth_entries( &self, ) -> BoxFuture<'_, Result<Vec<AuthSelectorEntry>, String>>; fn get_scoped_models_entries( &self, ) -> BoxFuture<'_, Result<ScopedModelEntries, String>>; fn get_settings_entries( &self, ) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>; fn get_config_entries( &self, ) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>; fn execute_bash( &self, command: &str, exclude_from_context: bool, ) -> BoxFuture<'_, Result<(), String>>; fn new_session(&self) -> BoxFuture<'_, Result<(), String>>; fn fork(&self, entry_id: &str) -> BoxFuture<'_, Result<(), String>>; fn clone(&self) -> BoxFuture<'_, Result<(), String>>; fn switch_session(&self, path: &str) -> BoxFuture<'_, Result<(), String>>; fn export_html( &self, path: Option<&str>, ) -> BoxFuture<'_, Result<String, String>>; fn set_session_name(&self, name: &str) -> BoxFuture<'_, Result<(), String>>; fn logout(&self) -> BoxFuture<'_, Result<(), String>>; fn last_assistant_text( &self, ) -> BoxFuture<'_, Result<Option<String>, String>>; // Provided methods fn footer_snapshot(&self) -> BoxFuture<'_, SessionFooterSnapshot> { ... } fn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>> { ... } fn hide_thinking_block(&self) -> bool { ... } fn set_hide_thinking_block(&self, _hide: bool) -> Result<(), String> { ... } fn external_editor_command(&self) -> String { ... }
}
Expand description

Asynchronous session surface consumed by the runtime.

All async methods return BoxFuture so the trait stays object-safe; the runtime is generic over S: SessionHost so production wires a thin AgentSessionHost wrapper and tests wire [FakeSessionHost]. Methods that can fail return Result<_, String>; the runtime records the error onto the status indicator (never panics, never aborts the loop).

§Implementation invariants

  • subscribe MUST invoke its callback for every public session event, including ones emitted during async actions performed by this trait.
  • partial_rx MAY return a receiver that never fires (no streaming); the runtime treats None updates as no-ops.
  • The runtime NEVER holds the host across .await points that touch the same host mutably; each action is dispatched on a fresh &self borrow.

Required Methods§

Source

fn snapshot(&self) -> SessionSnapshot

Snapshot of synchronous state for view projection.

Source

fn subscribe(&self) -> EventSubscription

Subscribe to public session events. The returned EventSubscription owns an mpsc receiver plus the unsubscribe token.

Source

fn partial_rx(&self) -> Receiver<Option<Arc<AssistantMessage>>>

Receiver for the latest partial assistant message (None when idle).

Source

fn prompt( &self, text: &str, opts: PromptOptions, ) -> BoxFuture<'_, Result<(), String>>

Submit a prompt.

Source

fn steer(&self, text: &str) -> BoxFuture<'_, Result<(), String>>

Steer the in-flight stream (mid-turn injection).

Source

fn follow_up(&self, text: &str) -> BoxFuture<'_, Result<(), String>>

Queue a follow-up message for the next turn.

Source

fn abort(&self) -> BoxFuture<'static, Result<(), String>>

Abort the active run, retry, compaction, bash, or branch summary.

The returned future owns the concrete session selected at method-call time. Interactive prompt operations retain it so a later session replacement cannot redirect cleanup to the replacement session.

Source

fn compact( &self, instructions: Option<&str>, ) -> BoxFuture<'_, Result<(), String>>

Manually compact the context with optional custom instructions.

Source

fn cycle_thinking_level(&self) -> BoxFuture<'_, Result<(), String>>

Cycle the thinking level forward.

Source

fn cycle_model(&self, forward: bool) -> BoxFuture<'_, Result<(), String>>

Cycle the active model in the given direction.

Source

fn reload(&self) -> BoxFuture<'_, Result<(), String>>

Reload extensions / resources / keybindings.

Source

fn messages(&self) -> Vec<AgentMessage>

Returns the full transcript for the current session (used on rebind).

Source

fn get_model_entries( &self, ) -> BoxFuture<'_, Result<Vec<ModelSelectorEntry>, String>>

Fetch the model list for the model selector.

Source

fn get_session_entries( &self, ) -> BoxFuture<'_, Result<Vec<SessionPickerEntry>, String>>

Fetch the recent sessions for the session picker.

Source

fn get_tree_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>

Fetch the session tree (entries with depth) for the tree selector.

Source

fn get_fork_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>

Fetch the user-message fork list (tree entries, only user messages).

Source

fn get_trust_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>

Fetch the trust-state settings rows.

Source

fn get_auth_entries( &self, ) -> BoxFuture<'_, Result<Vec<AuthSelectorEntry>, String>>

Fetch the auth selector entries (provider list).

Source

fn get_scoped_models_entries( &self, ) -> BoxFuture<'_, Result<ScopedModelEntries, String>>

Fetch the scoped-models selector entries with current enabled map.

Source

fn get_settings_entries( &self, ) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>

Fetch the settings selector rows.

Source

fn get_config_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>

Fetch the config selector rows.

Source

fn execute_bash( &self, command: &str, exclude_from_context: bool, ) -> BoxFuture<'_, Result<(), String>>

Execute a bash command (the runtime passes the typed command minus the ! / !! prefix).

Source

fn new_session(&self) -> BoxFuture<'_, Result<(), String>>

Start a new session (replacement pipeline).

Source

fn fork(&self, entry_id: &str) -> BoxFuture<'_, Result<(), String>>

Open the fork selector’s confirmation; runtime supplies the entry id.

Source

fn clone(&self) -> BoxFuture<'_, Result<(), String>>

Clone the session at the current leaf.

Source

fn switch_session(&self, path: &str) -> BoxFuture<'_, Result<(), String>>

Switch to a different session file (resume).

Source

fn export_html( &self, path: Option<&str>, ) -> BoxFuture<'_, Result<String, String>>

Export the current session to HTML; runtime passes an optional path.

Source

fn set_session_name(&self, name: &str) -> BoxFuture<'_, Result<(), String>>

Set the session display name.

Source

fn logout(&self) -> BoxFuture<'_, Result<(), String>>

Log out of the active auth / open the login selector.

Source

fn last_assistant_text(&self) -> BoxFuture<'_, Result<Option<String>, String>>

Copy the last assistant text (returns the text so the runtime can resolve the platform clipboard).

Provided Methods§

Source

fn footer_snapshot(&self) -> BoxFuture<'_, SessionFooterSnapshot>

Snapshot persisted token/cost/context state for the footer.

Source

fn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>>

Concrete extension host for interactive UI bridging, when enabled.

Source

fn hide_thinking_block(&self) -> bool

Initial persisted thinking-block visibility.

Source

fn set_hide_thinking_block(&self, _hide: bool) -> Result<(), String>

Persist thinking-block visibility.

§Errors

Returns a human-readable message when persisting the preference fails.

Source

fn external_editor_command(&self) -> String

Configured external editor command.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§