Description
All sources currently refresh simultaneously at t=0 on every startup and every 30s interval, causing a thundering herd against the Next.js API. Add deterministic per-source jitter so each source's first fetch is offset by hash(source_kind) % MAX_JITTER_MS milliseconds. The offset should be stable across restarts (same source = same offset), so phase relationships don't change between runs.
Implementation sketch:
- Write a
_jitter(kind: str, max_ms: int = 8000) -> floatfunction usinghashlib.md5(kind.encode()).digest()as seed - In
on_mount, instead ofself.set_interval(REFRESH_SECS, self.refresh_data), fire each source's first refresh after its individual jitter offset viaself.set_timer(jitter_secs, lambda: ...)then start the repeating interval - Or: a single interval timer that checks per-source "next due" timestamps rather than refreshing everything at once
Acceptance Criteria
- #1 Restarting the TUI does not cause all API calls to fire at the same instant
- #2 Same source always gets the same jitter offset across restarts
- #3 Max jitter is configurable via a constant at the top of the file
- #4 Overall data refresh still completes within REFRESH_SECS of startup