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
subscribeMUST invoke its callback for every public session event, including ones emitted during async actions performed by this trait.partial_rxMAY return a receiver that never fires (no streaming); the runtime treatsNoneupdates as no-ops.- The runtime NEVER holds the host across
.awaitpoints that touch the same host mutably; each action is dispatched on a fresh&selfborrow.
Required Methods§
Sourcefn snapshot(&self) -> SessionSnapshot
fn snapshot(&self) -> SessionSnapshot
Snapshot of synchronous state for view projection.
Sourcefn subscribe(&self) -> EventSubscription
fn subscribe(&self) -> EventSubscription
Subscribe to public session events. The returned EventSubscription
owns an mpsc receiver plus the unsubscribe token.
Sourcefn partial_rx(&self) -> Receiver<Option<Arc<AssistantMessage>>>
fn partial_rx(&self) -> Receiver<Option<Arc<AssistantMessage>>>
Receiver for the latest partial assistant message (None when idle).
Sourcefn prompt(
&self,
text: &str,
opts: PromptOptions,
) -> BoxFuture<'_, Result<(), String>>
fn prompt( &self, text: &str, opts: PromptOptions, ) -> BoxFuture<'_, Result<(), String>>
Submit a prompt.
Sourcefn steer(&self, text: &str) -> BoxFuture<'_, Result<(), String>>
fn steer(&self, text: &str) -> BoxFuture<'_, Result<(), String>>
Steer the in-flight stream (mid-turn injection).
Sourcefn follow_up(&self, text: &str) -> BoxFuture<'_, Result<(), String>>
fn follow_up(&self, text: &str) -> BoxFuture<'_, Result<(), String>>
Queue a follow-up message for the next turn.
Sourcefn abort(&self) -> BoxFuture<'static, Result<(), String>>
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.
Sourcefn compact(
&self,
instructions: Option<&str>,
) -> BoxFuture<'_, Result<(), String>>
fn compact( &self, instructions: Option<&str>, ) -> BoxFuture<'_, Result<(), String>>
Manually compact the context with optional custom instructions.
Sourcefn cycle_thinking_level(&self) -> BoxFuture<'_, Result<(), String>>
fn cycle_thinking_level(&self) -> BoxFuture<'_, Result<(), String>>
Cycle the thinking level forward.
Sourcefn cycle_model(&self, forward: bool) -> BoxFuture<'_, Result<(), String>>
fn cycle_model(&self, forward: bool) -> BoxFuture<'_, Result<(), String>>
Cycle the active model in the given direction.
Sourcefn reload(&self) -> BoxFuture<'_, Result<(), String>>
fn reload(&self) -> BoxFuture<'_, Result<(), String>>
Reload extensions / resources / keybindings.
Sourcefn messages(&self) -> Vec<AgentMessage>
fn messages(&self) -> Vec<AgentMessage>
Returns the full transcript for the current session (used on rebind).
Sourcefn get_model_entries(
&self,
) -> BoxFuture<'_, Result<Vec<ModelSelectorEntry>, String>>
fn get_model_entries( &self, ) -> BoxFuture<'_, Result<Vec<ModelSelectorEntry>, String>>
Fetch the model list for the model selector.
Sourcefn get_session_entries(
&self,
) -> BoxFuture<'_, Result<Vec<SessionPickerEntry>, String>>
fn get_session_entries( &self, ) -> BoxFuture<'_, Result<Vec<SessionPickerEntry>, String>>
Fetch the recent sessions for the session picker.
Sourcefn get_tree_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>
fn get_tree_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>
Fetch the session tree (entries with depth) for the tree selector.
Sourcefn get_fork_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>
fn get_fork_entries(&self) -> BoxFuture<'_, Result<Vec<TreeEntry>, String>>
Fetch the user-message fork list (tree entries, only user messages).
Sourcefn get_trust_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
fn get_trust_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
Fetch the trust-state settings rows.
Sourcefn get_auth_entries(
&self,
) -> BoxFuture<'_, Result<Vec<AuthSelectorEntry>, String>>
fn get_auth_entries( &self, ) -> BoxFuture<'_, Result<Vec<AuthSelectorEntry>, String>>
Fetch the auth selector entries (provider list).
Sourcefn get_scoped_models_entries(
&self,
) -> BoxFuture<'_, Result<ScopedModelEntries, String>>
fn get_scoped_models_entries( &self, ) -> BoxFuture<'_, Result<ScopedModelEntries, String>>
Fetch the scoped-models selector entries with current enabled map.
Sourcefn get_settings_entries(
&self,
) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
fn get_settings_entries( &self, ) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
Fetch the settings selector rows.
Sourcefn get_config_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
fn get_config_entries(&self) -> BoxFuture<'_, Result<Vec<SettingsRow>, String>>
Fetch the config selector rows.
Sourcefn execute_bash(
&self,
command: &str,
exclude_from_context: bool,
) -> BoxFuture<'_, Result<(), String>>
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).
Sourcefn new_session(&self) -> BoxFuture<'_, Result<(), String>>
fn new_session(&self) -> BoxFuture<'_, Result<(), String>>
Start a new session (replacement pipeline).
Sourcefn fork(&self, entry_id: &str) -> BoxFuture<'_, Result<(), String>>
fn fork(&self, entry_id: &str) -> BoxFuture<'_, Result<(), String>>
Open the fork selector’s confirmation; runtime supplies the entry id.
Sourcefn switch_session(&self, path: &str) -> BoxFuture<'_, Result<(), String>>
fn switch_session(&self, path: &str) -> BoxFuture<'_, Result<(), String>>
Switch to a different session file (resume).
Sourcefn export_html(
&self,
path: Option<&str>,
) -> BoxFuture<'_, Result<String, String>>
fn export_html( &self, path: Option<&str>, ) -> BoxFuture<'_, Result<String, String>>
Export the current session to HTML; runtime passes an optional path.
Sourcefn set_session_name(&self, name: &str) -> BoxFuture<'_, Result<(), String>>
fn set_session_name(&self, name: &str) -> BoxFuture<'_, Result<(), String>>
Set the session display name.
Provided Methods§
Snapshot persisted token/cost/context state for the footer.
Sourcefn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>>
fn host_extension_runner(&self) -> Option<Arc<HostExtensionRunner>>
Concrete extension host for interactive UI bridging, when enabled.
Sourcefn hide_thinking_block(&self) -> bool
fn hide_thinking_block(&self) -> bool
Initial persisted thinking-block visibility.
Sourcefn set_hide_thinking_block(&self, _hide: bool) -> Result<(), String>
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.
Sourcefn external_editor_command(&self) -> String
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".