From 73a8dba82a2e175c9d9886d4aa5ea3a44604cd06 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 8 May 2026 19:46:53 -0500 Subject: [PATCH] Fall back to Main when sensitivity slice is empty for the active country Binary only on the UK leaderboard rendered an empty list because UK has zero binary outputs. The leaderboard now falls back to the Main view (with a notice) for any single-country selection that has no rows under the active sensitivity slice, mirroring the existing Global+Binary behaviour. Sensitivity buttons that would yield no rows for the current selectedView are disabled with a tooltip explaining which country to switch to. - Adds viewSupportsSelected(rows, view, selectedView) to lib/sensitivity. - ModelLeaderboard's fallback flag is now sensitivityUnsupportedForView (was globalUnsupportedForView) and applies to US, UK, and Global. - Disable + tooltip copy now name the missing country instead of always referring to "the Global view". --- app/src/components/ModelLeaderboard.tsx | 67 ++++++++++++++++--------- app/src/lib/sensitivity.ts | 14 ++++++ 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/app/src/components/ModelLeaderboard.tsx b/app/src/components/ModelLeaderboard.tsx index cf3e364..571063a 100644 --- a/app/src/components/ModelLeaderboard.tsx +++ b/app/src/components/ModelLeaderboard.tsx @@ -17,7 +17,7 @@ import { SENSITIVITY_VIEWS, buildAllRows, modelScoresForView, - viewSupportsGlobal, + viewSupportsSelected, type SensitivityViewId, } from "../lib/sensitivity"; import { @@ -122,18 +122,18 @@ export default function ModelLeaderboard({ const allRows = useMemo(() => buildAllRows(dashboard), [dashboard]); - // Some sensitivity slices have no rows in one country (e.g. "Binary only" - // has zero UK rows). In that case the global view cannot be a true - // cross-country score; fall back to the canonical Main view so the global - // tab still has a defensible ranking and surface a notice on the leaderboard. - const globalUnsupportedForView = useMemo( + // Some sensitivity slices have no rows in the selected country (e.g. + // "Binary only" has zero UK rows; "Binary only" on Global has zero UK + // rows so the global view cannot be a true cross-country score). In that + // case we fall back to the canonical Main view so the leaderboard still + // has a defensible ranking and surface a notice explaining why. + const sensitivityUnsupportedForView = useMemo( () => - isGlobal && sensitivityView !== "main" && - !viewSupportsGlobal(allRows, sensitivityView), - [allRows, isGlobal, sensitivityView], + !viewSupportsSelected(allRows, sensitivityView, selectedView), + [allRows, selectedView, sensitivityView], ); - const effectiveView: SensitivityViewId = globalUnsupportedForView + const effectiveView: SensitivityViewId = sensitivityUnsupportedForView ? "main" : sensitivityView; @@ -242,27 +242,34 @@ export default function ModelLeaderboard({ > {SENSITIVITY_VIEWS.map((view) => { const isActive = sensitivityView === view.id; - const disabledForGlobal = - isGlobal && - view.id !== "main" && - !viewSupportsGlobal(allRows, view.id); + const supported = + view.id === "main" || + viewSupportsSelected(allRows, view.id, selectedView); + const disabled = !supported; + const disabledTitleSuffix = isGlobal + ? " (not available for the Global view; switch to US or UK)" + : selectedView === "uk" + ? " (no UK rows under this slice; switch to US or Global)" + : selectedView === "us" + ? " (no US rows under this slice; switch to UK or Global)" + : ""; return (