Pick attach vs resume from actual session liveness when jumping into a session - #116
Merged
Conversation
`a` on a review task whose `claude --bg` session was still resident failed: jump-in read its verb from task state alone, and `claude --resume` refuses a session the supervisor still holds. The two do not track each other — a bg session commonly outlives `running` (DESIGN.md §8's stale-review rebase attaches to a review task's session), and a session can die while its task is still `running`, where `attach` has nothing to join. Liveness now decides the verb wherever the agent can report it, and task state stands in only when it cannot. The `sessions` run-and-parse step reconcile owned moves to a `session_probe` module shared by all three callers — reconcile, dispatch's ref capture, and the jump-in key — keeping liveness three-valued, so an agent with no `sessions` verb behaves exactly as before. The chosen verb then degrades to whichever template the agent actually defines (the built-in codex has only `resume`), erroring only when it defines neither. Verified with unit tests over the verb choice, app-level tests driving the key against a canned listing in each configuration, and the TUI itself against a scratch database: `a` on a review task logs `attach` while its session is listed live, and `resume` once the listing marks it done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
aon a review task whoseclaude --bgsession was still resident failed withthe supervisor's refusal (
Session <uuid> is currently running as a background agent), becausejump_into_sessionread its verb from task state alone:Running →
attach, Review/Stalled →resume. Session liveness does not tracktask state in either direction — a bg session commonly outlives
running(theoperator jumps into a review task's session to ask for a rebase, DESIGN.md §8),
and a session can die while its task is still
running, whereattachhasnothing to join.
What changed
crates/voro/src/session_probe.rsholds the run-and-parse of anagent's
sessionsverb, previously duplicated inreconcile.rsanddispatch.rs.run_sessions_command(cmd, cwd)andlisting_says_liveserve reconcile (which keeps its own per-agent listing cache) and dispatch's
ref capture (which keeps its cwd/startedAt filtering);
session_is_liveserves a caller holding no listing. Liveness stays three-valued:
Nonewhenthere is no
sessionsverb, no captured ref, or the listing would not run.jump_into_sessionprobes on keypress — synchronous, since the TUI isabout to hand the terminal over anyway — and picks the verb from the answer,
falling back to the task-state mapping only when liveness is unknowable.
jump_verbtakes whichevertemplate the agent defines when its preferred one is absent (the built-in
codexhas onlyresume), and errors naming both verbs only when itdefines neither.
running/review/stalled, and the no-session / no-ref status lines are as they
were.
No DESIGN.md change: §8 already describes the operator attaching to a review
task's still-open session, which is what this makes possible.
Verification
cargo test --workspaceandcargo clippy --workspace --all-targets -- -D warningspass. The verb choice is a pure function with unit tests over theliveness × state × available-verbs grid; the app-level jump-in tests now drive
aagainst a canned listing in each configuration — review + live → attach,running + finished → resume, no
sessionsverb → state mapping unchanged,one-verb agent → that verb, no verbs → both named in the message.
Also driven through the real TUI against a scratch database with a stub agent:
on a review task whose listing showed the session
blocked,aloggedattach: echo I-AM-ATTACHING '<ref>'inlaunches.log; rewriting the listingto
state: doneand pressingaagain logged theresumecommand.