Repository navigation
fix(remote): a reply that is already in the transcript, drawn once - #1008
Merged
Merged
Conversation
Opening a conversation whose newest exchange is still running drew the
answer twice: the host's page already carries a partial copy of it — the
agent writes each completed model call to its journal mid-run — and the
pushed frames of that same run were then appended beside it. The reader saw
the reply once frozen (and without the streaming mark) and once growing
under it.
Neither copy can simply be dropped. The page's copy is the reply's
beginning (the stream starts when this window subscribes) and the bubble is
its end (it is written as the host writes it, which is why the reader opened
the conversation). `foldLiveReply` draws them as the one reply they are: the
record's segments, then the stream's, in the order they were produced. The
merged row keeps the record's identity — its entry id, its timestamp and the
user entry a fork branches at — and takes the stream's liveness, so the row
on screen is the one still being written, and the one that offers nothing to
act on.
The two lanes stay disjoint by rule rather than by luck: a tail read
restarts the live lane (`RemoteRunStreams.restart`), because the page it just
read is the record of everything the pushes had built up to that point. The
run's clock survives the restart — a reconnect must not make the elapsed time
of a reply being watched fall back to zero. A call or a compaction the record
already carries is not drawn twice either; text has no identity across the
lanes, and the boundary is what keeps it from repeating.
Verified: the view test (a reply the transcript already carries is one row,
carrying both halves), `foldLiveReply`'s own cases (append when there is no
copy, fold in place, keep the record's identity, no call or checkpoint twice),
the live lane's restart with its clock, and 491 remote-peer tests. The harness
gained `remote-mid-flight`, which opens `rs_forest` — a fixture whose newest
turn the host still reports as running — and continues that run on the push
lane: it asserts the reply is one row, carrying the page's beginning and the
stream's tail, that the header reports the run while it is live, and that the
settled transcript draws it once. It fails on the parent commit ("it was drawn
across 2 row(s) at its widest"), and `remote-streaming` and
`remote-lean-stream` still pass against the reworked mock.
huichen
enabled auto-merge (squash)
October 13, 2026 04:04
…jector CI caught what a same-millisecond local run hid: the elapsed-time anchor was written whenever a projector was created, so rebuilding one (`restart`) reset it — the assertion that a rebuilt reply keeps its clock passed here and failed there, one millisecond apart. The anchor is now set only for a run this client has not seen; an evicted or restarted run keeps the time a reader has been watching.
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.
Opening a conversation whose newest exchange is still running drew the answer twice: the host's page already carries a partial copy of it (the agent writes each completed model call to its journal mid-run), and the pushed frames of that same run were then appended beside it. On screen that is the reply once frozen — and without the streaming mark — and once growing under it.
Reproduced from the real client before the fix, through the new harness scenario (
remote-mid-flight, live state):Neither copy can simply be dropped: the page's copy is the reply's beginning (the stream starts when this window subscribes) and the bubble is its end (it is written as the host writes it, which is why the reader opened the conversation).
foldLiveReplydraws them as the one reply they are — the record's segments, then the stream's, in the order they were produced — and the merged row keeps the record's identity (its entry id, its timestamp, the user entry a fork branches at) while taking the stream's liveness. So the row on screen is the one still being written, and the one that offers nothing to act on.The two lanes stay disjoint by rule rather than by luck: a tail read restarts the live lane (
RemoteRunStreams.restart), because the page it just read is the record of everything the pushes had built up to that point. The run's own clock survives that restart — a reconnect must not make the elapsed time of a reply being watched fall back to zero. A tool call or a compaction the record already carries is not drawn a second time either; text has no identity across the two lanes, and the boundary is what keeps it from repeating.Verified
foldLiveReply(append when there is no copy, fold in place, keep the record's identity, no call or checkpoint twice, an earlier run untouched, a runless bubble never folded),RemoteRunStreams.restart(restarts the projection, keeps the clock),useRemoteTimeline(a catch-up read restarts the lane from the page it read).RemoteConversationView— a reply the transcript already carries is one row carrying both halves, and it offers nothing to act on. Both new tests fail on the parent commit.remote-mid-flightopensrs_forest— a fixture whose newest turn the host still reports as running — and continues that run on the push lane. It asserts the reply is one row carrying the page's beginning and the stream's tail, that the header reports the run while it is live, and that the settled transcript draws it once. It fails on the parent commit and passes here;remote-streamingandremote-lean-streamstill pass against the reworked mock (which now shares one frame publisher).tsc --noEmit,eslint,vitest run(293 files / 3912 tests), all green on this branch merged withorigin/main.The phone does not have this bug: it rebuilds the run from the host's replay (
get_events_since) and strips the durable copy of it, which is the same rule this change expresses for a client that reads pages and pushes only.