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
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.
243 lines
13 KiB
Markdown
243 lines
13 KiB
Markdown
# rhema claw web
|
|
|
|
A small, hand-rolled web client for the claw (`rhema-claw`): a live
|
|
transcript of one session, the session inventory, and a settings area
|
|
(model providers, about). Nuxt 4 + Vue 3 + TypeScript, no component
|
|
library, no store. It is strictly **one client** of the claw's public
|
|
`/v1` HTTP surface.
|
|
|
|
## Run it against a locally running claw
|
|
|
|
```sh
|
|
rhema-claw # the daemon, on 127.0.0.1:7799
|
|
cd web/claw
|
|
npm install
|
|
npm run dev # http://localhost:3000
|
|
```
|
|
|
|
In dev, the `server/middleware/claw-proxy.ts` middleware forwards
|
|
`/v1` and `/healthz` to `http://127.0.0.1:7799` (`NUXT_CLAW_UPSTREAM`
|
|
overrides), so the browser sees a same-origin API and CORS never enters
|
|
the picture. If the claw is not running, the page still loads: the
|
|
down/401/stream banners tell you what is wrong.
|
|
|
|
### Token
|
|
|
|
When the claw config sets `token:`, every `/v1` route wants
|
|
`Authorization: Bearer <token>`. Give the UI a token either way:
|
|
|
|
- the environment: `NUXT_PUBLIC_CLAW_TOKEN=... npm run dev` (runtime
|
|
config `clawToken`), or
|
|
- the inline field in the 401 banner; it is stored in `localStorage`.
|
|
|
|
`/healthz` is open either way, which is how the sidebar's health word
|
|
stays honest when the token is wrong.
|
|
|
|
## Build
|
|
|
|
```sh
|
|
npm run build # nuxt generate -> .output/public, fully static
|
|
npm run typecheck # vue-tsc over the whole app
|
|
```
|
|
|
|
`npm run build` produces a static SPA in `.output/public`, the artifact
|
|
an ingress serves. The ingress owns routing: same-origin `/v1` and
|
|
`/healthz` to the claw. `runtimeConfig.public.clawBase` can point the
|
|
client at another base, but the claw sends no CORS headers, so
|
|
cross-origin use needs a proxy, not a different origin.
|
|
|
|
## The one-consumer principle
|
|
|
|
The claw's `/v1` API is the contract (`crates/rhema-claw/src/http.rs`):
|
|
sessions, messages, events, providers. This client uses only public
|
|
routes, speaks the wire shapes the Rust side serializes, and adds
|
|
nothing server-side. UI needs never justify private endpoints; they
|
|
justify claw API changes, argued in the Rust tree.
|
|
|
|
Two consequences worth knowing before changing this code:
|
|
|
|
- **The daemon owns the conversation.** `POST .../messages` is
|
|
fire-and-forget (202); the reply streams back on
|
|
`GET /v1/sessions/{key}/events`. The transcript here is a mirror of
|
|
the stream, and the stream opens on the newest turn before the live
|
|
feed. That turn comes back whole even when it is longer than the
|
|
replay window, so a reload never lands mid-reply with the file the
|
|
turn handed over above the cut. A reload paints the latest
|
|
conversation at once instead of replaying a session that may have run
|
|
for weeks, and the turns above it come from
|
|
`GET /v1/sessions/{key}/history`, one whole turn per
|
|
page, as the reader scrolls up (or right away, while the transcript
|
|
is shorter than the screen). So the transcript survives the browser,
|
|
not just the claw.
|
|
- **Every frame names its seq, and a reconnect names it back.** The
|
|
frame's `id:` is the record's seq for the event, and
|
|
`useClaw().subscribeEvents` keeps the last one it delivered: a retry
|
|
sends `?since=<seq>` and receives exactly the gap, so a dropped
|
|
connection costs nothing on screen and nothing on the wire. The mirror
|
|
is not reset on reconnect for the same reason — its items are still
|
|
true. A `reset;` comment means the cursor named events the record no
|
|
longer holds (a wiped database): the mirror drops, and the tail that
|
|
follows rebuilds it.
|
|
- **SSE goes over fetch, not `EventSource`.** The claw's auth reads
|
|
only the `Authorization: Bearer` header (`http.rs` `require_auth`); it
|
|
has no query-param fallback, and `EventSource` cannot set headers. So
|
|
`useClaw().subscribeEvents` holds a `GET` with the auth header, reads
|
|
the body as a `ReadableStream`, and parses `data:`/`id:` frames by
|
|
hand (`composables/useClaw.ts`). Drops retry with backoff; the hub's
|
|
`lagged` comments surface as notices.
|
|
- **The dev proxy forwards the query string.** `server/middleware/
|
|
claw-proxy.ts` rebuilds the upstream URL from the request's pathname,
|
|
and `since`/`before` are the whole history protocol: dropping them
|
|
silently turns every resume into a full replay and every history page
|
|
into the tail.
|
|
|
|
## What the transcript does with the stream
|
|
|
|
- **Replies, asks and files only.** The stream carries tool calls and
|
|
the model's thinking trace; this surface drops both and renders the
|
|
reply. A consent card and an attachment card still appear inline,
|
|
because the reader has to answer or open them. The mirror still
|
|
folds those other events; only the render ignores them.
|
|
- **Long pastes travel as chips.** A paste over three lines (the TUI's
|
|
`PASTE_INLINE_LINES`) never lands in the composer; it stages as a
|
|
droppable chip (`▣1 42L`) and rides the body's `pastes` array beside
|
|
the plain draft — the claw composes the record (the payload in
|
|
place, the span note beside it) — so no mark ever crosses the wire.
|
|
The `user_message` echo names each chip as the byte span it stands
|
|
for (the session record's own shape, `paste::PasteSpan`), and the
|
|
transcript renders from that. Rows recorded before spans rode the
|
|
stream carry the legacy mark form in the text instead; the render
|
|
still scans for those, and an unpaired mark stays literal.
|
|
- **The agent can ask.** A `consent_request` event renders as an
|
|
inline card: kind `secret` gets a password input plus submit, kind
|
|
`phone` gets Approve/Deny, and both carry a deny link
|
|
(`DELETE /v1/consents/{id}`). The card flips when the answer lands
|
|
and again on the stream's `consent_resolved` echo; nothing persists
|
|
client-side, so a reload rebuilds the cards from the replay.
|
|
- **Attachments render inline.** An `attachment` event becomes a card
|
|
— media glyph, file name, B/KB/MB size, caption. The media kind comes
|
|
from the file extension, decided by the daemon when it stores the
|
|
file, so a `.png` renders and a `.patch` downloads without the client
|
|
guessing. Images fetch the bearer-guarded bytes
|
|
(`GET /v1/attachments/{id}`, blob → object URL, like the identity
|
|
images) and render capped at 240px; every card downloads on click,
|
|
images included. A card lives inside the turn that produced it, so
|
|
the scan that fetches image bytes walks finished turns and the live
|
|
one, not just the top-level rows. Object URLs cache per id, so a
|
|
replay never refetches.
|
|
- **Your images ride along.** The composer's `+` — and an image on the
|
|
clipboard — stage as removable chips (`▣1 photo.png 1.2 MB`), the
|
|
claw's own budget enforced client-side (8 a message, 5 MiB decoded
|
|
each; the draft stays required, the route 422s an empty text). The
|
|
sent row renders the local previews at once; the stream's
|
|
`user_message` echo carries the stored attachment ids and dedupes
|
|
against that row, so a replayed message renders its own thumbnails
|
|
through the same bearer-guarded fetch as an attachment card.
|
|
- **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 interactive prefixes
|
|
(`interactive:`) list above the fold; *others* holds the whole rest
|
|
of the inventory — `task:`, `calendar:`, the phone's keys
|
|
(`phone:…`), the coding jobs' `job:<instance>#<id>` keys and forge
|
|
keys.
|
|
- **Every row opens, and some open read-only.** A resident key
|
|
(`interactive:`, `task:`, `phone:`, `calendar:`) has a live stream,
|
|
and the chat resets its mirror whenever that stream reopens. A key
|
|
outside them has none: its dispatch runs outside the hub. The panel
|
|
fetches `GET /v1/sessions/{key}/history` instead, which serves the
|
|
session the engine checkpointed, and shows the turns with a
|
|
`snapshot` status and the composer replaced by a line saying why.
|
|
The inventory's `revision` is that view's only reload signal: a poll
|
|
that sees it move fetches the newest page again, so an older page
|
|
the reader walked back to survives polling until a turn runs.
|
|
- **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
|
|
confirm — so a key created again under the same name starts empty.
|
|
A 409 (a turn holds the key) and a 404 (already gone) land in the
|
|
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 says
|
|
`held` in the warn tone — 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
|
|
|
|
The shell is one sidebar plus a view, switched by a tiny hash router
|
|
(`#/chat`, `#/settings/agent/general`, `#/settings/agent/accounts`,
|
|
`#/settings/providers`, `#/settings/about`), no vue-router. The sidebar
|
|
holds the session list in chat and the searchable settings nav in
|
|
settings. Both start with the product mark and end with a link to the
|
|
other view plus the claw's health. The chat view is the live
|
|
transcript; the settings view is pages on an 880px column. The agent's
|
|
identity (name, mark, avatar) loads once and renders in the chat rows
|
|
and the sidebar account row through `AgentAvatar`, which owns the
|
|
precedence: avatar image, then mark or initials. Settings pages stage
|
|
edits into a local draft and
|
|
apply them with an explicit Save (`PUT /v1/providers/active` answers
|
|
the new pair only; the client carries the provider list forward).
|
|
The providers page also manages the roster itself: the add form renders
|
|
from the `addable` kinds the claw serves; each kind's `fields` carry
|
|
`{name, required}`, `required` marking what the daemon refuses the login
|
|
without (llama.cpp needs neither of its fields, it serves keyless on a
|
|
default url); the form demands only those, marks the rest optional, and
|
|
takes an optional instance name; unnamed, the id is the kind. Model
|
|
options carry a `(vision)` note when the live listing knows the model
|
|
takes images (`supports_vision: true`); the key's absence is unknown,
|
|
never a no, so it renders nothing. A login
|
|
is `PUT /v1/providers/{id}/credentials`: apply immediately,
|
|
credentials persist; roster rows are backend instances (`id`, the kind
|
|
unless the login named it, plus the credential's `source`
|
|
badge, env-backed kinds return on restart after a removal), and the
|
|
remove button (`DELETE /v1/providers/{id}`) refuses the last backend
|
|
claw-side.
|
|
|
|
```
|
|
app/
|
|
app.vue the shell: sidebar, banners, view switch
|
|
assets/css/main.css the Rhema Together palette (light and
|
|
dark), type scale, controls, cards,
|
|
markdown
|
|
assets/fonts/ FiraCode Nerd Font Mono for code
|
|
components/
|
|
SidebarBrand.vue the product mark and name
|
|
AppBadge.vue the quiet tag
|
|
AppCallout.vue the toned inline note (info/ok/warn/error)
|
|
AppMarkdown.vue agent replies as markdown (markdown-it,
|
|
raw HTML escaped, styles in main.css .md)
|
|
ClawBanner.vue the one error/notice banner surface
|
|
ChatPanel.vue transcript: sent lines (paste chips),
|
|
streamed turns as reply text plus
|
|
consent + attachment cards; the growing
|
|
composer; agent replies render through
|
|
AppMarkdown
|
|
SessionsSidebar.vue conversable dispatch keys (phone status
|
|
keys hidden), interactive first; the
|
|
+ form creates a session; settings and
|
|
the agent's health in the footer
|
|
PageHeader.vue title + subtitle + page actions
|
|
SettingCard.vue one titled card of rows
|
|
SettingRow.vue name + description + control
|
|
SettingsNav.vue searchable settings nav; chat and
|
|
health in the footer
|
|
settings/
|
|
ProvidersPage.vue the backend switch: draft → Save/Discard
|
|
AboutPage.vue identity, stack, the routes spoken
|
|
composables/
|
|
useClaw.ts the typed API client + fetch-based SSE
|
|
useTranscript.ts folds TurnEvents into renderable turn
|
|
blocks; owns the paste span record (and
|
|
the legacy mark form old rows carry)
|
|
server/
|
|
middleware/claw-proxy.ts dev-only same-origin proxy to a running claw
|
|
```
|