chat: optional streamed answers (SSE) instead of POST-and-render #11

Open
opened 2026-06-11 07:59:01 +00:00 by mathias · 0 comments
Owner

Context

v1 chat (ADR-027) uses a simple HTMX POST-and-render: the answer appears only
after the model call fully completes. The spec explicitly allowed "HTMX streaming
if clean" and we chose the simpler path for v1.

Problem

On a slow/cold model (e.g. the gemma fallback's ~37s cold-load, ADR-022), the
user stares at the "thinking…" indicator with no partial output. Streaming would
make the wait feel responsive.

Proposal

  • Stream tokens via SSE (or chunked HTMX) into the chat panel as they arrive.
  • Reuse the existing gateway client's streaming mode if available; otherwise this
    needs an llm streaming method (the copied package — change tapir's copy per
    ADR-004, do not lift upstream).
  • Keep the no-JS fallback: without JS the form still POSTs and renders the full
    answer.

Scope

UX polish, not correctness. Deferred from v1. Reassess if chat sees real use and
the wait is a felt friction.

Source: ADR-027 §2, internal/web/chat.go, internal/adapters/llm.

## Context v1 chat (ADR-027) uses a simple HTMX POST-and-render: the answer appears only after the model call fully completes. The spec explicitly allowed "HTMX streaming if clean" and we chose the simpler path for v1. ## Problem On a slow/cold model (e.g. the gemma fallback's ~37s cold-load, ADR-022), the user stares at the "thinking…" indicator with no partial output. Streaming would make the wait feel responsive. ## Proposal - Stream tokens via SSE (or chunked HTMX) into the chat panel as they arrive. - Reuse the existing gateway client's streaming mode if available; otherwise this needs an `llm` streaming method (the copied package — change tapir's copy per ADR-004, do not lift upstream). - Keep the no-JS fallback: without JS the form still POSTs and renders the full answer. ## Scope UX polish, not correctness. Deferred from v1. Reassess if chat sees real use and the wait is a felt friction. Source: ADR-027 §2, `internal/web/chat.go`, `internal/adapters/llm`.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mathias/tapir#11