fix(claw): open a fresh stream on the newest turn's first event

A client with no cursor opens on the newest 400 events, and the route cut
that window back to the first question in it. A turn longer than the
window has no question inside it, so the cut did nothing and the replay
started mid-turn. A reload then landed on the middle of a reply: the
question was gone from the top, and so was everything the turn began
with, attachments included. A turn that attaches a file and then streams
a long answer hits this every time.

The window now widens by doubling while it sits inside one turn, up to
the history scan cap, and a record that opens inside a turn comes back
whole. A record with no question in it reads once to its start and
stops, so the walk still terminates.
This commit is contained in:
vhaudiquet committed 2026-11-24 21:33:15 +01:00
1 parent 04b06e7623
commit ea6edfe67a
3 files changed
+121 -31

No files matched your search

+8 -5
View File
@@ -204,11 +204,14 @@ The seq is the record's dense per-key number for the event, and it is
the client's cursor. A subscription opens with a replay cut atomically
against the live feed, and the frames of both carry their seqs, so a
client that reconnects sends `?since=<last seq it saw>` and receives
exactly the gap. With no cursor the replay is the tail — the newest 400
events, cut back to the first turn boundary in them — so a weeks-old
session paints its latest turn at once instead of replaying everything;
the turns above it come from the history route, one whole turn per
page, each ending exactly where the previous page began. A cursor the
exactly the gap. With no cursor the replay is the tail: the newest 400
events, cut back to the first turn boundary in them. The window widens
by doubling while it sits inside one turn, because a long agent turn
streams hundreds of deltas and a reload that opened mid-reply would
drop what the turn began with. A weeks-old session thus paints its
latest turn at once instead of replaying everything, and the turns
above it come from the history route, one whole turn per page, each
ending exactly where the previous page began. A cursor the
record can no longer serve (a wiped table) answers with a `reset;`
comment and the tail, and the client rebuilds rather than splice.