Skip to content

operator: flag idle sessions + byte-bounded PTY-screen previews in ambient tick#371

Merged
edwin-zvs merged 2 commits into
mainfrom
operator-idle-and-preview
Jun 6, 2026
Merged

operator: flag idle sessions + byte-bounded PTY-screen previews in ambient tick#371
edwin-zvs merged 2 commits into
mainfrom
operator-idle-and-preview

Conversation

@edwin-zvs

@edwin-zvs edwin-zvs commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #369. Closes the fleet-observation blind spot and gives the operator selective per-session previews.

The blind spot

Interactive claude/codex/shell sessions never emit AwaitingInput (only their headless paths do), and the daemon doesn't infer idle from PTY quiescence. So an interactive session idle at its prompt looks identical to a busy one (both Running), and the operator couldn't surface "this session finished and is waiting" — the most useful signal for those harnesses.

Changes

Idle detection. The ambient snapshot flags running but quiet ≥10m sessions (from last_pty_at_ms) as idle/waiting/stuck. Headless sessions (no PTY) are unaffected.

Selective, byte-bounded previews. For the most relevant sessions — errored → idle → long-awaiting → recently-active — the tick attaches a compact preview:

  • Source = the rendered PTY screen (recent pty.log tail run through vt100). Interactive claude/codex transcripts are nearly all Pty events near the tail, so a transcript-message preview was empty for them; the rendered screen shows what they're actually displaying. Headless/no-PTY sessions fall back to recent transcript messages.
  • Per-session byte budget (PREVIEW_BYTES, default 800, env-tunable): when content exceeds it, the older part is truncated, keeping the most recent.
  • Up to PREVIEW_SESSIONS (default 10, env-tunable) sessions previewed.
  • Each preview is headed by the full session id, and the observation tells the operator it can call agentd_get_transcript/agentd_get_output/agentd_get_diff (or agentd_list_sessions) to peek deeper.

Adds a bounded client.pty_replay_tail and a vt100 dep on the adapter.

Verification

  • Unit tests: snapshot counts/idle/delta/preview-priority; truncate_keep_tail keeps the recent tail.
  • Built clean; 35 interactive tests pass.
  • Rendered live against the running fleet:
    Fleet now: 5 running (2 idle ≥10m), 2 awaiting_input, 0 errored.
    Needs attention: s7abe002 "Release" running but quiet 18m (idle/waiting?); s8353ee8 "dogfood" …
    
    [s08d5395…] "run using zarvis" running … — recent:
      …(older truncated) Quick safety check: Is this a project you trust? … ❯ 1. Yes, I trust this folder  2. No, exit
    [s277f8d4…] "cycle approval mode…" running … — recent:
      …(older truncated) Updated PR #372 again. The approval-mode hover tooltip now anchors two rows above the modeline …
    
    — including catching a session stuck on a trust prompt, previously invisible to the operator.

Spec 0021 updated. Code in agentd-adapter-zarvis + small agentd-client helpers.

edwin-zvs added 2 commits June 6, 2026 09:24
…ent tick

Closes the fleet-observation blind spot: interactive claude/codex/shell
sessions never emit AwaitingInput (only their headless paths do) and the daemon
doesn't infer idle from PTY quiescence, so the operator couldn't tell a
finished/waiting session from a busy one. The ambient snapshot now flags
"running but quiet >=10m" (from last_pty_at_ms) as idle/waiting/stuck.

It also attaches a compact, ANSI-free preview (last few transcript messages) for
the few most notable sessions (errored, then idle, then long-awaiting; capped at
PREVIEW_SESSIONS), so the operator has concrete content to judge -- selective to
keep input context bounded on a large fleet. Adds client.transcript_tail for the
bounded fetch. Pure snapshot builder is unit-tested; spec 0021 updated.

Verified live: "5 running (4 idle >=10m) ..." with per-session previews.
…ssions

Refines the ambient-tick previews per review:
- Per-session byte budget (PREVIEW_BYTES, default 800, env-tunable); when the
  recent content exceeds it, the OLDER part is truncated (keep most recent).
- Preview cap raised to 10 (PREVIEW_SESSIONS, env-tunable).
- Recently-active running sessions are now included in the preview selection
  (after needs-attention), so the operator sees live activity too.
- Each preview is headed by the full session id, and the observation tells the
  operator it can call agentd_get_transcript/get_output/get_diff (or
  list_sessions) to peek deeper.

Preview source switched from transcript messages to the rendered PTY screen
(vt100 over a bounded pty.log tail): interactive claude/codex transcripts are
all Pty markers near the tail, so message previews were empty for them. Headless
/ no-PTY sessions fall back to transcript messages. Adds client.pty_replay_tail
(bounded) and a vt100 dep.

Verified live: idle sessions show their waiting prompt; one session was caught
stuck on a "trust this folder?" prompt; an active session showed its latest
PR-update summary -- all byte-truncated.
@edwin-zvs
edwin-zvs force-pushed the operator-idle-and-preview branch from 9083495 to 17c5afd Compare June 6, 2026 16:25
@edwin-zvs edwin-zvs changed the title operator: flag idle running sessions + selective per-session previews in ambient tick operator: flag idle sessions + byte-bounded PTY-screen previews in ambient tick Jun 6, 2026
@edwin-zvs
edwin-zvs merged commit 671bdb3 into main Jun 6, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the operator-idle-and-preview branch June 6, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant