A run's state is worked out from what it did (#8707)
- One function:
runState(src/runs/state.ts) names a run waiting, working, needs input, failed, done or silent from its row, its last sign of life and its plan — never from anything the run says about itself. The runs API rows carry it asshown; the runs tab and home badges read it. - Silent: a running agent run with no log line and no plan update for 10 minutes. One
silentflow alarm names the one silent longest (home, /boards, the notifier). Signs of life are kept in memory (runs/activity.ts); a run started before this process booted is measured from its start. Because the signs are in this process's memory only, during a roll a run that is logging to the other process, or one logging from before a restart, can read silent falsely; the alarm is then a prompt to look, not a verdict. - Stopped by a person (#13457): a run someone cancels from its page reads Stopped by alice, 2 minutes ago — one sentence (
stoppedWords,src/runs/cancelled.ts) on the run page, its feed row (kept a post, never folded as a quiet run) and the terminal's run log — in the quiet colour, never red. A run that ended on its own first keeps its real end. - Repeat stop: more than 3 agent runs on one issue in 10 minutes, whatever each said (
crew/repeat.ts), parks the issue with one note and raises onerepeatalarm; nothing starts until a person who directs the crew speaks. - Plan: a run keeps up to 12 checklist items on its issue, replaced whole each time:
PUT /api/v1/repos/:owner/:name/issues/:number/plan{ items: [{ text, done? }], ask? }, the MCP toolkeep_plan, shown on the issue page and inGET …/issues/:numberasplan.askmarks the run needs input until the next update. Only the agent with a run going on that issue may set its plan (a writer's or another run's call is refused,forbidden). Not an event: it is progress, like a log. - Runs tab count is
runningCount: running agent runs and checks, the sum of the pipeline's building, review and checking stages. GET …/runs?state=queued|running|ok|failed|cancelledfilters; an unknown state is a 422.- In the terminal: the issue screen (
src/tui/screens/issue.ts, rows fromsrc/tui/screens/runplan.ts) shows a Plan card above the thread —[x]/[ ]items and the question asneeds input: …— read through the samereadPlan(so gated as the page is), and its title says silent or needs input when the issue's runs read that way, fromshownStates. - The runs API works out
shownfor a page of runs with one plan read (shownStates), not one per row. - Stopping: a cancel marks the row at once, but the run's page says stopping (a moving word, filed under working) until its worker here has ended every process the run started — SIGTERM to the group, SIGKILL once the grace runs out, an agent's orphans reaped — and only then cancelled; the cancel's one
run.finishedis announced at that moment, not before (src/runs/ending.ts, #13291;test/run-cancel-stopping.test.tscancels a check whose stand-in step holds on after the abort, and finds the word stopping and norun.finisheduntil the step lets go, then cancelled and the onerun.finishedafter). That none of the processes is left istest/run-cancel-tree.test.ts's: a cancelled check's command, the child it forked and that child's child are all gone within 2 s, and a step and the sleeper it forked that both ignore SIGTERM are killed once the grace runs out. A worker that never lets go is announced at the 30 s deadline (ENDING_DEADLINE_MS) while the page still says stopping; when it lets go later, arun.stoppedwake-up (not a secondrun.finished) turns the live head to cancelled.