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>
);
}
+32 -25
View File
@@ -1,9 +1,12 @@
"use client";
import { XIcon } from "lucide-react";
import Link from "next/link";
import { useEffect, useMemo, useState } from "react";
import { useMemo, useState } from "react";
import { toast } from "sonner";
import { FileRoleBadge } from "@/components/labels";
import { TagBadge } from "@/components/tag-badge";
import { TagPicker } from "@/components/tag-picker";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
@@ -46,15 +49,7 @@ export function AddModelForm({
const [includeText, setIncludeText] = useState("");
const [excludeText, setExcludeText] = useState("");
const [submitting, setSubmitting] = useState(false);
const [tagsText, setTagsText] = useState("");
const [knownTags, setKnownTags] = useState<string[]>([]);
useEffect(() => {
fetch("/api/tags")
.then((r) => (r.ok ? r.json() : []))
.then((all: { name: string }[]) => setKnownTags(all.map((t) => t.name)))
.catch(() => {});
}, []);
const [tags, setTags] = useState<{ name: string; color?: string | null }[]>([]);
async function lookup(e: React.FormEvent) {
e.preventDefault();
@@ -67,7 +62,7 @@ export function AddModelForm({
setChecked(new Set());
setIncludeText("");
setExcludeText("");
setTagsText("");
setTags([]);
} catch (err) {
setResult(null);
setError(err instanceof Error ? err.message : String(err));
@@ -146,7 +141,7 @@ export function AddModelForm({
sha: result.sha,
include: [...includePatterns, ...[...checked].sort().map(escapeGlob)],
exclude: excludePatterns,
tags: parsePatternList(tagsText),
tags: tags.map((t) => t.name),
});
toast.success(`${result.repoId} added, download queued`);
onAdded(id);
@@ -289,20 +284,32 @@ export function AddModelForm({
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="tags">Tags</Label>
<Input
id="tags"
value={tagsText}
onChange={(e) => setTagsText(e.target.value)}
placeholder="roleplay, security"
list="known-tags"
/>
<datalist id="known-tags">
{knownTags.map((t) => (
<option key={t} value={t} />
<Label>Tags</Label>
<div className="flex flex-wrap items-center gap-1.5">
{tags.map((t) => (
<TagBadge key={t.name.toLowerCase()} name={t.name} color={t.color}>
<button
type="button"
aria-label={`Remove tag ${t.name}`}
onClick={() => setTags((prev) => prev.filter((x) => x !== t))}
className="opacity-60 hover:opacity-100"
>
<XIcon className="size-3" />
</button>
</TagBadge>
))}
</datalist>
<p className="text-xs text-muted-foreground">Optional, comma-separated. Editable later on the model page.</p>
<TagPicker
exclude={tags.map((t) => t.name)}
onPick={(name, tag) =>
setTags((prev) =>
prev.some((x) => x.name.toLowerCase() === name.toLowerCase())
? prev
: [...prev, { name, color: tag?.color }],
)
}
/>
</div>
<p className="text-xs text-muted-foreground">Optional. Editable later on the model page.</p>
</div>
</CardContent>
</Card>
+12 -22
View File
@@ -1,8 +1,9 @@
import Link from "next/link";
import { redirect } from "next/navigation";
import { auth, signOut } from "@/auth";
import { Button } from "@/components/ui/button";
import { AppNav } from "@/components/app-nav";
import { LabelSettingsProvider } from "@/components/labels";
import { UserMenu } from "@/components/user-menu";
import { WorkerIndicator } from "@/components/worker-indicator";
import { getFileRoleStyles } from "@/lib/settings";
import { getWorkerStatus } from "@/lib/worker-status";
@@ -16,34 +17,23 @@ 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-6 px-4">
<Link href="/" className="flex items-baseline gap-1.5 font-semibold">
<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="text-xs font-normal text-muted-foreground">{process.env.APP_VERSION ?? "dev"}</span>
<span className="hidden text-xs font-normal text-muted-foreground sm:inline">{process.env.APP_VERSION ?? "dev"}</span>
</Link>
<nav className="flex items-center gap-4 text-sm text-muted-foreground">
<Link href="/" className="hover:text-foreground">
Library
</Link>
<Link href="/settings" className="hover:text-foreground">
Settings
</Link>
</nav>
<AppNav />
<div className="ml-auto flex items-center gap-3">
<WorkerIndicator initial={worker} />
<span className="hidden text-sm text-muted-foreground sm:inline">
{session.user.name ?? session.user.email}
</span>
<form
action={async () => {
<UserMenu
user={{ name: session.user.name ?? null, email: session.user.email ?? null, image: session.user.image ?? null }}
signOutAction={async () => {
"use server";
await signOut({ redirectTo: "/login" });
}}
>
<Button type="submit" variant="ghost" size="sm">
Sign out
</Button>
</form>
/>
</div>
</div>
</header>
+6 -1
View File
@@ -6,6 +6,7 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useMemo, useState } from "react";
import { JobProgress, JobStateBadge } from "@/components/job-progress";
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";
@@ -55,6 +56,7 @@ function toSearchable(r: LibraryRow): SearchableModel {
pipelineTag: r.pipelineTag,
license: r.license,
status: r.status,
hubStatus: r.hubState && r.hubState !== "available" ? HUB_STATE_LABEL[r.hubState].label : null,
};
}
@@ -218,7 +220,10 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
{job.state !== "queued" && <JobProgress job={job} compact />}
</Link>
) : (
<ModelStatusBadge status={r.status} />
<span className="flex flex-wrap gap-1">
<ModelStatusBadge status={r.status} />
<HubStateBadge state={r.hubState} />
</span>
)}
</TableCell>
</TableRow>
+2 -10
View File
@@ -1,18 +1,10 @@
import type { Metadata } from "next";
import { getFileRoleStyles } from "@/lib/settings";
import { listTags } from "@/lib/tags";
import { FileLabelSettings } from "./file-label-settings";
import { TagSettings } from "./tag-settings";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "Labels · Settings" };
export const metadata: Metadata = { title: "File labels · Settings" };
export default async function LabelSettingsPage() {
const [fileRoles, tags] = await Promise.all([getFileRoleStyles(), listTags()]);
return (
<div className="flex flex-col gap-4">
<FileLabelSettings initial={fileRoles} />
<TagSettings tags={tags} />
</div>
);
return <FileLabelSettings initial={await getFileRoleStyles()} />;
}
+5 -2
View File
@@ -1,7 +1,10 @@
import { TagsIcon } from "lucide-react";
import { TagIcon, TagsIcon } from "lucide-react";
import { SettingsNav } from "./settings-nav";
const SECTIONS = [{ href: "/settings/labels", label: "Labels", icon: <TagsIcon className="size-4" /> }];
const SECTIONS = [
{ href: "/settings/labels", label: "File labels", icon: <TagIcon className="size-4" /> },
{ href: "/settings/tags", label: "Tags", icon: <TagsIcon className="size-4" /> },
];
export default function SettingsLayout({ children }: LayoutProps<"/settings">) {
return (
+10
View File
@@ -0,0 +1,10 @@
import type { Metadata } from "next";
import { listTags } from "@/lib/tags";
import { TagSettings } from "./tag-settings";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "Tags · Settings" };
export default async function TagSettingsPage() {
return <TagSettings tags={await listTags()} />;
}
@@ -1,6 +1,6 @@
"use client";
import { Trash2Icon } from "lucide-react";
import { PlusIcon, Trash2Icon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
@@ -19,21 +19,22 @@ import {
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { autoTagColor, isLabelColor } from "@/lib/colors";
import { autoTagColor, isLabelColor, type LabelColor } from "@/lib/colors";
import type { Tag } from "@/lib/tags";
import { ColorPicker } from "./color-picker";
import { ColorPicker } from "../labels/color-picker";
/** Rename, recolor or delete user tags. Changes save immediately. */
/** Create, rename, recolor or delete user tags. Changes save immediately. */
export function TagSettings({ tags }: { tags: (Tag & { count: number })[] }) {
return (
<Card>
<CardHeader>
<CardTitle>Tags</CardTitle>
<CardDescription>
Your own tags (added on a model page or when adding a model). Tags without a color get an automatic one.
Your own tags, to attach on a model page or when adding a model. Tags without a color get an automatic one.
</CardDescription>
</CardHeader>
<CardContent>
<CardContent className="flex flex-col gap-3">
<NewTagRow />
{tags.length === 0 ? (
<p className="text-sm text-muted-foreground">No tags yet.</p>
) : (
@@ -48,6 +49,64 @@ export function TagSettings({ tags }: { tags: (Tag & { count: number })[] }) {
);
}
function NewTagRow() {
const router = useRouter();
const [name, setName] = useState("");
const [color, setColor] = useState<LabelColor | null>(null);
const [busy, setBusy] = useState(false);
async function create(e: React.FormEvent) {
e.preventDefault();
if (!name.trim()) return;
setBusy(true);
try {
const res = await fetch("/api/tags", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ name, color }),
});
const json = await res.json().catch(() => ({}));
if (!res.ok) {
toast.error(json.error?.message ?? `Could not create tag (${res.status})`);
return;
}
toast.success(`Tag "${json.name}" created`);
setName("");
setColor(null);
router.refresh();
} finally {
setBusy(false);
}
}
return (
<form
onSubmit={create}
className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-2 rounded-lg border border-dashed px-4 py-3 sm:grid-cols-[8rem_minmax(0,1fr)_8rem_6rem_2rem]"
>
{name.trim() ? (
<TagBadge name={name.trim()} color={color} className="justify-self-start" />
) : (
<span className="text-xs text-muted-foreground">New tag</span>
)}
<Input
value={name}
maxLength={40}
disabled={busy}
onChange={(e) => setName(e.target.value)}
placeholder="e.g. roleplay"
aria-label="New tag name"
className="h-8"
/>
<ColorPicker value={color} onChange={setColor} allowAuto autoColor={autoTagColor(name.trim())} />
<Button type="submit" size="sm" disabled={busy || !name.trim()} className="sm:col-span-2">
<PlusIcon />
Add
</Button>
</form>
);
}
function TagRow({ tag }: { tag: Tag & { count: number } }) {
const router = useRouter();
const [name, setName] = useState(tag.name);
@@ -0,0 +1,12 @@
import { NextResponse } from "next/server";
import { withAuth } from "@/lib/api-auth";
import { apiError } from "@/lib/api-errors";
import { checkHubAvailability, getCheckedModel } from "@/lib/hub/availability";
/** Check right now whether the repo and pinned commit are still on the Hub. */
export const POST = withAuth<RouteContext<"/api/models/[id]/hub-check">>(async (_req, { params }) => {
const { id } = await params;
const model = await getCheckedModel(id);
if (!model) return apiError(404, "not_found", "Model not found.");
return NextResponse.json(await checkHubAvailability(model));
});
+15 -1
View File
@@ -1,8 +1,22 @@
import { NextResponse } from "next/server";
import { z } from "zod";
import { withAuth } from "@/lib/api-auth";
import { listTags } from "@/lib/tags";
import { apiError, handleApiError } from "@/lib/api-errors";
import { createTag, listTags, TagError } from "@/lib/tags";
export const dynamic = "force-dynamic";
/** All user tags with usage counts. */
export const GET = withAuth(async () => NextResponse.json(await listTags()));
const Body = z.object({ name: z.string(), color: z.string().nullable().optional() });
/** Create a tag that isn't on any model yet. */
export const POST = withAuth(async (req) => {
try {
return NextResponse.json(await createTag(Body.parse(await req.json())), { status: 201 });
} catch (err) {
if (err instanceof TagError) return apiError(err.status, err.code, err.message);
return handleApiError(err);
}
});