feat(web/claw): open every key, read-only when it has no stream

Every row in the sidebar was disabled unless its key started with a
resident prefix, so a forge thread or a finished job could only be
paused or aborted, never read.

Now every row opens. A resident key subscribes as before. Any other key
loads the snapshot its history route serves, which carries `read_only`;
the header says `snapshot` instead of claiming a live stream, and the
composer becomes a line saying why there is none. The mirror is the same
one the stream feeds, so paging, outcomes, and the turn renderer come
for free.

That view has no stream to tell it a dispatch ran, so the inventory's
revision drives reloads: a poll that sees it move fetches the newest
page again, and nothing else does, so the pages a reader walked back to
survive polling.

`phone:` joins the client's resident prefixes, which the daemon already
carried: those rows were dead ends that refused the message the phone
client sends every day.

The user label follows the key: a chat or phone key's rows are the
human's, any other key's are the prompt its dispatch started with.
This commit is contained in:
vhaudiquet committed 2026-11-24 20:58:02 +01:00
1 parent 8d7dc7c4c7
commit 1a1ace014a
5 files changed
+153 -49

No files matched your search

+17 -8
View File
@@ -319,12 +319,13 @@ export function isInteractive(key: string): boolean {
return key.startsWith(INTERACTIVE_PREFIX)
}
/** The prefixes the chat surface answers for: the daemon's
* `is_resident_key` (`crates/rhema-claw/src/interactive.rs`). Every other
* key in the inventory — `phone:` status reporting, `job:<instance>#<id>`,
* a forge thread — has no transcript: the message, event and history
* routes 400 on it. */
const RESIDENT_PREFIXES = ['interactive:', 'task:', 'calendar:']
/** The prefixes the daemon's resident context owns: its
* `is_resident_key` (`crates/rhema-claw/src/interactive.rs`). A resident
* key has a live turn record the event stream follows. Every other key
* in the inventory — a forge thread, a coding job — answers no stream
* and takes no message: its history route serves the snapshot the
* engine checkpointed, and the panel renders it read-only. */
const RESIDENT_PREFIXES = ['interactive:', 'task:', 'phone:', 'calendar:']
/** Whether `key` is one the transcript surface can open. */
export function isResidentKey(key: string): boolean {
@@ -414,6 +415,9 @@ export interface StreamHandlers {
export interface HistoryPage {
events: { seq: number; event: TurnEvent }[]
more: boolean
/** The page is a snapshot of a key the daemon cannot take messages
* for: the chat surface renders it and hides the composer. */
readOnly: boolean
}
export interface ClawApi {
@@ -511,6 +515,7 @@ export interface ClawApi {
* `GET /v1/sessions/{key}/history` — one page of whole turns ending
* at `before` (absent: the newest). Pages stack: the next call passes
* the seq of the oldest event held, and stops when `more` is false.
* A non-resident key answers a read-only snapshot here.
*/
history(key: string, before?: number | null, limit?: number): Promise<HistoryPage>
}
@@ -631,7 +636,11 @@ export function useClaw(token: Ref<string | null>): ClawApi {
const body = (await get(
`/v1/sessions/${encodeURIComponent(key)}/history${query}`,
token.value,
)) as { events?: { seq?: unknown; event?: unknown }[]; more?: unknown }
)) as {
events?: { seq?: unknown; event?: unknown }[]
more?: unknown
read_only?: unknown
}
// The wire shape is trusted only as far as it parses: an event the
// parser does not know is dropped, and its seq with it — the page
// still renders what it could read.
@@ -639,7 +648,7 @@ export function useClaw(token: Ref<string | null>): ClawApi {
const event = parseTurnEvent(JSON.stringify(entry.event))
return event && typeof entry.seq === 'number' ? [{ seq: entry.seq, event }] : []
})
return { events, more: body.more === true }
return { events, more: body.more === true, readOnly: body.read_only === true }
}
async function providers(): Promise<ProvidersState> {