Hub 2.19.0: the server agent's releases; Update agent picks one

- AgentRelease (migration 20261123150000_agent_release): the agent's releases, apart from the
  products' so licences and billing are untouched.
- Release sources can be for the Server agent; the defaults include it (monorepo agent@ tags,
  apps/agent/WHATS-NEW.md). Same sync rules as products. A saved list without it gets an
  "Add the agent's source" button on the Releases page.
- GET /api/admin/agent-releases; server summaries carry agentLatest; update-agent jobs go to a
  known agent release, the latest when none is asked for (agentTag).
- Update agent is a ReleaseSelect with the chosen version's notes; the Servers list and a server's
  page say when a newer agent is out; the Releases page shows agent releases (Server agent filter,
  Everything newest first by date).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 13:18:56 +02:00
co-authored by Claude Opus 5.5
parent 44fac310eb
commit 65637711c6
19 changed files with 292 additions and 50 deletions
+27 -8
View File
@@ -7,8 +7,10 @@ import { Plus, Trash2, Upload } from "lucide-react";
import { api, errorText } from "@/lib/api";
import { ago, bytes, fmtDate } from "@/lib/format";
import { useServerPaged } from "@/lib/paging";
import { Field, Fields, FormError, Loading, Message, Modal, ModalButtons, PageMessage, PageTitle, Pager, ReadCard, useSubmit } from "@/components/ui";
import { PercentChart, ServersNav, StatusPill, pct, type Deployment, type Job, type ServerSummary } from "@/components/servers";
import { Field, Fields, FormError, Loading, Message, Modal, ModalButtons, PageMessage, PageTitle, Pager, ReadCard, ReleaseNotes, useSubmit } from "@/components/ui";
import { PercentChart, ServersNav, StatusPill, agentUpdate, pct, type Deployment, type Job, type ServerSummary } from "@/components/servers";
import { ReleaseSelect } from "@/components/ReleaseSelect";
import type { AgentRelease } from "@/lib/types";
import { FrpConfig, type FrpState } from "@/components/FrpConfig";
type Msg = { type: "ok" | "err"; text: string } | null;
@@ -69,17 +71,34 @@ function ConfigModal({ id, config, onClose, onSaved }: { id: string; config: Rec
);
}
/** Hub 2.17.0: Update agent in a popup; queuing it opens the job. */
/**
* Hub 2.17.0: Update agent in a popup; queuing it opens the job. 2.19.0: the version is picked from
* the agent's releases (Latest by default; the one running here can't be picked), with its notes.
*/
function UpdateAgentModal({ current, onClose, queue }: { current: string | null; onClose: () => void; queue: (version: string) => Promise<void> }) {
const [version, setVersion] = useState("");
const [releases, setReleases] = useState<AgentRelease[] | null>(null);
const { busy, error, run } = useSubmit();
useEffect(() => { api<AgentRelease[]>("/api/admin/agent-releases").then(setReleases).catch(() => setReleases([])); }, []);
const chosen = releases?.find(r => (version ? r.version === version : r.latest)) || null;
const nothingNew = !version && !!chosen && chosen.version === current;
return (
<Modal title="Update agent" onClose={onClose} dirty={version.trim() !== ""}>
<form onSubmit={e => { e.preventDefault(); run(() => queue(version.trim())); }} className="space-y-3">
<Modal title="Update agent" onClose={onClose} dirty={version !== ""} wide>
<form onSubmit={e => { e.preventDefault(); run(() => queue(version ? `agent@${version}` : "")); }} className="space-y-3">
<p className="text-sm text-slate-600">The agent here is {current || "an unknown version"}. The new version is queued as a job on this server.</p>
<div><label className="label" htmlFor="agent-version">Version</label><input id="agent-version" className="input font-mono" placeholder="agent@1.0.1" value={version} onChange={e => setVersion(e.target.value)} required /></div>
<div>
<label className="label" htmlFor="agent-version">Version</label>
{!releases ? <Loading /> : <ReleaseSelect id="agent-version" releases={releases} value={version} onChange={setVersion} current={current} currentPickable={false} />}
</div>
{chosen && (
<div className="max-h-64 overflow-y-auto rounded-lg border border-slate-200 bg-slate-50 p-3">
<div className="mb-1 text-xs font-medium text-slate-500">What&apos;s new in {chosen.version}{chosen.urgent ? " (urgent)" : ""}</div>
{chosen.notes ? <ReleaseNotes notes={chosen.notes} /> : <p className="text-sm text-slate-500">No notes for this version.</p>}
</div>
)}
{nothingNew && <p className="text-sm text-slate-500">This server already runs the latest agent.</p>}
<FormError error={error} />
<ModalButtons busy={busy} onCancel={onClose} label="Update agent" busyLabel="Queuing…" />
<ModalButtons busy={busy} onCancel={onClose} label="Update agent" busyLabel="Queuing…" disabled={nothingNew} />
</form>
</Modal>
);
@@ -116,7 +135,7 @@ export default function ServerPage() {
return (
<div className="space-y-6">
<div>
<PageTitle title={s.name} subtitle={<>{s.mode === "central" ? "Central server" : "Church server"} · {s.hostname} · agent {s.agentVersion} · last heard {ago(s.lastSeenAt)} <StatusPill status={s.busy ? "busy" : s.online ? "online" : "offline"} /></>} />
<PageTitle title={s.name} subtitle={<>{s.mode === "central" ? "Central server" : "Church server"} · {s.hostname} · agent {s.agentVersion}{agentUpdate(s) && <span className="font-medium text-amber-700"> ({agentUpdate(s)} available)</span>} · last heard {ago(s.lastSeenAt)} <StatusPill status={s.busy ? "busy" : s.online ? "online" : "offline"} /></>} />
<ServersNav active="/servers" />
<PageMessage msg={msg} onClose={() => setMsg(null)} />
</div>