From 91833c613d730264a14016b85261156d94284c52 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 1 Nov 2026 16:12:32 -0600 Subject: [PATCH] fix(aggregator): show Cost Explorer freshness --- pm-stack/aggregator/src/render.ts | 32 ++++++++++++++++++-- pm-stack/aggregator/src/server.ts | 2 +- pm-stack/aggregator/test/aa.test.ts | 46 ++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index 2ca3b61b2..a0df88846 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -4784,13 +4784,28 @@ function jsonForScript(json: string): string { return json.replace(/ AA_COLLECTOR_CADENCE_MS; + const retainedAfterFailure = section?.status === "ok" && section.stale === true; + const chipDetail: ProvenanceDetail = olderThanOneCycle || retainedAfterFailure + ? { ...detail, aa: { ...aaFacet, state: "stale" } } + : detail; + return freshnessChips(chipDetail, ["aa"]); +} + +export function renderAa(section: AaFeedSection | null, provenance: Provenance, detail?: ProvenanceDetail): string { if (!section) { return layout( "Cost Explorer", `

Cost Explorer

`, provenance, "/aa", + "", + aaFreshnessChips(detail, null), ); } if (section.status === "absent") { @@ -4799,6 +4814,8 @@ export function renderAa(section: AaFeedSection | null, provenance: Provenance): `

Cost Explorer

`, provenance, "/aa", + "", + aaFreshnessChips(detail, section), ); } const s: AaSection = section; @@ -4820,6 +4837,15 @@ export function renderAa(section: AaFeedSection | null, provenance: Provenance):

Catalog ids verbatim from the config — this is where unmeasured newcomers (e.g. commandcode/reflection/beam:free, the Reflection Beam seat) sit until the import measures them.

${aaNameList(cov.catalogNotPooledUnmeasured)}` : `

Coverage — measured but not pooled

Coverage was not computed for this section — the collector could not read .opencode/opencode.jsonc on that run.

`; const catalog = s.catalog; + const feedAge = detail?.aa.ageMs === undefined ? "unavailable" : ageMsText(detail.aa.ageMs); + const aaTabAge = detail + ? `

AA data age: ${esc(feedAge)} (fleet-feed age).

` + : ""; + const catalogTabAge = detail + ? catalog + ? `

Model catalog age: ${esc(feedAge)} (fleet-feed age; catalog and AA are read in the same collector run; no separate catalog timestamp is carried).

` + : `

Model catalog age: unavailable — no catalog in this feed (fleet-feed age: ${esc(feedAge)}).

` + : ""; const modelCards = catalog ? `
${catalog.length} models in the fleet's provider catalogs
from .opencode/opencode.jsonc, read by the same collector run as the AA data
@@ -4870,6 +4896,7 @@ ${s.stale ? `