UI-SP5 — Realtime SSE swap (view-free)#22
Merged
Conversation
1 additive backend SSE endpoint (GET /tasks/{id}/stream, hand-rolled
StreamingResponse, zero new dep, zero migration) + opt-in extension of
useLiveResource with streamUrl/applyEvent (additive; existing callers
unaffected) + ONE consumer (useTaskDetail) opts in. 9 other composables stay
polling = truly view-free. fetch+ReadableStream (Bearer-via-header) over
EventSource (would leak JWT via ?token query string). UI-SP4 AI-Copilot
deferred (v2.1 scope, requires full AI backend not implemented).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
M1 backend (openapi+config; SSE route+4 tests; gate). M2 frontend (parseSseChunk pure parser; streamSse+shouldStream; gate). M3 cutover (useLiveResource opt-in; useTaskDetail opts in; full gate + headed smoke + docs). Complete code, no placeholders; grounded in hf_proxy.py StreamingResponse idiom + post-SP3 on-disk state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BLOCKER (frontend): Vue 3.5 watch({immediate:true}) fires SYNCHRONOUSLY
before stopWatch is assigned → calling stopWatch() in the handler hits TDZ
when vue-query serves a cached snapshot synchronously. Fix: let stopWatch +
optional-call + started flag.
IMPORTANTs:
- Backend: yield b":open\n\n" first byte to defeat httpx 0.27.x ASGITransport
buffering (could hang the multi-snapshot test).
- Backend: replace hard-coded 447 baseline with record-then-add (SP3 added
extra tests since the baseline was estimated).
- Frontend: pollingFallback → ref(false) for Vue idiom clarity.
- Frontend: streamSse fast-fail on 403/404 (no point burning 7s of backoff).
- Frontend: parseSseChunk hasData flag preserves "0"/"" payloads (SSE-spec).
- Frontend: NEW streamSse happy-path / 401 / 404 unit tests (3 tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…s testability hatch for httpx ASGITransport)
…gate + happy-path tests
This was referenced May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Web UI sub-project 5 of 5 (after UI-SP1 #19, UI-SP2 #20
de9573a, UI-SP3 #21a32f165). Delivers the locked "single-seam SSE swap, view-free" promise recorded multiple times across SP1/SP2/SP3:useLiveResourceinternals swap from polling to SSE, every view/page/other composable is unchanged.GET /api/v1/tasks/{id}/stream— hand-rolledtext/event-streamvia FastAPIStreamingResponse(same idiom ashf_proxy.py). 1 Hz default tick (envDLW_TASK_STREAM_INTERVAL_SECONDS, clamped[0.1, 10.0]). Proven cancel-pattern tenant gate (404 cross-tenant) + per-tick re-filter. Terminates on terminal task status, client disconnect, or controller shutdown.?max_ticks=Ntestability hatch (httpxASGITransportbuffers the body until generator close — needed for the multi-snapshot test).frontend/src/api/sse.ts(pureparseSseChunk+streamSsefetch+ReadableStream +shouldStreamgate);useLiveResourcegains optionalstreamUrl+applyEvent(additive — existing callers untouched);useTaskDetailopts in. 9 other composables stay polling.watch({immediate:true})fires SYNCHRONOUSLY beforestopWatchis assigned → TDZ if vue-query serves a cached snapshot) + 6 IMPORTANT (httpx ASGITransport buffering mitigation;pollingFallback→ ref; 403/404 fast-fail;parseSseChunkhasDataflag for"0"/""payloads; newstreamSsehappy-path/401/404 unit tests; baseline-record). All fixed in plan before code.Verification
--max-warnings=0; vite build success./tasks/<id>; live:open\n\ndata: <TaskDetail JSON>\n\nverified via direct curl on the ephemeral:8011controller with current SP5 code.useTaskDetail.spec.ts(SP1) andTaskDetailSP2.spec.ts(SP2 page) tests pass UNCHANGED.TaskDetail.vuewas NOT modified. 9 non-opted composables NOT modified.Known follow-ups (non-blocking, record-and-accept)
task_stream_interval_secondsclamping is runtime-only (Pydantic field has noge=/le=); a misconfigured env var would be silently capped at request time instead of failing fast at startup.pollingFallbackis one-way: once SSE gives up, the composable stays on polling for the lifetime of the consumer (tab refresh restores SSE) — documented inweb-ui.md.useTaskDetailroute-id reuse: same composable instance across task-id changes would stream the stale id; current router setup mounts fresh per route, so benign today.Test plan
🤖 Generated with Claude Code