"use client"; import { ArrowUpCircleIcon } from "lucide-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { startUpdate } from "@/components/job-actions"; import { LocalTime } from "@/components/local-time"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import type { UpdateDiff, UpdateDiffFile } from "@/lib/db/schema"; import { formatBytes, shortSha } from "@/lib/format"; function FileGroup({ title, files, tone }: { title: string; files: UpdateDiffFile[]; tone: string }) { if (files.length === 0) return null; return (
{title} ({files.length})
); } /** "Update available": what would change in the selection, and the deliberate Update action. */ export function UpdateBanner({ modelId, revision, pinnedSha, diff, hubUrl, }: { modelId: string; revision: string; pinnedSha: string; diff: UpdateDiff; hubUrl: string; }) { const router = useRouter(); const [busy, setBusy] = useState(false); const changes = diff.changed.length + diff.added.length + diff.removed.length; const download = [...diff.changed, ...diff.added].reduce((s, f) => s + f.size, 0); async function update() { setBusy(true); try { if (await startUpdate(modelId)) router.refresh(); } finally { setBusy(false); } } return (

Update available: {revision} is at{" "} {shortSha(diff.sha)}

You have {shortSha(pinnedSha)}.{" "} {changes === 0 ? "None of your selected files changed; updating only moves the pin." : `${changes} of your selected files would change (${formatBytes(download)} to download).`}{" "} Checked .

}>Update Update to {shortSha(diff.sha)}? The model is pinned to the new commit (the old one stays in the history) and changed or new files are downloaded. Files that are no longer part of your selection are deleted after the download succeeded. Cancel Update
{changes > 0 && (
)}
); }