streamd v0.2.2: session uptimes, egress DNS, Support, agent/Widevine
All checks were successful
release / build-and-upload (push) Successful in 7m2s

Dashboard Live uptimes + Recent runs from stream_sessions; overview.recent_sessions.
WireGuard netns resolv.conf + missing-deps WARN. Support donations card.
Agent start/stop/update, job_backoff default off, wvkey ensure/venv, phonecap retries,
modhost YAML enrich, DRM SetCredentials requires keys.
This commit is contained in:
404errordeveloper 2026-10-10 19:26:39 +02:00
parent 3ae1dd58b3
commit a091922efa
34 changed files with 2391 additions and 154 deletions

View file

@ -1,15 +1,26 @@
// Dashboard: the headline numbers, what is scheduled next, and recent events.
import { el, pill, fmtRelative, fmtDateTime, setText, reconcile } from "../util.js";
import {
el, pill, fmtRelative, fmtDateTime, fmtSeconds, setText, reconcile, copyText,
} from "../util.js";
import { state, subscribe, refresh } from "../store.js";
import { timeline } from "../components.js";
const DONATIONS = [
{ coin: "ETH", addr: "0xa6314ce4deaa8329abba301802e3f511b3fa80a6" },
{ coin: "LTC", addr: "ltc1qpm26uccjgn4gx5pqxwzvs89mdp9hcshx9xj5a6" },
{ coin: "BTC", addr: "bc1qzr70ur76jhm5gjsuqelzqaskumpkhkk2ewjgha" },
];
export function dashboard(root) {
const alarmTiles = el("div.tiles");
const trafficTiles = el("div.tiles");
const upcomingBody = el("tbody");
const feed = el("div");
const attention = el("div.stack");
const uptimeBody = el("tbody");
const sessionsBody = el("tbody");
const supportBody = el("div.stack");
root.append(el("div.stack",
el("div.tile-band",
@ -24,6 +35,38 @@ export function dashboard(root) {
el("div.card-head", el("h2", { text: "Needs attention" })),
attention,
),
el("div.card",
el("div.card-head",
el("h2", { text: "Live uptimes" }),
el("span.spacer"),
el("a", { href: "#/streams", text: "All streams" }),
),
el("div.table-wrap",
el("table",
el("thead", el("tr",
el("th", { text: "Stream" }),
el("th", { text: "Health" }),
el("th", { text: "Uptime" }),
)),
uptimeBody,
),
),
),
el("div.card",
el("div.card-head", el("h2", { text: "Recent runs" })),
el("div.table-wrap",
el("table",
el("thead", el("tr",
el("th", { text: "Stream" }),
el("th", { text: "Started" }),
el("th", { text: "Ended" }),
el("th", { text: "Duration" }),
el("th", { text: "Reason" }),
)),
sessionsBody,
),
),
),
el("div.card",
el("div.card-head",
el("h2", { text: "Coming up" }),
@ -46,8 +89,36 @@ export function dashboard(root) {
el("div.card-head", el("h2", { text: "Recent activity" })),
feed,
),
el("div.card",
el("div.card-head", el("h2", { text: "Support the project" })),
el("p.sub", {
text: "If Streamd saves you time, donations keep development going.",
}),
supportBody,
),
));
supportBody.replaceChildren(...DONATIONS.map((d) =>
el("div.row",
el("span.pill", { text: d.coin }),
el("code.mono", { text: d.addr }),
el("span.spacer"),
el("button.tiny.ghost", {
type: "button",
text: "Copy",
onclick: (ev) => copyText(d.addr, d.coin + " address", ev.currentTarget),
}),
),
));
function liveUptimeSeconds(s) {
const health = s.health || "";
if (health !== "ok" && health !== "starting") return null;
const base = Number(s.uptime_s) || 0;
const fetched = state.refreshedAt || Date.now();
return base + Math.max(0, (Date.now() - fetched) / 1000);
}
function paint() {
const t = (state.overview && state.overview.totals) || {};
const streams = state.streams || [];
@ -126,6 +197,75 @@ export function dashboard(root) {
);
}
// Live uptimes: prefer enabled streams; fall back to all if none enabled.
const uptimeRows = (() => {
const enabled = streams.filter((s) => s.enabled);
return (enabled.length ? enabled : streams).slice().sort((a, b) =>
String(a.title || a.name).localeCompare(String(b.title || b.name)));
})();
if (!uptimeRows.length) {
reconcile(uptimeBody, [{ id: "none" }], (x) => x.id,
() => el("tr", el("td.empty", { colspan: "3", text: "No streams yet." })), () => {});
} else {
reconcile(uptimeBody, uptimeRows, (s) => s.id,
() => el("tr",
el("td.who"),
el("td.health"),
el("td.uptime.mono"),
),
(tr, s) => {
const who = tr.querySelector(".who");
who.replaceChildren(el("a", {
href: `#/stream/${s.id}`, text: s.title || s.name,
}));
tr.querySelector(".health").replaceChildren(pill(s.health || "stopped"));
const live = liveUptimeSeconds(s);
setText(tr.querySelector(".uptime"),
live == null ? "—" : fmtSeconds(live));
},
);
}
const sessions = (state.overview && state.overview.recent_sessions) || [];
if (!sessions.length) {
reconcile(sessionsBody, [{ id: "none" }], (x) => x.id,
() => el("tr", el("td.empty", {
colspan: "5",
text: "No completed runs yet — start a stream to begin history.",
})), () => {});
} else {
reconcile(sessionsBody, sessions, (s) => s.id,
() => el("tr",
el("td.who"),
el("td.started"),
el("td.ended"),
el("td.dur.mono"),
el("td.reason"),
),
(tr, s) => {
const who = tr.querySelector(".who");
who.replaceChildren(el("a", {
href: `#/stream/${s.stream_id}`,
text: s.stream_title || s.stream_name || `#${s.stream_id}`,
}));
const started = tr.querySelector(".started");
started.replaceChildren(
el("div", { text: fmtRelative(s.started_at) }),
el("div.sub", { text: fmtDateTime(s.started_at) }),
);
const ended = tr.querySelector(".ended");
ended.replaceChildren(
el("div", { text: fmtRelative(s.ended_at) }),
el("div.sub", { text: fmtDateTime(s.ended_at) }),
);
setText(tr.querySelector(".dur"), fmtSeconds(s.duration_s));
tr.querySelector(".reason").replaceChildren(
pill(s.end_reason || s.health_at_end || "—"),
);
},
);
}
const upcoming = (state.overview && state.overview.upcoming) || [];
if (!upcoming.length) {
reconcile(upcomingBody, [{ id: "none" }], (x) => x.id,
@ -160,8 +300,8 @@ export function dashboard(root) {
const off = subscribe(paint);
paint();
refresh("dashboard");
// Keep the relative times honest without a full refetch.
const tick = setInterval(paint, 30000);
// Keep relative times and live uptimes honest without a full refetch.
const tick = setInterval(paint, 1000);
return () => {
off();
clearInterval(tick);