Expand description
Per-session actor. Owns one Arc<AgentHandle>βs event drain
(AgentHandle::take_events) plus a per-session Command
receiver. Translates each AgentEvent into the matching
SessionUpdate envelope and emits onto the workspace-wide
fan-out, which hands one update to every subscriber. Mutates
DomainSession inline before each
emit so workspace-side projections stay current.
SessionTask::run is the sole consumer of the AgentHandle event
stream.
Re-exportsΒ§
use std::sync::Arc;πuse forge_agent::AgentHandle;πuse forge_agent::client::AgentEvent;πuse forge_primitives::SessionId;πuse parking_lot::Mutex;πuse tokio::sync::mpsc;πuse tracing::Instrument;πuse crate::SessionSlot;πuse crate::domain_session::DomainSession;πuse crate::domain_session::PendingAutoContinue;πuse crate::handoff;πuse crate::protocol::Command;πuse crate::protocol::NoticeSeverity;πuse crate::protocol::PendingInteractionSlot;πuse crate::protocol::PromptSource;πuse crate::protocol::SessionUpdate;πuse crate::update_fanout::UpdateFanout;π
StructsΒ§
- Moved π
- What one event MOVED in the domainβs whole sets.
- Session
Task π
EnumsΒ§
- Monitor
Origin π - Which side of the session a monitor was folded from, which decides the state it starts in.
- Moved
Turn πEnd - What a turnβs end was, for the caller to announce.
ConstantsΒ§
- API_
RETRY_ πSUBTYPE - The wire subtype of the retry frame, where the CLI names an authentication failure on the retry path. A view matches the same literal.
FunctionsΒ§
- apply_
event_ πto_ domain - Apply an
AgentEventto aDomainSession. Pure mutation; no I/O, no async, no sends. Called from insideSessionTask::translate_eventunder the domainβs lock. - clear_
runtime_ πidentity - Drop every fact that describes one run of a session: the hookβs mode and effort, the model it resolved, the two bridge snapshots that describe a subprocess tree, and the monitor set that run started.
- drain_
settled_ πmonitors - Drop the monitor set once every entry in it is terminal.
- execute_
command_ πvia_ handle - Forward a
Commandstraight tohandle. Pure transport - no pending-interaction bookkeeping; the only commands that consultPendingInteractionSlot(RespondPermission / RespondQuestion) must be handled by the caller before delegation here. - failure_
reason π - What the failure is called in the nudge: the CLIβs own errors when the result frame reported any, else its subtype, else a plain fallback.
- fill_of π
- The fill a reading states, against the CLIβs own effective window.
- fold_
monitor π - Fold one wire message into the sessionβs monitor set: the
Monitortool call that starts one, the task id the CLI assigns it, and the lifecycle message that settles it. - held_
while_ πswapping - The words a permission answer carried, where it carried any: the boxβs own notes, the one field a dictation into the ask lands in (#1360). Hold a prompt aimed at a seat that is swapping its occupant, answering whether it went into the hold.
- hold_
view_ πfacts - The facts this event carries that a view reads through the view surface: the hook observationβs mode and effort, the two bridge snapshots, the resolved model, and the monitor set.
- maybe_
kick_ πlead_ on_ connected - A leadβs first turn after a boot spawn handed it a stored session id
to resume: the restart note the spawn stamped on the domain when the
boot read the seat as mid-turn. The hook takes the note, so a reconnect
repeats nothing, and a parked seat, a first boot or
--newnever stamped one. - maybe_
kick_ πworker_ on_ connected - Shared worker-kick hook: when the session that connected is a worker,
dispatch a
Command::Promptcarrying the live workerβs stored kick to it. Claude sessions donβt act until a user-turn arrives, so without this kick a worker would sit idle indefinitely after spawn (its charter would shape behaviour IF prompted, but nothing prompts it). - maybe_
respawn_ πworkers_ on_ connected - Shared worker Connected hook: when the session that connected is a
projectβs lead and no live workers exist for the project yet,
(re-)spawn its workers - one
SpawnWorkerper persisted worker row. Called fromSessionTask::translate_event(production) andon_connected_for_test(tests). Idempotent; safe to call multiple times for the same session - thelive_workers.is_empty()gate guards against double-spawn on/newreconnects or transient retries, andrespawn_workers_for_leadno-ops when the project has no worker rows. - monitor_
status_ πfrom_ wire - The status a terminal
task_updatednames, in the vocabulary the renderers use.Nonefor a status that is not terminal, and for one forge does not know: a patch that only stamps an end time carries no status at all. - permission_
words π - question_
words π - The words a question answer carried, where it carried any: its own note,
for the same reason as
permission_words. - reconcile_
model_ πfrom_ init - Take the model a turnβs
system/initnames, which is how a switch reaches a reader:/modelre-fires the frame with the model the turn runs under, and the frame arrives at the head of every turn besides. - settle_
monitor π - spawn_
permission_ πresponse_ forwarder - Forward an awaited permission outcome to the agent so the bridge can complete the round-trip with the CLI subprocess.
- spawn_
question_ πresponse_ forwarder - Forward an awaited question outcome to the agent so the bridge can complete the round-trip with the CLI subprocess.
- task_
status_ πis_ terminal - Whether a
task_updatedpatch names a status that ends the task. - warn_
no_ πsession