Skip to content

feat: live updates (experimental) — a running answer on every open page - #216

Draft
valstu wants to merge 4 commits into
mainfrom
feat/live-stream
Draft

valstu wants to merge 4 commits into
mainfrom
feat/live-stream

Conversation

@valstu

@valstu valstu commented Nov 13, 2026

Copy link
Copy Markdown
Member

What

A page that didn't start an answer can show it as it is written: a second tab, a page reloaded mid-answer, and the answer to a signal, a held message or a schedule. Optional and labelled experimental. Without liveStreams on the runtime nothing changes.

  • liveStreams on the runtime (LiveStreams): publish / subscribe keep a running answer's stream where another request can read it; optional notify / listen carry per-chat events. Every turn's stream is copied into it under runId:fencingToken.
  • memoryLiveStreams() in core, for one long-running server.
  • Redis is a recipe in the guide, not a package: about 30 lines over resumable-stream and two pub/sub commands.
  • runtime.streamChat / GET chats/:id/stream: the running answer from its start, as useChat reads it on resume. 204 when nothing is running.
  • runtime.watchChat / GET chats/:id/events: server-sent events (hello, started, ended, changed), so a page needs no poll loop. 404 when the store can't notify.
  • Docs: new guide guides/live-updates, reference and route tables, pointers from the queue, signals, chat UI, streaming and Vercel pages. Changeset: patch for core and server.

Tested

  • packages/core/src/live-stream.test.ts: each case against the in-memory store and against resumable-stream over a stand-in pub/sub. Second reader gets the answer from its start; a held turn's answer is readable; events for started / ended / changed; a failed publish doesn't stop the answer.
  • apps/example/src/live-stream.smoke.ts (pnpm --filter @intentface/latch-example smoke:live-stream, needs a Redis at REDIS_URL, default redis://127.0.0.1:6390): two runtimes with their own connections to a real Valkey and one database, three tabs driven by the AI SDK's chat client (AbstractChat + DefaultChatTransport). A tab on the other instance shows the first half of an answer before it is finished; the sending tab, also watching, shows each message once; a tab opened mid-answer catches up; a signal's answer is read live by all three. Not run in CI.

Not tested

  • React itself: useChat and EventSource in a browser. The guide's snippet follows the logic the smoke runs, but has not been run.
  • A real serverless host (function duration cut on the events connection, concurrency).
  • Crash recovery: resuming a stream when the history already holds part of that answer.
  • Held messages over real Redis (covered by the unit tests only).

Known limits

  • Events sent while a page reconnects are not replayed; hello covers a running answer.
  • If the instance writing an answer dies, its stream ends with it.
  • Each open chat holds one request open.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CN7rKG2PbHZnCtCWmFAP2w

valstu and others added 4 commits November 13, 2026 16:50
…s/:id/events)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CN7rKG2PbHZnCtCWmFAP2w
… client as second tab

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CN7rKG2PbHZnCtCWmFAP2w
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
intentface-latch-docs Ready Ready Preview Nov 13, 2026 5:30pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

This branch was successfully deployed

1 active deployment
Preview — 21e9b53a Deployed Nov 13, 2026 by vercel[bot]
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