import type { DatasetInfo, QuestionData } from "../types";
interface InfoBarProps {
activeDatasets: DatasetInfo[];
questionIdx: number;
sampleIdx: number;
getQuestionData: (dsId: string) => QuestionData | undefined;
}
export default function InfoBar({ activeDatasets, questionIdx, sampleIdx, getQuestionData }: InfoBarProps) {
let questionText = "";
let nSamples = 0;
const firstData = activeDatasets.length > 0 ? getQuestionData(activeDatasets[0].id) : undefined;
if (firstData) {
questionText = firstData.question;
nSamples = firstData.n_samples;
}
if (!questionText) {
return (
Load repos and select a question to begin
);
}
return (
{/* Question text */}
Q{questionIdx}: {questionText}
{/* Sample bar */}
{nSamples > 1 && (
Samples:
{Array.from({ length: nSamples }, (_, i) => {
const results = activeDatasets.map((ds) => {
const d = getQuestionData(ds.id);
return d?.eval_correct[i];
});
const allCorrect = results.every((r) => r === true);
const someCorrect = results.some((r) => r === true);
const noneCorrect = results.every((r) => r === false);
let bgColor = "bg-gray-700";
if (allCorrect) bgColor = "bg-green-700";
else if (someCorrect) bgColor = "bg-yellow-700";
else if (noneCorrect) bgColor = "bg-red-900";
const isSelected = i === sampleIdx;
return (
`${activeDatasets[j]?.name}=${r ? "correct" : "wrong"}`).join(", ")}`}
>
{i + 1}
);
})}
all
some
none
)}
{/* Per-repo correctness for current sample */}
{activeDatasets.map((ds) => {
const d = getQuestionData(ds.id);
const correct = d?.eval_correct[sampleIdx];
return (
{ds.name}:
{correct === undefined ? "?" : correct ? "Correct" : "Wrong"}
);
})}
);
}