Files
rhema-claw/web/claw/app/components/SessionsSidebar.vue
T
vhaudiquet d17d8e2973
android / debug (push) Successful in 2m16s
android / release (push) Successful in 2m9s
ci / checks (push) Successful in 3m39s
ci / test (push) Successful in 2m5s
ci / docker (push) Successful in 1m52s
ci / web (push) Successful in 13s
ci / publish-edge-images (deploy/docker/claw.Dockerfile, rhema-claw) (push) Successful in 1m56s
ci / chart (push) Successful in 6s
ci / publish-edge-images (deploy/docker/ui.Dockerfile, rhema-claw-ui) (push) Successful in 20s
ci / publish-edge-chart (push) Successful in 4s
feat(web/claw): restyle the interface after Rhema Together
The web client kept its own dark shell: an icon rail, neon jade
accents, and rows that reported state with colored dots and pills.
Rhema Together had since settled on a warmer, quieter language, and
the two surfaces no longer looked like one product.

The shell is now one 232px sidebar plus a view. Chat lists sessions in
the sidebar and renders the transcript in a 760px column; settings
moves its searchable nav into the same sidebar and its pages onto an
880px column. The palette, type scale, controls, cards, and markdown
come from Together's light theme, with its dark values following the
OS. FiraCode Nerd Font Mono sets code, and the product mark, logo, and
lucide icons replace the glyph characters.

Status is a word now: running, waiting, held, connected, live,
snapshot. The rail, its dots, the duplicate consent deny action, and
the session key tag are gone. The model backend moved into the chat
topbar beside the stream state.

The mobile shell keeps the composer fixed in chat and lets settings
scroll as a document.

README and component docs follow the new layout. nuxt typecheck and
build pass; checked light and dark at 1280x800 and 390x844 against
mock API data.
2026-11-30 18:23:57 +01:00

613 lines
15 KiB
Vue

<script setup lang="ts">
// The session inventory: the dispatch keys a human converses with,
// interactive first. Clicking selects the session the chat mirrors.
// Displayed names drop the `interactive:` prefix, the full key stays
// in the tooltip. Creating and deleting are intent only: the name (or
// the key) flows up, the shell answers, and the form closes when the
// new key lands in the inventory. The delete button asks nothing itself:
// the confirmation, which names the transcript that goes with the
// session, is the shell's.
//
// 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, 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.
//
// State is a word, not a dot: running, waiting, held, and the queued
// count. The controls appear on hover. Hold and run pause and resume the
// key's dispatch. Stop aborts: it cuts a live turn, or drops the key's
// queued work when none runs.
import { Pause, Play, Plus, RefreshCw, Settings, Square, Trash2 } from 'lucide-vue-next'
import { SESSION_NAME_PATTERN, isResidentKey } from '~/composables/useClaw'
import type { ClawSession } from '~/composables/useClaw'
const props = defineProps<{
sessions: ClawSession[]
activeKey: string
loading: boolean
clawUp: boolean | null
identity?: { name: string | null; tagline: string | null; mark: string | null; initials: string | null } | null
avatarUrl?: string | null
}>()
const emit = defineEmits<{
home: []
select: [key: string]
refresh: []
create: [name: string]
delete: [key: string]
pause: [key: string]
resume: [key: string]
abort: [key: string]
navigateSettings: []
}>()
interface Group {
label: string
rows: {
key: string
name: string
session: ClawSession
/** 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. */
collapsible: boolean
}
const groups = computed<Group[]>(() => {
const byKey = (a: ClawSession, b: ClawSession) => a.key.localeCompare(b.key)
// 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
.filter((session) => !session.key.startsWith('interactive:'))
.sort(byKey)
const row = (session: ClawSession) => ({
key: session.key,
name: session.key.replace(/^interactive:/, ''),
session,
abortable: session.state === 'leased' || session.inbox_depth > 0,
})
const working = (sessions: ClawSession[]) =>
sessions.filter((session) => session.state === 'leased').length
const groups: Group[] = []
if (interactive.length > 0)
groups.push({
label: 'Interactive',
rows: interactive.map(row),
working: working(interactive),
collapsible: false,
})
if (others.length > 0)
groups.push({
label: 'Other keys',
rows: others.map(row),
working: working(others),
collapsible: true,
})
return groups
})
/** 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),
)
const healthLabel = computed(() =>
props.clawUp === null ? 'checking' : props.clawUp ? 'connected' : 'unreachable',
)
const healthTone = computed(() =>
props.clawUp === null ? 'idle' : props.clawUp ? 'ok' : 'error',
)
// --- new sessions -----------------------------------------------------
const creating = ref(false)
const nameDraft = ref('')
const nameInput = ref<HTMLInputElement | null>(null)
/** The name this form is waiting on; the create is in flight. */
const pendingCreate = ref<string | null>(null)
const nameValid = computed(() => SESSION_NAME_PATTERN.test(nameDraft.value))
function openCreate(): void {
creating.value = true
nameDraft.value = ''
void nextTick(() => nameInput.value?.focus())
}
function closeCreate(): void {
creating.value = false
nameDraft.value = ''
pendingCreate.value = null
}
function submitCreate(): void {
if (!nameValid.value) return
pendingCreate.value = nameDraft.value
emit('create', nameDraft.value)
}
// The form closes when the claw answers with the session in the
// inventory; a failed create answers nothing, and the form stays.
watch(
() => props.sessions,
(sessions) => {
if (
pendingCreate.value !== null &&
sessions.some((session) => session.key === `interactive:${pendingCreate.value}`)
) {
closeCreate()
}
},
)
</script>
<template>
<aside class="sidebar">
<div class="sidebar-top">
<SidebarBrand @home="$emit('home')" />
</div>
<div class="sidebar-label">
<span class="sidebar-label-text">Sessions</span>
<span class="count">{{ shownCount }}</span>
<button
class="icon-btn"
title="Refresh sessions"
aria-label="Refresh sessions"
:disabled="loading"
@click="$emit('refresh')"
>
<RefreshCw :size="14" aria-hidden="true" />
</button>
<button
class="icon-btn"
:title="creating ? 'Cancel new session' : 'New session'"
:aria-label="creating ? 'Cancel new session' : 'New session'"
@click="creating ? closeCreate() : openCreate()"
>
<Plus :size="16" aria-hidden="true" />
</button>
</div>
<form v-if="creating" class="new-session" @submit.prevent="submitCreate">
<input
ref="nameInput"
v-model="nameDraft"
type="text"
placeholder="Session name"
autocomplete="off"
maxlength="64"
>
<div class="new-actions">
<button type="button" class="btn btn-sm btn-quiet" @click="closeCreate">Cancel</button>
<button type="submit" class="btn btn-sm btn-primary" :disabled="!nameValid">Create</button>
</div>
<p v-if="nameDraft !== '' && !nameValid" class="new-note">
Letters, digits, dots, dashes, underscores, up to 64.
</p>
</form>
<p v-if="shownCount === 0" class="empty">
{{ loading ? 'Loading sessions.' : 'No sessions yet. Use + to create one.' }}
</p>
<nav class="sidebar-sessions" aria-label="Sessions">
<div v-for="group in groups" :key="group.label" class="group">
<div class="sidebar-label group-head">
<span class="sidebar-label-text">{{ group.label }}</span>
<span v-if="group.collapsible && group.working > 0" class="working">
{{ group.working }} running
</span>
<button
v-if="group.collapsible"
class="btn btn-sm btn-quiet toggle"
:title="othersOpen ? 'Fold the other keys away' : 'Show every other key'"
@click="othersOpen = !othersOpen"
>
{{ othersOpen ? 'Less' : 'More' }}
</button>
</div>
<template v-if="!group.collapsible || othersOpen">
<div
v-for="row in group.rows"
:key="row.key"
class="session"
:class="{ active: row.key === activeKey }"
:title="row.key"
>
<button class="session-entry" @click="$emit('select', row.key)">
<span class="session-name">{{ row.name }}</span>
<span class="session-meta">
<span v-if="row.session.paused" class="state warn">held</span>
<span v-else-if="row.session.state === 'leased'" class="state ok">running</span>
<span v-else-if="row.session.state === 'reacquire'" class="state warn">waiting</span>
<span v-if="row.session.inbox_depth > 0" class="state idle">
{{ row.session.inbox_depth }} queued
</span>
</span>
</button>
<div class="session-actions">
<button
v-if="row.session.paused"
class="icon-btn"
:title="`Resume ${row.key}`"
:aria-label="`Resume ${row.key}`"
@click.stop="$emit('resume', row.key)"
>
<Play :size="14" aria-hidden="true" />
</button>
<button
v-else
class="icon-btn"
:title="`Hold ${row.key}`"
:aria-label="`Hold ${row.key}`"
@click.stop="$emit('pause', row.key)"
>
<Pause :size="14" aria-hidden="true" />
</button>
<button
class="icon-btn"
:disabled="!row.abortable"
:title="`Abort ${row.key}`"
:aria-label="`Abort ${row.key}`"
@click.stop="$emit('abort', row.key)"
>
<Square :size="12" aria-hidden="true" />
</button>
<button
class="icon-btn"
:title="`Delete ${row.key}`"
:aria-label="`Delete ${row.key}`"
@click.stop="$emit('delete', row.key)"
>
<Trash2 :size="14" aria-hidden="true" />
</button>
</div>
</div>
</template>
</div>
</nav>
<div class="sidebar-bottom">
<button class="sidebar-link" @click="$emit('navigateSettings')">
<Settings :size="16" aria-hidden="true" />
<span>Settings</span>
</button>
<div class="sidebar-account">
<AgentAvatar
:avatar-url="avatarUrl"
:initials="identity?.initials ?? identity?.name?.slice(0, 1)"
:size="26"
/>
<div class="account-text">
<span class="account-name" :title="identity?.tagline ?? undefined">
{{ identity?.name?.trim() || 'rhema' }}
</span>
<span class="account-state" :class="healthTone">{{ healthLabel }}</span>
</div>
</div>
</div>
</aside>
</template>
<style scoped>
.sidebar {
display: flex;
flex-direction: column;
width: var(--sidebar-w);
flex: 0 0 var(--sidebar-w);
position: sticky;
top: 0;
height: 100vh;
border-right: 1px solid var(--border);
background: var(--surface);
}
.sidebar-top {
padding: var(--sp-4) var(--sp-3) var(--sp-1);
}
.sidebar-label {
display: flex;
align-items: center;
gap: var(--sp-2);
padding: var(--sp-3) var(--sp-2) var(--sp-1);
color: var(--faint);
font-size: var(--fs-small);
font-weight: 500;
}
.sidebar-label-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.count {
color: var(--faint);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.sidebar-label .icon-btn {
width: 24px;
min-height: 24px;
margin-left: calc(var(--sp-1) * -1);
}
.new-session {
display: flex;
flex-direction: column;
gap: var(--sp-2);
padding: var(--sp-1) var(--sp-2) var(--sp-2);
}
.new-session input {
min-height: 32px;
padding: var(--sp-1) var(--sp-2);
font-size: var(--fs-meta);
}
.new-actions {
display: flex;
justify-content: flex-end;
gap: var(--sp-1);
}
.new-note {
margin: 0;
color: var(--faint);
font-size: var(--fs-small);
}
.empty {
margin: 0;
padding: var(--sp-3) var(--sp-2);
color: var(--muted);
font-size: var(--fs-meta);
}
.sidebar-sessions {
flex: 1;
min-height: 0;
overflow-y: auto;
padding: 0 var(--sp-2);
scrollbar-width: thin;
}
.group {
display: flex;
flex-direction: column;
gap: 1px;
margin-bottom: var(--sp-4);
}
.group-head {
padding: var(--sp-2) var(--sp-2) var(--sp-1);
}
.working {
color: var(--accent);
font-size: var(--fs-small);
}
.toggle {
height: 22px;
padding: 0 var(--sp-1);
font-size: var(--fs-small);
}
.session {
display: flex;
align-items: center;
gap: 0;
border-radius: var(--r-control);
color: var(--text);
}
.session:hover,
.session:focus-within {
background: var(--surface-2);
}
.session.active {
background: var(--accent-soft);
}
.session-entry {
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: center;
gap: 1px;
flex: 1;
min-width: 0;
min-height: 0;
padding: var(--sp-1) var(--sp-2);
border: 0;
border-radius: var(--r-control);
background: transparent;
color: inherit;
font-weight: 400;
text-align: left;
}
.session-entry:hover:not(:disabled) {
background: transparent;
}
.session-name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--fs-meta);
line-height: var(--lh-body);
}
.session.active .session-name {
color: var(--accent);
font-weight: 600;
}
.session-meta {
display: flex;
align-items: center;
gap: var(--sp-2);
min-height: 14px;
color: var(--faint);
font-size: var(--fs-small);
line-height: 1.2;
}
.state {
white-space: nowrap;
}
.state.ok {
color: var(--accent);
}
.state.warn {
color: var(--warn);
}
.state.idle {
color: var(--faint);
}
.session-actions {
display: flex;
align-items: center;
gap: 1px;
flex: none;
padding-right: var(--sp-1);
opacity: 0;
}
.session:hover .session-actions,
.session:focus-within .session-actions {
opacity: 1;
}
.session-actions .icon-btn {
width: 22px;
min-height: 22px;
color: var(--muted);
}
.session-actions .icon-btn:hover:not(:disabled) {
color: var(--text);
}
.sidebar-bottom {
padding: var(--sp-2);
border-top: 1px solid var(--border);
display: flex;
flex-direction: column;
gap: var(--sp-1);
}
.sidebar-link {
display: flex;
align-items: center;
justify-content: flex-start;
gap: var(--sp-2);
width: 100%;
min-height: 0;
padding: var(--sp-2);
border: 0;
border-radius: var(--r-control);
background: transparent;
color: var(--muted);
font-size: var(--fs-meta);
font-weight: 400;
text-align: left;
}
.sidebar-link:hover:not(:disabled) {
background: var(--surface-2);
color: var(--text);
}
.sidebar-account {
display: flex;
align-items: center;
gap: var(--sp-2);
min-width: 0;
padding: var(--sp-2);
}
.account-text {
display: flex;
flex-direction: column;
min-width: 0;
line-height: 1.3;
}
.account-name {
overflow: hidden;
color: var(--text);
font-size: var(--fs-meta);
text-overflow: ellipsis;
white-space: nowrap;
}
.account-state {
color: var(--faint);
font-size: var(--fs-small);
}
.account-state.ok {
color: var(--accent);
}
.account-state.error {
color: var(--danger);
}
@media (max-width: 860px) {
.sidebar {
position: static;
width: 100%;
flex: none;
height: auto;
max-height: 42vh;
min-height: 0;
overflow: hidden;
border-right: 0;
border-bottom: 1px solid var(--border);
}
}
</style>