The acp view shows a tool call when it starts, and its status when it ends #75
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!75
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/rexcity-mrj1z"
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 acp log writes a tool call twice: when it starts and when it ends (rexcity-mrj1z, the user's choice on #73). A call that runs for minutes is now in the pane within seconds.
What the log shows
HH:MM:SS ▷ Bash #3, with the input under it as #73 shows it (line breaks kept, JSON indented, 30 lines of 240 characters). The time is when the call was first seen.HH:MM:SS ✓ Bash #3 (4s), or✗ … (4s) — why. It carries the time it ended, the final status and how long it ran. The input is not repeated.#N, assigned in the order calls are first seen and carried by both entries. It is two or three characters, unlike atoolCallId, and calls of one turn overlap and end in any order.… Bash #3 (no final status), after its start (written first if it was not).When the start is written, and what happens to a later input
The recorded streams show what claudeacp sends (
internal/acpbox/testdata/*.stream, andclaudeacp@v0.5.0/claudeacp/toolcalls.go, which streams withIncludePartialMessages: true):tool_callwithrawInput: {}and the titleTerminal.tool_call_updates with the fields the model has finished, each time whole (permission.stream:{command}, then{command, description}). The last field only comes with the whole input.in_progressbetween the whole input at 0.18s and the first result at 1.27s, and thesleep 6ends at 6.3s. Nothing on the wire says the input is whole.So "at once with what is known" would write a start with no input at all (step 1), and "when the input is first complete" cannot be known. The start is written when the adapter moves on from the call:
in_progress,completed,failed);SettleTimeout(2s,Config.SettleTimeout: a timer that pushes onto the renderer's queue and never blocks the relay).Before the start the renderer keeps the last input, as the lines that show it. After the start it keeps nothing, and an input that changes afterwards is not written again: the log is only appended to. The cost: a call whose last field the model is still writing when the stream has been quiet for 2s (a big
WriteorEdit, whose last field is the content) starts with the fields known then. I chose that over holding the start for the status, which would put asleep 600in the pane only when it ends.The wrapper held a call's whole input until the call ended (the follow-up of #73's review). It now holds, until the start is written, only the bounded lines that show the input, and the call's title and name cut to one line (plus the rune that says it was cut). The title matters: claudeacp sets a Bash call's title to the whole command (
claudeacp/reporters.go:65), so a 10 MB command was held whole in the title after its start was written, the first time round.TestAHugeInputIsNotHeldPastItsStartruns a 200 000-lineWrite, andTestAHugeTitleIsNotHeldPastItsStartEitheran 8 MB Bash command as the title. What stays for the run is the id of each call that ended, so that a late update is known for one.A message about a call whose end is written (a final status, or the end of a turn without one) is ignored: it used to open the call again as a new call, with a new number, written as a start and an end (
TestAnUpdateAfterACallEndedOpensNoNewCall). An empty line inside a command is written empty, not as the indent alone, and the highlighter lets it pass and goes on colouring the body after it.The passthrough
Not touched. The timer calls
box.push, which never blocks;TestAHeldUpRendererNeverHoldsUpTheRelaystill passes, andgo test -race ./internal/acpboxis clean. With highlighting off,rexcity acp followstill writes the log's bytes (TestFollowCommandHighlightsOnlyWhenAsked). With it on, the highlighter takes a▷head for a body's head, since end entries have none;TestHighlightColoursTheBodyOfAStartEntryAndNothingOfAnEndruns it over the renderer's own output.One recorded turn: a long-running call and two overlapping calls
Recorded from real claude 2.1.322 through
claudeacp(the one in the city's bin) against a throwaway mock Messages API (not in the tree) that streams three Bash calls in one message, their input in severalinput_json_deltas:sleep 6(the long one),sleep 1andsleep 2, which claude ran concurrently. The wire timeline:testdata/overlap.streamis that, with@SECONDSoffsets (the fixture reader sets the renderer's clock by them), andoverlap.goldenis the log as it now is:(The fixture's clock starts at 17:42:05. Here the starts are written when the first call ends, at 1.27s; with no sibling, the 2s timer writes a lone call's start.) The goldens of
turn,permissionandtoolschanged to the new shape;toolsstill has itssleep 600that never ends:▷ Bash #6, then… Bash #6 (no final status).Changes
internal/acpbox/render.go: start and end entries,#N, durations,startCallsbefore any other write,inputLineskept instead of the raw input.internal/acpbox/box.go:SettleTimeoutand its timer.internal/acpbox/highlight.go: only▷heads begin a body.[Unreleased], which says it changes what 0.32.0 shows. The release of #73 (rexcity-9vo91) has not merged: origin/main is stillce44061. If it merges first, the entry has to move under the new, empty[Unreleased].Verification
With a stub
rexthat exits 1 first on PATH:go vet ./...,GOOS=darwin GOARCH=arm64 go vet ./...,go test ./...andgo test -race ./internal/acpboxpass; the v1 changelog check (changelog@v1.6.0, offline) saysvalid=true.Bead: rexcity-mrj1z
In 0.32.0's log a tool call is one entry, written at its final status, so a call that runs for minutes is not in the pane until it ends. The user asked for a start line (rexcity-mrj1z, on rexcity#73). A call is now two entries tied by its number in the run, '#N': the start ('HH:MM:SS ▷ Bash #3', with the input as before, stamped with when the call was first seen) and the end ('HH:MM:SS ✓ Bash #3 (4s)', or ✗ with why, without the input, with how long it ran). A call without a final status at the end of a turn or run ends as '… Bash #3 (no final status)', after its start. claudeacp opens a call with an empty input, sends the fields the model has finished, then the whole input, and then says nothing until the tool has run (no in_progress in the recordings), so nothing on the wire says the input is whole. The start is written when the adapter moves on: a status, any entry or message that is not a call's own, or, for a call that runs on in silence, the box's SettleTimeout (2s) of quiet. An input that changes after the start is not written again, since the log is only appended to. The renderer keeps only the lines that show an input, and drops them at the start, so a huge Write is no longer held until it ends. The highlighter takes only a start entry's head for a body's head: end entries have no body. Tests: the renderer's cases (overlap, late input, retention, the settle hook), a box test for the timer, and a recorded turn (overlap.stream, real claude 2.1.322 through claudeacp against a mock Messages API streaming three Bash calls) whose fixture lines carry their offsets. Validation: go vet, go vet for darwin/arm64, go test ./... with a stub rex on PATH, go test -race on internal/acpbox, the v1 changelog check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>Review of
e9edc422c7against maince44061. Changes required: one, small. Everything else passes.Required
internal/acpbox/render.go:436-437(toolCall.merge) keeps the title whole until the call ends. For a Bash call, claudeacp makes the title the command itself:claudeacp@v0.5.0/claudeacp/reporters.go:65,title: cmp.Or(in.Command, "Terminal"), andoverlap.streamshows the same. So acat <<'EOF' > fileheredoc of thousands of lines is still held whole for as long as the call runs. That is the case the bead's follow-up is about ("Hold no more than what is still needed"), and the description's claim that the wrapper "now holds only the bounded lines" does not hold for it.A scratch test sent a 10 MB title and input on a call that had not finished. Afterwards the call's struct held 10,486,016 bytes: the bounded body was gone and the whole title was still there.
The title is used only by
toolLabel, which is always passed throughclip(240 runes). Fix: inmerge, storet.title = clip(title). Better still, drop the title once the start entry is written with an input (t.shown), since the end entry then usest.name. Then add a case toTestAHugeInputIsNotHeldPastItsStartwith a huge Bash command as the title.Checked and fine
settleSoon) runs on the renderer goroutine. ItsAfterFunconly callsbox.push, which does not block, and a push after the queue has closed is dropped.rawInput, absent or null params, and duplicatecompletedmessages caused no panic. The output was 979 bytes.in_progress, and the input arrives in whole-object updates.#Nties each end to its start. Durations and the(no final status)end are as described.▷heads begin a body). With highlighting off,followstill writes the log's bytes.▷ Bash #1/#2/#3at 17:42:05, then✓ Bash #2 (1s)at :06,✓ Bash #3 (2s)at :07 and✓ Bash #1 (6s)at :11.waiting,startCallsandranFor). On the merge result, bothgo vetruns,go test ./...,-raceoninternal/acpboxand the changelog check fromv1(1.6.0,valid=true) pass. CI is green.Not merged: the Operator's reviewing agent, under the user's interim mandate of 2026-11-11, requires the change above.
Re-review of
f729106b62against maince44061. Changes required: one line. It was not merged, and the merge was not attempted.Required
internal/acpbox/render.go:703(headRunes):return s[:i]keeps the whole title in memory.s[:i]is a substring, so it shares the original string's backing array, and the 10 MB title thatjson.Unmarshalallocated stays alive under the 241-runet.title. The memory the bead wants freed is therefore still held.I measured it with a scratch test: a Bash call whose 10 MB command is also its title, with the heap read after GC once the start entry was written:
t.titleis 241 runes, but the heap grew by 10,522,424 bytes;return strings.Clone(s[:i]): the heap grew by 36,792 bytes.TestAHugeTitleIsNotHeldPastItsStartEitheronly counts the runes oft.title, so it cannot see this. Thet.namepath goes through the same function.Fix:
return strings.Clone(s[:i])on line 703. To keep the test from missing it again, have it check thatunsafe.StringData(r.tools["t1"].title)is not insidecmd's bytes, or measure the heap.Checked and fine
e9edc42.#N(overlap.goldenunchanged), andfollowwith highlighting on and off.go vetruns,go test ./...,-raceoninternal/acpboxand the changelog check fromv1(valid=true) pass. CI is green.From the Operator's reviewing agent, under the user's interim mandate of 2026-11-11.
Re-review of
ed6beec33fagainst maince44061: READY. Not merged and not approved, as instructed: main requires an approval, and this account is the author.f729106).t.titleis 241 bytes.headRunesnow copies its cut, and the name, title and kind all go through it.inputIndent + …), and so is the… N more linesmarker.strings.Clonetaken out,TestAHugeTitleIsNotHeldPastItsStartEitherandTestAHugeKindIsNotHeldfail. The body-lines test passes either way, since those lines were already copies.#N(overlap.goldenunchanged), andfollowwith highlighting on and off.go vetruns,go test ./...,-raceoninternal/acpboxand the changelog check fromv1(valid=true) pass. CI is green.From the Operator's reviewing agent, under the user's interim mandate of 2026-11-11.
Approved by the Operator's reviewing agent, acting for the Reviewer role until it exists. The review is in the comments of this pull request.
Approved at
ed6beecby city-root-review and squash-merged asc44d584a8fonto maince44061, the main the merge result was tested against.Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.