pub struct LiveState {
pub output_lines: Vec<String>,
pub updated_at: DateTime<Utc>,
pub machine_state: MachineState,
pub last_heartbeat: DateTime<Utc>,
}Expand description
Live streaming state for a session, written frequently during Claude runs.
This struct holds the most recent output lines and current state, enabling the monitor command to display real-time output without reading the full state. Written atomically to prevent partial reads.
The last_heartbeat field is the authoritative indicator of whether a run is
still active. GUI/TUI should consider a run “active” if heartbeat is recent
(< 10 seconds old).
Fields§
§output_lines: Vec<String>Recent output lines from Claude (max 50 lines, newest last)
updated_at: DateTime<Utc>When this live state was last updated (by output or state change)
machine_state: MachineStateCurrent machine state
last_heartbeat: DateTime<Utc>Heartbeat timestamp - updated every 2-3 seconds while run is active. This is the authoritative indicator of whether the run is still alive. GUI/TUI should consider a run “active” if this is < 10 seconds old.
Implementations§
Source§impl LiveState
impl LiveState
Sourcepub fn new(machine_state: MachineState) -> Self
pub fn new(machine_state: MachineState) -> Self
Create a new LiveState with the given machine state.
Sourcepub fn append_line(&mut self, line: String)
pub fn append_line(&mut self, line: String)
Append a line to the output, keeping at most 50 lines.
Updates the updated_at timestamp.
Sourcepub fn update_heartbeat(&mut self)
pub fn update_heartbeat(&mut self)
Update the heartbeat timestamp to indicate the run is still active. This should be called every 2-3 seconds during an active run.
Sourcepub fn update_state(&mut self, new_state: MachineState)
pub fn update_state(&mut self, new_state: MachineState)
Update the machine state and refresh timestamps. Called when the state machine transitions to a new state.
Sourcepub fn is_heartbeat_fresh(&self) -> bool
pub fn is_heartbeat_fresh(&self) -> bool
Check if the heartbeat is recent enough to consider the run active. Returns true if the heartbeat is less than HEARTBEAT_STALE_THRESHOLD_SECS old.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LiveState
impl<'de> Deserialize<'de> for LiveState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LiveState
impl RefUnwindSafe for LiveState
impl Send for LiveState
impl Sync for LiveState
impl Unpin for LiveState
impl UnwindSafe for LiveState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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