Draw a peer message above the turn it started, not below it
The live Claude Code path only learns a turn was another agent's when the turn ends -- the whole of the message arrives as an `origin` object on the `result` -- so the note was appended after everything it caused, and the transcript showed the answer above the question. It cannot be recorded in place: by the time anyone knows, the reply is already written, and the transcript is append-only. So the event carries where it belongs instead. `PeerMessage` gains `turnStart`, the seq of the status that opened its turn, stamped by the pump -- the only thing that knows a seq and the only thing that sees every driver's turns. The phone gives the note that seq, so it sorts into place rather than being drawn out of order at the end. A status draws no row, so there is nothing for it to collide with and the list stays sorted, which the scroll anchor and paging both depend on. Absent where there is nothing to correct: a message replayed out of a session file by `import` is already in the right place, and one that opened no turn has no turn to sit above. Both stay where they arrive. The echo driver gets `/peer-turn` for the live shape, beside `/peer` for the in-place one. Verified on the emulator both ways, live and on replay, plus an ordinary `/tools` turn to confirm the run grouping the insertion cuts through is unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7525fc925a
commit
465645cefb
9 files changed
+246
-13
No files matched your search
@@ -300,13 +300,30 @@ both, and there is one function for one wire format. Only peer-caused turns
|
||||
carry it: four ordinary results on a real session's stdout had no `origin`
|
||||
between them.
|
||||
|
||||
**The cost is the position.** The note lands after the reply it caused rather
|
||||
than above it, because at no earlier point in the turn does the CLI say why
|
||||
the turn started. The alternative is a second reader tailing the CLI's own
|
||||
session file for the one record stdout does not carry — two sources of truth
|
||||
for one conversation and a poll per live session — and it was rejected on
|
||||
that. If the CLI ever announces the injection at the point it happens, this
|
||||
moves to that record and the ordering comes right with it.
|
||||
**The cost was the position, and it is paid on the wire rather than on
|
||||
screen** (2026-09-01). The event cannot be *recorded* in place: at no earlier
|
||||
point in the turn does the CLI say why the turn started, and the transcript
|
||||
is append-only, so by the time anyone knows, everything the message caused
|
||||
has already been written above it. Reading it out of the CLI's own session
|
||||
file instead — a second reader tailing the one record stdout does not carry —
|
||||
was rejected then and stays rejected: two sources of truth for one
|
||||
conversation and a poll per live session.
|
||||
|
||||
So the event carries **where it belongs** instead. `PeerMessage` has a
|
||||
`turnStart`: the seq of the `Status` that opened the turn it started, stamped
|
||||
by the pump, which is the only thing that knows a seq and the only thing that
|
||||
sees every driver's turns. The phone gives the note that seq, so it sorts
|
||||
into the transcript above the turn rather than being drawn out of order at
|
||||
the end. That seq belongs to a status change, and a status draws no row, so
|
||||
there is nothing for the note to collide with and the list stays sorted —
|
||||
which is what the scroll anchor and paging depend on.
|
||||
|
||||
`turnStart` is absent where there is nothing to correct: a message replayed
|
||||
out of a session file by `import` is already in the right place, and one that
|
||||
opened no turn has no turn to sit above. Both are drawn where they arrive.
|
||||
The echo driver models both shapes — `/peer` for the in-place one, and
|
||||
`/peer-turn` for the live one, which reveals the note only after a reply and
|
||||
a run of tool calls.
|
||||
|
||||
### Taking a queued message back (decided 2026-08-31)
|
||||
|
||||
|
||||
Reference in new issue
Block a user