feat(cli): claw run tails the server-side run in the terminal - #93
Merged
Conversation
After starting a run, the CLI discovers its id (GET issues/{id}/runs, since the id is minted inside the run and not returned by the start) and polls the trace, rendering each row exactly as an in-process run does. A human gate is shown with a hint to answer it in the dashboard; Ctrl-C detaches without stopping the run. Restores the live progress the server cutover removed. Verified live: the trace renders as the run works. Reads list endpoints directly — HttpResponse::json() refuses a top-level array by contract.
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 third slice of TODO item 2. #92 made
claw runhand the run to the server and return; this brings the live view back to the terminal. After starting the run, the CLI follows it and prints the trace as it arrives, ending when the run does.GET /api/projects/{key}/issues/{id}/runs— the runs for an issue (needed because the run id is minted inside the run, so a start cannot return it).ServerClient:runs(),trace(),latestRunId(),awaitRun()— find the run a start produced (the first id past the pre-start high-water mark) and poll its trace.WorkflowMode::tailRun()— renders each trace row exactly as an in-process run does (sameTraceFormat, same depth indentation and▶ ◀ ·glyphs, same level threshold from-q/-v), and stops ondone/failed.Behaviour
claw runprints the run's trace live again, thenRun #N finished issue #M.(or a failure pointer toclaw log).⏸ waiting for a human — answer it in the dashboard; Ctrl-C detaches (the run continues).Detaching loses only the view — the run keeps going on the server andclaw logshows the rest. Answering the gate from the terminal is the next slice (3b).watch it with: claw logand exits 0.Verified live
Against the real server extension:
claw run 6autospawned a server, started the run, discovered its id, and rendered the trace as it worked —Design notes
tracepoll (?since=<seq>) is the SSE fallback endpoint and returns the same rows;CurlHttpClientbuffers the whole body, so it cannot stream an SSE response anyway. 500 ms cadence.runs,trace) are decoded directly inServerClient, not viaHttpResponse::json()— that method refuses a top-level JSON array by contract (it is for string-keyed objects). This surfaced as three tests throwingHttpException; Testo's parallel runner misattributed them to unrelated files at first.Not in this PR
POST …/answer), which turns the read-only tail interactive./startreturning the run id (would remove theawaitRundiscovery poll; deferred because the id is created mid-run).Checks
composer qagreen — cs, PHPStan level 8, Testo (457 tests). NewServerClienttests cover the run-list parsing,latestRunId,awaitRun, andtracedecoding (incl. the top-level-array case).