"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; // THE OPERATOR'S MARK ON A DISAGREEMENT (release 29 V1): was the MODEL right, // where its answer is not the ruling? Right / Wrong (pressed when set; again // to unmark), POSTed to /api/bench/marks, then the page re-reads so the // marked precision beside the bar moves. R6's triage marks, on the bench. export default function MarkButtons({ run, model, item, initial }: { run: string; model: string; item: string; initial?: "right" | "wrong" }) { const router = useRouter(); const [mark, setMark] = useState<"right" | "wrong" | undefined>(initial); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); async function send(next: "right" | "wrong") { const verdict = mark === next ? null : next; setBusy(true); setError(null); try { const r = await fetch("/api/bench/marks", { method: "POST", body: JSON.stringify({ run, model, key: item, verdict }) }); const body = await r.json(); if (!r.ok) throw new Error(body.error ?? `HTTP ${r.status}`); setMark(body.mark ?? undefined); router.refresh(); } catch (e) { setError((e as Error).message); } finally { setBusy(false); } } const cls = (on: boolean) => cn(buttonVariants({ variant: on ? "pressed" : "outline", size: "sm" })); return ( {error && ( {error} )} ); }