Live updates: one poller per tab instead of SSE streams

Every useLive() call opened its own EventSource, and the library page and a
model's Jobs tab call it twice. Over plain HTTP a browser allows 6 connections
per host, so with three library tabs open the third took ~10 s to load and its
requests never got an answer; a fourth tab didn't load.

- /api/live answers one short request with the job snapshot (left out when the
  client already has that version) and, for job pages, new log lines.
- src/lib/live-store.ts runs one poller per query per tab, shared by every
  component showing it, paused while the tab is hidden, with backoff on errors.
  One router.refresh() per finished job instead of one per component.
- The worker dot reads the status from that poll; it only asks /api/status
  (every 10 s) when nothing else is polled.
- The worker status no longer carries the heartbeat time (it changed every 5 s,
  so every idle stream re-sent its snapshot) and rounds free space to MiB.
- Removes /api/stream: its sleep() added an abort listener per second to the
  request signal and never removed it.
- Job actions poll right away after starting or cancelling a job; drops
  approveJob/rejectJob, whose routes went away in 0.15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
This commit is contained in:
Claude committed 2026-11-01 20:46:54 +00:00
1 parent 16c3fcc113
commit 76d851896e
11 files changed
+623 -185

No files matched your search

+2 -1
View File
@@ -143,7 +143,8 @@ More guides are in the [wiki](https://git.linxweiler.xyz/pascallinxweiler/Kaname
Three containers from the same image; web and worker share one SQLite database:
- **web:** Next.js UI and API, OIDC login (Auth.js); live updates via Server-Sent Events.
- **web:** Next.js UI and API, OIDC login (Auth.js); live updates by polling once a second from
the visible tab (paused in background tabs, so any number of tabs can stay open).
- **worker:** runs the download queue, spawns `hf download --revision <sha> --include <files>`, and
measures progress from bytes on disk; runs benchmarks against endpoints (BetterBench, the quality
eval). Only one worker runs at a time.