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

+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()} />;
}
@@ -1,122 +0,0 @@
"use client";
import { Trash2Icon } from "lucide-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
import { TagBadge } from "@/components/tag-badge";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
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 type { Tag } from "@/lib/tags";
import { ColorPicker } from "./color-picker";
/** 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.
</CardDescription>
</CardHeader>
<CardContent>
{tags.length === 0 ? (
<p className="text-sm text-muted-foreground">No tags yet.</p>
) : (
<div className="divide-y rounded-lg ring-1 ring-foreground/10">
{tags.map((t) => (
<TagRow key={t.id} tag={t} />
))}
</div>
)}
</CardContent>
</Card>
);
}
function TagRow({ tag }: { tag: Tag & { count: number } }) {
const router = useRouter();
const [name, setName] = useState(tag.name);
const [busy, setBusy] = useState(false);
async function patch(body: { name?: string; color?: string | null }) {
setBusy(true);
try {
const res = await fetch(`/api/tags/${tag.id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
const json = await res.json().catch(() => ({}));
if (!res.ok) {
toast.error(json.error?.message ?? `Could not save (${res.status})`);
setName(tag.name);
return;
}
router.refresh();
} finally {
setBusy(false);
}
}
async function remove() {
const res = await fetch(`/api/tags/${tag.id}`, { method: "DELETE" });
if (!res.ok) toast.error(`Could not delete (${res.status})`);
else toast.success(`Tag "${tag.name}" deleted`);
router.refresh();
}
const color = isLabelColor(tag.color) ? tag.color : null;
return (
<div className="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-4 gap-y-2 px-4 py-3 sm:grid-cols-[8rem_minmax(0,1fr)_8rem_6rem_2rem]">
<TagBadge name={name || tag.name} color={tag.color} className="justify-self-start" />
<Input
value={name}
maxLength={40}
disabled={busy}
onChange={(e) => setName(e.target.value)}
onBlur={() => name.trim() && name !== tag.name && patch({ name })}
onKeyDown={(e) => e.key === "Enter" && (e.target as HTMLInputElement).blur()}
aria-label={`Rename tag ${tag.name}`}
className="h-8"
/>
<ColorPicker value={color} onChange={(c) => patch({ color: c })} allowAuto autoColor={autoTagColor(tag.name)} />
<span className="text-xs text-muted-foreground tabular-nums">
{tag.count} model{tag.count === 1 ? "" : "s"}
</span>
<AlertDialog>
<AlertDialogTrigger render={<Button variant="ghost" size="icon-sm" aria-label={`Delete tag ${tag.name}`} />}>
<Trash2Icon />
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete tag &ldquo;{tag.name}&rdquo;?</AlertDialogTitle>
<AlertDialogDescription>
It is removed from {tag.count} model{tag.count === 1 ? "" : "s"}. The models themselves are not touched.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive" onClick={remove}>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
);
}