Add a weekly digest and report which version of the agent each server runs

- Weekly digest through the notification channels: alerts now, a week of uptime, what happened, disks
  heading for full, expiring secrets and domains, updates waiting, planned maintenance. Off until switched
  on in Settings -> Notifications; Preview and Send it now there. Setting key 'digest'.
- Agents say their version in every report (Linux and Windows scripts are version 2); the server compares
  it with the scripts it serves and marks agents that are behind on the Servers, server and Updates pages.
  servers.agent_version, migration 0026.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-17 19:49:36 +02:00
1 parent 3da5c639b1
commit aa94d84f6c
28 files changed
+3179 -19

No files matched your search

+24 -5
View File
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DockhandContainer, type UpdatesServer } from "../api/client";
import { api, type AgentLatest, type DockhandContainer, type UpdatesServer } from "../api/client";
import { agentState, agentVersionWords } from "../utils/agent";
import SortableTh from "../components/SortableTh";
import TableToolbar from "../components/TableToolbar";
import TimeAgo from "../components/TimeAgo";
@@ -24,6 +25,7 @@ interface Row {
/** ISO — when updates were first seen waiting. */
since: string | null;
reportedAt: string | null;
agentVersion: number | null;
server: UpdatesServer;
}
@@ -38,6 +40,7 @@ function toRow(s: UpdatesServer): Row {
restart: s.updates?.rebootRequired ?? false,
since: s.pendingSince,
reportedAt: s.updates?.reportedAt || null,
agentVersion: s.agentVersion,
server: s,
};
}
@@ -51,6 +54,7 @@ const DAY_MS = 86_400_000;
*/
export default function Updates() {
const [servers, setServers] = useState<UpdatesServer[] | null>(null);
const [agentLatest, setAgentLatest] = useState<AgentLatest | null>(null);
const [containers, setContainers] = useState<(DockhandContainer & { integrationName: string })[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [onlyWaiting, setOnlyWaiting] = useState(false);
@@ -59,7 +63,11 @@ export default function Updates() {
let alive = true;
api.servers
.updates()
.then((res) => alive && setServers(res.servers))
.then((res) => {
if (!alive) return;
setServers(res.servers);
setAgentLatest(res.agentLatest);
})
.catch((err) => alive && setError(readableError(err)));
api.integrations
.list()
@@ -91,6 +99,7 @@ export default function Updates() {
const restarts = rows.filter((r) => r.restart).length;
const oldest = waiting.map((r) => r.since).filter((s): s is string => !!s).sort()[0];
const notReporting = rows.length - reporting;
const behind = rows.filter((r) => agentState(r.server, agentLatest) === "behind").length;
function exportCsv() {
if (!sorted) return;
@@ -105,6 +114,7 @@ export default function Updates() {
{ label: "Servers with updates waiting", value: servers ? `${waiting.length} of ${reporting}` : "…", note: notReporting > 0 ? `${notReporting} haven't reported updates` : undefined, color: waiting.length > 0 ? "text-yellow" : "text-green" },
{ label: "Security updates waiting", value: servers ? securityTotal : "…", color: securityTotal > 0 ? "text-red" : "text-green" },
{ label: "Need a restart", value: servers ? restarts : "…", color: restarts > 0 ? "text-orange" : "text-green" },
{ label: "Agents to update", value: servers ? behind : "…", note: behind > 0 ? "run their install command again" : undefined, color: behind > 0 ? "text-yellow" : "text-green" },
{ label: "Longest wait", value: oldest ? `${Math.max(1, Math.floor((Date.now() - Date.parse(oldest)) / DAY_MS))} d` : servers ? "—" : "…", color: "text-secondary" },
];
@@ -120,7 +130,7 @@ export default function Updates() {
<div className="row row-cards mb-3">
{cards.map((c) => (
<div className="col-6 col-lg-3" key={c.label}>
<div className="col-6 col-lg" key={c.label}>
<div className="card card-sm">
<div className="card-body">
<div className={`h2 mb-0 ${c.color}`}>{c.value}</div>
@@ -157,12 +167,13 @@ export default function Updates() {
<SortableTh<Row> label="Security" sortKeyName="security" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Waiting since" sortKeyName="since" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Reported" sortKeyName="reportedAt" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
<SortableTh<Row> label="Agent" sortKeyName="agentVersion" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
</tr>
</thead>
<tbody>
{servers === null && !error && (
<tr>
<td colSpan={5}>
<td colSpan={6}>
<BlockSkeleton lines={3} />
</td>
</tr>
@@ -178,11 +189,19 @@ export default function Updates() {
<td>{r.security === null ? <span className="text-secondary">—</span> : r.security}</td>
<td className="text-secondary">{r.since ? <TimeAgo value={r.since} /> : "—"}</td>
<td className="text-secondary">{r.reportedAt ? <TimeAgo value={r.reportedAt} /> : "—"}</td>
<td>
{agentVersionWords(r.agentVersion)}{" "}
{agentState(r.server, agentLatest) === "behind" && (
<span className="badge bg-yellow-lt text-yellow" title="Older than the agent this Homelab Manager would install now.">
behind
</span>
)}
</td>
</tr>
))}
{servers !== null && sorted?.length === 0 && (
<tr>
<td colSpan={5} className="text-secondary text-center">
<td colSpan={6} className="text-secondary text-center">
{tableSearch.active || onlyWaiting ? "Nothing matches that." : "No server has reported yet."}
</td>
</tr>