feat(web/claw): list every key and control its dispatch

The sidebar listed only the resident prefixes. The phone's status keys,
the coding jobs' `job:<instance>#<id>` keys and the forge threads were
on the wire and invisible in the client: an operator watching a job fill
a queue had no row to look at, let alone act on. *Others* now carries
the whole inventory, folded to the working count as before and every row
listed unfolded. A row the chat cannot open is a control row — the
resident prefixes are the only ones with a transcript — so it renders
as a disabled entry rather than a dead click-through, and it keeps the
status dot, the held badge and the depth that every row has.

Beside the delete button, on hover: `hold` posts the pause and the row
badges `held` in the warn tone, `run` posts the resume, `stop` posts the
abort. `stop` is disabled when there is neither a live turn nor queued
work, so an idle row sends nothing instead of collecting a no-op
answer. What the abort did reads in the notice — the turn stopped, N
queued items dropped, or nothing running — straight from the answer's
`cut` and `dropped`.

An aborted turn renders in the warn tone too: cut by the operator, not
failed, and unlike a steered turn nothing replaces it. The About page's
route list gains the three, and the README's inventory and delete
paragraphs follow the fold and the controls.

nuxt typecheck and build pass; checked against a mock daemon on a
seeded store, folded and unfolded, with a held row, a queued job and an
aborted turn.
This commit is contained in:
vhaudiquet committed 2026-11-23 22:38:26 +01:00
1 parent 38292b6344
commit dc269472eb
6 files changed
+224 -16

No files matched your search

+17 -5
View File
@@ -128,11 +128,13 @@ Two consequences worth knowing before changing this code:
- **Sessions are created in place.** The sidebar's `+` form posts
`POST /v1/sessions` with a client-validated name
(`[A-Za-z0-9._-]{1,64}`), switches the chat to the new key, and
lets 400/409 land in the error banner. The inventory lists only the
resident prefixes (`interactive:`, `task:`, `calendar:`) — the ones the
message, event and history routes answer for. The phone's status keys
(`phone:…`), the coding jobs' `job:<instance>#<id>` keys and forge keys
stay out, and the full list stays on the wire.
lets 400/409 land in the error banner. The interactive prefixes
(`interactive:`) list above the fold; *others* holds the whole rest
of the inventory — `task:`, `calendar:`, the phone's status keys
(`phone:…`), the coding jobs' `job:<instance>#<id>` keys and forge
keys. Only the resident prefixes have a transcript, so a row in
*others* for anything else is a control row: no click-through, but
the same pause/resume/abort and delete as every other row.
- **Deleting a session is a decision, not a click.** The row's delete
button only names the key; the shell's dialog spells out that the
turn history goes with it, and `DELETE /v1/sessions/{key}` runs on
@@ -141,6 +143,16 @@ Two consequences worth knowing before changing this code:
error banner like every other refusal, and the chat moves to the
first remaining session, the stream's watcher following the key so
nothing keeps streaming a session that no longer exists.
- **Every row is controllable.** Beside the delete button, on hover:
`hold` posts `POST /v1/sessions/{key}/pause` and the row badges
`held` — queued work accumulates and nothing dispatches until `run`
posts the resume, both answered by the inventory's `paused` flag.
`stop` posts `POST /v1/sessions/{key}/abort`: a live turn is cut
(the stream closes on its `aborted` marker, in the warn tone, since
nothing failed), and an idle key's queued work is dropped instead —
the notice says which, from the answer's `cut`/`dropped`. A key with
neither running nor queued work has `stop` disabled rather than
sending a no-op.
## Layout
+46
View File
@@ -377,6 +377,49 @@ async function confirmDeleteSession(): Promise<void> {
}
}
/** The pause gate: hold a key's dispatch, lift the hold. The inventory
* refresh carries the `paused` flag back to the sidebar. */
async function pauseSession(key: string): Promise<void> {
try {
await claw.pauseSession(key)
pushNotice(`${key} held`)
apiError.value = null
} catch (err) {
noteApiError(err)
}
void refreshSessions()
}
async function resumeSession(key: string): Promise<void> {
try {
await claw.resumeSession(key)
pushNotice(`${key} resumed`)
apiError.value = null
} catch (err) {
noteApiError(err)
}
void refreshSessions()
}
/** Abort: cut a live turn, or drop the key's queued work. The answer
* says which happened; the inventory refresh settles the row. */
async function abortSession(key: string): Promise<void> {
try {
const result = await claw.abortSession(key)
pushNotice(
result.cut
? `turn on ${key} stopped`
: result.dropped > 0
? `${result.dropped} queued item(s) dropped on ${key}`
: `nothing running on ${key}`,
)
apiError.value = null
} catch (err) {
noteApiError(err)
}
void refreshSessions()
}
async function refreshProviders(): Promise<void> {
try {
providersState.value = await claw.providers()
@@ -770,6 +813,9 @@ onUnmounted(() => {
@refresh="refreshSessions"
@create="createSession"
@delete="askDeleteSession"
@pause="pauseSession"
@resume="resumeSession"
@abort="abortSession"
/>
<ChatPanel
:items="transcriptItems"
+12 -1
View File
@@ -490,7 +490,11 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
<div
v-if="item.turn.outcome"
class="outcome mono"
:class="{ failed: item.turn.outcome === 'failed', steered: item.turn.outcome === 'steered' }"
:class="{
failed: item.turn.outcome === 'failed',
steered: item.turn.outcome === 'steered',
aborted: item.turn.outcome === 'aborted',
}"
>
{{ item.turn.outcome }}
</div>
@@ -759,6 +763,13 @@ function streamTone(status: StreamStatus): 'ok' | 'warn' | 'error' {
color: var(--accent-text);
}
/* An aborted turn: stopped from the controls, and nothing replaced
it. Not a failure either — the same warn tone the held badge
carries, which is what an operator's stop is. */
.outcome.aborted {
color: var(--warn);
}
/* While the turn runs but no reply text has landed yet. Tool rows and
the thinking trace never render on this surface, so this line is the
turn's only pulse between its first event and its first delta — the
+103 -10
View File
@@ -10,7 +10,16 @@
//
// 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.
// 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.
//
// 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
// live turn, or drops the key's queued work when none runs. Nothing
// here is destructive beyond the delete, which keeps its own dialog.
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
import type { ClawSession } from '~/composables/useClaw'
@@ -27,11 +36,24 @@ const emit = defineEmits<{
refresh: []
create: [name: string]
delete: [key: string]
pause: [key: string]
resume: [key: string]
abort: [key: string]
}>()
interface Group {
label: string
rows: { key: string; name: string; session: ClawSession }[]
rows: {
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
}[]
/** How many rows hold a lease; the others' header shows the count. */
working: number
/** Whether the rows fold away until the toggle says otherwise. */
@@ -42,23 +64,25 @@ 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 has no transcript to open —
// `phone:<device>:<topic>` is status reporting, `job:<instance>#<id>`
// is the coding jobs' bookkeeping, a forge key is a thread the handler
// reports on — and the daemon's message, event and history routes
// refuse those prefixes, so a row for one is a dead end. The inventory
// hides them rather than the API narrowing.
// 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
.filter((session) => session.key.startsWith('interactive:'))
.sort(byKey)
const others = conversable
const others = props.sessions
.filter((session) => !session.key.startsWith('interactive:'))
.sort(byKey)
const row = (session: ClawSession) => ({
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[]) =>
sessions.filter((session) => session.state === 'leased').length
@@ -205,13 +229,48 @@ watch(
:class="{ active: row.key === activeKey }"
:title="row.key"
>
<button class="entry" @click="$emit('select', row.key)">
<button
class="entry"
:disabled="!row.selectable"
@click="$emit('select', row.key)"
>
<StatusDot :tone="stateTone(row.session.state)" />
<span class="name">{{ row.name }}</span>
<span
v-if="row.session.paused"
class="held"
title="dispatch held: nothing runs until resume"
>
held
</span>
<span v-if="row.session.inbox_depth > 0" class="depth" title="inbox depth">
{{ row.session.inbox_depth }}
</span>
</button>
<button
v-if="row.session.paused"
class="ghost act"
:title="`resume ${row.key}`"
@click.stop="$emit('resume', row.key)"
>
run
</button>
<button
v-else
class="ghost act"
:title="`pause ${row.key}`"
@click.stop="$emit('pause', row.key)"
>
hold
</button>
<button
class="ghost act stop"
:disabled="!row.abortable"
:title="`abort ${row.key}`"
@click.stop="$emit('abort', row.key)"
>
stop
</button>
<button
class="ghost remove"
aria-label="delete session"
@@ -390,6 +449,27 @@ watch(
font-weight: inherit;
}
.row .act {
flex: none;
padding: 0 4px;
font-size: 11px;
font-family: var(--mono);
opacity: 0;
}
.row .act.stop {
color: var(--error);
}
.row .act:disabled {
color: var(--text3);
cursor: default;
}
.entry:disabled {
cursor: default;
}
.row .remove {
flex: none;
padding: 0 5px;
@@ -397,12 +477,25 @@ watch(
opacity: 0;
}
.row:hover .act,
.row:hover .remove,
.row:focus-within .act,
.row:focus-within .remove,
.row.active .act,
.row.active .remove {
opacity: 1;
}
.held {
flex: none;
font-size: 10px;
font-family: var(--mono);
color: var(--warn);
border: 1px solid var(--border-strong);
border-radius: 999px;
padding: 0 5px;
}
.name {
flex: 1;
min-width: 0;
@@ -14,6 +14,9 @@ const routes = [
{ method: 'GET', path: '/v1/sessions', note: 'the dispatch-key inventory' },
{ method: 'POST', path: '/v1/sessions', note: 'create an interactive session from a name' },
{ method: 'DELETE', path: '/v1/sessions/{key}', note: 'delete a session and its turn history' },
{ method: 'POST', path: '/v1/sessions/{key}/pause', note: "hold a key's dispatch" },
{ method: 'POST', path: '/v1/sessions/{key}/resume', note: 'lift the hold' },
{ method: 'POST', path: '/v1/sessions/{key}/abort', note: 'cut the live turn, or drop the queue' },
{ method: 'POST', path: '/v1/sessions/{key}/messages', note: 'message ingest, 202 + stream' },
{ method: 'GET', path: '/v1/sessions/{key}/events', note: 'the turn-event stream (SSE)' },
{ method: 'POST', path: '/v1/consents/{id}', note: 'answer a consent (a secret or a grant)' },
+43
View File
@@ -95,6 +95,17 @@ export interface ClawSession {
revision: number
inbox_depth: number
last_outcome: string | null
/** Whether the pause gate holds the key: queued work waits, nothing
* dispatches, until resume lifts the hold. */
paused: boolean
}
/** The `POST /v1/sessions/{key}/abort` answer: `cut` when a live turn
* was signalled, `dropped` the queued items the route drained. */
export interface AbortResult {
key: string
cut: boolean
dropped: number
}
/** One watch (config.rs `Watch`, as the watches routes accept and return it). */
@@ -416,6 +427,14 @@ export interface ClawApi {
* same name starts empty. 409 while a turn holds the key, 404 when it is
* already gone. */
deleteSession(key: string): Promise<void>
/** `POST /v1/sessions/{key}/pause` — hold the key's dispatch. 404
* when the inventory has no such key. */
pauseSession(key: string): Promise<void>
/** `POST /v1/sessions/{key}/resume` — lift the hold. */
resumeSession(key: string): Promise<void>
/** `POST /v1/sessions/{key}/abort` — cut the live turn, or drop the
* queued work when none runs. */
abortSession(key: string): Promise<AbortResult>
/** `GET /v1/consents` — the pending consents, oldest first. */
listConsents(): Promise<ConsentRequest[]>
/** `POST /v1/consents/{id}` — answer one consent; 409 when already
@@ -543,6 +562,27 @@ export function useClaw(token: Ref<string | null>): ClawApi {
})
}
async function pauseSession(key: string): Promise<void> {
await send(`/v1/sessions/${encodeURIComponent(key)}/pause`, {
method: 'POST',
headers: authHeaders(token.value),
})
}
async function resumeSession(key: string): Promise<void> {
await send(`/v1/sessions/${encodeURIComponent(key)}/resume`, {
method: 'POST',
headers: authHeaders(token.value),
})
}
async function abortSession(key: string): Promise<AbortResult> {
return (await send(`/v1/sessions/${encodeURIComponent(key)}/abort`, {
method: 'POST',
headers: authHeaders(token.value),
})) as AbortResult
}
async function listConsents(): Promise<ConsentRequest[]> {
const body = (await get('/v1/consents', token.value)) as { consents: ConsentRequest[] }
return body.consents
@@ -866,6 +906,9 @@ export function useClaw(token: Ref<string | null>): ClawApi {
sessions,
createSession,
deleteSession,
pauseSession,
resumeSession,
abortSession,
listConsents,
resolveConsent,
denyConsent,