UXDL Docs

Streaming & Realtime

SSE, webhooks, Socket.io, and polling for AI output.

How UXDL surfaces AI output to clients: live tokens, durable completion, and job status updates.

Mechanisms

MechanismUse caseTypical pattern
SSEToken-by-token display for in-process agentsAgents & pipelines + POST /chat/stream
LangGraph webhookDurable completion for hosted runsWebhooks & reconciliation
Socket.ioPush job status when the DB row updatesBackend → Socket.io
PollingFallback while status === processingGET job endpoint on an interval

In-process chat (SSE)

Expose streaming from agent.stream() or equivalent via Server-Sent Events.

Event types (convention):

EventPayloadMeaning
token{ token: string, node: string }Streamed AI chunk
done""Generation complete
error{ message: string }Runtime error

Persist the full assistant message to the database after the stream completes so history survives restarts.

Hosted runs (webhook + optional stream)

Hosted graphs may stream interim events via LangGraph streamMode, but durable user-visible text for async jobs should still land via the webhook handler writing to the product DB.

Async jobs (poll + socket)

Frontend pattern for long-running generation:

  1. Optimistic UI after POST creates the job.
  2. Poll GET /jobs/:id while status === processing.
  3. Optionally subscribe to a Socket.io event when the row updates.
  4. Stop when status is completed or error.

Reconciliation on read can unblock stuck jobs. See Local development.

See also

Official documentation