Flag models deleted from the Hub; tag picker, tags in settings, account menu

- Worker checks each model's repo and pinned commit on the Hub every
  UPDATE_CHECK_INTERVAL_HOURS and after failed downloads; missing repos or
  commits are flagged (badge, banner, Status filter) and block new
  downloads. Local files are never touched. "Check now" on the model page.
- Tag picker dropdown ("Create new tag…" first, then existing tags) on the
  model page and in Add model.
- Settings: separate File labels and Tags pages; create tags there. Unused
  tags are no longer deleted automatically.
- Header: app icon, nav with active state, account menu with the OIDC
  profile picture, theme switch and sign out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 22:53:57 +02:00
1 parent df18415e02
commit 3603742637
33 files changed
+1708 -122

No files matched your search

+12 -1
View File
@@ -15,7 +15,16 @@ import { formatBytes, percent } from "@/lib/format";
const OPEN = ["queued", "downloading", "verifying"];
/** Sidebar card: current download state, actions and (while running) per-file progress. */
export function DownloadCard({ modelId, status }: { modelId: string; status: ModelStatus }) {
export function DownloadCard({
modelId,
status,
hubMissing,
}: {
modelId: string;
status: ModelStatus;
/** The repo or pinned commit is gone from the Hub; no new downloads. */
hubMissing: boolean;
}) {
const { snapshot } = useLive({ model: modelId });
const [busy, setBusy] = useState(false);
const latest = snapshot?.jobs[0];
@@ -35,6 +44,7 @@ export function DownloadCard({ modelId, status }: { modelId: string; status: Mod
if (open?.state === "queued") hint = snapshot?.worker.online ? "Waiting for a free download slot." : "Queued, but the worker is offline.";
else if (open) hint = "Runs in the background; you can close this page.";
else if (status === "ready") hint = "All selected files are present.";
else if (hubMissing) hint = "Can't download: no longer available on Hugging Face. Local files are kept.";
return (
<div className="flex flex-col gap-3">
@@ -84,6 +94,7 @@ export function DownloadCard({ modelId, status }: { modelId: string; status: Mod
</Button>
) : (
status !== "ready" &&
!hubMissing &&
snapshot && (
<Button size="sm" disabled={busy} onClick={() => run(() => startDownload(modelId))}>
{latest ? "Download again" : "Download"}
+4 -1
View File
@@ -28,6 +28,7 @@ export function FilesHeader({
candidates,
freeBytes,
busy,
hubMissing,
}: {
modelId: string;
sha: string;
@@ -39,6 +40,8 @@ export function FilesHeader({
freeBytes: number | null;
/** A download is queued/running; adding files has to wait. */
busy: boolean;
/** The repo or pinned commit is gone from the Hub; nothing more can be downloaded. */
hubMissing: boolean;
}) {
const router = useRouter();
const [open, setOpen] = useState(false);
@@ -114,7 +117,7 @@ export function FilesHeader({
<span className="text-muted-foreground">
{localCount} of {selectedCount} on disk · {formatBytes(localBytes)}
</span>
{candidates.length > 0 && (
{candidates.length > 0 && !hubMissing && (
<Button
size="sm"
variant={open ? "outline" : "default"}
+3
View File
@@ -122,6 +122,7 @@ export function FilesTab({
others,
freeBytes,
busy,
hubMissing,
}: {
modelId: string;
repoId: string;
@@ -130,6 +131,7 @@ export function FilesTab({
others: FileRow[];
freeBytes: number | null;
busy: boolean;
hubMissing: boolean;
}) {
const hub = `https://huggingface.co/${repoId}`;
// Split files link to their folder (all parts), single files to the file itself.
@@ -155,6 +157,7 @@ export function FilesTab({
candidates={others.map((f) => ({ path: f.path, size: f.size }))}
freeBytes={freeBytes}
busy={busy}
hubMissing={hubMissing}
/>
<ul className="divide-y">
+37
View File
@@ -0,0 +1,37 @@
"use client";
import { RefreshCwIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
/** Re-check right now whether the repo and pinned commit are still on the Hub. */
export function HubCheckButton({ modelId, label = "Check now" }: { modelId: string; label?: string }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
async function check() {
setBusy(true);
try {
const res = await fetch(`/api/models/${modelId}/hub-check`, { method: "POST" });
const json = await res.json().catch(() => ({}));
if (!res.ok) toast.error(json.error?.message ?? `Check failed (${res.status})`);
else if (json.state === "available") toast.success("Still available on Hugging Face");
else if (json.state === "repo_missing") toast.warning("The repo is no longer on Hugging Face");
else if (json.state === "commit_missing") toast.warning("The pinned commit is no longer on Hugging Face");
else toast.error(`Could not check: ${json.error ?? "unknown error"}`);
router.refresh();
} finally {
setBusy(false);
}
}
return (
<Button variant="ghost" size="xs" onClick={check} disabled={busy}>
<RefreshCwIcon className={cn(busy && "animate-spin")} />
{label}
</Button>
);
}
+51 -1
View File
@@ -11,11 +11,13 @@ import {
MessagesSquareIcon,
ScaleIcon,
SparklesIcon,
TriangleAlertIcon,
} from "lucide-react";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound, redirect } from "next/navigation";
import { CopyButton } from "@/components/copy-button";
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";
@@ -30,6 +32,7 @@ import { modelTagList } from "@/lib/tags";
import { getWorkerStatus } from "@/lib/worker-status";
import { DownloadCard } from "./download-card";
import { FilesTab } from "./files-tab";
import { HubCheckButton } from "./hub-check";
import { JobsTab } from "./jobs-tab";
import { ModelCard } from "./model-card";
import { RemoveModelButton } from "./remove-model-button";
@@ -90,6 +93,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
const hub = `https://huggingface.co/${model.repoId}`;
const baseModels = model.baseModels ?? [];
const hubTags = model.hubTags ?? [];
const hubMissing = model.hubState === "repo_missing" || model.hubState === "commit_missing";
const [tags, related, card, worker] = await Promise.all([
modelTagList(model.id),
@@ -125,6 +129,7 @@ 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} />
<HubStateBadge state={model.hubState} />
<div className="ml-auto flex items-center gap-2">
{model.status === "pending" && <RemoveModelButton id={model.id} />}
<ExternalButton href={hub}>🤗 Hugging Face</ExternalButton>
@@ -159,6 +164,32 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
</Panel>
{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">
<TriangleAlertIcon className="mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400" />
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
<p className="font-medium text-amber-800 dark:text-amber-200">
{model.hubState === "repo_missing"
? "This repo is no longer on Hugging Face"
: "The pinned commit is no longer on Hugging Face"}
</p>
<p className="text-muted-foreground">
{model.hubState === "repo_missing"
? "It was deleted, renamed or made private. "
: "The repo's history was rewritten. "}
Your local copy is kept and stays usable; downloading more files or repairing isn&apos;t possible.
{model.hubMissingSince && (
<>
{" "}
Missing since <LocalTime value={model.hubMissingSince} />.
</>
)}
</p>
</div>
<HubCheckButton modelId={model.id} label="Check again" />
</div>
)}
<div className="grid items-start gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
{/* Content card with the tabs as a segmented control in its header */}
<Panel className="min-w-0 overflow-hidden">
@@ -220,6 +251,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
others={others}
freeBytes={worker.online ? worker.modelsDirFreeBytes : null}
busy={model.status === "downloading"}
hubMissing={hubMissing}
/>
)}
{tab === "jobs" && (
@@ -231,7 +263,7 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
<aside className="flex flex-col gap-4">
<SideCard>
<DownloadCard modelId={model.id} status={model.status} />
<DownloadCard modelId={model.id} status={model.status} hubMissing={hubMissing} />
</SideCard>
<SideCard title="Local copy" icon={ListChecksIcon}>
@@ -271,6 +303,24 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
<dd className="flex flex-col font-mono text-xs">{model.excludePatterns.map((p) => <span key={p} className="break-all">{p}</span>)}</dd>
</>
)}
<dt className="text-muted-foreground">On the Hub</dt>
<dd className="flex flex-col items-start gap-0.5">
<span className={cn(hubMissing && "text-amber-700 dark:text-amber-300")}>
{model.hubState === "available"
? "Available"
: model.hubState === "repo_missing"
? "Repo deleted"
: model.hubState === "commit_missing"
? "Commit deleted"
: "Not checked yet"}
</span>
{model.lastCheckedAt && (
<span className="text-xs text-muted-foreground" title={model.lastCheckError ?? undefined}>
{model.lastCheckError ? "check failed" : "checked"} <LocalTime value={model.lastCheckedAt} />
</span>
)}
<HubCheckButton modelId={model.id} />
</dd>
<dt className="text-muted-foreground">Added</dt>
<dd>
<LocalTime value={model.createdAt} />
+4 -40
View File
@@ -2,29 +2,18 @@
import { XIcon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useEffect, useId, useState } from "react";
import { useState } from "react";
import { toast } from "sonner";
import { TagBadge } from "@/components/tag-badge";
import { Input } from "@/components/ui/input";
import { TagPicker } from "@/components/tag-picker";
import type { Tag } from "@/lib/tags";
/** Add/remove user tags on a model; suggests existing tags. */
/** Add/remove user tags on a model. */
export function TagEditor({ modelId, tags }: { modelId: string; tags: Tag[] }) {
const router = useRouter();
const listId = useId();
const [value, setValue] = useState("");
const [busy, setBusy] = useState(false);
const [suggestions, setSuggestions] = useState<string[]>([]);
useEffect(() => {
fetch("/api/tags")
.then((r) => (r.ok ? r.json() : []))
.then((all: Tag[]) => setSuggestions(all.map((t) => t.name)))
.catch(() => {});
}, [tags]);
async function add(name: string) {
if (!name.trim()) return;
setBusy(true);
const res = await fetch(`/api/models/${modelId}/tags`, {
method: "POST",
@@ -37,7 +26,6 @@ export function TagEditor({ modelId, tags }: { modelId: string; tags: Tag[] }) {
toast.error(body.error?.message ?? `Could not add tag (${res.status})`);
return;
}
setValue("");
router.refresh();
}
@@ -47,7 +35,6 @@ export function TagEditor({ modelId, tags }: { modelId: string; tags: Tag[] }) {
router.refresh();
}
const current = new Set(tags.map((t) => t.name.toLowerCase()));
return (
<div className="flex flex-wrap items-center gap-1.5">
{tags.map((t) => (
@@ -57,30 +44,7 @@ export function TagEditor({ modelId, tags }: { modelId: string; tags: Tag[] }) {
</button>
</TagBadge>
))}
<form
onSubmit={(e) => {
e.preventDefault();
void add(value);
}}
>
<Input
value={value}
onChange={(e) => setValue(e.target.value)}
list={listId}
placeholder="Add tag…"
disabled={busy}
maxLength={40}
className="h-6 w-36 text-xs"
aria-label="Add tag"
/>
<datalist id={listId}>
{suggestions
.filter((s) => !current.has(s.toLowerCase()))
.map((s) => (
<option key={s} value={s} />
))}
</datalist>
</form>
<TagPicker exclude={tags.map((t) => t.name)} onPick={add} disabled={busy} />
</div>
);
}