feat(cli): answer a run's human gate from the terminal - #94
Merged
Conversation
When a tailed run parks at a question, the CLI prompts on the terminal and POSTs the reply to …/answer; the run wakes and carries on. A non-tty (piped) run keeps the read-only hint instead of blocking on input, and a closed stream detaches. Turns the read-only tail interactive. answer() status mapping is unit-tested; the interactive path is not live-verified (a real gate fires non-deterministically).
From Fable's review: re-prompt on a bare Enter rather than spending the gate on an empty answer; suppress the doubled hint after an EOF detach; reject an answer that will not JSON-encode instead of sending an empty body. The stale-answer-to-a-second-question window (a dashboard answer racing the terminal user's typing) is left for a server-side fix — /answer should take a question id and 409 on mismatch.
EdmondDantes
added a commit
that referenced
this pull request
Jul 27, 2026
Closes the terminal-vs-dashboard race from #94's review: while the CLI blocks on input, the same gate can be answered in the dashboard and the run can open a new question — the terminal reply then landed on the wrong question with a 202. /answer now accepts the question id the caller is reading from the trace and returns 409 when it is no longer the open one; the CLI re-prompts for the current question. A missing id keeps the old behaviour.
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.
What
The fourth slice of TODO item 2 (3b), completing the run experience over the server. #93 brought the trace back to the terminal read-only; this makes it interactive — when a tailed run parks at a question, the CLI asks the person and sends their reply, and the run carries on.
ServerClient::answer()—POST /api/projects/{key}/issues/{id}/answerwith{"text": …}, mapping 202→ok, 409→"the run is not waiting" exception, else error.WorkflowMode::tailRun()— aquestiontrace row opens the gate (itspromptis the question), ananswerrow closes it; on a tty the CLI prompts on STDIN and posts the reply, on a pipe it keeps the read-only hint so it never blocks on input.Behaviour
claw runnever blocks: it prints the dashboard hint once and keeps following.Honesty
answer()'s status mapping is unit-tested. The interactive path is not live-verified — a real gate fires only when the model decides to ask, which is non-deterministic and costs a full run to reach. The read-only tail it builds on was verified live in #93. Reviewed for control-flow (no spin/double-prompt/missed-gate).Design note
Answering by issue, not by question id: the server matches the reply to the issue's one open gate (
POST …/answertakes onlytext), and has a dead-gate fallback that journals the answer if the run that asked is gone — so a reply is never lost to a restart.Not in this PR
/startreturning the run id (would remove theawaitRundiscovery poll).claw -i/-cwriters behind the server.Checks
composer qagreen — cs, PHPStan level 8, Testo (459 tests). New tests cover the answer status mapping (accepted carries the text; 409 is surfaced).