feat(claw): read a non-chat key's history back as a snapshot

The history route served only the resident prefixes, and every other key
in the inventory answered 400: a forge thread, a finished coding job.
Those keys never stream, because their handlers run outside the hub, so
the daemon holds no turn record to page.

What it does hold is the session stash the step engine checkpoints after
every step, with the engine's own history in it. `thread` turns that
history back into the hub's event shapes and cuts pages at turn
boundaries with the hub's own rule, so one client renderer paints both a
live chat and a finished thread. The store's `last_outcome` lands on the
newest turn; earlier turns closed handled.

The response carries `read_only`: the key takes no message, which the
message route and the event stream already enforce. A key with no stash
answers an empty page, since the inventory lists it and an empty
transcript is the truth about it.

A page ends at `before` and starts on the first user message in its
window, widening by doubling while the window sits inside one turn. A
turn longer than the limit comes back whole, and `more` says whether
anything sits below the page.
This commit is contained in:
vhaudiquet committed 2026-11-24 20:57:58 +01:00
1 parent 23aea1195d
commit 8d7dc7c4c7
6 files changed
+556 -11

No files matched your search

+9
View File
@@ -212,6 +212,15 @@ 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.
The history route answers for every key in the inventory, not only the
resident prefixes. A key outside them — a forge thread, a finished
coding job — has no turn record to subscribe to, but the engine
checkpoints its session after every step. The route reads that stash
back as the same event shapes, cut into the same pages, and marks the
response `read_only: true`: the transcript a client can render, with no
stream to follow and no message the daemon would take. A key with no
stash yet answers an empty page.
A chat UI subscribes once, POSTs messages, and resets its mirror
whenever the stream (re)opens, letting the replay rebuild it; the daemon
owns the conversation, so the client mirrors the stream rather than