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 (