fix(stats): render Agents-running sparkline immediately on first paint#85
Conversation
The fsb-agents-running chart fed Chart.js a 1-point line dataset for the first 5 minutes after mount: agentHistoryRing starts empty, FSBTelemetryService polls every 5 min, so only the immediate-fetch sample existed until the next poll. With pointRadius:0 (sparkline aesthetic) a 1-point line draws literally nothing — Chart.js needs >=2 points to stroke. Net effect: visitors landed on /stats, switched to "Agents running", and saw a 360px void for 5 minutes. Fix: render-time fallback inside the fsb-agents-running switch case only. When ring.length < 2, synthesize [live, live] from the current active_agents_now headline value so the chart draws a flat "currently N agents" line from the first paint, gaining real shape as the ring fills. Polling cadence, ring buffer, legend i18n marker, and all other tabs untouched. Scoped to lines 1029-1059 of stats-page.component.ts. messages.xlf line-number context drift regenerated via ng extract-i18n.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac1c4da9d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const live = headline?.active_agents_now ?? 0; | ||
| const data = ring.length >= 2 ? ring : [live, live]; |
There was a problem hiding this comment.
Avoid synthesizing zeros before FSB data exists
When the GitHub datasets have already put the page in ready but the FSB headline request is still pending or has failed, selecting the Agents running tab reaches this branch with latestFsbHeadline === null and an empty agentHistoryRing; the new fallback then renders [0, 0] as if there are zero active agents. The template intentionally hides the FSB headline while fsbHeadline is null, so this can show a misleading zero chart for the duration of a slow request or indefinitely after an FSB error instead of an empty/loading state. Only synthesize the two-point fallback once a real headline/ring sample exists.
Useful? React with 👍 / 👎.
Codex review on PR #85 flagged that when GitHub datasets flip viewState to 'ready' before the FSB headline endpoint resolves (or when it errors), the first-paint fallback synthesizes [0, 0] -- a misleading flat-zero line as if there were genuinely zero active agents. Add a `!headline` gate around the fallback so the canvas stays empty until at least one real FSB sample arrives. Once latestFsbHeadline is non-null, onFsbHeadlineUpdate has atomically pushed onto the ring, so the live-value seed is always backed by a real reading. messages.xlf line-number context drift regenerated via ng extract-i18n.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
/stats, switched to the "Agents running" tab, and saw a 360px black void for ~5 minutes before any line appeared. Headline row above ("20 active agents · 15,844 lifetime agents") populated instantly, so the network was healthy — only the chart canvas was empty.agentHistoryRingis a component-local buffer that starts empty on every mount.FSBTelemetryServicepolls every 5 min (POLL_INTERVAL_MS = 5 * 60 * 1000) andstart()only fires ONE immediate refresh. So the ring had exactly 1 sample for the first 5 min. Thefsb-agents-runningchart config usespointRadius: 0(sparkline aesthetic), and Chart.js needs ≥2 points to stroke a line — a 1-point dataset with invisible points draws nothing.fsb-agents-runningswitch case only — whenring.length < 2, synthesize[live, live]from the currentactive_agents_nowheadline value so the chart draws an immediate flat "currently N agents" line that gains real shape as the ring fills with subsequent samples.Constraints respected
stats-page.component.ts(thefsb-agents-runningswitch arm).FSBTelemetryServiceuntouched (out of scope; that's a privacy/cost-of-egress decision).agentHistoryRingbuffer untouched — no pre-seed, no localStorage, no shared service state.SHOWCASE_STATS_FSB_CHART_AGENTS_RUNNING_LEGENDbyte-identical.ring.length >= 2, behavior is byte-identical to pre-fix.messages.xlfline-number context drift regenerated viang extract-i18nso the CI "no diff" gate stays green.Test plan
cd showcase/angular && npm run build— passes (11s, 30 routes prerendered).npm run lint:i18n— 0 errors (one pre-existing unrelated warning on agents-page).npx ng extract-i18n— only line-number context drift, no new/removed trans-units, no source text changes; regenerated file committed./stats, click "Agents running" tab, confirm a flat horizontal line appears immediately at the current value (e.g. ~20 agents) instead of an empty 360px black void.🤖 Generated with Claude Code