Model page: Files tab first with a new file list, colored tags, single Hub link

- Files is the default tab: icon/size/LFS/state per file, on-disk summary, unselected files collapsed
- Custom tags color-coded by name (editor, library, filter chips and menu)
- Header: only the Hugging Face link (top right); README link moved to the end of the model card
- App icon; proxy lets /icon.svg through

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 20:24:23 +02:00
1 parent 5fadd64367
commit 6dc9527682
9 files changed
+263 -119

No files matched your search

+22 -108
View File
@@ -19,7 +19,6 @@ import { CopyButton } from "@/components/copy-button";
import { LocalTime } from "@/components/local-time";
import { ModelStatusBadge } from "@/components/model-status-badge";
import { buttonVariants } from "@/components/ui/button";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { cn } from "@/lib/utils";
import { formatBytes, shortSha } from "@/lib/format";
import { fetchModelCard } from "@/lib/hub/client";
@@ -28,6 +27,7 @@ import { getModelByRepo, relatedModels } from "@/lib/library";
import { quantGroup } from "@/lib/selection";
import { modelTagList } from "@/lib/tags";
import { DownloadCard } from "./download-card";
import { FilesTab } from "./files-tab";
import { JobsTab } from "./jobs-tab";
import { ModelCard } from "./model-card";
import { RemoveModelButton } from "./remove-model-button";
@@ -36,8 +36,8 @@ import { TagEditor } from "./tag-editor";
export const dynamic = "force-dynamic";
const TABS = [
{ id: "card", label: "Model card", icon: FileTextIcon },
{ id: "files", label: "Files", icon: FolderIcon },
{ id: "card", label: "Model card", icon: FileTextIcon },
{ id: "jobs", label: "Jobs", icon: HistoryIcon },
] as const;
type TabId = (typeof TABS)[number]["id"];
@@ -83,7 +83,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
const { model, files } = data;
if (model.repoId !== `${org}/${repo}`) redirect(`/${model.repoId}`); // canonical spelling
const tab: TabId = TABS.some((t) => t.id === sp.tab) ? (sp.tab as TabId) : "card";
const tab: TabId = TABS.some((t) => t.id === sp.tab) ? (sp.tab as TabId) : "files";
const [author, name] = model.repoId.split("/");
const hub = `https://huggingface.co/${model.repoId}`;
const baseModels = model.baseModels ?? [];
@@ -105,7 +105,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
const shown = new Set([...Object.keys(FORMATS), model.architecture, author.toLowerCase(), model.pipelineTag]);
const extraTags = hubTags.filter((t) => !shown.has(t) && !languageName(t)).slice(0, 8);
const tabHref = (id: TabId) => (id === "card" ? `/${model.repoId}` : `/${model.repoId}?tab=${id}`);
const tabHref = (id: TabId) => (id === "files" ? `/${model.repoId}` : `/${model.repoId}?tab=${id}`);
return (
<div className="flex flex-col gap-4">
@@ -120,11 +120,10 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
<h1 className="text-xl font-semibold break-all">{name}</h1>
<CopyButton value={model.repoId} label="Copy repo ID" />
<ModelStatusBadge status={model.status} />
{model.status === "pending" && (
<div className="ml-auto">
<RemoveModelButton id={model.id} />
</div>
)}
<div className="ml-auto flex items-center gap-2">
{model.status === "pending" && <RemoveModelButton id={model.id} />}
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
</div>
</div>
<div className="flex flex-wrap items-center gap-1.5">
@@ -153,15 +152,6 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
<TagEditor modelId={model.id} tags={tags} />
</div>
<div className="flex flex-wrap gap-2">
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
<ExternalButton href={`${hub}/tree/${model.pinnedSha}`}>Files @ {shortSha(model.pinnedSha)}</ExternalButton>
<ExternalButton href={`${hub}/commits/${encodeURIComponent(model.trackedRevision)}`}>Commits</ExternalButton>
<ExternalButton href={`${hub}/discussions`}>Community</ExternalButton>
{baseModels[0] && (
<ExternalButton href={`https://huggingface.co/${baseModels[0]}`}>Base: {baseModels[0]}</ExternalButton>
)}
</div>
</Panel>
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
@@ -187,23 +177,25 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
</Link>
))}
</nav>
{tab === "card" && card && (
<a
href={`${hub}/blob/${model.pinnedSha}/README.md`}
target="_blank"
rel="noreferrer"
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
>
README.md @ {shortSha(model.pinnedSha)}
<ExternalLinkIcon className="size-3" />
</a>
)}
</div>
{tab === "card" && (
<div className="p-5 sm:p-6">
{card ? (
<ModelCard markdown={card} repoId={model.repoId} sha={model.pinnedSha} />
<>
<ModelCard markdown={card} repoId={model.repoId} sha={model.pinnedSha} />
<div className="mt-6 flex justify-end">
<a
href={`${hub}/blob/${model.pinnedSha}/README.md`}
target="_blank"
rel="noreferrer"
className="flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground"
>
README.md @ {shortSha(model.pinnedSha)}
<ExternalLinkIcon className="size-3" />
</a>
</div>
</>
) : (
<p className="text-sm text-muted-foreground">
{card === null ? "This repository has no model card." : "The model card could not be loaded."}{" "}
@@ -400,81 +392,3 @@ function ModelTree({
</ol>
);
}
function FilesTab({
repoId,
sha,
selected,
others,
}: {
repoId: string;
sha: string;
selected: { id: string; path: string; size: number; lfsSha256: string | null; state: string }[];
others: { id: string; path: string; size: number; lfsSha256: string | null }[];
}) {
const blob = (path: string) => `https://huggingface.co/${repoId}/blob/${sha}/${path}`;
return (
<div>
<div className="flex flex-wrap items-baseline gap-x-2 px-5 pt-4 pb-2 text-sm">
<span className="font-medium">Selected files</span>
<span className="text-muted-foreground">
{selected.length} · {formatBytes(selected.reduce((s, f) => s + f.size, 0))} · at {shortSha(sha)}
</span>
</div>
<div className="px-2">
<Table>
<TableHeader>
<TableRow>
<TableHead>File</TableHead>
<TableHead className="text-right">Size</TableHead>
<TableHead>Local</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{selected.map((f) => (
<TableRow key={f.id}>
<TableCell className="font-mono text-xs break-all whitespace-normal">
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
{f.path}
</a>
{f.lfsSha256 && <span className="ml-2 rounded border px-1 text-[10px] text-muted-foreground">LFS</span>}
</TableCell>
<TableCell className="text-right tabular-nums">{formatBytes(f.size)}</TableCell>
<TableCell className="text-sm text-muted-foreground">{f.state}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
{others.length > 0 && (
<details className="group mt-2 border-t">
<summary className="flex cursor-pointer list-none flex-wrap items-baseline gap-x-2 px-5 py-3 text-sm hover:bg-muted/40">
<span className="font-medium">Other files in the repo</span>
<span className="text-muted-foreground">
{others.length} · {formatBytes(others.reduce((s, f) => s + f.size, 0))} · not downloaded
</span>
<span className="ml-auto text-xs text-muted-foreground group-open:hidden">Show</span>
<span className="ml-auto hidden text-xs text-muted-foreground group-open:inline">Hide</span>
</summary>
<div className="px-2 pb-2">
<Table>
<TableBody>
{others.map((f) => (
<TableRow key={f.id}>
<TableCell className="font-mono text-xs break-all whitespace-normal text-muted-foreground">
<a href={blob(f.path)} target="_blank" rel="noreferrer" className="hover:underline">
{f.path}
</a>
</TableCell>
<TableCell className="w-28 text-right text-muted-foreground tabular-nums">{formatBytes(f.size)}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
</details>
)}
</div>
);
}