- 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>
116 lines
4.1 KiB
TypeScript
116 lines
4.1 KiB
TypeScript
"use client";
|
|
|
|
import { DownloadIcon } from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useState } from "react";
|
|
import { cancelJob, startDownload } from "@/components/job-actions";
|
|
import { JobProgress, JobStateBadge } from "@/components/job-progress";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Progress } from "@/components/ui/progress";
|
|
import { useLive } from "@/hooks/use-live";
|
|
import type { ModelStatus } from "@/lib/db/schema";
|
|
import { groupJobFiles } from "@/lib/file-groups";
|
|
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,
|
|
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];
|
|
const open = latest && OPEN.includes(latest.state) ? latest : undefined;
|
|
const files = open ? groupJobFiles(snapshot?.files ?? []) : [];
|
|
|
|
async function run(fn: () => Promise<void>) {
|
|
setBusy(true);
|
|
try {
|
|
await fn();
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
let hint = "Downloads the selected files at the pinned commit.";
|
|
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">
|
|
<div className="flex items-center justify-between gap-2">
|
|
<h3 className="flex items-center gap-1.5 text-sm font-semibold">
|
|
<DownloadIcon className="size-4 text-muted-foreground" />
|
|
Download
|
|
</h3>
|
|
{latest && <JobStateBadge job={latest} />}
|
|
</div>
|
|
<p className="text-xs text-muted-foreground">{hint}</p>
|
|
|
|
{latest && !(latest.state === "completed" && status === "ready") && <JobProgress job={latest} compact />}
|
|
|
|
{latest?.state === "failed" && latest.errorMessage && (
|
|
<pre className="max-h-40 overflow-auto rounded-md bg-destructive/10 px-2.5 py-2 text-xs whitespace-pre-wrap text-destructive">
|
|
{latest.errorMessage}
|
|
</pre>
|
|
)}
|
|
|
|
{files.length > 0 && (
|
|
<ul className="flex flex-col gap-1.5">
|
|
{files.map((f) => (
|
|
<li key={f.path} className="flex flex-col gap-1">
|
|
<div className="flex justify-between gap-2 text-xs">
|
|
<span className="truncate font-mono" title={f.path}>
|
|
{f.path}
|
|
{f.parts > 1 && <span className="text-muted-foreground"> · {f.parts} parts</span>}
|
|
</span>
|
|
<span className="shrink-0 text-muted-foreground tabular-nums">{formatBytes(f.expectedBytes)}</span>
|
|
</div>
|
|
<Progress value={percent(f.doneBytes, f.expectedBytes)} />
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
|
|
<div className="flex flex-wrap gap-2">
|
|
{open ? (
|
|
<Button
|
|
variant="destructive"
|
|
size="sm"
|
|
disabled={busy || open.cancelRequested}
|
|
onClick={() => run(() => cancelJob(open.id))}
|
|
>
|
|
{open.cancelRequested ? "Cancelling…" : "Cancel"}
|
|
</Button>
|
|
) : (
|
|
status !== "ready" &&
|
|
!hubMissing &&
|
|
snapshot && (
|
|
<Button size="sm" disabled={busy} onClick={() => run(() => startDownload(modelId))}>
|
|
{latest ? "Download again" : "Download"}
|
|
</Button>
|
|
)
|
|
)}
|
|
{latest && (
|
|
<Link
|
|
href={`/jobs/${latest.id}`}
|
|
className="inline-flex h-7 items-center rounded-md px-2.5 text-[0.8rem] hover:bg-muted"
|
|
>
|
|
View log
|
|
</Link>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|