Release / release (push) Successful in 3m0s
Scopes deployments:read/write and benchmarks:read/run; /api/v1 endpoints for runtimes, deployments (create with dry run, edit, start, stop, delete own ones), benchmark runs, A/B, sweeps and comparisons; ?wait= on all status endpoints. Guardrails: approval, agent deployments at once, one GPU job at a time, time limits, sweep variants, runtime and argument allowlists, host port range, memory/CPU caps, protected deployments with a VRAM check. Requested-by filters, approval bars, per-token activity log, scope editing, docs/agent/SKILL-tuning.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
211 lines
7.4 KiB
TypeScript
211 lines
7.4 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
ExternalLinkIcon,
|
|
PlayIcon,
|
|
RocketIcon,
|
|
SquareIcon,
|
|
} from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useEffect, useState } from "react";
|
|
import { DeploymentStateBadge } from "@/components/deployment-state";
|
|
import { RequestedByBadge } from "@/components/requested-by-badge";
|
|
import { NativeSelect } from "@/components/ui/native-select";
|
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
import { Card } from "@/components/ui/card";
|
|
import { useHostname, webUiUrl } from "@/hooks/use-hostname";
|
|
import type { DeploymentRow } from "@/lib/deployments";
|
|
import { formatBytes } from "@/lib/format";
|
|
import { quantGroup } from "@/lib/selection";
|
|
import { startDeployment, stopDeployment } from "./actions";
|
|
|
|
type Row = Omit<
|
|
DeploymentRow,
|
|
"startedAt" | "readyAt" | "stoppedAt" | "createdAt"
|
|
> & {
|
|
startedAt: string | null;
|
|
readyAt: string | null;
|
|
stoppedAt: string | null;
|
|
createdAt: string;
|
|
};
|
|
|
|
const isActive = (r: Row) =>
|
|
r.desiredState === "running" ||
|
|
r.state === "starting" ||
|
|
r.state === "running" ||
|
|
r.state === "stopping";
|
|
|
|
/** Live list (polls every 2 s while something is starting/stopping, else every 5 s). */
|
|
export function DeploymentList({ rows: initial }: { rows: Row[] }) {
|
|
const [rows, setRows] = useState(initial);
|
|
// "" = everything, "-" = created in the UI, else a token name.
|
|
const [by, setBy] = useState("");
|
|
const tokens = [
|
|
...new Set(rows.map((r) => r.requestedBy).filter((x): x is string => !!x)),
|
|
].sort();
|
|
const shown = rows.filter(
|
|
(r) => !by || (by === "-" ? !r.requestedBy : r.requestedBy === by),
|
|
);
|
|
const hostname = useHostname();
|
|
const busy = rows.some(
|
|
(r) =>
|
|
r.state === "starting" ||
|
|
r.state === "stopping" ||
|
|
(r.desiredState === "running") !== (r.state === "running"),
|
|
);
|
|
|
|
async function reload() {
|
|
const res = await fetch("/api/deployments", { cache: "no-store" }).catch(
|
|
() => null,
|
|
);
|
|
if (res?.ok) setRows(await res.json());
|
|
}
|
|
useEffect(() => {
|
|
const t = setInterval(reload, busy ? 2_000 : 5_000);
|
|
return () => clearInterval(t);
|
|
}, [busy]);
|
|
|
|
if (rows.length === 0) {
|
|
return (
|
|
<Card className="items-center gap-3 py-10 text-center">
|
|
<RocketIcon className="size-8 text-muted-foreground" />
|
|
<p className="text-sm text-muted-foreground">
|
|
No deployments yet. Pick a runtime and a downloaded model to start
|
|
one.
|
|
</p>
|
|
<Link href="/deployments/new" className="text-sm underline">
|
|
New deployment
|
|
</Link>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col gap-3">
|
|
{tokens.length > 0 && (
|
|
<label className="flex items-center gap-2 self-end text-xs text-muted-foreground">
|
|
Requested by
|
|
<NativeSelect
|
|
value={by}
|
|
onChange={(e) => setBy(e.target.value)}
|
|
className="h-7 text-xs"
|
|
aria-label="Requested by"
|
|
>
|
|
<option value="">Anyone</option>
|
|
<option value="-">Created in Kaname</option>
|
|
{tokens.map((t) => (
|
|
<option key={t} value={t}>
|
|
{t} (API)
|
|
</option>
|
|
))}
|
|
</NativeSelect>
|
|
</label>
|
|
)}
|
|
<div className="grid gap-3 md:grid-cols-2">
|
|
{shown.map((r) => {
|
|
const file = r.options.modelFile
|
|
? (quantGroup(r.options.modelFile) ?? r.options.modelFile)
|
|
: null;
|
|
const loadSecs =
|
|
r.readyAt && r.startedAt
|
|
? (new Date(r.readyAt).getTime() -
|
|
new Date(r.startedAt).getTime()) /
|
|
1000
|
|
: null;
|
|
return (
|
|
<Card key={r.id} className="gap-3 px-4 py-3">
|
|
<div className="flex items-start justify-between gap-3">
|
|
<div className="flex min-w-0 flex-col gap-0.5">
|
|
<Link
|
|
href={`/deployments/${r.id}`}
|
|
className="truncate font-medium hover:underline"
|
|
>
|
|
{r.name}
|
|
</Link>
|
|
<span className="truncate text-xs text-muted-foreground">
|
|
{r.repoId}
|
|
{file && ` · ${file}`}
|
|
{r.options.mmproj && " · vision"}
|
|
{r.options.draftFile && " · MTP/draft"}
|
|
</span>
|
|
<span className="flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground">
|
|
{r.runtimeName}
|
|
<RequestedByBadge
|
|
name={r.requestedBy}
|
|
className="h-4 text-[10px]"
|
|
/>
|
|
{r.protected && (
|
|
<span className="text-emerald-700 dark:text-emerald-300">
|
|
protected
|
|
</span>
|
|
)}
|
|
{r.startRequestedAt && (
|
|
<span className="text-amber-700 dark:text-amber-300">
|
|
start awaits approval
|
|
</span>
|
|
)}
|
|
</span>
|
|
</div>
|
|
<DeploymentStateBadge
|
|
state={r.state}
|
|
desiredState={r.desiredState}
|
|
/>
|
|
</div>
|
|
<div className="flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground">
|
|
<span className="tabular-nums">
|
|
{r.state === "running" && r.stats
|
|
? `CPU ${(r.stats.cpuPercent / 100).toFixed(1)} cores · RAM ${formatBytes(r.stats.memoryBytes)}${r.memoryMb ? ` / ${formatBytes(r.memoryMb * 2 ** 20)}` : ""}`
|
|
: r.state === "failed"
|
|
? (r.error?.split("\n")[0] ?? "failed")
|
|
: `ctx ${r.options.contextSize}${r.memoryMb ? ` · ${formatBytes(r.memoryMb * 2 ** 20)} RAM` : ""}`}
|
|
{r.state === "running" &&
|
|
loadSecs != null &&
|
|
` · loaded in ${loadSecs.toFixed(1)} s`}
|
|
</span>
|
|
<span className="flex items-center gap-1.5">
|
|
{r.state === "running" && webUiUrl(r, hostname) && (
|
|
<a
|
|
href={webUiUrl(r, hostname)!}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className={buttonVariants({
|
|
size: "xs",
|
|
variant: "outline",
|
|
})}
|
|
>
|
|
<ExternalLinkIcon />
|
|
Web UI
|
|
</a>
|
|
)}
|
|
{isActive(r) ? (
|
|
<Button
|
|
size="xs"
|
|
variant="outline"
|
|
onClick={async () =>
|
|
(await stopDeployment(r.id)) && reload()
|
|
}
|
|
>
|
|
<SquareIcon />
|
|
Stop
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
size="xs"
|
|
onClick={async () =>
|
|
(await startDeployment(r.id)) && reload()
|
|
}
|
|
>
|
|
<PlayIcon />
|
|
Start
|
|
</Button>
|
|
)}
|
|
</span>
|
|
</div>
|
|
</Card>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|