feat(web): delete a session from the sidebar

A session could be created from the sidebar but never removed, so the
chat surface accumulated every experiment anyone ever named. Each row
now carries a small delete affordance that only names the key: the
confirmation is the shell's, and it says the turn history goes with
the session before calling the new route. On confirm the chat moves to
the first remaining session — the stream's watcher follows the key —
so nothing keeps streaming a session that no longer exists.

The row had to stop being a single button, since a nested button is
invalid HTML: the select button and the delete button now sit in a
container that owns the hover and active surface.
This commit is contained in:
kosmos authored and Kosmos committed 2026-11-11 16:11:07 +00:00
1 parent 8db1e2aa11
commit 994df09c8f
5 files changed
+160 -22

No files matched your search

+13
View File
@@ -339,6 +339,11 @@ export interface ClawApi {
/** `POST /v1/sessions` — create an interactive session from a name;
* 400 for a name off `SESSION_NAME_PATTERN`, 409 when it exists. */
createSession(name: string): Promise<NewSession>
/** `DELETE /v1/sessions/{key}` — delete a session, its dispatch record
* and the turn history recorded under it, so a key re-created under the
* same name starts empty. 409 while a turn holds the key, 404 when it is
* already gone. */
deleteSession(key: string): Promise<void>
/** `GET /v1/consents` — the pending consents, oldest first. */
listConsents(): Promise<ConsentRequest[]>
/** `POST /v1/consents/{id}` — answer one consent; 409 when already
@@ -454,6 +459,13 @@ export function useClaw(token: Ref<string | null>): ClawApi {
})) as NewSession
}
async function deleteSession(key: string): Promise<void> {
await send(`/v1/sessions/${encodeURIComponent(key)}`, {
method: 'DELETE',
headers: authHeaders(token.value),
})
}
async function listConsents(): Promise<ConsentRequest[]> {
const body = (await get('/v1/consents', token.value)) as { consents: ConsentRequest[] }
return body.consents
@@ -722,6 +734,7 @@ export function useClaw(token: Ref<string | null>): ClawApi {
return {
sessions,
createSession,
deleteSession,
listConsents,
resolveConsent,
denyConsent,