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
@@ -9,6 +9,7 @@ import { db } from "@/lib/db/client";
import { runMigrations } from "@/lib/db/migrate";
import { ACTIVE_JOB_STATES, jobFiles, jobLogs, jobs, modelFiles, models, workerState } from "@/lib/db/schema";
import { coreEnv } from "@/lib/env";
import { checkHubAvailability, modelsDueForHubCheck } from "@/lib/hub/availability";
import { backfillMetadata } from "@/lib/hub/refresh";
import { DownloadRunner } from "./download";
import { log } from "./log";
@@ -19,6 +20,8 @@ const TICK_MS = 1_000;
/** A lease older than this is considered abandoned (worker crashed without releasing it). */
const LEASE_STALE_MS = 20_000;
const SHUTDOWN_GRACE_MS = 8_000;
/** How often to look for models whose Hub check is due (the check interval itself is configurable). */
const HUB_CHECK_SCAN_MS = 10 * 60_000;
/** Touched on every heartbeat; the Docker healthcheck checks its age. */
const HEALTH_FILE = join(tmpdir(), "kaname-worker-alive");
@@ -208,10 +211,42 @@ async function startJob(job: typeof jobs.$inferSelect) {
log.info(`job ${job.id}: downloading ${model.repoId} (${files.length} files, attempt ${job.attempt})`);
runner
.run()
.then(async () => {
// A failed download may mean the repo or commit is gone from the Hub; find out right away.
const done = await db().query.jobs.findFirst({ columns: { state: true }, where: eq(jobs.id, job.id) });
if (done?.state === "failed") await reportHubCheck(model, await checkHubAvailability(model));
})
.catch((err) => log.error(`job ${job.id} crashed`, err))
.finally(() => runners.delete(job.id));
}
// ---------------------------------------------------------------------------
// Hub availability: flags models whose repo or pinned commit disappeared from the Hub
// ---------------------------------------------------------------------------
function reportHubCheck(model: { repoId: string }, result: Awaited<ReturnType<typeof checkHubAvailability>>) {
if (result.state === null) log.warn(`Hub check for ${model.repoId} failed: ${result.error}`);
else if (result.state !== "available") log.warn(`${model.repoId}: ${result.state.replace("_", " ")} on the Hub (local files kept)`);
}
let checkingHub = false;
async function checkHubDue() {
const hours = coreEnv().UPDATE_CHECK_INTERVAL_HOURS;
if (checkingHub || stopping || hours <= 0) return;
checkingHub = true;
try {
for (const model of await modelsDueForHubCheck(hours * 3_600_000)) {
if (stopping) break;
reportHubCheck(model, await checkHubAvailability(model));
await sleep(1_000); // be gentle with the Hub API
}
} catch (err) {
log.error("Hub check failed", err);
} finally {
checkingHub = false;
}
}
let ticking = false;
async function tick() {
if (ticking || stopping) return;
@@ -278,7 +313,9 @@ async function main() {
await heartbeat();
timers.push(setInterval(() => heartbeat().catch((err) => log.error("heartbeat failed", err)), HEARTBEAT_MS));
timers.push(setInterval(() => void tick(), TICK_MS));
timers.push(setInterval(() => void checkHubDue(), HUB_CHECK_SCAN_MS));
void tick();
setTimeout(() => void checkHubDue(), 15_000);
}
function sleep(ms: number) {