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

+37
View File
@@ -0,0 +1,37 @@
"use client";
import { LibraryIcon, SettingsIcon } from "lucide-react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { cn } from "@/lib/utils";
const LINKS = [
{ href: "/", label: "Library", icon: LibraryIcon, active: (p: string) => !p.startsWith("/settings") && !p.startsWith("/jobs/") },
{ href: "/settings", label: "Settings", icon: SettingsIcon, active: (p: string) => p.startsWith("/settings") },
];
/** Main navigation; model and job pages count as part of the library. */
export function AppNav() {
const pathname = usePathname();
return (
<nav className="flex items-center gap-1 text-sm">
{LINKS.map((l) => {
const active = l.active(pathname) || (l.href === "/" && pathname.startsWith("/jobs/"));
return (
<Link
key={l.href}
href={l.href}
aria-current={active ? "page" : undefined}
className={cn(
"flex items-center gap-1.5 rounded-md px-2.5 py-1.5 transition-colors",
active ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted/60 hover:text-foreground",
)}
>
<l.icon className="size-4" />
<span className="hidden sm:inline">{l.label}</span>
</Link>
);
})}
</nav>
);
}
+32
View File
@@ -0,0 +1,32 @@
import { TriangleAlertIcon } from "lucide-react";
import type { HubState } from "@/lib/db/schema";
import { cn } from "@/lib/utils";
export const HUB_STATE_LABEL: Record<Exclude<HubState, "available">, { label: string; title: string }> = {
repo_missing: {
label: "deleted on Hub",
title: "The repo is no longer on Hugging Face (deleted, or made private). Your local files are kept.",
},
commit_missing: {
label: "commit deleted on Hub",
title: "The pinned commit is no longer on Hugging Face (history rewritten). Your local files are kept.",
},
};
/** Warning badge when a model's repo or pinned commit disappeared from the Hub; nothing otherwise. */
export function HubStateBadge({ state, className }: { state: HubState | null; className?: string }) {
if (!state || state === "available") return null;
const { label, title } = HUB_STATE_LABEL[state];
return (
<span
title={title}
className={cn(
"inline-flex h-5 shrink-0 items-center gap-1 rounded-4xl border border-amber-500/30 bg-amber-500/10 px-2 text-xs font-medium whitespace-nowrap text-amber-700 dark:text-amber-300",
className,
)}
>
<TriangleAlertIcon className="size-3" />
{label}
</span>
);
}
+131
View File
@@ -0,0 +1,131 @@
"use client";
import { ChevronDownIcon, PlusIcon, SettingsIcon } from "lucide-react";
import Link from "next/link";
import { useEffect, useRef, useState } from "react";
import { TagDot } from "@/components/tag-badge";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Input } from "@/components/ui/input";
import type { Tag } from "@/lib/tags";
import { cn } from "@/lib/utils";
/**
* "Add tag" dropdown: the first entry creates a new tag (inline name field), below it the existing
* tags that aren't picked yet. Calls `onPick` with the tag name.
*/
export function TagPicker({
exclude,
onPick,
disabled,
className,
}: {
/** Tag names already applied (case-insensitive), hidden from the list. */
exclude: string[];
/** Picked tag name; `tag` is set when an existing tag was chosen. */
onPick: (name: string, tag?: Tag) => void | Promise<void>;
disabled?: boolean;
className?: string;
}) {
const [known, setKnown] = useState<Tag[]>([]);
const [creating, setCreating] = useState(false);
const [name, setName] = useState("");
const inputRef = useRef<HTMLInputElement>(null);
const cancelled = useRef(false);
function load() {
fetch("/api/tags")
.then((r) => (r.ok ? r.json() : []))
.then((all: Tag[]) => setKnown(all))
.catch(() => {});
}
useEffect(load, []);
useEffect(() => {
if (!creating) return;
cancelled.current = false;
inputRef.current?.focus();
}, [creating]);
function finishCreating() {
setCreating(false);
setName("");
}
async function submit() {
const value = name.trim();
const existing = known.find((t) => t.name.toLowerCase() === value.toLowerCase());
if (value) await onPick(existing?.name ?? value, existing);
finishCreating();
}
if (creating) {
return (
<form
className={className}
onSubmit={(e) => {
e.preventDefault();
inputRef.current?.blur(); // blur submits, so Enter and click-away can't add twice
}}
>
<Input
ref={inputRef}
value={name}
onChange={(e) => setName(e.target.value)}
onBlur={() => (name.trim() && !cancelled.current ? void submit() : finishCreating())}
onKeyDown={(e) => {
if (e.key !== "Escape") return;
cancelled.current = true;
inputRef.current?.blur();
}}
placeholder="New tag name…"
disabled={disabled}
maxLength={40}
className="h-6 w-40 text-xs"
aria-label="New tag name"
/>
</form>
);
}
const hidden = new Set(exclude.map((n) => n.toLowerCase()));
const available = known.filter((t) => !hidden.has(t.name.toLowerCase()));
return (
<DropdownMenu onOpenChange={(open) => open && load()}>
<DropdownMenuTrigger
disabled={disabled}
className={cn(
"inline-flex h-6 items-center gap-1 rounded-full border border-dashed px-2 text-xs text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:opacity-50",
className,
)}
>
<PlusIcon className="size-3" />
Add tag
<ChevronDownIcon className="size-3 opacity-60" />
</DropdownMenuTrigger>
<DropdownMenuContent className="max-h-72 w-auto min-w-44">
<DropdownMenuItem onClick={() => setCreating(true)}>
<PlusIcon />
Create new tag…
</DropdownMenuItem>
{available.length > 0 && <DropdownMenuSeparator />}
{available.map((t) => (
<DropdownMenuItem key={t.id} onClick={() => void onPick(t.name, t)}>
<TagDot name={t.name} color={t.color} />
{t.name}
</DropdownMenuItem>
))}
<DropdownMenuSeparator />
<DropdownMenuItem render={<Link href="/settings/tags" />} className="text-muted-foreground">
<SettingsIcon />
Manage tags…
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}
+97
View File
@@ -0,0 +1,97 @@
"use client";
import { LogOutIcon, MonitorIcon, MoonIcon, SunIcon, TagIcon, TagsIcon } from "lucide-react";
import Link from "next/link";
import { useTheme } from "next-themes";
import { useTransition } from "react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
export type MenuUser = { name: string | null; email: string | null; image: string | null };
function initials(user: MenuUser): string {
const source = user.name || user.email || "?";
const parts = source.split(/[\s@._-]+/).filter(Boolean);
return ((parts[0]?.[0] ?? "?") + (parts.length > 1 ? parts[1][0] : "")).toUpperCase();
}
function UserAvatar({ user, size }: { user: MenuUser; size?: "sm" | "default" | "lg" }) {
return (
<Avatar size={size}>
{user.image && <AvatarImage src={user.image} alt="" referrerPolicy="no-referrer" />}
<AvatarFallback className="text-xs font-medium">{initials(user)}</AvatarFallback>
</Avatar>
);
}
/** Avatar from the OIDC profile; opens a menu with account info, settings, theme and sign out. */
export function UserMenu({ user, signOutAction }: { user: MenuUser; signOutAction: () => Promise<void> }) {
const { theme, setTheme } = useTheme();
const [signingOut, startSignOut] = useTransition();
return (
<DropdownMenu>
<DropdownMenuTrigger
aria-label="Account menu"
className="flex items-center gap-2 rounded-full p-0.5 outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 sm:pr-3"
>
<UserAvatar user={user} />
<span className="hidden max-w-40 truncate text-sm sm:inline">{user.name ?? user.email}</span>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-64">
<div className="flex items-center gap-3 px-1.5 py-2">
<UserAvatar user={user} size="lg" />
<div className="flex min-w-0 flex-col">
<span className="truncate text-sm font-medium">{user.name ?? "Signed in"}</span>
{user.email && <span className="truncate text-xs text-muted-foreground">{user.email}</span>}
</div>
</div>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuLabel>Settings</DropdownMenuLabel>
<DropdownMenuItem render={<Link href="/settings/labels" />}>
<TagIcon />
File labels
</DropdownMenuItem>
<DropdownMenuItem render={<Link href="/settings/tags" />}>
<TagsIcon />
Tags
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuLabel>Theme</DropdownMenuLabel>
<DropdownMenuRadioGroup value={theme ?? "system"} onValueChange={(v) => setTheme(v as string)}>
<DropdownMenuRadioItem value="system" closeOnClick={false}>
<MonitorIcon />
System
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="light" closeOnClick={false}>
<SunIcon />
Light
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="dark" closeOnClick={false}>
<MoonIcon />
Dark
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem variant="destructive" disabled={signingOut} onClick={() => startSignOut(() => signOutAction())}>
<LogOutIcon />
{signingOut ? "Signing out…" : "Sign out"}
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}