Release / release (push) Successful in 4m33s
- Dot-matrix "Creation of Adam" page banners behind a floating menu, glass cards and tables, library header with live stats, table toolbar with pagination, Cmd/Ctrl+K search across models, endpoints, runs, tags, settings and actions. - Remove single files from a model (selection + disk, via a worker job). - Containers start as root to prepare folders and drop to PUID:PGID; AUTH_SECRET is generated when unset; sandbox runs as nobody; KANAME_IMAGE and image docs in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
154 lines
5.4 KiB
TypeScript
154 lines
5.4 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { useEffect, useRef, useState } from "react";
|
|
import { cancelJob } from "@/components/job-actions";
|
|
import { JobFilesTable } from "@/components/job-files-table";
|
|
import { JobProgress } from "@/components/job-progress";
|
|
import { PageHero } from "@/components/hero/page-hero";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { useLive } from "@/hooks/use-live";
|
|
import { formatDuration } from "@/lib/format";
|
|
import { LocalTime } from "@/components/local-time";
|
|
import { jobLabel } from "@/lib/job-labels";
|
|
import type { JobSnapshot } from "@/lib/jobs";
|
|
|
|
const OPEN = ["queued", "downloading", "verifying"];
|
|
|
|
export function JobLive({ initial }: { initial: JobSnapshot }) {
|
|
const { snapshot, logs } = useLive({ job: initial.id }, true);
|
|
const job = snapshot?.jobs[0] ?? initial;
|
|
const files = snapshot?.files ?? [];
|
|
const open = OPEN.includes(job.state);
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
const logRef = useRef<HTMLDivElement>(null);
|
|
const [follow, setFollow] = useState(true);
|
|
useEffect(() => {
|
|
if (follow && logRef.current) logRef.current.scrollTop = logRef.current.scrollHeight;
|
|
}, [logs, follow]);
|
|
|
|
// Tick once per second while running so the duration keeps counting.
|
|
const [now, setNow] = useState(() => Date.now());
|
|
useEffect(() => {
|
|
if (job.finishedAt != null) return;
|
|
const t = setInterval(() => setNow(Date.now()), 1000);
|
|
return () => clearInterval(t);
|
|
}, [job.finishedAt]);
|
|
const duration = job.startedAt != null ? ((job.finishedAt ?? now) - job.startedAt) / 1000 : null;
|
|
|
|
return (
|
|
<PageHero
|
|
title={
|
|
<>
|
|
{jobLabel(job)} ·{" "}
|
|
<Link href={`/${job.repoId}`} className="hover:underline">
|
|
{job.repoId}
|
|
</Link>
|
|
</>
|
|
}
|
|
painting={{ view: 0.5, focus: [0.3, 0.55], anchor: [0.7, 0.45] }}
|
|
actions={
|
|
open && (
|
|
<Button
|
|
variant="destructive"
|
|
size="sm"
|
|
disabled={busy || job.cancelRequested}
|
|
onClick={async () => {
|
|
setBusy(true);
|
|
await cancelJob(job.id);
|
|
setBusy(false);
|
|
}}
|
|
>
|
|
{job.cancelRequested ? "Cancelling…" : "Cancel"}
|
|
</Button>
|
|
)
|
|
}
|
|
>
|
|
|
|
<Card>
|
|
<CardContent className="flex flex-col gap-3">
|
|
<JobProgress job={job} />
|
|
<dl className="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-1 text-sm">
|
|
<dt className="text-muted-foreground">Created</dt>
|
|
<dd><LocalTime value={job.createdAt} /></dd>
|
|
<dt className="text-muted-foreground">Started</dt>
|
|
<dd>
|
|
<LocalTime value={job.startedAt} />
|
|
{job.attempt > 1 ? ` (attempt ${job.attempt})` : ""}
|
|
</dd>
|
|
<dt className="text-muted-foreground">Finished</dt>
|
|
<dd><LocalTime value={job.finishedAt} /></dd>
|
|
<dt className="text-muted-foreground">Duration</dt>
|
|
<dd>{formatDuration(duration)}</dd>
|
|
{job.exitCode != null && (
|
|
<>
|
|
<dt className="text-muted-foreground">Exit code</dt>
|
|
<dd className="font-mono">{job.exitCode}</dd>
|
|
</>
|
|
)}
|
|
</dl>
|
|
{job.errorMessage && (
|
|
<pre className="rounded-md bg-destructive/10 px-3 py-2 text-xs whitespace-pre-wrap text-destructive">
|
|
{job.errorMessage}
|
|
</pre>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
|
|
{files.length > 0 && (
|
|
<Card className="py-0">
|
|
<CardHeader className="pt-4">
|
|
<CardTitle>Files</CardTitle>
|
|
</CardHeader>
|
|
<JobFilesTable files={files} />
|
|
</Card>
|
|
)}
|
|
|
|
<Card className="gap-2">
|
|
<CardHeader className="flex flex-row items-center justify-between">
|
|
<CardTitle>Log</CardTitle>
|
|
<div className="flex items-center gap-3 text-sm">
|
|
<label className="flex items-center gap-1.5 text-muted-foreground">
|
|
<input type="checkbox" checked={follow} onChange={(e) => setFollow(e.target.checked)} />
|
|
Follow
|
|
</label>
|
|
<a href={`/api/jobs/${job.id}/log`} className="underline">
|
|
Download full log
|
|
</a>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<div
|
|
ref={logRef}
|
|
className="h-96 overflow-auto rounded-md bg-muted/50 p-3 font-mono text-xs leading-relaxed"
|
|
>
|
|
{logs.length === 0 ? (
|
|
<span className="text-muted-foreground">No output yet.</span>
|
|
) : (
|
|
logs.map((l) => (
|
|
<div
|
|
key={l.id}
|
|
className={
|
|
l.stream === "stderr"
|
|
? "text-amber-700 dark:text-amber-400"
|
|
: l.stream === "system"
|
|
? "text-sky-700 dark:text-sky-400"
|
|
: undefined
|
|
}
|
|
>
|
|
<span className="text-muted-foreground select-none">
|
|
{new Date(l.ts).toLocaleTimeString("en-GB")}{" "}
|
|
</span>
|
|
<span className="whitespace-pre-wrap break-all">{l.line}</span>
|
|
</div>
|
|
))
|
|
)}
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</PageHero>
|
|
);
|
|
}
|