From 2af9998b122c46676cb03882ec7b674905a760eb Mon Sep 17 00:00:00 2001 From: Florent Tapponnier Date: Fri, 29 May 2026 15:52:46 +0200 Subject: [PATCH] fix: compute bestPerChain for filtered variants too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #181 fixed the snapshot + cache key roundtrip. Fixed bestPerChain on the unfiltered hub, but filtered variants still surfaced raw {{best_name:chain:X}} placeholders. Root cause: bench page (src/app/benchmarks/[slug]/page.tsx:162) pre-fetches 9 variants (3 chains × 3 regions) via getBenchmark(slug, filters) → loadBenchmarkFiltered → specToBenchmark(spec, activeLabels) with isFiltered=true. A1's per-chain compute guard `!isFiltered` skipped the fan-out for those variants, so their findings/seo_intro/faq ended up in the streamed RSC payload with raw placeholders. Switching tabs client-side surfaced them. Drop the guard. Filtered variants now compute bestPerChain too. Cost: extra 3 Prom roundtrips per filtered variant, but each variant is cached per (slug, filterSig) via loadBenchmarkFiltered's unstable_cache so the cost is paid once per cache window, not per request. --- src/lib/spec.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/spec.ts b/src/lib/spec.ts index 53f53112..79fd5ce5 100644 --- a/src/lib/spec.ts +++ b/src/lib/spec.ts @@ -362,7 +362,15 @@ async function specToBenchmark( // with no Prom data just doesn't show up in bestPerChain. let bestPerChain: Record | undefined; let worstPerChain: Record | undefined; - if (!isFiltered && spec.dimensions?.chain && spec.dimensions.chain.length > 0) { + // Compute per-chain leaders for BOTH unfiltered and filtered views. + // Filtered variants are pre-fetched by the page (one per chain × region + // combo) and end up in the RSC payload; their findings/seo_intro/faq + // reference `{{best_name:chain:X}}` for ALL chains, not just the + // currently selected one, so each variant needs the full stash to + // resolve those placeholders. Cached per (slug, filterSig) via + // loadBenchmarkFiltered's unstable_cache so the extra Prom roundtrips + // are paid once per variant, not per request. + if (spec.dimensions?.chain && spec.dimensions.chain.length > 0) { const chainValues = spec.dimensions.chain .map((c) => c.value) .filter((v) => v !== "all");