Release 0.16.0: new look, search, remove files, easier deploy
Release / release (push) Successful in 4m33s

- Dot-matrix "Creation of Adam" page banners behind a floating menu,
  glass cards and tables, library header with live stats, table toolbar
  with pagination, Cmd/Ctrl+K search across models, endpoints, runs,
  tags, settings and actions.
- Remove single files from a model (selection + disk, via a worker job).
- Containers start as root to prepare folders and drop to PUID:PGID;
  AUTH_SECRET is generated when unset; sandbox runs as nobody;
  KANAME_IMAGE and image docs in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-30 14:06:46 +01:00
1 parent c6bcb514e6
commit 5becfc47a0
53 files changed
+1869 -468

No files matched your search

@@ -59,7 +59,7 @@ export function DeleteModelButton({
<Button
variant="outline"
size="sm"
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
className="border-foreground/20 bg-background/90 font-medium text-red-600 shadow-xs backdrop-blur-sm hover:bg-destructive/15 hover:text-red-600 dark:border-foreground/20 dark:bg-background/90 dark:text-red-400 dark:hover:bg-destructive/25 dark:hover:text-red-300"
/>
}
>
+21 -4
View File
@@ -17,6 +17,7 @@ import { formatBytes } from "@/lib/format";
import { type FileGroup, groupSplitFiles } from "@/lib/file-groups";
import { cn } from "@/lib/utils";
import { FilesHeader } from "./download-more";
import { RemoveFileButton } from "./remove-file-button";
type FileRow = { id: string; path: string; size: number; lfsSha256: string | null; state: ModelFileState };
@@ -67,12 +68,12 @@ function entryState(e: Entry): { state: ModelFileState; label: string } {
const isLocal = (e: Entry) => e.parts.every((p) => p.state === "present" || p.state === "verified");
function Row({ entry, href, muted, showState }: { entry: Entry; href: string; muted?: boolean; showState: boolean }) {
function Row({ entry, href, muted, showState, action }: { entry: Entry; href: string; muted?: boolean; showState: boolean; action?: React.ReactNode }) {
const { state: stateKey, label } = entryState(entry);
const state = STATE[stateKey];
const split = entry.totalParts > 1;
return (
<li>
<li className="flex items-center pr-3">
<a
href={href}
target="_blank"
@@ -80,7 +81,7 @@ function Row({ entry, href, muted, showState }: { entry: Entry; href: string; mu
title={split ? entry.parts.map((p) => p.path).join("\n") : undefined}
className={cn(
// Fixed status column so sizes line up between selected and unselected rows.
"grid grid-cols-[1rem_auto_minmax(0,1fr)_auto] items-center gap-x-3 px-5 py-2.5 transition-colors hover:bg-muted/50 sm:grid-cols-[1rem_auto_minmax(0,1fr)_5rem_1rem] md:grid-cols-[1rem_auto_minmax(0,1fr)_5rem_7.5rem]",
"grid min-w-0 flex-1 grid-cols-[1rem_auto_minmax(0,1fr)_auto] items-center gap-x-3 py-2.5 pr-2 pl-5 transition-colors hover:bg-muted/50 sm:grid-cols-[1rem_auto_minmax(0,1fr)_5rem_1rem] md:grid-cols-[1rem_auto_minmax(0,1fr)_5rem_7.5rem]",
muted && "text-muted-foreground",
)}
>
@@ -109,6 +110,7 @@ function Row({ entry, href, muted, showState }: { entry: Entry; href: string; mu
<span className="text-right text-sm tabular-nums sm:hidden">{formatBytes(entry.size)}</span>
)}
</a>
<span className="flex w-7 shrink-0 justify-end">{action}</span>
</li>
);
}
@@ -163,7 +165,22 @@ export function FilesTab({
<ul className="divide-y">
{selectedEntries.map((e) => (
<Row key={e.path} entry={e} href={href(e)} showState />
<Row
key={e.path}
entry={e}
href={href(e)}
showState
action={
<RemoveFileButton
modelId={modelId}
name={e.path.split("/").pop()!}
paths={e.parts.map((p) => p.path)}
size={e.size}
disabled={busy || selectedEntries.length < 2}
reason={busy ? "Wait until the current job has finished." : "The model's only file: delete the model instead."}
/>
}
/>
))}
</ul>
+38 -36
View File
@@ -19,10 +19,10 @@ import Link from "next/link";
import { notFound, redirect } from "next/navigation";
import { CopyButton } from "@/components/copy-button";
import { BenchmarkStateBadge } from "@/components/benchmark-state";
import { PageHero } from "@/components/hero/page-hero";
import { HubStateBadge } from "@/components/hub-state-badge";
import { LocalTime } from "@/components/local-time";
import { ModelStatusBadge } from "@/components/model-status-badge";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { formatBytes, shortSha } from "@/lib/format";
import { listBenchmarks } from "@/lib/benchmarks";
@@ -129,17 +129,27 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
const tabHref = (id: TabId) => (id === "files" ? `/${model.repoId}` : `/${model.repoId}?tab=${id}`);
return (
<div className="flex flex-col gap-4">
{/* Header card, styled after the Hugging Face model page */}
<Panel className="flex flex-col gap-4 p-5">
<div className="flex flex-wrap items-center gap-x-2 gap-y-2">
<PageHero
painting={{ view: 0.5, focus: [0.48, 0.42], anchor: [0.72, 0.35] }}
title={
<span className="flex flex-wrap items-center gap-x-2 gap-y-2">
<Avatar url={model.authorAvatarUrl} name={author} />
<Link href={`/?author=${encodeURIComponent(author)}`} className="text-muted-foreground hover:text-foreground hover:underline">
<Link href={`/?author=${encodeURIComponent(author)}`} className="font-normal text-muted-foreground hover:text-foreground hover:underline">
{author}
</Link>
<span className="text-muted-foreground">/</span>
<h1 className="text-xl font-semibold break-all">{name}</h1>
<span className="font-normal text-muted-foreground">/</span>
<span className="break-all">{name}</span>
<CopyButton value={model.repoId} label="Copy repo ID" />
<a
href={hub}
target="_blank"
rel="noreferrer"
title="Open on Hugging Face"
aria-label="Open on Hugging Face"
className="inline-flex size-7 items-center justify-center rounded-md text-base font-normal hover:bg-muted"
>
🤗
</a>
<ModelStatusBadge status={model.status} />
<HubStateBadge state={model.hubState} />
{update && (
@@ -147,17 +157,10 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
update available
</span>
)}
<div className="ml-auto flex items-center gap-2">
<DeleteModelButton
id={model.id}
repoId={model.repoId}
localPath={model.localPath}
mayHaveFiles={model.status !== "pending" || recentJobs.length > 0}
/>
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
</div>
</div>
</span>
}
extra={
<div className="flex flex-col gap-3">
<div className="flex flex-wrap items-center gap-1.5">
{model.pipelineTag && (
<Pill icon={MessagesSquareIcon} accent>
@@ -180,11 +183,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
</div>
<div className="flex flex-wrap items-center gap-2">
<span className="text-xs text-muted-foreground">Your tags</span>
<span className="text-xs font-medium text-foreground/85">Your tags</span>
<TagEditor modelId={model.id} tags={tags} />
</div>
</Panel>
</div>
}
>
{hubMissing && (
<div className="flex flex-wrap items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm">
@@ -239,6 +243,12 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
</Link>
))}
</nav>
<DeleteModelButton
id={model.id}
repoId={model.repoId}
localPath={model.localPath}
mayHaveFiles={model.status !== "pending" || recentJobs.length > 0}
/>
</div>
{tab === "card" && (
@@ -402,7 +412,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
</SideCard>
</aside>
</div>
</div>
</PageHero>
);
}
@@ -432,9 +442,10 @@ function Pill({
return (
<span
className={cn(
"inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs",
accent && "border-indigo-500/30 bg-indigo-500/10 text-indigo-700 dark:text-indigo-300",
muted && "text-muted-foreground",
// Own background: these sit on the painting in the page banner.
"inline-flex items-center gap-1 rounded-full border border-foreground/15 bg-background/80 px-2.5 py-0.5 text-xs font-medium text-foreground backdrop-blur-sm",
accent && "border-indigo-500/40 text-indigo-700 dark:text-indigo-300",
muted && "font-normal text-foreground/80",
)}
>
{Icon && <Icon className="size-3.5" />}
@@ -443,18 +454,9 @@ function Pill({
);
}
function ExternalButton({ href, children }: { href: string; children: React.ReactNode }) {
return (
<a href={href} target="_blank" rel="noreferrer" className={cn(buttonVariants({ variant: "outline", size: "sm" }), "border-foreground/15 bg-background shadow-xs")}>
{children}
<ExternalLinkIcon className="opacity-60" />
</a>
);
}
/** Card surface shared by header, content and sidebar. */
function Panel({ className, children }: { className?: string; children: React.ReactNode }) {
return <div className={cn("rounded-xl bg-card text-card-foreground ring-1 ring-foreground/10", className)}>{children}</div>;
return <div className={cn("rounded-xl bg-card/55 text-card-foreground ring-1 ring-foreground/10 backdrop-blur-md", className)}>{children}</div>;
}
function SideCard({
@@ -0,0 +1,72 @@
"use client";
import { Trash2Icon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { formatBytes } from "@/lib/format";
/** Remove one selected file (all parts of a split file) from the model and from disk. */
export function RemoveFileButton({ modelId, name, paths, size, disabled, reason }: { modelId: string; name: string; paths: string[]; size: number; disabled: boolean; reason?: string }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
async function remove() {
setBusy(true);
try {
const res = await fetch(`/api/models/${modelId}/files`, { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ remove: paths }) });
const json = await res.json().catch(() => ({}));
if (!res.ok) return toast.error(json.error?.message ?? `Could not remove (${res.status})`);
toast.success(`Removing ${name}`);
router.refresh();
} finally {
setBusy(false);
}
}
return (
<AlertDialog>
<AlertDialogTrigger
render={
<Button
variant="ghost"
size="icon-xs"
disabled={disabled || busy}
title={disabled ? reason : `Remove ${name}`}
aria-label={`Remove ${name}`}
className="text-muted-foreground hover:text-destructive"
/>
}
>
<Trash2Icon />
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove {name}?</AlertDialogTitle>
<AlertDialogDescription>
{paths.length > 1 ? `All ${paths.length} parts (${formatBytes(size)})` : `The file (${formatBytes(size)})`} will be deleted from the models folder and taken out of
this model&apos;s selection. The rest of the model stays. You can download it again later with Download more.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive" onClick={remove}>
Remove
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
+21 -11
View File
@@ -12,22 +12,38 @@ import { AddModelForm, type ImportFolder } from "./add-model-form";
type Folder = ImportFolder & { totalBytes: number };
/** The "Add model" / "Close" toggle (shown in the library hero). */
export function AddModelToggle({ open, onToggle }: { open: boolean; onToggle: () => void }) {
return (
<Button variant={open ? "outline" : "default"} onClick={onToggle}>
{open ? "Close" : "Add model"}
</Button>
);
}
/**
* Library header with an "Add model" toggle that opens the lookup/selection form inline, and the
* folders in the models folder that aren't in the library yet, each with "Import".
* The lookup/selection form, opened inline by the "Add model" toggle, and the folders in the models
* folder that aren't in the library yet, each with "Import".
*/
export function AddModelPanel({
freeBytes,
defaultOpen,
folders,
open,
setOpen,
}: {
freeBytes: number | null;
defaultOpen: boolean;
folders: Folder[];
open: boolean;
setOpen: (open: boolean) => void;
}) {
const router = useRouter();
const [open, setOpen] = useState(defaultOpen);
const [importing, setImporting] = useState<Folder | null>(null);
// Closed from outside (the toggle in the hero): forget the folder being imported.
const [wasOpen, setWasOpen] = useState(open);
if (open !== wasOpen) {
setWasOpen(open);
if (!open) setImporting(null);
}
const [scanning, setScanning] = useState(false);
function close() {
@@ -53,12 +69,6 @@ export function AddModelPanel({
return (
<>
<div className="flex items-center justify-between">
<h1 className="text-xl font-semibold">Library</h1>
<Button variant={open ? "outline" : "default"} onClick={() => (open ? close() : setOpen(true))}>
{open ? "Close" : "Add model"}
</Button>
</div>
{open && (
<AddModelForm
key={importing?.path ?? "new"}
+1 -1
View File
@@ -69,7 +69,7 @@ export function AbReport({ run }: { run: ListRow }) {
const same = rows.filter((x) => x.va === x.vb);
return (
<article className="flex flex-col gap-8 rounded-2xl bg-card px-5 py-6 ring-1 ring-foreground/10 sm:px-8 sm:py-8">
<article className="flex flex-col gap-8 rounded-2xl bg-card/55 px-5 py-6 ring-1 ring-foreground/10 backdrop-blur-md sm:px-8 sm:py-8">
<header className="flex flex-col gap-3">
<span className="font-mono text-[11px] tracking-wider text-muted-foreground uppercase">
BetterBench {ab.betterbenchVersion} · paired A/B · {ab.pairs} pairs
+161 -130
View File
@@ -31,10 +31,23 @@ import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { reportSummary, weightsLabel } from "@/lib/benchmark-report";
import { CONFIG_ROWS, describeSettings, engineName, isEndpointSnapshot, modelName, targetName } from "@/lib/benchmark-view";
import {
CONFIG_ROWS,
describeSettings,
engineName,
isEndpointSnapshot,
modelName,
targetName,
} from "@/lib/benchmark-view";
import type { ListRow } from "../benchmark-list";
import { PageHero } from "@/components/hero/page-hero";
import { RunMetaCard } from "@/components/run-meta";
import { cancelBenchmark, deleteBenchmark, describeBenchmark, renameBenchmark } from "../actions";
import {
cancelBenchmark,
deleteBenchmark,
describeBenchmark,
renameBenchmark,
} from "../actions";
import { AbReport } from "./ab-report";
import { QualityReport } from "./quality-report";
import { BenchmarkReport } from "./benchmark-report";
@@ -104,7 +117,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
// Runs from before 0.15 measured a deployment (gone now); newer ones an endpoint.
const legacy = !isEndpointSnapshot(s);
const endpointLink = (id: string | null, name: string) =>
legacy ? name : id ? (
legacy ? (
name
) : id ? (
<Link href={`/endpoints/${id}`} className="hover:underline">
{name}
</Link>
@@ -114,136 +129,141 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
const took = duration(r.startedAt, r.finishedAt, now);
return (
<div className="flex flex-col gap-4">
<Card>
<CardContent className="flex flex-wrap items-start justify-between gap-4">
<div className="flex min-w-0 flex-col gap-1">
<div className="flex flex-wrap items-center gap-2">
<h1 className="text-xl font-semibold">
{r.label ?? (r.kind === "ab" && sB ? `${targetName(s)} vs ${targetName(sB)}` : targetName(s))}
</h1>
{r.kind === "ab" && (
<span className="rounded-md border px-1.5 text-xs text-muted-foreground">
A/B
</span>
)}
<BenchmarkStateBadge
state={r.state}
cancelling={!!r.cancelRequestedAt}
/>
</div>
<p className="text-sm text-muted-foreground">
{endpointLink(r.endpointId, targetName(s))} ·{" "}
{r.modelId ? (
<Link href={`/models/${r.modelId}`} className="hover:underline">
{modelName(s)}
</Link>
) : (
modelName(s)
)}{" "}
· {engineName(s)}
{r.kind === "ab" && sB && (
<>
{" "}
· B: {endpointLink(r.endpointBId, targetName(sB))} ({engineName(sB)})
</>
)}
</p>
<p className="text-xs text-muted-foreground">
{r.kind === "eval" ? "Kaname" : "BetterBench"} ·{" "}
{r.kind === "ab"
? `paired A/B, target ±${r.settings.mdePct ?? 1}%, up to ${r.settings.maxPairs ?? 200} pairs`
: describeSettings(r.settings)}{" "}
· created <LocalTime value={r.createdAt} />
{took &&
` · ${r.state === "running" ? "running for" : "took"} ${took}`}
</p>
</div>
<div className="flex flex-wrap items-center gap-2">
{r.hasReport && (
<a
href={`/api/benchmarks/${r.id}/report`}
target="_blank"
rel="noreferrer"
className={buttonVariants({ variant: "outline" })}
>
<ExternalLinkIcon />
Full report
</a>
<PageHero
painting={{ view: 0.6, focus: [0.25, 0.6], anchor: [0.65, 0.4] }}
title={
<span className="flex flex-wrap items-center gap-2">
{r.label ??
(r.kind === "ab" && sB
? `${targetName(s)} vs ${targetName(sB)}`
: targetName(s))}
{r.kind === "ab" && (
<span className="rounded-md border px-1.5 text-xs font-normal text-muted-foreground">
A/B
</span>
)}
<BenchmarkStateBadge
state={r.state}
cancelling={!!r.cancelRequestedAt}
/>
</span>
}
description={
<div className="flex flex-col gap-0.5">
<p>
{endpointLink(r.endpointId, targetName(s))} ·{" "}
{r.modelId ? (
<Link href={`/models/${r.modelId}`} className="hover:underline">
{modelName(s)}
</Link>
) : (
modelName(s)
)}{" "}
· {engineName(s)}
{r.kind === "ab" && sB && (
<>
{" "}
· B: {endpointLink(r.endpointBId, targetName(sB))} (
{engineName(sB)})
</>
)}
{r.state === "completed" && (
<a
href={`/api/benchmarks/${r.id}/results`}
className={buttonVariants({ variant: "outline" })}
>
<DownloadIcon />
{r.kind === "ab" ? "ab.json" : "results.json"}
</a>
)}
{active ? (
</p>
<p className="text-xs text-muted-foreground">
{r.kind === "eval" ? "Kaname" : "BetterBench"} ·{" "}
{r.kind === "ab"
? `paired A/B, target ±${r.settings.mdePct ?? 1}%, up to ${r.settings.maxPairs ?? 200} pairs`
: describeSettings(r.settings)}{" "}
· created <LocalTime value={r.createdAt} />
{took &&
` · ${r.state === "running" ? "running for" : "took"} ${took}`}
</p>
</div>
}
actions={
<>
{r.hasReport && (
<a
href={`/api/benchmarks/${r.id}/report`}
target="_blank"
rel="noreferrer"
className={buttonVariants({ variant: "outline" })}
>
<ExternalLinkIcon />
Full report
</a>
)}
{r.state === "completed" && (
<a
href={`/api/benchmarks/${r.id}/results`}
className={buttonVariants({ variant: "outline" })}
>
<DownloadIcon />
{r.kind === "ab" ? "ab.json" : "results.json"}
</a>
)}
{active ? (
<Button
variant="outline"
disabled={!!r.cancelRequestedAt}
onClick={async () =>
(await cancelBenchmark(r.id)) && router.refresh()
}
>
<SquareIcon />
Cancel
</Button>
) : (
r.endpointId &&
(r.kind !== "ab" || r.endpointBId) && (
<Button
variant="outline"
disabled={!!r.cancelRequestedAt}
onClick={async () =>
(await cancelBenchmark(r.id)) && router.refresh()
}
onClick={again}
title="Queue a new run with the same settings against the same endpoint"
>
<SquareIcon />
Cancel
<RotateCcwIcon />
Run again
</Button>
) : (
r.endpointId &&
(r.kind !== "ab" || r.endpointBId) && (
)
)}
<AlertDialog>
<AlertDialogTrigger
render={
<Button
variant="outline"
onClick={again}
title="Queue a new run with the same settings against the same endpoint"
disabled={r.state === "running"}
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
/>
}
>
<Trash2Icon />
Delete
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this benchmark?</AlertDialogTitle>
<AlertDialogDescription>
Its numbers, log, results.json and HTML report are removed.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
onClick={async () => {
if (await deleteBenchmark(r.id)) {
router.push("/benchmarks");
router.refresh();
}
}}
>
<RotateCcwIcon />
Run again
</Button>
)
)}
<AlertDialog>
<AlertDialogTrigger
render={
<Button
variant="outline"
disabled={r.state === "running"}
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
/>
}
>
<Trash2Icon />
Delete
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this benchmark?</AlertDialogTitle>
<AlertDialogDescription>
Its numbers, log, results.json and HTML report are removed.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="destructive"
onClick={async () => {
if (await deleteBenchmark(r.id)) {
router.push("/benchmarks");
router.refresh();
}
}}
>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</CardContent>
</Card>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
}
>
{r.error && (
<div className="flex gap-3 rounded-xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm">
<TriangleAlertIcon className="mt-0.5 size-4 shrink-0 text-destructive" />
@@ -263,7 +283,13 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_340px]">
<div className="flex min-w-0 flex-col gap-4">
{r.kind === "ab" ? <AbReport run={r} /> : r.kind === "eval" ? <QualityReport quality={r.quality} running={active} /> : <BenchmarkReport run={r} />}
{r.kind === "ab" ? (
<AbReport run={r} />
) : r.kind === "eval" ? (
<QualityReport quality={r.quality} running={active} />
) : (
<BenchmarkReport run={r} />
)}
<LiveLog
url={`/api/benchmarks/${r.id}/logs`}
title="BetterBench output"
@@ -275,7 +301,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
{r.kind === "run" && r.state === "completed" && r.summary && (
<PublishCard
runId={r.id}
defaultTitle={r.label ?? `${modelName(s).split("/").pop()} ${weightsLabel(s)}`}
defaultTitle={
r.label ?? `${modelName(s).split("/").pop()} ${weightsLabel(s)}`
}
defaultSummary={reportSummary(r)}
/>
)}
@@ -319,7 +347,8 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
}
/>
<p className="text-[11px] text-muted-foreground">
Passed to BetterBench (when set before the run starts) and to the launch80 preview, together with the system summary.
Passed to BetterBench (when set before the run starts) and to
the launch80 preview, together with the system summary.
</p>
</CardContent>
</Card>
@@ -353,7 +382,9 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
</div>
)}
{isEndpointSnapshot(s) && s.hardware.description && (
<p className="text-xs whitespace-pre-wrap text-muted-foreground">{s.hardware.description}</p>
<p className="text-xs whitespace-pre-wrap text-muted-foreground">
{s.hardware.description}
</p>
)}
{sum && (
<p className="text-[11px] text-muted-foreground">
@@ -366,6 +397,6 @@ export function BenchmarkDetail({ initial }: { initial: ListRow }) {
)}
</aside>
</div>
</div>
</PageHero>
);
}
@@ -72,7 +72,7 @@ export function BenchmarkReport({ run }: { run: ListRow }) {
].filter(Boolean) as string[];
return (
<article className="flex flex-col gap-8 rounded-2xl bg-card px-5 py-6 ring-1 ring-foreground/10 sm:px-8 sm:py-8">
<article className="flex flex-col gap-8 rounded-2xl bg-card/55 px-5 py-6 ring-1 ring-foreground/10 backdrop-blur-md sm:px-8 sm:py-8">
<header className="flex flex-col gap-3">
<span className="font-mono text-[11px] tracking-wider text-muted-foreground uppercase">
BetterBench {sum.betterbenchVersion} · {date(sum.timestamp ?? run.startedAt)}
+13 -10
View File
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import Link from "next/link";
import { BenchmarkStateBadge } from "@/components/benchmark-state";
import { PageHero } from "@/components/hero/page-hero";
import { Card } from "@/components/ui/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { getBenchmarks } from "@/lib/benchmarks";
@@ -117,15 +118,17 @@ export default async function ComparePage({ searchParams }: PageProps<"/benchmar
const anyQuick = runs.some((r) => r.summary?.quick);
return (
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<h1 className="text-xl font-semibold">Compare benchmarks</h1>
<p className="text-sm text-muted-foreground">
Differences are against the first run. Separate runs aren&apos;t paired in time, so differences below ~{NOISE_PCT}% are within normal noise.
</p>
{corpora.size > 1 && <p className="text-sm text-destructive">These runs used different prompt sets (corpus versions), so their numbers aren&apos;t comparable.</p>}
{anyQuick && <p className="text-sm text-amber-700 dark:text-amber-300">Some runs are quick runs (5 passes); their numbers are rough.</p>}
</div>
<PageHero
title="Compare benchmarks"
painting={{ view: 0.6, focus: [0.25, 0.6], anchor: [0.65, 0.4] }}
description={
<div className="flex flex-col gap-0.5">
<p>Differences are against the first run. Separate runs aren&apos;t paired in time, so differences below ~{NOISE_PCT}% are within normal noise.</p>
{corpora.size > 1 && <p className="text-destructive">These runs used different prompt sets (corpus versions), so their numbers aren&apos;t comparable.</p>}
{anyQuick && <p className="text-amber-700 dark:text-amber-300">Some runs are quick runs (5 passes); their numbers are rough.</p>}
</div>
}
>
<Card className="py-0">
<Table>
@@ -193,7 +196,7 @@ export default async function ComparePage({ searchParams }: PageProps<"/benchmar
</TableBody>
</Table>
</Card>
</div>
</PageHero>
);
}
+10 -7
View File
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import Link from "next/link";
import { listBenchmarks } from "@/lib/benchmarks";
import { getModel } from "@/lib/library";
import { PageHero } from "@/components/hero/page-hero";
import { BenchmarkList } from "./benchmark-list";
export const dynamic = "force-dynamic";
@@ -12,10 +13,11 @@ export default async function BenchmarksPage({ searchParams }: PageProps<"/bench
const model = typeof modelId === "string" ? await getModel(modelId) : null;
const rows = await listBenchmarks({ modelId: model?.model.id });
return (
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1">
<h1 className="text-xl font-semibold">Benchmarks</h1>
<p className="text-sm text-muted-foreground">
<PageHero
title="Benchmarks"
painting={{ view: 0.6, focus: [0.25, 0.6], anchor: [0.65, 0.4] }}
description={
<>
{model ? (
<>
Runs of{" "}
@@ -36,9 +38,10 @@ export default async function BenchmarksPage({ searchParams }: PageProps<"/bench
. Start one from an endpoint; select runs to compare their settings and numbers.
</>
)}
</p>
</div>
</>
}
>
<BenchmarkList rows={JSON.parse(JSON.stringify(rows))} filter={{ model: model?.model.id }} />
</div>
</PageHero>
);
}
+3 -3
View File
@@ -1,4 +1,5 @@
import type { Metadata } from "next";
import { PageHero } from "@/components/hero/page-hero";
import { notFound } from "next/navigation";
import { getEndpoint } from "@/lib/endpoints";
import { EndpointForm } from "../../endpoint-form";
@@ -10,9 +11,8 @@ export default async function EditEndpointPage({ params }: PageProps<"/endpoints
const endpoint = await getEndpoint((await params).id);
if (!endpoint) notFound();
return (
<div className="flex flex-col gap-4">
<h1 className="text-xl font-semibold">Edit {endpoint.name}</h1>
<PageHero title={`Edit ${endpoint.name}`} painting={{ view: 0.55, focus: [0.75, 0.35], anchor: [0.65, 0.35] }}>
<EndpointForm initial={endpoint} />
</div>
</PageHero>
);
}
@@ -17,13 +17,21 @@ import {
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { PageHero } from "@/components/hero/page-hero";
import type { EndpointView } from "@/lib/endpoints";
import { ProbeResult } from "../endpoint-form";
import { EndpointStatus } from "../endpoint-status";
/** Name, URL, connection test, edit and delete. */
export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView; runCount: number }) {
/** The page banner: name, URL, connection test, edit and delete; the page's content below it. */
export function EndpointHeader({
endpoint,
runCount,
children,
}: {
endpoint: EndpointView;
runCount: number;
children: React.ReactNode;
}) {
const router = useRouter();
const [probe, setProbe] = useState(endpoint.probe);
const [testing, setTesting] = useState(false);
@@ -31,9 +39,14 @@ export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView;
async function test() {
setTesting(true);
try {
const res = await fetch(`/api/endpoints/${endpoint.id}/test`, { method: "POST" });
const res = await fetch(`/api/endpoints/${endpoint.id}/test`, {
method: "POST",
});
const json = await res.json().catch(() => ({}));
if (!res.ok) return toast.error(json.error?.message ?? `Test failed (${res.status})`);
if (!res.ok)
return toast.error(
json.error?.message ?? `Test failed (${res.status})`,
);
setProbe(json);
router.refresh();
} finally {
@@ -42,60 +55,82 @@ export function EndpointHeader({ endpoint, runCount }: { endpoint: EndpointView;
}
async function remove() {
const res = await fetch(`/api/endpoints/${endpoint.id}`, { method: "DELETE" });
const res = await fetch(`/api/endpoints/${endpoint.id}`, {
method: "DELETE",
});
if (!res.ok) {
const json = await res.json().catch(() => ({}));
return toast.error(json.error?.message ?? `Could not delete (${res.status})`);
return toast.error(
json.error?.message ?? `Could not delete (${res.status})`,
);
}
router.push("/endpoints");
router.refresh();
}
return (
<Card>
<CardContent className="flex flex-col gap-3">
<div className="flex flex-wrap items-start justify-between gap-3">
<div className="flex min-w-0 flex-col gap-1">
<h1 className="text-xl font-semibold">{endpoint.name}</h1>
<p className="text-sm break-all text-muted-foreground">
{endpoint.baseUrl}
{endpoint.hasApiKey ? " · API key set" : ""}
</p>
</div>
<div className="flex flex-wrap items-center gap-2">
<EndpointStatus probe={probe} />
<Button variant="outline" onClick={test} disabled={testing}>
{testing ? <Loader2Icon className="animate-spin" /> : <PlugZapIcon />}
Test connection
</Button>
<Link href={`/endpoints/${endpoint.id}/edit`} className={buttonVariants({ variant: "outline" })}>
<PencilIcon />
Edit
</Link>
<AlertDialog>
<AlertDialogTrigger render={<Button variant="outline" className="text-destructive hover:bg-destructive/10 hover:text-destructive" />}>
<Trash2Icon />
Delete
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete {endpoint.name}?</AlertDialogTitle>
<AlertDialogDescription>
The endpoint and its stored API key are removed.{runCount > 0 ? ` Its ${runCount} run${runCount === 1 ? "" : "s"} stay, with what they recorded.` : ""}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive" onClick={remove}>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</div>
{probe && <ProbeResult probe={probe} />}
</CardContent>
</Card>
<PageHero
title={endpoint.name}
description={
<span className="break-all">
{endpoint.baseUrl}
{endpoint.hasApiKey ? " · API key set" : ""}
</span>
}
painting={{ view: 0.55, focus: [0.75, 0.35], anchor: [0.65, 0.35] }}
actions={
<>
<EndpointStatus probe={probe} />
<Button variant="outline" onClick={test} disabled={testing}>
{testing ? (
<Loader2Icon className="animate-spin" />
) : (
<PlugZapIcon />
)}
Test connection
</Button>
<Link
href={`/endpoints/${endpoint.id}/edit`}
className={buttonVariants({ variant: "outline" })}
>
<PencilIcon />
Edit
</Link>
<AlertDialog>
<AlertDialogTrigger
render={
<Button
variant="outline"
className="text-destructive hover:bg-destructive/10 hover:text-destructive"
/>
}
>
<Trash2Icon />
Delete
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete {endpoint.name}?</AlertDialogTitle>
<AlertDialogDescription>
The endpoint and its stored API key are removed.
{runCount > 0
? ` Its ${runCount} run${runCount === 1 ? "" : "s"} stay, with what they recorded.`
: ""}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive" onClick={remove}>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</>
}
>
{probe && <ProbeResult probe={probe} />}
{children}
</PageHero>
);
}
+3 -4
View File
@@ -35,8 +35,7 @@ export default async function EndpointPage({ params }: PageProps<"/endpoints/[id
});
return (
<div className="flex flex-col gap-4">
<EndpointHeader endpoint={endpoint} runCount={runs.length} />
<EndpointHeader endpoint={endpoint} runCount={runs.length}>
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_360px]">
<div className="flex min-w-0 flex-col gap-4">
<BenchmarkStart
@@ -48,10 +47,10 @@ export default async function EndpointPage({ params }: PageProps<"/endpoints/[id
<aside className="flex flex-col gap-4">
<RunMetaCard meta={preview} system={endpointSystem(endpoint.hardware, kanameVersion())} />
{endpoint.hardware.description && (
<p className="rounded-xl bg-card px-4 py-3 text-xs whitespace-pre-wrap text-muted-foreground ring-1 ring-foreground/10">{endpoint.hardware.description}</p>
<p className="rounded-xl bg-card/55 px-4 py-3 text-xs backdrop-blur-md whitespace-pre-wrap text-muted-foreground ring-1 ring-foreground/10">{endpoint.hardware.description}</p>
)}
</aside>
</div>
</div>
</EndpointHeader>
);
}
+3 -3
View File
@@ -1,13 +1,13 @@
import type { Metadata } from "next";
import { PageHero } from "@/components/hero/page-hero";
import { EndpointForm } from "../endpoint-form";
export const metadata: Metadata = { title: "New endpoint" };
export default function NewEndpointPage() {
return (
<div className="flex flex-col gap-4">
<h1 className="text-xl font-semibold">New endpoint</h1>
<PageHero title="New endpoint" painting={{ view: 0.55, focus: [0.75, 0.35], anchor: [0.65, 0.35] }}>
<EndpointForm />
</div>
</PageHero>
);
}
+9 -8
View File
@@ -8,6 +8,7 @@ import { ENGINE_LABEL } from "@/lib/benchmark-meta";
import { headline } from "@/lib/benchmark-view";
import { listBenchmarks } from "@/lib/benchmarks";
import { listEndpoints } from "@/lib/endpoints";
import { PageHero } from "@/components/hero/page-hero";
import { EndpointStatus } from "./endpoint-status";
export const dynamic = "force-dynamic";
@@ -26,17 +27,17 @@ export default async function EndpointsPage() {
}
return (
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-end justify-between gap-2">
<div className="flex flex-col gap-1">
<h1 className="text-xl font-semibold">Endpoints</h1>
<p className="text-sm text-muted-foreground">OpenAI-compatible servers to benchmark. They run elsewhere; Kaname only sends them requests.</p>
</div>
<PageHero
title="Endpoints"
description="OpenAI-compatible servers to benchmark. They run elsewhere; Kaname only sends them requests."
painting={{ view: 0.6, focus: [0.75, 0.35], anchor: [0.62, 0.35] }}
actions={
<Link href="/endpoints/new" className={buttonVariants()}>
<PlusIcon />
Add endpoint
</Link>
</div>
}
>
{endpoints.length === 0 ? (
<Card className="items-center gap-3 py-10 text-center">
@@ -89,6 +90,6 @@ export default async function EndpointsPage() {
</Table>
</Card>
)}
</div>
</PageHero>
);
}
+29 -6
View File
@@ -1,15 +1,17 @@
"use client";
import { ChevronDownIcon } from "lucide-react";
import { CirclePlusIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
/** Multi-select dropdown for one facet, with per-value counts. */
/** Multi-select filter for one facet (a dashed pill in the table toolbar), with per-value counts. */
export function FacetFilter({
label,
values,
@@ -30,13 +32,26 @@ export function FacetFilter({
return (
<DropdownMenu>
<DropdownMenuTrigger
render={<Button variant={active ? "secondary" : "outline"} size="sm" disabled={values.length === 0} />}
render={<Button variant="outline" size="sm" className="h-8 border-dashed bg-transparent" disabled={values.length === 0} />}
>
<CirclePlusIcon className="opacity-60" />
{label}
{active && <span className="rounded bg-background/60 px-1 text-xs tabular-nums">{selected.length}</span>}
<ChevronDownIcon className="opacity-60" />
{active && (
<>
<span className="mx-0.5 h-4 w-px bg-border" aria-hidden />
{selected.length > 2 ? (
<span className="rounded bg-muted px-1.5 text-xs font-normal">{selected.length} selected</span>
) : (
selected.map((v) => (
<span key={v} className="max-w-28 truncate rounded bg-muted px-1.5 text-xs font-normal">
{format(v)}
</span>
))
)}
</>
)}
</DropdownMenuTrigger>
<DropdownMenuContent className="w-auto min-w-48">
<DropdownMenuContent className="w-auto min-w-52">
{values.map(([value, count]) => (
<DropdownMenuCheckboxItem
key={value}
@@ -49,6 +64,14 @@ export function FacetFilter({
<span className="ml-4 text-xs text-muted-foreground tabular-nums">{count}</span>
</DropdownMenuCheckboxItem>
))}
{active && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => onChange([])} className="justify-center text-muted-foreground">
Clear {label.toLowerCase()}
</DropdownMenuItem>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
);
+13 -9
View File
@@ -5,6 +5,7 @@ import { useEffect, useRef, useState } from "react";
import { cancelJob } from "@/components/job-actions";
import { JobFilesTable } from "@/components/job-files-table";
import { JobProgress } from "@/components/job-progress";
import { PageHero } from "@/components/hero/page-hero";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { useLive } from "@/hooks/use-live";
@@ -38,17 +39,19 @@ export function JobLive({ initial }: { initial: JobSnapshot }) {
const duration = job.startedAt != null ? ((job.finishedAt ?? now) - job.startedAt) / 1000 : null;
return (
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-center gap-3">
<h1 className="text-xl font-semibold">
<PageHero
title={
<>
{jobLabel(job)} ·{" "}
<Link href={`/${job.repoId}`} className="hover:underline">
{job.repoId}
</Link>
</h1>
{open && (
</>
}
painting={{ view: 0.5, focus: [0.3, 0.55], anchor: [0.7, 0.45] }}
actions={
open && (
<Button
className="ml-auto"
variant="destructive"
size="sm"
disabled={busy || job.cancelRequested}
@@ -60,8 +63,9 @@ export function JobLive({ initial }: { initial: JobSnapshot }) {
>
{job.cancelRequested ? "Cancelling…" : "Cancel"}
</Button>
)}
</div>
)
}
>
<Card>
<CardContent className="flex flex-col gap-3">
@@ -144,6 +148,6 @@ export function JobLive({ initial }: { initial: JobSnapshot }) {
</div>
</CardContent>
</Card>
</div>
</PageHero>
);
}
+14 -10
View File
@@ -2,6 +2,7 @@ import Link from "next/link";
import { redirect } from "next/navigation";
import { auth, signOut } from "@/auth";
import { AppNav } from "@/components/app-nav";
import { CommandPalette, CommandPaletteButton } from "@/components/command-palette";
import { LabelSettingsProvider } from "@/components/labels";
import { UserMenu } from "@/components/user-menu";
import { WorkerIndicator } from "@/components/worker-indicator";
@@ -20,16 +21,18 @@ export default async function AppLayout({ children }: LayoutProps<"/">) {
return (
<div className="flex min-h-screen flex-col overflow-x-clip">
<header className="border-b">
<div className="mx-auto flex h-14 max-w-7xl items-center gap-3 px-4 sm:gap-6">
<Link href="/" className="flex items-center gap-2 font-semibold">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src="/icon.svg" alt="" className="size-6" />
Kaname
<span className="hidden text-xs font-normal text-muted-foreground sm:inline">{process.env.APP_VERSION ?? "dev"}</span>
</Link>
<AppNav />
<div className="ml-auto flex items-center gap-3">
{/* Floating menu: two pills (name + navigation, status + account) over the page. */}
<header className="pointer-events-none sticky top-0 z-40">
<div className="mx-auto flex h-16 max-w-7xl items-center justify-between gap-3 px-4 pt-3">
<div className="pointer-events-auto flex h-12 min-w-0 items-center gap-3 rounded-2xl bg-black/80 px-3 text-white shadow-lg ring-1 ring-white/10 backdrop-blur-md sm:gap-5 dark [color-scheme:dark]">
<Link href="/" className="flex items-center gap-2 pl-1 font-semibold">
Kaname
<span className="hidden text-xs font-normal text-muted-foreground sm:inline">{process.env.APP_VERSION ?? "dev"}</span>
</Link>
<AppNav />
</div>
<div className="pointer-events-auto flex h-12 items-center gap-3 rounded-2xl bg-black/80 px-3 text-white shadow-lg ring-1 ring-white/10 backdrop-blur-md dark [color-scheme:dark]">
<CommandPaletteButton />
<WorkerIndicator initial={worker} />
<UserMenu
user={{ name: session.user.name ?? null, email: session.user.email ?? null, image: session.user.image ?? null }}
@@ -41,6 +44,7 @@ export default async function AppLayout({ children }: LayoutProps<"/">) {
</div>
</div>
</header>
<CommandPalette />
<main className="mx-auto w-full max-w-7xl flex-1 px-4 py-6">
<LabelSettingsProvider fileRoles={fileRoles} recommendedRoles={recommendedRoles}>{children}</LabelSettingsProvider>
</main>
+23
View File
@@ -0,0 +1,23 @@
"use client";
import { useState } from "react";
import { LibraryHero } from "@/components/hero/library-hero";
import type { WorkerStatus } from "@/lib/worker-status";
import { AddModelPanel, AddModelToggle } from "./add-model-panel";
type HeroProps = Omit<React.ComponentProps<typeof LibraryHero>, "action" | "initialWorker">;
type PanelProps = Omit<React.ComponentProps<typeof AddModelPanel>, "open" | "setOpen">;
/** The hero with the "Add model" toggle, and the form it opens below. */
export function LibraryTop({ hero, panel, worker, defaultOpen }: { hero: HeroProps; panel: PanelProps; worker: WorkerStatus; defaultOpen: boolean }) {
const [open, setOpen] = useState(defaultOpen);
return (
<>
<LibraryHero {...hero} initialWorker={worker} action={<AddModelToggle open={open} onToggle={() => setOpen(!open)} />} />
{/* Above the hero, which runs on behind what follows. */}
<div className="relative z-10 flex flex-col gap-4 empty:hidden">
<AddModelPanel {...panel} open={open} setOpen={setOpen} />
</div>
</>
);
}
+125 -71
View File
@@ -1,6 +1,6 @@
"use client";
import { SearchIcon, XIcon } from "lucide-react";
import { ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, SearchIcon, XIcon } from "lucide-react";
import Link from "next/link";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useMemo, useState } from "react";
@@ -9,10 +9,10 @@ import { LocalTime } from "@/components/local-time";
import { HUB_STATE_LABEL, HubStateBadge } from "@/components/hub-state-badge";
import { MODEL_STATUS, ModelStatusBadge } from "@/components/model-status-badge";
import { TagBadge, TagDot } from "@/components/tag-badge";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { NativeSelect } from "@/components/ui/native-select";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { useLive } from "@/hooks/use-live";
import type { ModelStatus } from "@/lib/db/schema";
@@ -31,7 +31,8 @@ import {
} from "@/lib/search";
import { FacetFilter } from "./facet-filter";
const OPEN = ["pending_approval", "queued", "downloading", "verifying"];
const OPEN = ["queued", "downloading", "verifying"];
const PAGE_SIZES = [10, 25, 50, 100];
const FACET_LABEL: Record<Facet, string> = {
author: "Author",
@@ -71,6 +72,8 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
const pathname = usePathname();
const params = useSearchParams();
const [query, setQuery] = useState(() => params.get("q") ?? "");
const [page, setPage] = useState(0);
const [pageSize, setPageSize] = useState(25);
const [filters, setFilters] = useState<Filters>(() => {
const f = { ...EMPTY_FILTERS };
for (const facet of FACETS) f[facet] = params.getAll(facet);
@@ -84,18 +87,22 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
const qs = p.toString();
router.replace(qs ? `${pathname}?${qs}` : pathname, { scroll: false });
}
// A new search or filter starts on the first page.
const updateQuery = (q: string) => {
setQuery(q);
setPage(0);
sync(q, filters);
};
const updateFilter = (facet: Facet, values: string[]) => {
const next = { ...filters, [facet]: values };
setFilters(next);
setPage(0);
sync(query, next);
};
const clearAll = () => {
setQuery("");
setFilters(EMPTY_FILTERS);
setPage(0);
sync("", EMPTY_FILTERS);
};
@@ -103,6 +110,9 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
const tagColors = useMemo(() => new Map(rows.flatMap((r) => r.tags.map((t) => [t.name, t.color] as const))), [rows]);
const visible = rows.filter((_, i) => matchesQuery(searchable[i], query) && matchesFilters(searchable[i], filters));
const anyActive = query.trim() !== "" || FACETS.some((f) => filters[f].length > 0);
const pages = Math.max(1, Math.ceil(visible.length / pageSize));
const current = Math.min(page, pages - 1);
const shown = visible.slice(current * pageSize, (current + 1) * pageSize);
const { snapshot } = useLive();
const openJobs = new Map<string, JobSnapshot>();
@@ -111,86 +121,76 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
}
return (
<div className="flex flex-col gap-3">
<div className="flex flex-wrap items-center gap-2">
<div className="relative min-w-56 flex-1">
<SearchIcon className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
<Input
value={query}
onChange={(e) => updateQuery(e.target.value)}
placeholder="Search repo, author, family, quant, tag…"
className="pl-8"
aria-label="Search models"
/>
// Glass: the painting from the hero shows through, blurred.
<Card className="relative z-10 gap-0 overflow-hidden bg-card/55 py-0 backdrop-blur-md">
{/* Toolbar: title, search and filters, part of the table. */}
<div className="flex flex-col gap-3 border-b px-4 py-3">
<div className="flex flex-wrap items-center gap-2">
<h2 className="mr-1 text-base font-semibold">Models</h2>
<span className="rounded-md bg-muted px-1.5 text-xs text-muted-foreground tabular-nums">
{anyActive ? `${visible.length} of ${rows.length}` : rows.length}
</span>
</div>
<div className="flex flex-wrap items-center gap-2">
{/* Same height and border as the filter pills. */}
<div className="relative w-full sm:w-64">
<SearchIcon className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
<Input
value={query}
onChange={(e) => updateQuery(e.target.value)}
placeholder="Search models…"
className="h-8 bg-transparent pl-8 text-sm"
aria-label="Search models"
/>
</div>
{FACETS.map((facet) => (
<FacetFilter
key={facet}
label={FACET_LABEL[facet]}
values={facetCounts(searchable, facet, query, filters)}
selected={filters[facet]}
onChange={(v) => updateFilter(facet, v)}
format={facet === "status" ? statusLabel : undefined}
marker={facet === "tag" ? (v) => <TagDot name={v} color={tagColors.get(v)} /> : undefined}
/>
))}
{anyActive && (
<Button variant="ghost" size="sm" className="h-8" onClick={clearAll}>
Reset
<XIcon />
</Button>
)}
</div>
{FACETS.map((facet) => (
<FacetFilter
key={facet}
label={FACET_LABEL[facet]}
values={facetCounts(searchable, facet, query, filters)}
selected={filters[facet]}
onChange={(v) => updateFilter(facet, v)}
format={facet === "status" ? statusLabel : undefined}
marker={facet === "tag" ? (v) => <TagDot name={v} color={tagColors.get(v)} /> : undefined}
/>
))}
</div>
{anyActive && (
<div className="flex flex-wrap items-center gap-1.5 text-sm">
<span className="text-muted-foreground">
{visible.length} of {rows.length} models
</span>
{FACETS.flatMap((facet) =>
filters[facet].map((v) => (
<Badge key={`${facet}:${v}`} variant="secondary" className="gap-1">
{facet === "tag" && <TagDot name={v} color={tagColors.get(v)} />}
{FACET_LABEL[facet]}: {facet === "status" ? statusLabel(v) : v}
<button
type="button"
aria-label={`Remove filter ${v}`}
onClick={() => updateFilter(facet, filters[facet].filter((x) => x !== v))}
>
<XIcon className="size-3" />
</button>
</Badge>
)),
)}
<Button variant="ghost" size="xs" onClick={clearAll}>
Clear all
</Button>
</div>
)}
{visible.length === 0 ? (
<Card>
<CardHeader>
<CardTitle>No matching models</CardTitle>
<CardDescription>Try a different search or remove a filter.</CardDescription>
</CardHeader>
</Card>
<div className="flex flex-col items-center gap-1 px-4 py-12 text-center">
<p className="text-sm font-medium">No matching models</p>
<p className="text-sm text-muted-foreground">Try a different search or remove a filter.</p>
</div>
) : (
<Card className="py-0">
<>
<Table>
<TableHeader>
<TableRow>
<TableHead>Model</TableHead>
<TableHead className="pl-4">Model</TableHead>
<TableHead>Selection</TableHead>
<TableHead className="text-right">Size</TableHead>
<TableHead className="hidden lg:table-cell">Pinned</TableHead>
<TableHead className="hidden md:table-cell">Downloaded</TableHead>
<TableHead className="w-56">Status</TableHead>
<TableHead className="w-56 pr-4">Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{visible.map((r) => {
{shown.map((r) => {
const job = openJobs.get(r.id);
const base = r.baseModels[0];
return (
<TableRow key={r.id}>
<TableCell className="whitespace-normal">
<Link href={`/${r.repoId}`} className="font-medium hover:underline">
{r.repoId}
<TableCell className="pl-4 whitespace-normal">
<Link href={`/${r.repoId}`} className="hover:underline">
<span className="text-muted-foreground">{r.author}/</span>
<span className="font-medium">{r.repoId.slice(r.author.length + 1)}</span>
</Link>
<div className="mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground">
{base && base !== r.repoId && <span>base {base}</span>}
@@ -206,19 +206,31 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
))}
</div>
</TableCell>
<TableCell className="text-sm">
{r.quants.length > 0 ? r.quants.join(", ") : `${r.fileCount} file${r.fileCount === 1 ? "" : "s"}`}
<TableCell>
{r.quants.length > 0 ? (
<span className="flex flex-wrap gap-1">
{r.quants.map((q) => (
<span key={q} className="rounded-md border px-1.5 font-mono text-[11px] leading-5">
{q}
</span>
))}
</span>
) : (
<span className="text-sm text-muted-foreground">
{r.fileCount} file{r.fileCount === 1 ? "" : "s"}
</span>
)}
</TableCell>
<TableCell className="text-right tabular-nums">{formatBytes(r.totalBytes)}</TableCell>
<TableCell className="hidden lg:table-cell">
<code className="font-mono text-xs" title={r.pinnedSha}>
<code className="font-mono text-xs text-muted-foreground" title={r.pinnedSha}>
{r.trackedRevision}@{shortSha(r.pinnedSha)}
</code>
</TableCell>
<TableCell className="hidden text-sm text-muted-foreground md:table-cell">
<LocalTime value={r.downloadedAt} />
</TableCell>
<TableCell>
<TableCell className="pr-4">
{job ? (
<Link href={`/jobs/${job.id}`} className="flex flex-col gap-1">
<JobStateBadge job={job} />
@@ -241,8 +253,50 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
})}
</TableBody>
</Table>
</Card>
<div className="flex flex-wrap items-center justify-between gap-3 border-t px-4 py-2.5 text-sm">
<span className="text-muted-foreground tabular-nums">
{current * pageSize + 1}–{Math.min(visible.length, (current + 1) * pageSize)} of {visible.length}
</span>
<div className="flex items-center gap-3">
<label className="flex items-center gap-2 text-muted-foreground">
<span className="hidden sm:inline">Rows per page</span>
<NativeSelect
value={pageSize}
onChange={(e) => {
setPageSize(Number(e.target.value));
setPage(0);
}}
className="h-8 w-20"
aria-label="Rows per page"
>
{PAGE_SIZES.map((n) => (
<option key={n} value={n}>
{n}
</option>
))}
</NativeSelect>
</label>
<span className="text-muted-foreground tabular-nums">
Page {current + 1} of {pages}
</span>
<div className="flex items-center gap-1">
<Button variant="outline" size="icon-sm" onClick={() => setPage(0)} disabled={current === 0} aria-label="First page">
<ChevronsLeftIcon />
</Button>
<Button variant="outline" size="icon-sm" onClick={() => setPage(current - 1)} disabled={current === 0} aria-label="Previous page">
<ChevronLeftIcon />
</Button>
<Button variant="outline" size="icon-sm" onClick={() => setPage(current + 1)} disabled={current >= pages - 1} aria-label="Next page">
<ChevronRightIcon />
</Button>
<Button variant="outline" size="icon-sm" onClick={() => setPage(pages - 1)} disabled={current >= pages - 1} aria-label="Last page">
<ChevronsRightIcon />
</Button>
</div>
</div>
</div>
</>
)}
</div>
</Card>
);
}
+20 -8
View File
@@ -1,21 +1,33 @@
import { auth } from "@/auth";
import { listLibrary } from "@/lib/library";
import { listLocalFolders } from "@/lib/local-folders";
import { getWorkerStatus } from "@/lib/worker-status";
import { AddModelPanel } from "./add-model-panel";
import { LibraryTop } from "./library-top";
import { LibraryView } from "./library-view";
export const dynamic = "force-dynamic";
export default async function LibraryPage() {
const [rows, worker, folders] = await Promise.all([listLibrary(), getWorkerStatus(), listLocalFolders()]);
export default async function LibraryPage({ searchParams }: PageProps<"/">) {
const [rows, worker, folders, session] = await Promise.all([listLibrary(), getWorkerStatus(), listLocalFolders(), auth()]);
return (
<div className="flex flex-col gap-4">
{/* Opens by default while the library is empty and there's nothing on disk to import. */}
<AddModelPanel
freeBytes={worker.online ? worker.modelsDirFreeBytes : null}
defaultOpen={rows.length === 0 && folders.length === 0}
folders={folders.map((f) => ({ path: f.path, commit: f.commit, files: f.files, fileCount: f.fileCount, totalBytes: f.totalBytes }))}
{/* The form opens by default while the library is empty and there's nothing on disk to import,
and with ?add=1 (the ⌘K palette's "Add model"). */}
<LibraryTop
worker={worker}
defaultOpen={(rows.length === 0 && folders.length === 0) || (await searchParams).add === "1"}
hero={{
name: session?.user?.name ?? null,
models: rows.length,
libraryBytes: rows.reduce((s, r) => s + r.presentBytes, 0),
updates: rows.filter((r) => r.updateAvailable && (r.hubState === "available" || !r.hubState)).length,
goneFromHub: rows.filter((r) => r.hubState === "repo_missing" || r.hubState === "commit_missing").length,
}}
panel={{
freeBytes: worker.online ? worker.modelsDirFreeBytes : null,
folders: folders.map((f) => ({ path: f.path, commit: f.commit, files: f.files, fileCount: f.fileCount, totalBytes: f.totalBytes })),
}}
/>
{rows.length > 0 && <LibraryView rows={rows} />}
</div>
@@ -65,7 +65,7 @@ export function ScanSettings({ initial }: { initial: ScanStatus }) {
}
return (
<Card>
<Card id="scan" className="scroll-mt-24">
<CardHeader>
<CardTitle>Models folder scan</CardTitle>
<CardDescription>
+7 -3
View File
@@ -1,4 +1,5 @@
import { DownloadIcon, TagIcon, TagsIcon } from "lucide-react";
import { PageHero } from "@/components/hero/page-hero";
import { SettingsNav } from "./settings-nav";
const SECTIONS = [
@@ -9,12 +10,15 @@ const SECTIONS = [
export default function SettingsLayout({ children }: LayoutProps<"/settings">) {
return (
<div className="flex flex-col gap-4">
<h1 className="text-xl font-semibold">Settings</h1>
<PageHero
title="Settings"
description="File labels, tags, and how Kaname downloads and scans models."
painting={{ view: 0.4, focus: [0.5, 0.43], anchor: [0.7, 0.4] }}
>
<div className="grid items-start gap-4 md:grid-cols-[200px_minmax(0,1fr)]">
<SettingsNav sections={SECTIONS} />
<div className="min-w-0">{children}</div>
</div>
</div>
</PageHero>
);
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { cn } from "@/lib/utils";
export function SettingsNav({ sections }: { sections: { href: string; label: string; icon: React.ReactNode }[] }) {
const pathname = usePathname();
return (
<nav className="flex gap-1 rounded-xl bg-card p-2 ring-1 ring-foreground/10 md:flex-col">
<nav className="flex gap-1 rounded-xl bg-card/55 p-2 ring-1 ring-foreground/10 backdrop-blur-md md:flex-col">
{sections.map((s) => (
<Link
key={s.href}
+15 -1
View File
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
import { z } from "zod";
import { withAuth } from "@/lib/api-auth";
import { apiError, handleApiError } from "@/lib/api-errors";
import { addFilesToModel, ModelError } from "@/lib/models";
import { addFilesToModel, ModelError, removeFilesFromModel } from "@/lib/models";
const Body = z.object({ add: z.array(z.string().min(1).max(1024)).min(1).max(10_000) });
@@ -17,3 +17,17 @@ export const POST = withAuth<RouteContext<"/api/models/[id]/files">>(async (req,
return handleApiError(err);
}
});
const RemoveBody = z.object({ remove: z.array(z.string().min(1).max(1024)).min(1).max(10_000) });
/** Remove files from a model's selection and queue deleting them from disk. */
export const DELETE = withAuth<RouteContext<"/api/models/[id]/files">>(async (req, { params }) => {
const { id } = await params;
try {
const { remove } = RemoveBody.parse(await req.json());
return NextResponse.json(await removeFilesFromModel(id, remove), { status: 202 });
} catch (err) {
if (err instanceof ModelError) return apiError(err.status, err.code, err.message);
return handleApiError(err);
}
});
+28
View File
@@ -0,0 +1,28 @@
import { NextResponse } from "next/server";
import { withAuth } from "@/lib/api-auth";
import { listBenchmarks } from "@/lib/benchmarks";
import { modelName, targetName } from "@/lib/benchmark-view";
import { listEndpoints } from "@/lib/endpoints";
import { listLibrary } from "@/lib/library";
import { listTags } from "@/lib/tags";
export const dynamic = "force-dynamic";
/** Everything the ⌘K palette can jump to, compact (it filters in the browser). */
export const GET = withAuth(async () => {
const [models, endpoints, runs, tags] = await Promise.all([listLibrary(), listEndpoints(), listBenchmarks(), listTags()]);
return NextResponse.json({
models: models.map((m) => ({ id: m.id, repoId: m.repoId, quants: m.quants, status: m.status, tags: m.tags.map((t) => t.name) })),
endpoints: endpoints.map((e) => ({ id: e.id, name: e.name, model: e.model, engine: e.engine ?? e.probe?.engine ?? null })),
benchmarks: runs.slice(0, 300).map((r) => ({
id: r.id,
label: r.label,
kind: r.kind,
state: r.state,
target: targetName(r.snapshot),
model: modelName(r.snapshot),
createdAt: r.createdAt.getTime(),
})),
tags: tags.map((t) => t.name),
});
});
-11
View File
@@ -1,11 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#7c5cff"/>
<stop offset="1" stop-color="#14b8a6"/>
</linearGradient>
</defs>
<rect width="64" height="64" rx="14" fill="url(#g)"/>
<text x="32" y="45" text-anchor="middle" font-size="38" font-weight="700" fill="#fff"
font-family="'Yu Gothic','Meiryo','Noto Sans JP','Hiragino Sans',sans-serif">要</text>
</svg>

Before

Width:  |  Height:  |  Size: 497 B