Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions showcase/angular/src/app/pages/stats/stats-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,17 +1029,40 @@ export class StatsPageComponent implements OnInit, AfterViewInit, OnDestroy {
// 288 samples = 24h @ 5-min poll). slice() copies so Chart.js can't
// mutate the canonical buffer. Axes hidden so the line reads as a
// sparkline; bucket label still appears in the legend for context.
//
// First-paint warmup (bug fix 260527): the ring buffer starts empty
// and only grows by one sample per 5-min poll. A 1-point line dataset
// with pointRadius:0 draws NOTHING -- Chart.js needs >=2 points to
// stroke a line, and we hide point markers for the sparkline aesthetic.
// Result: the canvas was visually empty for ~5 minutes after page load
// until the second poll arrived. Fix: when ring.length < 2 AND we have
// a real FSB headline, synthesize a 2-point flat-line dataset at the
// current `active_agents_now` value so the chart immediately reads as
// "currently N agents" and gains real shape as the ring fills.
//
// Gate on `headline` (per Codex P2 review): GitHub datasets can flip
// viewState to 'ready' before the FSB headline endpoint resolves (or
// when it errors). Without this gate, the fallback would draw a
// misleading [0, 0] flat-zero line during that window -- as if there
// were genuinely zero active agents. Better to render an empty canvas
// (honest "no data yet") until at least one real FSB sample arrives.
// Note: onFsbHeadlineUpdate assigns `latestFsbHeadline` and pushes onto
// the ring atomically, so `headline !== null` implies `ring.length >= 1`.
const headline = this.latestFsbHeadline;
const bucket = headline?.active_agents_bucket ?? '0';
const ring = this.agentHistoryRing.slice();
const live = headline?.active_agents_now ?? 0;
const data = !headline
? []
: ring.length >= 2 ? ring : [live, live];
return {
type: 'line',
data: {
labels: ring.map((_, i) => String(i)),
labels: data.map((_, i) => String(i)),
datasets: [
{
label: $localize`:@@SHOWCASE_STATS_FSB_CHART_AGENTS_RUNNING_LEGEND:Active agents (10 min window)` + ` [${bucket}]`,
data: ring,
data,
borderColor: tokens.primary,
backgroundColor: tokens.primarySoft,
fill: true,
Expand Down
8 changes: 4 additions & 4 deletions showcase/angular/src/locale/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -3030,28 +3030,28 @@
<source>Active agents (10 min window)</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/stats/stats-page.component.ts</context>
<context context-type="linenumber">1041</context>
<context context-type="linenumber">1064</context>
</context-group>
</trans-unit>
<trans-unit id="SHOWCASE_STATS_FSB_CHART_PENDING_MCP" datatype="html">
<source>Pending (k&gt;=5 floor)</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/stats/stats-page.component.ts</context>
<context context-type="linenumber">1070</context>
<context context-type="linenumber">1093</context>
</context-group>
</trans-unit>
<trans-unit id="SHOWCASE_STATS_FSB_CHART_POPULAR_AGENTS_LEGEND" datatype="html">
<source>Popular agents</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/stats/stats-page.component.ts</context>
<context context-type="linenumber">1077</context>
<context context-type="linenumber">1100</context>
</context-group>
</trans-unit>
<trans-unit id="SHOWCASE_STATS_FSB_CHART_AVG_AGENTS_LEGEND" datatype="html">
<source>Avg agents per active user (last 30 days)</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/pages/stats/stats-page.component.ts</context>
<context context-type="linenumber">1109</context>
<context context-type="linenumber">1132</context>
</context-group>
</trans-unit>
<trans-unit id="support.hero.title" datatype="html">
Expand Down
Loading