pub struct StreamTracker { /* private fields */ }Expand description
The authoritative session-state machine over one wrapped claude process.
Feed it every line of both stdio directions; it returns an ObserveRequest
exactly when the session’s effective state changes, so a long turn costs one
report at its start and one at its end rather than one per streamed token.
Implementations§
Source§impl StreamTracker
impl StreamTracker
Sourcepub fn diagnostics(&self) -> StreamDiagnostics
pub fn diagnostics(&self) -> StreamDiagnostics
Returns cumulative metadata-only protocol diagnostic counts.
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
The session id, once a line has carried one.
Sourcepub fn model(&self) -> Option<&str>
pub fn model(&self) -> Option<&str>
The most recently reported model id, once a line has carried one.
Unlike Self::session_id, this can change over a session’s
lifetime (see Self::absorb_identity) — callers that need to react
to a model change compare successive reads rather than treating a
first sighting as final.
Sourcepub fn observe_line(
&mut self,
direction: Direction,
line: &str,
) -> Option<ObserveRequest>
pub fn observe_line( &mut self, direction: Direction, line: &str, ) -> Option<ObserveRequest>
Feeds one stdio line and returns a sighting when the effective state changed as a result.
Returns None for every line that is unparseable, unrecognized, seen
before the session id is known, or that leaves the state unchanged.
Sourcepub fn keepalive(&self) -> Option<ObserveRequest>
pub fn keepalive(&self) -> Option<ObserveRequest>
Re-reports the current state while the session is busy, so one that has been silent for a while — a long turn, an unanswered permission prompt — does not age out of the registry on its TTL.
An idle session is deliberately not re-reported (#1454). The wrapper
lives exactly as long as the claude process does, but the Claude VS
Code extension keeps a process per chat in a window, not per visible
tab: a never-prompted spare, or a conversation the user finished hours
ago, stays alive indefinitely. Process lifetime is therefore not tab
visibility, and re-reporting idle would pin every such process in the
registry forever. The transition to idle is still reported once by
Self::observe_line; after that the session ages out on the registry’s
TTL and reappears the moment it next does anything.
Trait Implementations§
Source§impl Debug for StreamTracker
impl Debug for StreamTracker
Auto Trait Implementations§
impl Freeze for StreamTracker
impl RefUnwindSafe for StreamTracker
impl Send for StreamTracker
impl Sync for StreamTracker
impl Unpin for StreamTracker
impl UnsafeUnpin for StreamTracker
impl UnwindSafe for StreamTracker
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> 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