Expand description
Fleet snapshot — the cluster-wide session view, shared on disk.
claudectl relay serve owns the write side: on every tick it records the
sessions each connected peer advertised in its heartbeat, plus the sessions
running on this machine. Readers (the TUI, claudectl --json) pick the file
up on their own refresh.
A file rather than an HTTP call, because the relay and the TUI are separate processes on the same machine and the peers panel already reads peer state off disk the same way. That keeps the fleet view working with no port or token to configure first; the coordinator’s HTTP API stays available for dashboards outside the machine.
Writes go through a temp file + rename so a reader mid-tick never sees a
half-formed snapshot.
Structs§
- Fleet
Snapshot - What
relay servepublishes for local readers. - Fleet
Worker - One peer’s contribution to the fleet view.
- Local
Session Collector - Collects this machine’s sessions for advertising to peers, keeping the per-session parse state that makes repeated collection cheap.
Constants§
- SNAPSHOT_
STALE_ SECS - A snapshot older than this means
relay serveis no longer running, so the whole file is ignored rather than showing a frozen fleet. - WORKER_
STALE_ SECS - Workers whose last heartbeat is older than this are dropped on read. Three times the default 30s heartbeat interval, matching the mesh’s own expiry so a peer doesn’t linger in the fleet view after it stops reporting.
Functions§
- build_
snapshot - Build a snapshot from the local identity and the per-peer state the relay has accumulated.
- collect_
local_ sessions - One-shot collection, for callers that run once and exit (
relay fleet). Long-running callers should hold aLocalSessionCollectorinstead. - read_
snapshot - Read the snapshot, or
Nonewhen it’s absent, unparseable, or stale enough thatrelay servehas clearly stopped writing it. - read_
snapshot_ from - Read from an explicit path. Exists so tests don’t touch
$HOME. - remote_
sessions - The remote sessions a local reader should display, with stale workers dropped and each entry tagged with its originating worker.
- sessions_
from - Map a snapshot’s live workers into displayable sessions.
- snapshot_
path - Where the fleet snapshot lives.
- write_
snapshot - Write the snapshot atomically (temp file + rename).
- write_
snapshot_ to - Write into an explicit directory. Exists so tests don’t touch
$HOME.