paliadin chat: server-side history persistence (so responses survive navigate-away) #19

Open
opened 2026-05-08 16:56:24 +00:00 by mAi · 0 comments
Collaborator

Currently paliadin.ts stores history only in localStorage (paliadin:history:<sessionId>). Design comment at line 7-8 of frontend/src/client/paliadin.ts: "session-only persistence".

Real-world friction (m, 2026-05-08): if the user navigates away from the paliadin chat before a response finishes streaming (or before localStorage gets written), the response is lost from the UI. The shim has already written /tmp/paliadin/<uuid>.txt and (presumably) the Go side has the result, but nothing persists it.

Fix

  1. Backend: persist each (session_id, user_id, turn_id, prompt, response, started_at, duration_ms, error_code) row to a paliadin_turns (or similar) table in paliad schema.
  2. Endpoint: GET /api/paliadin/history?limit=N returns the user's most recent turns, oldest-first.
  3. Frontend: hydrate() renders localStorage immediately, then fetches server history and reconciles — same pattern that just landed in youpcorg frontend/js/components/ai/chat.js (commit on mai/klaus/124d-history-hydrate-fix in yoUPC/youpc.org).

Out of scope

Multi-device sync semantics, deletion endpoints — separate ticket if needed.

Cross-ref

  • youpcorg analog: yoUPC/youpc.org#124 + the chat-hydrate fix shipping today.
  • paliadin design doc §0.5.4 (session-only persistence) needs an addendum once this lands.
Currently `paliadin.ts` stores history only in `localStorage` (`paliadin:history:<sessionId>`). Design comment at line 7-8 of frontend/src/client/paliadin.ts: "session-only persistence". Real-world friction (m, 2026-05-08): if the user navigates away from the paliadin chat before a response finishes streaming (or before localStorage gets written), the response is lost from the UI. The shim has already written `/tmp/paliadin/<uuid>.txt` and (presumably) the Go side has the result, but nothing persists it. ## Fix 1. Backend: persist each `(session_id, user_id, turn_id, prompt, response, started_at, duration_ms, error_code)` row to a `paliadin_turns` (or similar) table in `paliad` schema. 2. Endpoint: `GET /api/paliadin/history?limit=N` returns the user's most recent turns, oldest-first. 3. Frontend: `hydrate()` renders localStorage immediately, then fetches server history and reconciles — same pattern that just landed in youpcorg `frontend/js/components/ai/chat.js` (commit on mai/klaus/124d-history-hydrate-fix in yoUPC/youpc.org). ## Out of scope Multi-device sync semantics, deletion endpoints — separate ticket if needed. ## Cross-ref - youpcorg analog: yoUPC/youpc.org#124 + the chat-hydrate fix shipping today. - paliadin design doc §0.5.4 (session-only persistence) needs an addendum once this lands.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: m/paliad#19
No description provided.