pub trait Actions: Send + Sync {
// Required methods
fn terminate_session(&self, pid: u32) -> Result<(), String>;
fn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>;
fn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>;
fn log_observation(
&self,
observation: ObservationInput,
) -> Result<(), String>;
fn log_decision(&self, input: LogDecisionInput) -> Result<(), String>;
fn mark_canonical(
&self,
decision_id: &str,
note: Option<String>,
) -> Result<(), String>;
fn bind_bus_role(
&self,
name: &str,
cwd: &str,
pid: u32,
) -> Result<(), String>;
}Expand description
Side-effecting paths the TUI invokes when the user takes an action (terminating a session, sending a prompt, flipping the brain mode, recording an observation, marking a decision canonical for teaching).
Each method is fallible — implementations return a Result rather than
silently swallowing errors so the TUI can surface failures in the status
bar instead of pretending an action succeeded.
Not modeled here (intentionally):
launch::*— launching a new Claude Code session is wider than a single call (cwd selection, model defaults, plugin propagation). Will get its own trait once the TUI’s launcher surface is refactored alongside #275.mailbox::deliver_pending— orchestrator-style mailbox delivery; should eventually move to anOrchestratortrait, notActions.log_decision(vs.log_observation) — currently only called from the plugin gate path, not the TUI. Stays a direct call until a TUI site needs it.
Required Methods§
Sourcefn terminate_session(&self, pid: u32) -> Result<(), String>
fn terminate_session(&self, pid: u32) -> Result<(), String>
Terminate the OS process with the given PID. The TUI uses this for “kill session” hotkeys.
Sourcefn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>
fn inject_text(&self, session_id: &str, text: &str) -> Result<(), String>
Inject text into the session’s terminal. Implementations pick the right backend (tmux, Kitty, etc.) from the session metadata.
The text is sent verbatim — the caller is responsible for any
trailing newline they want. Sanitization (e.g. neutralizing a leading
/) belongs to the caller; this trait is a transport.
Sourcefn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>
fn set_gate_mode(&self, mode: BrainGateMode) -> Result<(), String>
Update the persisted brain gate mode. Reflected back through
BrainView::gate_mode on the next call.
Sourcefn log_observation(&self, observation: ObservationInput) -> Result<(), String>
fn log_observation(&self, observation: ObservationInput) -> Result<(), String>
Record an observation about a user action — non-LLM “the user did X.” Drives the brain’s outcome telemetry and preference distillation.
Sourcefn log_decision(&self, input: LogDecisionInput) -> Result<(), String>
fn log_decision(&self, input: LogDecisionInput) -> Result<(), String>
Record a user’s accept/reject decision on a brain suggestion. The
distinction from log_observation is that log_decision carries
the actual suggestion that was on screen — the brain pairs it with
the user’s response for outcome telemetry, counterfactual analysis,
and few-shot retrieval.
Sourcefn mark_canonical(
&self,
decision_id: &str,
note: Option<String>,
) -> Result<(), String>
fn mark_canonical( &self, decision_id: &str, note: Option<String>, ) -> Result<(), String>
Mark a past brain decision as canonical for teaching. Optional note
is the operator’s annotation. Used by the Brain Review surface.
Sourcefn bind_bus_role(&self, name: &str, cwd: &str, pid: u32) -> Result<(), String>
fn bind_bus_role(&self, name: &str, cwd: &str, pid: u32) -> Result<(), String>
Bind an agent-bus role to a (cwd, pid) pair. The TUI calls this from
the new role-bind key (Ctrl+R) so the operator can attach a role to a
specific running Claude session without dropping to another terminal.
Returns Err when the bus feature is compiled out or the DB write
fails. See issue #307.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".