pub enum Cmd {
Show 45 variants
CallModel {
turn: TurnId,
request: ChatRequest,
},
CompactConversation {
turn: TurnId,
request: CompactionRequest,
},
ExecuteTool {
turn: TurnId,
call_id: ToolCallId,
source: ToolCall,
model_id: String,
safety_mode: SafetyMode,
intent: Option<String>,
},
CancelScope(TurnId),
BackgroundScope(TurnId),
ResolveApproval {
call_id: ToolCallId,
decision: ApprovalChoice,
},
SaveConversation(ConversationHistory),
SaveCompactionArchive {
archive: CompactionArchive,
record: CompactionRecord,
conversation: ConversationHistory,
},
SaveProcess(ManagedProcess),
PersistLastModel(String),
PersistReasoningFor {
model_id: String,
level: ReasoningLevel,
},
RefreshInstructions,
RefreshMemory,
ListMemory,
RememberMemory {
text: String,
},
ForgetMemory {
id: String,
},
ConsolidateMemory {
model_id: String,
},
LoadConversation(String),
ListConversations,
ListRuntimeTasks {
limit: usize,
},
LoadRuntimeTask {
id: String,
},
ListRuntimeProcesses {
limit: usize,
},
ShowRuntimeProcessLogs {
id: String,
},
StopRuntimeProcess {
id: String,
},
RestartRuntimeProcess {
id: String,
},
OpenRuntimeTarget {
target: String,
},
ShowRuntimePorts,
ListRuntimeApprovals,
DecideRuntimeApproval {
id: String,
decision: String,
},
ListRuntimeCheckpoints {
limit: usize,
},
ListRuntimePlugins,
UpdateRuntimeTaskStatus {
id: String,
status: TaskStatus,
final_report: Option<String>,
},
CreateRuntimeCheckpoint {
paths: Vec<PathBuf>,
},
RestoreRuntimeCheckpoint {
id: String,
},
ShowRuntimeModelInfo {
model: String,
},
InitMcpServers(HashMap<String, McpServerConfig>),
StopMcpServer {
name: String,
},
PullOllamaModel {
model: String,
},
OpenInSystem(PathBuf),
DismissStatusAfter {
ms: u64,
},
WriteImageToTemp {
path: PathBuf,
bytes: Vec<u8>,
format: String,
},
ReadClipboard,
CopyToClipboard(String),
Exit,
SetTerminalTitle(String),
}Expand description
A single side-effect request. Most variants are one-shot; CallModel
and ExecuteTool spawn long-running tasks inside a per-turn
TurnScope.
Variants§
CallModel
Dispatch the next chat request. Effect runner maps this onto
ModelProvider::chat for the session’s active provider.
CompactConversation
Generate a compact context checkpoint without continuing into a normal assistant turn.
ExecuteTool
Run one tool in parallel with any other tools in the same turn.
The runner wires ExecContext::token to the turn’s scope so
Cmd::CancelScope aborts them all at once.
model_id is the active session’s model id at the moment this
tool call was emitted. The runner passes it into ExecContext
so tools like SubagentTool can spawn children against the
same provider the parent is using.
Fields
call_id: ToolCallIdsafety_mode: SafetyModeEffective live safety mode (from state.session.safety_mode) at
the moment this call was emitted. The runner builds the policy
gate / Auto classifier from this rather than the static config.
CancelScope(TurnId)
Cancel every task in the given turn’s TurnScope. After the
scope drains, the runner emits a Msg::StreamDone (with a
synthetic “cancelled” marker in usage, or a batch of
ToolFinished { outcome: Cancelled } for tools already running)
so the reducer can transition back to Idle.
BackgroundScope(TurnId)
Ctrl+B: signal the turn’s scope to BACKGROUND (not cancel) its running
work. The scope’s background token fires; detachable tools (execute_
command) move their child to a background process and return. The scope
is left intact (unlike CancelScope).
ResolveApproval
Resolve an inline approval prompt: deliver the user’s decision to the
parked tool task via the ApprovalBroker. NOT turn-scoped — it’s a
fire-and-forget to the broker (the tool task it unblocks is the
turn-scoped work).
SaveConversation(ConversationHistory)
Save the current conversation to disk. No-op if unchanged since last save (effect-side idempotence).
SaveCompactionArchive
Persist the raw messages removed by a compaction, then the compacted (message-stripped) conversation. Both are written by ONE effect task, archive first — only overwriting the conversation if the archive persisted — so a failed/lagging archive can never lose messages while the stripped conversation is saved over the old one.
SaveProcess(ManagedProcess)
Persist a daemon-visible background process record.
PersistLastModel(String)
Persist the active model ID as last_used_model.
PersistReasoningFor
Persist reasoning level tied to a specific model ID.
RefreshInstructions
Re-stat MERMAID.md (cheap); emits Msg::InstructionsChanged
only when the mtime moved or the file appeared/disappeared.
RefreshMemory
Re-scan the memory directories (cheap); emits Msg::MemoryChanged.
ListMemory
List saved memories; emits Msg::RuntimeText with the rendered list.
RememberMemory
Save free-text to private memory; emits Msg::MemoryChanged + status.
ForgetMemory
Delete a memory by name/id; emits Msg::MemoryChanged + status.
ConsolidateMemory
Model-assisted prune of duplicate/obsolete memories, reversible via a
checkpoint. Emits Msg::RuntimeText (the report) + Msg::MemoryChanged.
LoadConversation(String)
Load a specific conversation by ID and emit
Msg::ConversationLoaded. Reducer consumes that event to
replace the current session.
ListConversations
Scan the conversations directory for the /load picker. Emits
Msg::ConversationsListed with one ConversationSummary per
saved session (newest first). The reducer transitions to
UiMode::ConversationList and the render shows the picker.
ListRuntimeTasks
List durable daemon/runtime tasks.
LoadRuntimeTask
Load one durable daemon/runtime task and its timeline.
ListRuntimeProcesses
List durable daemon/runtime background processes.
ShowRuntimeProcessLogs
Print one durable process log into the conversation.
StopRuntimeProcess
Stop a durable process by pid.
RestartRuntimeProcess
Restart a durable process using its recorded command/cwd.
OpenRuntimeTarget
Open a URL, path, or process target.
ShowRuntimePorts
Show listening ports.
ListRuntimeApprovals
List pending approval records.
DecideRuntimeApproval
Mark one approval as approved or denied.
ListRuntimeCheckpoints
List restore checkpoints.
ListRuntimePlugins
List installed plugins.
UpdateRuntimeTaskStatus
Update one durable task’s status.
CreateRuntimeCheckpoint
Create a shadow checkpoint for explicit paths.
RestoreRuntimeCheckpoint
Restore files from a shadow checkpoint.
ShowRuntimeModelInfo
Show provider/model capability information.
InitMcpServers(HashMap<String, McpServerConfig>)
Start every configured MCP server; each one emits
Msg::McpServerReady or Msg::McpServerErrored as it comes up.
StopMcpServer
Stop a running server (e.g. config was removed, or app quit).
PullOllamaModel
ollama pull <model> with progress → Msg::ModelPullFinished.
OpenInSystem(PathBuf)
xdg-open / open / start on a file path. Used by the
image-paste preview and the “open in editor” affordance.
DismissStatusAfter
Schedule Msg::StatusDismiss after ms milliseconds. Reducer
uses this to self-clear transient status lines.
WriteImageToTemp
Persist a pasted image to a temp file so the TUI can open it
via OpenInSystem. Emits no follow-up Msg on success; failure
is a log-and-drop.
ReadClipboard
Read the system clipboard on a blocking task. The per-platform
dispatch (xclip / wl-paste / pngpaste / PowerShell) can block
for hundreds of ms on macOS via osascript, so it never runs on
the reducer thread. Emits Msg::Paste(Paste::Image|Text) on
success; Msg::TransientStatus when the clipboard is empty or
the read fails.
CopyToClipboard(String)
Write text to the system clipboard on a blocking task (mirrors
ReadClipboard’s per-platform dispatch). Used by in-app drag-select
copy. Emits a Msg::TransientStatus (“Copied N chars” / failure).
Exit
Exit the main loop. No reply message — the loop observes
state.should_exit after the reducer returns and breaks out.
SetTerminalTitle(String)
Write the OSC 2 terminal-title sequence. Reducer diffs
against ui.last_title_dispatched so this only fires on
actual title changes, not every frame.
Implementations§
Source§impl Cmd
impl Cmd
Sourcepub fn tag(&self) -> &'static str
pub fn tag(&self) -> &'static str
Human-readable tag, for tracing + replay logs. Stable across refactors (tests assert against it).
Sourcepub fn is_turn_scoped(&self) -> bool
pub fn is_turn_scoped(&self) -> bool
True iff this command needs to run inside a TurnScope so it
can be cancelled by Cmd::CancelScope. The effect runner uses
this to decide between “spawn into JoinSet” and “spawn detached”.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cmd
impl RefUnwindSafe for Cmd
impl Send for Cmd
impl Sync for Cmd
impl Unpin for Cmd
impl UnsafeUnpin for Cmd
impl UnwindSafe for Cmd
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more