Repository navigation
feat(tui): report agent state to herdr - #289
Conversation
`tool_approval_requested` gains `delegated: true` when the gate consults the approval reviewer before any human (protocol 32, unreleased, so no version bump). Omitted when false, so every earlier hold encodes unchanged; a v32 golden pins the new shape. The client store records delegated holds in `LiveStatus::with_delegate`, drops them on escalation or settlement, and keeps them across a body reload. `SessionStore::activity()` folds a whole store into one state: blocked when any hold waits for a human, else working when any session runs or is queued (a delegate deciding counts as work), else idle. Refs: ENG-1034
Inside a herdr pane (HERDR_ENV=1 with HERDR_PANE_ID and HERDR_SOCKET_PATH) the TUI reports `idle` / `working` / `blocked` for everything it follows, with the focused session as the resume command (`qq --session ID`), and releases the pane on exit. One background task sends only the newest state over herdr's Unix socket, one JSON line per request with a 500 ms bound; failures are dropped and `update` never waits. The loop publishes only after input or a client update, deduplicated in the sink. `seq` starts at wall-clock microseconds so a restarted qq stays above what herdr last accepted. `qq serve` and `qq run` never report; Windows is off (no Unix socket). Refs: ENG-1034
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 650a42d2ae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex review on #289 found the aggregate read state that only warm bodies or previously seen events carry: cold sessions past the prewarmed four, clients that attach mid-hold, and side questions all reported the wrong state. The root cause is one: a per-session fact the client could not reconstruct. The server now projects it. - SessionSummary gains `pending_holds` (the active run's held calls, each with `delegated`, human-first, at most 16) and `running_side_question`, exact at the summary's cursor and omitted when empty. Protocol 32 is unreleased; existing goldens are unchanged, one new golden covers both. - Store schema 44 -> 45 adds `tool_calls.approval_delegated`, written with the hold and cleared on escalation. Schema 44 is unreleased (v0.1.6 shipped 43). Pre-upgrade holds read as waiting for a human. - The client seeds hold sets from every summary and tracks side questions for cold sessions; `activity()` reads summary-level state only. - herdr resume names the focused session's root (`--session` opens roots only), or nothing when the root is unknown. - The acknowledgement read is bounded to 4 KiB; the sequence clock is max(wall clock, previous + 1) with an injectable instant, so its test is deterministic; streamed deltas no longer trigger the aggregate fold. Refs: ENG-1034
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d36bdee123
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- activity() folds every stored session, including children whose parent is not loaded. - Snapshot replay covers every installed body, not only the focused one. - Hold and side-question projections fold into the summary query: no extra query per session. - A failed escalation write fails the run instead of waiting unannounced. - No herdr report before the first snapshot. Refs: ENG-1034
Closes ENG-1034.
What changes for users
In a herdr pane,
qqnow reports its own state ("supported by the agent"); there is nothing to install. herdr's sidebar,herdr agent list, notifications, andherdr agent waitsee one state for every session the window follows:blockedworkingidleAfter a herdr server restart the pane runs
qq --session <root of the focused session>and reopens it (a focused sub-agent reopens as its tree). Quitting clears the pane.qq serveandqq runnever report.Design
0f85584):tool_approval_requestedgainsdelegated: truewhen the gate consults the approval reviewer before any human. Without it a client cannot tell "reviewer is deciding" from "waiting on you" until an escalation. Protocol 32 is unreleased (v0.1.6 ships 31), so no version bump; the field is omitted when false, so every existing hold and golden encodes byte-identically. New v32 goldenevent_tool_approval_requested_delegated.d36bdee1, Codex review):SessionSummarygainspending_holds(active run's held calls, eachdelegatedwhen a delegate decides first; human-first, ≤16) andrunning_side_question, exact at the summary's cursor and omitted when empty. Store schema 44 → 45 (unreleased; v0.1.6 shipped 43) addstool_calls.approval_delegated, set with the hold and cleared on escalation; pre-upgrade holds read as waiting for a human. One new goldenevent_session_updated_with_holds; existing goldens unchanged.LiveStatushold sets; events move them on, for warm and cold sessions alike, and side-question state is tracked for every session.SessionStore::activity()reads only summary-level state and folds worst-first (blocked > working > idle), so sessions whose bodies were never loaded and clients attaching mid-hold report correctly.650a42d,qq-tui/src/herdr.rs): enabled only whenHERDR_ENV=1,HERDR_PANE_ID, andHERDR_SOCKET_PATHare all set. One background task fed by awatchchannel sends only the newest state (herdr's "drop older states" rule) as one JSON line over the Unix socket, 500 ms bound per request, failures dropped.updatenever waits on I/O. The loop publishes only after input or a client update (not frame/animation ticks), deduplicated in the sink.seqismax(wall-clock µs, previous + 1). The acknowledgement read is bounded to 4 KiB. Streamed deltas (text_appended,reasoning_delta,tool_call_output_delta,run_activity_changed) do not trigger the fold. Release is best-effort and bounded on every loop exit.qqlaunched by a tool never seesHERDR_*and cannot report over the parent.Verification
cargo test --workspace: all pass (one unrelated pre-existing timing test,plan::tests::async_compilation_bounds_waiters_and_releases_cancelled_requests, failed once under load and passed 5/5 alone).store_activity_counts_sessions_whose_bodies_were_never_loaded,the_session_summary_says_who_a_hold_waits_on_until_it_settles,version_forty_four_reads_existing_holds_as_waiting_for_a_human,a_child_resolves_to_its_root_and_an_unknown_parent_resolves_to_none,an_endless_answer_without_a_newline_is_read_only_to_the_bound; the seq test injects instants.cargo fmt --all -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings: clean.cargo build --workspace: ok. docs_truth: 23 passed.delegatedfor reviewer-consulted / no-reviewer /ask-with-reviewer-not-consulted.qqbinary under--tui-qa-rootin a pty with a fake herdr socket reportedpane.report_agent idlethenpane.release_agentwith increasingseq.Performance
The fold is
O(sessions)and runs only on state-bearing updates and input; socket I/O is off the loop. Each summary load adds one indexedside_questionslookup (partial unique index on running) and, only for sessions with an active run, onetool_callslookup on(run_id, …)bounded to 16 rows. Event size bound test passes.Not covered
No live run against a real herdr server (verified against herdr's documented contract and source at
241b99cd). The approval change is small but touchessessions/; workflow.md asks for an independent review.