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

+43 -12
View File
@@ -26,6 +26,8 @@ const props = defineProps<{
activeKey: string
/** Only `interactive:*` keys accept messages (the claw 400s the rest). */
canSend: boolean
/** The daemon answers this key with a snapshot, not a stream. */
readOnly: boolean
busy: boolean
session: ClawSession | null
activeBackend: { provider: string; model: string } | null
@@ -43,6 +45,27 @@ const props = defineProps<{
const agentName = computed(() => props.identity?.name?.trim() || 'rhema')
/** Why the composer is closed. A resident key that is not `interactive:`
* runs on its own trigger; anything else is a snapshot of a stash the
* engine checkpointed, whose answer went out through its dispatch. */
const readOnlyNote = computed(() =>
!props.readOnly
? 'Only interactive: keys take messages. This key runs on its own trigger and the transcript is read-only.'
: 'Read-only snapshot of the turns this key ran. The dispatch takes its input and posts its answer outside the chat.',
)
/** Whose words a user row holds. A chat key's are the human's, on the
* web surface or on the phone; every other key's are the prompt its
* dispatch was started with. */
const userLabel = computed(() =>
/^(interactive|phone):/.test(props.activeKey) ? 'you' : 'dispatch',
)
/** Whether the key has a stream at all. A snapshot answers a page once
* and follows nothing, so the header says so instead of claiming to be
* live. */
const streaming = computed(() => !props.readOnly)
/** One send as the panel hands it up: the text (pastes embedded) and
* the staged images, previews included for the optimistic row. */
interface SendPayload {
@@ -428,10 +451,13 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
<div class="text">
<h2>{{ displayName }}</h2>
</div>
<span class="stream-status" :title="`event stream: ${streamStatus}`">
<span v-if="streaming" class="stream-status" :title="`event stream: ${streamStatus}`">
<StatusDot :tone="streamTone(streamStatus)" />
{{ streamLabel }}
</span>
<span v-else class="stream-status" title="a snapshot of the stored session; no stream follows this key">
snapshot
</span>
<button class="ghost info" title="session info" @click="infoOpen = true">ⓘ</button>
</header>
@@ -446,7 +472,9 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
<div ref="scroller" class="stream-area" @scroll.passive="onScroll">
<p v-if="items.length === 0 && !live" class="empty">
nothing streamed yet; messages post to the claw and replies arrive here live
{{ streaming
? 'nothing streamed yet; messages post to the claw and replies arrive here live'
: 'nothing recorded for this key yet' }}
</p>
<p v-if="loadingOlder" class="older-hint">loading earlier turns</p>
@@ -455,7 +483,7 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
<div v-if="item.kind === 'sent'" class="msg">
<div class="avatar user" aria-hidden="true">·</div>
<div class="msg-body">
<div class="who">you</div>
<div class="who">{{ userLabel }}</div>
<div v-if="item.images.length > 0" class="sent-images">
<button
v-for="(image, index) in item.images"
@@ -563,8 +591,9 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
{{ imageError }}
<button class="chip-x" title="dismiss" @click="imageError = null">×</button>
</p>
<div class="input-row">
<button class="ghost attach" title="attach images" :disabled="!canSend" @click="pickImages">
<p v-if="!canSend" class="read-only">{{ readOnlyNote }}</p>
<div v-else class="input-row">
<button class="ghost attach" title="attach images" @click="pickImages">
+
</button>
<textarea
@@ -572,20 +601,15 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
v-model="draft"
rows="1"
:placeholder="
canSend
? live
? `Message ${agentName}… sending steers the running turn`
: `Message ${agentName}…`
: 'only interactive:* sessions accept messages'
live ? `Message ${agentName}… sending steers the running turn` : `Message ${agentName}…`
"
:disabled="!canSend"
@keydown="onPromptKeydown"
@paste="onPaste"
@input="resizePrompt"
/>
<button
class="primary send"
:disabled="!canSend || busy || draft.trim() === ''"
:disabled="busy || draft.trim() === ''"
:title="live ? 'send — interrupts the running turn' : 'send'"
@click="submit"
>
@@ -988,6 +1012,13 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
gap: 8px;
}
.read-only {
margin: 0;
padding: 2px 0;
color: var(--text3);
font-size: 12.5px;
}
.attach {
width: 38px;
padding: 0;
+24 -25
View File
@@ -10,11 +10,11 @@
//
// The non-interactive keys fold under *others*: folded (the default),
// the group shows only how many of them hold a lease, plus the
// more/less toggle; unfolded it lists every row — all of them, the
// whole inventory, not only the keys a transcript can open. A row the
// chat cannot open (a forge thread, a coding job, a phone topic) is a
// control row: pause/resume and abort act on its dispatch, and there
// is no transcript to click into.
// more/less toggle; unfolded it lists every row, the whole inventory.
// Every row opens: a resident key streams, and any other key (a forge
// thread, a coding job, a phone topic) opens the read-only snapshot its
// history route serves. The controls beside it act on its dispatch from
// either view.
//
// The controls sit beside the delete button, on hover, one word each:
// hold/run pauses and resumes the key's dispatch, stop aborts — cuts a
@@ -47,9 +47,6 @@ interface Group {
key: string
name: string
session: ClawSession
/** Whether the chat can open this key — the resident prefixes only.
* A non-selectable row is a control row: it has no transcript. */
selectable: boolean
/** Whether abort has anything to act on: a live turn, or queued
* work to drop. */
abortable: boolean
@@ -62,16 +59,13 @@ interface Group {
const groups = computed<Group[]>(() => {
const byKey = (a: ClawSession, b: ClawSession) => a.key.localeCompare(b.key)
// Only the resident prefixes are chat sessions: `interactive:` is the
// live chat surface, `task:` a scheduled task's own turn, `calendar:` a
// reminder's. The rest of the inventory — `phone:<device>:<topic>`
// status reporting, `job:<instance>#<id>` bookkeeping, a forge thread —
// has no transcript to open: the daemon's message, event and history
// routes refuse those prefixes, so a row for one is a dead end. The
// others group still lists them all: the inventory shows every key,
// and a dead-end row is a control row, not a hidden one.
const conversable = props.sessions.filter((session) => isResidentKey(session.key))
const interactive = conversable
// The resident prefixes are the chat sessions: `interactive:` is the
// live chat surface, `task:` a scheduled task's own turn, `phone:` the
// phone client's, `calendar:` a reminder's. The rest of the inventory —
// `job:<instance>#<id>`, a forge thread — holds no turn record: its
// handler never streams. Its history route serves the session stash
// instead, so the row still opens, read-only.
const interactive = props.sessions
.filter((session) => session.key.startsWith('interactive:'))
.sort(byKey)
const others = props.sessions
@@ -81,7 +75,6 @@ const groups = computed<Group[]>(() => {
key: session.key,
name: session.key.replace(/^interactive:/, ''),
session,
selectable: isResidentKey(session.key),
abortable: session.state === 'leased' || session.inbox_depth > 0,
})
const working = (sessions: ClawSession[]) =>
@@ -104,9 +97,19 @@ const groups = computed<Group[]>(() => {
return groups
})
/** Whether the others group is folded out; it starts folded. */
/** Whether the others group is folded out; it starts folded, and opens
* when the chat opens a row that lives in it — otherwise the selection
* would be invisible. */
const othersOpen = ref(false)
watch(
() => props.activeKey,
(key) => {
if (key !== '' && !isResidentKey(key)) othersOpen.value = true
},
{ immediate: true },
)
const shownCount = computed(() =>
groups.value.reduce((total, group) => total + group.rows.length, 0),
)
@@ -229,11 +232,7 @@ watch(
:class="{ active: row.key === activeKey }"
:title="row.key"
>
<button
class="entry"
:disabled="!row.selectable"
@click="$emit('select', row.key)"
>
<button class="entry" @click="$emit('select', row.key)">
<StatusDot :tone="stateTone(row.session.state)" />
<span class="name">{{ row.name }}</span>
<span