v0.1.0-alpha.46
·
237 commits
to main
since this release
feat: auto-resume abandoned in-flight turns via poll [alpha.46]
qlaud has no SSE-resume endpoint — once the client disconnects
from a stream, you can't reattach. But the edge worker DOES keep
the upstream call alive via waitUntil and persists the assistant
turn server-side. We just have to ask "is it there yet?" until
it shows up.
New module lib/in-flight.ts tracks threads with an active
send-in-flight (kicked off but not confirmed-complete locally):
- markInFlight(threadId) — called when send() starts
- clearInFlight(threadId) — called on success OR when poll
detects the assistant turn has landed
- hasLanded(threadId, messages) — heuristic: looks for an
assistant turn after the user's prompt
- 2-minute timeout so a stuck upstream doesn't spin forever
When send() finishes, we only clearInFlight if the run was NOT
superseded (runId === activeRunIdRef.current). If the user
switched threads mid-stream, the marker stays — server is still
working.
useThreadMessagesQuery now sets refetchInterval: 2_000 whenever
the active threadId is in-flight. Each poll checks hasLanded()
on the latest data; once true, polls stop and the marker clears.
The user sees the new assistant turn appear within ~2s of qlaud
persisting it.
UI: a "Still working on the previous turn — the response will
appear here when it lands" pill renders above the chat when the
active thread is in-flight + we're not actively streaming. Self-
dismissing once the turn arrives.
Net effect: send "hi" on chat A → switch to B mid-stream → come
back to A → see the in-progress indicator → response materializes
when qlaud finishes. The conversation never gets lost.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>