Repository navigation
feat(studio): back the chat list with the daemon's session store - #615
jtenniswood wants to merge 3 commits into
Conversation
Studio kept every chat in one browser key, `mecatl-studio-tasks`, while
mecated persisted the same sessions the whole time. The endpoints were
already there and Studio called none of them, so a second browser saw
nothing, "rename" renamed a local label that the next reload discarded,
and "delete" hid a session that stayed in the store for ever.
The daemon's store is now the record of which chats exist, what each is
called, and what was said in each:
- the chat list is a bounded walk of GET /v1/sessions, merged on connect
and on a slow poll, so a change made in another client shows up here
- rename is POST /v1/sessions/{id}/rename, optimistic and rolled back if
the daemon refuses, adopting the title it actually stored (it clamps)
- delete is POST /v1/sessions/{id}/delete; a refusal keeps the row,
because hiding a chat that still exists is the bug being fixed
- opening a chat reads GET /v1/sessions/{id}/transcript
- rename/delete eligibility comes from each row's `capabilities` and its
closed reason code, rather than the client re-deriving server policy
A row is dropped only once it has been observed present in a COMPLETE
walk and then absent, so a session created seconds ago is never pruned
as though someone had deleted it.
Two continuity fixes fall out. A failed turn no longer throws away the
session id — only a 404 does — so the next prompt continues the same
chat instead of silently starting a fresh, context-free one. And a
reload during a run no longer claims the task "was interrupted": the
chat is marked as still working on the daemon and its transcript is read
back when the run ends.
localStorage stays as a cache and as the home for unsent drafts.
Verified against a real offline mecated: rename and delete persist, a
chat deleted from another client disappears here without a reload, and
the list survives clearing browser storage entirely.
Co-Authored-By: Claude Opus 5 <[email protected]>
The panel called itself the oversight surface for scheduled tasks but
covered only half the daemon's API: list, pause, resume, fire, delete. A
schedule had to be created outside the UI, could not be changed once
armed, and its past fires were invisible — so the one place an operator
looks to understand unattended work could not tell them what it had done.
It now covers the rest of the surface:
- Create (POST /v1/schedules) and edit (PUT /v1/schedules/{name}) through
one form. The name is fixed on an edit because a schedule is addressed
by name — renaming would arm a second one and drop the firing history.
- Fire history per schedule (GET …/fires), newest first, with each fire's
stop reason, its error when it failed, and the sched-- session it ran
as. An in-flight fire re-reads on its own (GET …/fires/{id}) rather
than refetching the log.
Two rules the UI has to respect, both now documented in studio/CLAUDE.md
and pinned by tests:
- An update REPLACES the spec, so any field the form omits is DELETED.
ScheduleRow.carried carries the settings this form has no control for
(provider selector, misfire policy, singleton, carried context, per-fire
deadline, multimodal parts) and encodeScheduleSpec puts them back.
- A request body is not a response body: requests decode with protojson,
responses encode with stdlib encoding/json, and the two disagree on
every well-known type (Timestamp, Duration). The encoder is that
conversion, which is why the edit path decodes to a view model first.
The mutating/mode pair is coupled in the form because the daemon rejects a
non-mutating schedule with a write-capable posture, so an invalid pair is
not constructible rather than being caught by a 400. Everything else the
create-seam enforces — cron grammar, the cadence floor, the selector
inventory, name collisions — is surfaced verbatim rather than re-guessed.
Verified against a real offline mecated (--mock, --store-dir): an
out-of-band schedule carrying a misfire policy, carried context, a 900s
fire timeout and per-fire limits survives a prompt-only edit from the UI
with its firing state intact, and both trigger arms create, fire, and
render their log.
Co-Authored-By: Claude Opus 5 <[email protected]>
Brings feat/studio-schedule-authoring (create, edit, and fire history for the Schedules panel) onto the server-backed chat list, at the repository owner's direction, so both land as one change. Five files needed a hand resolution — the two branches append to the same regions of studio/lib/protocol.ts, studio/app/page.tsx and studio/tests/rendered-html.test.mjs, and both edit the lib/protocol.ts Shape bullet in studio/CLAUDE.md and add a section at the same anchor in user-docs/what-you-get/studio.md. Notes on the three that are not a plain union: - the import lists in page.tsx and the test file both name decodeScheduleRows and parseMecatlEvent, so keeping both sides duplicates the specifier and tsc fails; - the test-file conflict boundary cuts through the last schedule test, leaving its closing brace after the appended session tests — a plain union yields "SyntaxError: Unexpected end of input"; - the CLAUDE.md bullet now names the chat inventory and transcript envelopes AND the schedule-spec encoder and fire-log decoder, because picking either side understates what protocol.ts holds. Verified on the merged tree: studio test suite 17/17 (8 schedules + 9 session inventory/transcript), ESLint, and tsc all clean. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Added the Schedules panel work (previously PR #616, now closed) to this branch at the repository owner's direction, so both Studio changes land together. This PR now covers two things: the server-backed chat list, and the Schedules panel gaining create, edit, and fire history. What the schedules half does: the panel could only list, pause, resume, fire, and delete, so a schedule had to be created outside the UI, could not be changed once armed, and its past fires were invisible. It now covers Two invariants it adds to The merge needed a hand resolution in five files. Three points worth knowing if this is ever re-done: the import lists in Verified on the merged tree: studio suite 17/17 (9 session inventory/transcript + 8 schedules), ESLint, tsc, Reviewers: the two halves are separate commits ( 🤖 Generated with Claude Code |
The problem
Studio kept every chat in one browser key,
mecatl-studio-tasks(studio/app/page.tsx:375).mecatedpersisted the same sessions the whole time, and Studio called none of the endpoints that expose them —GET /v1/sessions,GET /v1/sessions/{id}/transcript,POST …/rename,POST …/delete.Every symptom followed from that one gap:
The persistence was never missing. It was unused.
What this does
The daemon's session store is now the record of which chats exist, what each is called, and what was said in each.
localStorageonlyGET /v1/sessions, merged on connect and on a 20s pollPOST …/rename, optimistic, rolled back on refusal, adopts the title the daemon storedPOST …/delete— snapshot and sidecars removed; a refusal keeps the rowGET …/transcriptwhen the row has no cached history, or when the daemon reports it advanced elsewherecapabilities+ its closed reason codeTwo continuity fixes fall out of the same work:
Design notes that carry their reasoning in the code:
active_elsewhere,awaiting_approval,storage_unsupported, …); it does not re-derive who may rename or delete what.localStoragestays as a cache and as the home for unsent drafts, which exist nowhere else.Verification
Built
bin/mecated, ran it offline (--mock,--store-dir), and drove Studio in external mode against it:title_provenance: operatorand the new title;204, gone fromGET /v1/sessions, and both.session.jsonland.events.jsonlremoved from disk; a second delete is204(idempotent);404, which is exactly the one path that detaches a chat;localStorageentirely and reloading brought the list back from the daemon with the rename applied and the deleted chat still gone;Gates:
npm run typecheck,npm run lint,npm test(14/14) all clean;task docsclean (0 broken links, 0 orphans, 0 unreachable). No Go code changed.Known gaps, stated rather than hidden
GET /v1/sessions/{id}/eventsis a finite replay of the durable log, and the live per-session subscription (Service.Subscribe) is reachable only over gRPCStreamSessionLive, which the ordinary run relay does not publish to. Closing that is a daemon change, not a client one.ConversationMessage, not string-sniffing in the client.Notes for review
feat/studio-enterprise-ui, so review the diff against that branch rather thanmain.docs/adr/0227-studio-server-backed-chats.md.studio/CLAUDE.mdgains four invariants;user-docs/what-you-get/studio.mdgains two sections./v1/sessionscall sites; the conversation render block andlib/transcript.tsbelong to the others. Expect small, additive merges inapp/page.tsx,lib/protocol.ts, and the test file. Oncelib/transcript.tslands,transcriptToMessagesshould move there and get its own test.🤖 Generated with Claude Code