fn last_line_preview_and_activity(
mstore: &Arc<Store>,
filestore: &Arc<FileStore>,
block_id: &str,
) -> (Option<String>, Option<u64>)Expand description
Last non-blank line of a block’s own transcript, truncated for preview
display, plus a real “when was this last written” timestamp — None
for either if the block has no session output yet (e.g. an agent
registered but no turn has produced output) — missing is not an error,
same “encode absence in the body, not the status” posture as the rest
of this file.
Fast path: a bounded tail read straight off the live FileStore file
(stat + a small read_at, not a full read) — covers the overwhelming
common case (an active or recently-active, non-archived block) without
loading/decompressing full session history just to preview one line
(codex P2 on PR #2715: the original version called
session_archive::read_session_output, a full-session-export
primitive, for every host agent on every conversations call). The
file’s own modts doubles as a REAL last-activity timestamp — unlike
AgentRegistration::last_seen, which nothing in this codebase updates
after registration (codex P2 on PR #2715: using it as
last_activity_ms made a long-lived, actively-working agent look
hours-stale). Falls back to the full-read primitive (which also
handles archived/gzip sessions) only when the fast path finds nothing —
no live file yet, or genuinely archived — at the cost of no cheap
activity timestamp in that fallback case (None, not a guessed value).