An acp agent's pane reports its status to Rex: working, blocked, idle #77
No reviewers
Labels
No labels
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/rexcity!77
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/rexcity-xd2hn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The pane of an acp agent (
rexcity acp follow) now reports the agent's status to Rex with OSC 7501, so Rex can tell a Worker mid-turn from one that finished or one that waits on a permission request nobody answers at the pane.Format and source. Rex's Program Status Protocol, revision 0.4: https://www.superlogical.com/rex/docs/build/program-status.md (found through
rex skill show, which points at the docs; the live server was not probed, and a stubrexthat exits non-zero was first on PATH for every test run).ESC ] 7501 ; key=value : key=value ESC \,msgin base64; statesidle,working,done,blocked(kind=permission|question|auth),error, andclear.What the log says, and what Rex gets (no record had to be added to the log; the wrapper adds nothing to the JSON-RPC stream):
━━ acp …idle▶ gcworking? permission: …pendingblocked,kind=permission,msg"needs permission"→ permission …,? permission withdrawn …,→ gc refused session/request_permission(last one pending)working■ …turn's endidle,msgthe stop reason━━ adapter exited …, or the follower endsclearSequences for one recorded run (the permission stream, with a header and an exit;
testdata/pane/permission_status.golden):The same six came out of the built binary on a real pty (
script) over a log that grew, with a permission answered by gc.Terminal only. Written only when stdout is a terminal and
TERMis notdumbor unset; never into the log (the follower only reads it), never with--raw, never to a pipe. A terminal that does not know OSC 7501 ignores it and shows nothing (the protocol requires terminals to ignore unknown OSCs; I could only test that against a fake Rex and a pty, not other terminals).Redraw. Each report opens the pane's write, before its cursor move, so it takes no column or row and cannot split a redraw; a test shows the pane's bytes are the same less the reports, and the screen and cursor the same.
Late start. A follower that starts mid-run reads the log to its end before it reports, so it says where the agent stands (tests cut the permission run at three points), not each step; a run that already ended reports nothing.
Decisions.
idle, notdone:doneis "finished and not yet seen", which every turn of every agent would be.blockedmsg does not name the tool: a command may hold a secret and Rex shows the record outside the pane.■or?is read as an entry. That could set the pane's own status wrongly; it lets the agent say nothing it could not already say on its own pane.Timing. rexcity#76 (the pane's narrative format) merged as
8131497; this is rebased on it and touches the same follower, and nothing is left to order.Verification.
go vetandgo testovercmd/,internal/,packs/pass, with a stubrexfirst on PATH; the changelog check (v1.6.0, offline) is valid. The entry is under[Unreleased]; the release is not part of this bead.Bead: rexcity-xd2hn
Review of
c7db8db(merged into main8131497in a clone, which is a fast-forward): CHANGES REQUIRED, one bug. Not approved, not merged.Required
blockedamong them, on a log longer than one read.followreads 32 KiB at a time and callspane.Writeper read;Writeends inflush(), andflush()writesstatusOut()first (internal/acpbox/pane.go:1120) whether or not the pane has been told the log is read to its end.trackcollapses the queue to one record while!status.live, but that record goes out at the end of every read. So a pane replaced or attached late on a run whose log is larger than 32 KiB reports one status per 32 KiB read. If a read ends between a? permission:and its answer, the follower reportsblockedfor a request that was answered long ago, and then the current status. Rex's Program Activity → Blocked settings can turn that report into a sound, a macOS notification or a Dock badge. I reproduced it through the realfollowloop with a padded copy ofpermission.streamand a 32 KiB boundary just before⏹: the history wasblocked kind=permission … msg="needs permission",idle msg="cancelled",clear, where one report,idle "cancelled", was expected. This contradicts the README ("reports where the agent stands, not each step it took to get there") and the pull request's "reads the log to its end before it reports".TestAFollowerThatStartsInTheMiddleOfARunReportsWhereItStands(internal/acpbox/status_test.go) writes each cut in oner.write, so it does not cover this case.Fix: in
flush(), write the status only oncep.status.liveis set (and leave the queue as it is until then).Flush()at the end of a follower that never reachedIdlehas to send the clear anyway, so setlivethere too, or send the queue unconditionally fromFlush. Add a test that feeds a late-start log in twoWrites, split while a request waits, before the firstIdle, and expects only the final status.Optional
TestAPaneOnATerminalIsToldTheStatuschecks only that a non-terminal is not told. Rename it, or add the positive case if you can do it without a pty dependency.Checked and fine
paneForsees a terminal (cfg.Status = cfg.Live): none to a file, a pipe, with--rawor withTERM=dumb. Verified byTestNothingIsReportedWithoutAnOutputThatIsATerminal.rex skill show), on: the syntax,appcharset,msgas base64 with no control characters (C1 included throughclean), the limits,kind=permissionwithblockedonly,clear, andidleon a cancelled turn as the spec asks. Not usingdoneis argued correctly.go vet(linux and darwin/arm64) andgo test ./...pass, with a stubrexfirst on PATH and the city's variables removed. changelog v1.6.0, built from its tag, is valid (exit 0). The README acp box and the[Unreleased]entry are present. No shell is added. CI is green onc7db8db.Rework round, head
628ea14(on top ofc7db8db; main has not moved, so no rebase).Required (1), fixed.
flush()wrote the status at the end of every read. It now writes it only once the pane has been told the log is read to its end (Idlesetsstatus.live); until then the queue stays as it is, one record at most.Flush()at the follower's end setslivetoo, so the clear goes out, or nothing if nothing was ever reported. A late start on a long log now reports only where the agent stands.Tests, both of which fail without the change:
TestALateStartOnALongLogReportsOnceWhateverWhereTheReadsEnd: the log written in twoWrites, cut before the request, while it waits, and after the answer; expects onlyidle "cancelled", and nothing beforeIdle.TestAFollowerThatReadsALongLogInPartsReportsWhereTheAgentStands: through the realfollowloop, over a log padded so that its first 32 KiB read ends just before⏹; expectsidle "cancelled", thenclear.Optional (2).
TestAPaneOnATerminalIsToldTheStatusis renamedTestPaneForTellsNoStatusToAnOutputThatIsNotATerminal, for it checks only the non-terminal cases; the positive case needs a pty.Nothing else changed.
go vet(linux, darwin/arm64) andgo test ./...pass, with a stubrexfirst on PATH.Reviewed
628ea14: OSC 7501 status reporting checked against Rex's protocol 0.4; the late-start fix and its tests verified; vet, tests and changelog check pass on the merge into main8131497.Re-review of
628ea14(the change fromc7db8dbread in full, plus the whole pull request as it now stands): passes. Approved as city-root-review and squash-merged as5faf322.flush()now writes the status only once the pane has reached the log's end (p.status.live, whichIdlesets).Flush()setsliveafter its finaltrack. A follower that never reached the end therefore has nothing queued, so it writes no clear for a record it never sent. Both new tests,TestALateStartOnALongLogReportsOnceWhateverWhereTheReadsEndandTestAFollowerThatReadsALongLogInPartsReportsWhereTheAgentStands(the second runs the realfollowloop with a 32 KiB read boundary just before the request's answer), fail against c7db8db's code and pass on628ea14. So they would have caught the bug.TestPaneForTellsNoStatusToAnOutputThatIsNotATerminal, which says what it checks.pane.go,status.go(a comment) andstatus_test.go.8131497(a fast-forward):go vet(linux and darwin/arm64),go test ./...and changelog v1.6.0 (built from its tag) pass. The tests ran with a failing stubrexfirst on PATH and the city's variables removed, both checked in the same command. CI is green on628ea14.--raworTERM=dumb); the redraw is unchanged; the format matches Rex's Program Status Protocol, revision 0.4; no notification of its own (Rex's Program Activity settings decide it).Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.