Skip to content

feat(ai): server-backed conversation history (objectui parity) - #98

Merged
os-zhuang merged 1 commit into
mainfrom
feat/ai-server-conversations
Jun 10, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
feat/ai-server-conversations

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

What

Brings the mobile AI assistant to web (objectui) parity: when the server exposes /api/v1/ai/conversations, chats are saved server-side — multi-conversation, cross-device, listable — instead of only an on-device cache.

  • lib/ai-conversations.ts — typed client for the conversation API (list/create/get/delete + addMessage) and a cached conversationsAvailable() probe so servers without it (published service-ai 8.0.1) degrade cleanly.
  • lib/ai-chat.ts — thread conversationId through stream/sendAiChat request bodies.
  • stores/ai-chat-store — two-tier persistence:
    • Server mode: create a conversation on first send, carry conversationId into /ai/chat, explicitly persist user+assistant via /:id/messages, list/load/delete, resume the cached active id on open.
    • Local mode (no API): the existing MMKV restart-survival cache (PR feat(ai): persist the conversation to disk (survives app restart) #97).
    • init() probes once and picks the mode.
  • app/ai.tsx — a Conversations drawer (new chat / switch / delete) + history actions in server mode; calls init() on mount.

Verification

  • End-to-end against the framework dev server (which ships the conversation API): create → chat(conversationId) (streamed a real LLM reply) → messages persist → GET /:id returns the thread → GET /conversations lists it. Confirmed the exact store sequence works server-side.
  • The published 8.0.1 server lacks the API → the demo falls back to the local cache (graceful, no breakage).
  • 48 AI tests (conversation client incl. availability probe; store server + local modes — create-on-send, persist, load, delete, new; drawer UI load/delete).
  • npm run lint 0 errors; jest 1249/1249 (152 suites).

Notes

  • The server-side conversation API is currently only in the unreleased framework source (published @objectstack/service-ai 8.0.1 has none) — so server-backed mode activates automatically once a server with /conversations is connected; until then mobile uses the local cache.
  • Persistence uses the explicit /:id/messages endpoint (reliable across server builds) rather than relying on chat-endpoint auto-persist.

🤖 Generated with Claude Code

Brings the mobile assistant to web (objectui) parity: when the server
exposes /api/v1/ai/conversations, chats are saved server-side — multi-
conversation, cross-device, listable — instead of only an on-device cache.

- lib/ai-conversations.ts: typed client for the conversation API
  (list/create/get/delete + addMessage) + a cached `conversationsAvailable()`
  probe so unsupported servers (published service-ai 8.0.1) degrade cleanly.
- lib/ai-chat.ts: thread `conversationId` through stream/sendAiChat bodies.
- stores/ai-chat-store: two-tier persistence. Server mode — create a
  conversation on first send, carry conversationId into /ai/chat, explicitly
  persist user+assistant via /:id/messages, list/load/delete, resume the
  cached active id on open. Local mode (no API) — the existing MMKV
  restart-survival cache. `init()` probes once and picks the mode.
- app/ai.tsx: a Conversations drawer (new chat / switch / delete) + history
  actions in server mode; calls init() on mount.

Verified end-to-end against the framework dev server (which ships the
conversation API): create → chat(conversationId) → messages persist →
load returns the thread → list shows it. The published 8.0.1 server lacks
the API, so the demo falls back to the local cache (graceful).

48 AI tests (conversation client, store server+local modes, drawer UI).
Suite 1249/1249, lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@os-zhuang
os-zhuang merged commit 955ffd4 into main Jun 10, 2026
@os-zhuang
os-zhuang deleted the feat/ai-server-conversations branch June 10, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant