pub enum TurnState {
Idle,
Generating {
id: TurnId,
started: SystemTime,
partial_text: String,
partial_reasoning: String,
tokens: usize,
phase: GenPhase,
thinking_signature: Option<String>,
pending_tool_calls: Vec<ToolCall>,
},
ExecutingTools {
id: TurnId,
started: SystemTime,
calls: Vec<PendingToolCall>,
outcomes: Vec<Option<ToolOutcome>>,
},
Compacting {
id: TurnId,
started: SystemTime,
trigger: CompactionTrigger,
},
Cancelling {
id: TurnId,
since: SystemTime,
},
}Expand description
The turn state machine. Each variant carries its own TurnId so
the reducer can cheaply check “is this effect result for the
current turn?” without threading the ID through every match arm.
The ExecutingTools::outcomes: Vec<Option<ToolOutcome>> field is
the architectural payoff: every slot starts None, flips to
Some(outcome) as each tool finishes, and the transition to the
follow-up Generating state requires outcomes to be fully
populated. Statically impossible to “lose” a tool result.
Variants§
Idle
Generating
Fields
started: SystemTimeExecutingTools
Fields
started: SystemTimeWhen tool execution started, so the status line can show elapsed
time (a long-running command — npm run dev, a slow build — would
otherwise look frozen at 0s).
calls: Vec<PendingToolCall>outcomes: Vec<Option<ToolOutcome>>Compacting
Summarizing history as a step of its own: a manual /compact
(trigger: Manual, ends the turn afterwards) or a truncation recovery
(trigger: TruncationRecovery, resumes the run afterwards). Pre-turn auto
compaction instead runs while Generating because it is preflight for the
same user turn. trigger is what the finished/failed handlers key off.
Cancelling
CancelTurn was dispatched. The reducer has already emitted a
Cmd::CancelScope — now we wait for the final Cancelled /
StreamDone that the effect runner sends back when the scope’s
JoinSet drains. Only then do we transition to Idle.
Stuck in Cancelling too long = effect runner has a bug. UI
surfaces a “cleanup taking a while…” hint after 2s.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TurnState
impl RefUnwindSafe for TurnState
impl Send for TurnState
impl Sync for TurnState
impl Unpin for TurnState
impl UnsafeUnpin for TurnState
impl UnwindSafe for TurnState
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