Hub: the Kanban and the Journal tabs, and /hub/journal.json

Kanban: every open issue and pull request and what closed in the last seven days, placed in To do,
In progress, In review and Done by the rules of Kira's work board, each card with its roadmap item
(its roadmap:<id> label or the item linking it) and a filter by item. Journal: every release with its
changes grouped by roadmap item, the merges no release has yet, and a weekly summary from
roadmap/journal/<year>-<week>.md. The same journal is /hub/journal.json, for Kira's #updates and posts
elsewhere: each entry names the roadmap items it moved and shipped, with their 240-character text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 15:35:27 +01:00
parent 68234ac407
commit c04b7afdb9
12 changed files with 435 additions and 7 deletions
+198
View File
@@ -4,6 +4,8 @@
// twice: `plain` (.hub-plain) for players and `dev` (.hub-dev) for contributors; the page's Simple / Technical
// switch shows one of them.
import { escape, inline } from "./markdown.js";
import { parts, plainItem, sections } from "./releases.js";
import { isGame, isLauncher } from "./versions.js";
export const REPO = "ludovic111/horizon";
const issueUrl = (n) => `https://github.com/${REPO}/issues/${n}`;
@@ -173,3 +175,199 @@ export function helpWantedHtml(roadmap) {
})
.join("");
}
// --- The work board --------------------------------------------------------------------------------------------
export const COLUMNS = [
{ id: "todo", name: "To do", about: "Open and free: pick one, and say so with /claim on Discord." },
{ id: "progress", name: "In progress", about: "Claimed, assigned, or a draft pull request." },
{ id: "review", name: "In review", about: "A pull request is ready for review." },
{ id: "done", name: "Done", about: "Closed or merged in the last seven days." },
];
const DONE_DAYS = 7;
// The roadmap item an issue or pull request moves: its roadmap:<id> label, else the item linking it, else (for a
// pull request) the item linking an issue it fixes.
export function itemOf(issue, roadmap) {
const label = issue.labels.find((l) => l.startsWith("roadmap:"));
const ids = new Set(roadmap.items.map((i) => i.id));
if (label && ids.has(label.slice(8))) return label.slice(8);
const linking = (n) => roadmap.items.find((i) => (i.links || []).includes(`#${n}`))?.id;
return linking(issue.n) || issue.fixes.map(linking).find(Boolean) || null;
}
// The board from GitHub's open issues and pull requests and those closed lately, placed as Kira's work board places
// them: an issue goes to review when an open, ready pull request fixes it, to progress when a draft one does or it is
// claimed or assigned; a pull request that fixes no open issue is a card of its own.
export function boardFrom(list, roadmap, now = Date.now()) {
const columns = Object.fromEntries(COLUMNS.map((c) => [c.id, []]));
const open = list.filter((i) => i.state === "open");
const openIssues = new Set(open.filter((i) => i.kind === "issue").map((i) => i.n));
const fixing = (n) => open.filter((p) => p.kind === "pr" && p.fixes.includes(n));
const card = (i, prs = []) => ({ n: i.n, kind: i.kind, title: i.title, user: i.user, url: i.url, item: itemOf(i, roadmap) || prs.map((p) => itemOf(p, roadmap)).find(Boolean) || null, prs: prs.map((p) => p.n) });
for (const i of open) {
if (i.kind === "issue") {
const prs = fixing(i.n);
const claimed = i.assigned || i.labels.some((l) => /^(in progress|claimed)$/i.test(l));
const column = prs.some((p) => !p.draft) ? "review" : prs.length || claimed ? "progress" : "todo";
columns[column].push(card(i, prs));
} else if (!i.fixes.some((n) => openIssues.has(n))) {
columns[i.draft ? "progress" : "review"].push(card(i));
}
}
const since = now - DONE_DAYS * 864e5;
const seen = new Set();
for (const i of list) {
if (seen.has(i.n) || !["merged", "closed"].includes(i.state) || !(Date.parse(i.at) >= since)) continue;
seen.add(i.n);
columns.done.push(card(i));
}
columns.done.sort((a, b) => b.n - a.n);
return columns;
}
const SHOWN = 20; // cards per column before "Show more"
function cardHtml(c, roadmap, more) {
const item = c.item && roadmap.items.find((i) => i.id === c.item);
return `<li class="hub-card" data-item="${escape(c.item || "")}"${more ? " data-more" : ""}><a href="${escape(c.url)}"><span class="hub-card-ref">${c.kind === "pr" ? "PR" : "Issue"} #${c.n}${c.prs.length ? ` · ${c.prs.map((n) => `PR #${n}`).join(", ")}` : ""}</span><span class="hub-card-title">${escape(c.title)}</span><span class="hub-card-meta">${item ? `<span class="hub-card-item">${escape(item.title)}</span>` : ""}${c.user ? `<span>${escape(c.user)}</span>` : ""}</span></a></li>`;
}
export function boardHtml(columns, roadmap) {
return COLUMNS.map(({ id, name, about }) => {
const cards = columns[id];
return `<section class="hub-column" data-column="${id}" aria-labelledby="col-${id}">
<h3 id="col-${id}"><span>${escape(name)}</span><span class="hub-count" data-count>${cards.length}</span></h3>
<p class="meta">${escape(about)}</p>
<ol class="hub-cards-list">${cards.map((c, i) => cardHtml(c, roadmap, i >= SHOWN)).join("")}</ol>
${cards.length > SHOWN ? `<button type="button" class="button secondary small hub-more" data-more-button>Show ${cards.length - SHOWN} more</button>` : ""}
</section>`;
}).join("\n");
}
// The board's roadmap filter: every item that has a card.
export function boardFilterHtml(columns, roadmap) {
const used = new Set(Object.values(columns).flat().map((c) => c.item).filter(Boolean));
return [`<option value="">Every card</option>`, `<option value="-">Cards of a roadmap item</option>`]
.concat(roadmap.items.filter((i) => used.has(i.id)).map((i) => `<option value="${escape(i.id)}">${escape(i.title)}</option>`))
.join("");
}
// --- The journal -----------------------------------------------------------------------------------------------
export const JOURNAL_URL = "https://playhorizon.dev/hub#journal";
const ENTRIES = 40;
// The journal, newest first: each release with its changes grouped by roadmap item, the weekly summaries
// (roadmap/journal/), and what merged since the newest game release. releases: GitHub's release objects; list: the
// hub's issues and pull requests (their roadmap:<id> labels place changes the roadmap doesn't link).
export function journalFrom(releases, list, roadmap) {
const prs = new Map(list.filter((i) => i.kind === "pr").map((i) => [i.n, i]));
const placed = (numbers) => {
for (const n of numbers) {
const known = prs.get(n);
const id = known ? itemOf(known, roadmap) : roadmap.items.find((i) => (i.links || []).includes(`#${n}`))?.id;
if (id) return id;
}
return null;
};
const ours = releases.filter((r) => !r.draft && (isGame(r.tag_name) || isLauncher(r.tag_name)));
const entries = ours.map((r) => {
const changes = sections(r.body)
.filter((x) => /^(new|what's new|fixed)/i.test(x.title))
.flatMap((x) => x.items.map((text) => ({ section: /^fixed/i.test(x.title) ? "fixed" : "new", text })))
.map((c) => {
const numbers = [...c.text.matchAll(/#(\d+)/g)].map((m) => Number(m[1]));
return { ...c, text: plainItem(c.text), prs: numbers, item: placed(numbers) };
});
return {
id: r.tag_name,
kind: isLauncher(r.tag_name) ? "launcher" : "release",
date: r.published_at || "",
title: r.name || r.tag_name,
plain: parts(r).line,
url: r.html_url,
changes,
shipped: roadmap.items.filter((i) => i.status === "shipped" && i.shipped_in === r.tag_name).map((i) => i.id),
};
});
// Merged but in no release's notes yet: a release is cut from main a while after its last merge, so the newest
// releases' notes, not their dates, say what they hold. Pull requests players don't see (skip-release) never are.
const games = ours.filter((r) => isGame(r.tag_name)).map((r) => r.published_at).sort().reverse();
const since = games[Math.min(4, games.length - 1)] || "";
const noted = new Set(entries.flatMap((e) => e.changes.flatMap((c) => c.prs)));
const pending = list
.filter((i) => i.kind === "pr" && i.state === "merged" && i.at > since && !noted.has(i.n) && !i.labels.includes("skip-release"))
.sort((a, b) => b.at.localeCompare(a.at));
if (pending.length) {
entries.push({
id: "next-release",
kind: "merged",
date: pending[0].at,
title: "Merged, in the next release",
plain: `${pending.length} change${pending.length === 1 ? "" : "s"} merged since the last release.`,
url: `https://github.com/${REPO}/pulls?q=is%3Apr+is%3Amerged`,
changes: pending.map((p) => ({ section: "merged", text: p.title, prs: [p.n], item: itemOf(p, roadmap) })),
shipped: [],
});
}
for (const w of roadmap.journal || []) {
// A week's summary sits after its last day's releases.
const end = new Date(Date.parse(w.date) + 7 * 864e5 - 1).toISOString();
entries.push({ id: `week-${w.week}`, kind: "week", date: end, title: w.title, plain: w.plain, dev: w.dev, url: `${JOURNAL_URL.replace("#journal", "")}#week-${w.week}`, changes: [], shipped: [] });
}
return entries.sort((a, b) => b.date.localeCompare(a.date)).slice(0, ENTRIES);
}
// /hub/journal.json: the journal for Kira's #updates and posts elsewhere, with each shipped item's short text.
export function journalJson(entries, roadmap, generated = new Date().toISOString()) {
const item = (id) => {
const i = roadmap.items.find((x) => x.id === id);
return i && { id: i.id, title: i.title, plain: i.plain, post: i.post || i.plain };
};
return {
format: "horizon-journal",
version: 1,
generated,
url: JOURNAL_URL,
entries: entries.map((e) => ({ ...e, items: [...new Set(e.changes.map((c) => c.item).filter(Boolean))].map(item).filter(Boolean), shipped: e.shipped.map(item).filter(Boolean) })),
};
}
const KIND = { release: "Game", launcher: "Launcher", merged: "Merged", week: "This week" };
function changesHtml(entry, roadmap) {
if (!entry.changes.length) return "";
const line = (c) => `<li>${inline(c.text)}${c.prs.length ? ` ${c.prs.map((n) => `<a class="hub-ref" href="${issueUrl(n)}">#${n}</a>`).join(" ")}` : ""}</li>`;
// Simple: what is new, then how many fixes. Technical: every change, under the roadmap item it moves.
const added = entry.changes.filter((c) => c.section !== "fixed");
const fixes = entry.changes.length - added.length;
const simple = `<div class="hub-plain">${added.length ? `<ul class="hub-changes">${added.map((c) => `<li>${inline(c.text)}</li>`).join("")}</ul>` : ""}${fixes ? `<p class="meta">${added.length ? "And " : ""}${fixes} fix${fixes === 1 ? "" : "es"}.</p>` : ""}</div>`;
const groups = new Map();
for (const c of entry.changes) groups.set(c.item || "", [...(groups.get(c.item || "") || []), c]);
const order = [...groups.keys()].sort((a, b) => (a === "") - (b === ""));
const dev = `<div class="hub-dev">${order
.map((id) => {
const item = roadmap.items.find((i) => i.id === id);
return `<p class="hub-group">${item ? `<a href="#item-${escape(id)}">${escape(item.title)}</a>` : "Other changes"}</p><ul class="hub-changes">${groups.get(id).map(line).join("")}</ul>`;
})
.join("")}</div>`;
return simple + dev;
}
export function journalHtml(entries, roadmap) {
return entries
.map((e) => {
const shipped = e.shipped.map((id) => roadmap.items.find((i) => i.id === id)).filter(Boolean);
const items = [...new Set(e.changes.map((c) => c.item).filter(Boolean))].map((id) => roadmap.items.find((i) => i.id === id)).filter(Boolean);
return `<article class="hub-entry hub-entry-${e.kind}" id="${e.kind === "week" ? escape(e.id) : `journal-${escape(e.id.replace(/[^\w.-]/g, "-"))}`}">
<p class="hub-entry-meta"><span class="badge${e.kind === "release" ? " badge-game" : e.kind === "launcher" ? " badge-launcher" : ""}">${KIND[e.kind]}</span><time datetime="${escape(e.date)}">${escape(e.date.slice(0, 10))}</time></p>
<h3 class="hub-entry-title">${e.url ? `<a href="${escape(e.url)}">${escape(e.title)}</a>` : escape(e.title)}</h3>
${e.kind === "week" ? `<p class="hub-plain">${inline(e.plain)}</p><p class="hub-dev">${inline(e.dev.replace(/(^|[^\w[/`])#(\d+)\b/g, (_, b, n) => `${b}[#${n}](${issueUrl(n)})`))}</p>` : ""}
${shipped.length ? `<p class="hub-shipped">Shipped: ${shipped.map((i) => `<a href="#item-${escape(i.id)}">${escape(i.title)}</a>`).join(", ")}</p>` : ""}
${items.length ? `<p class="hub-entry-items hub-plain">${items.map((i) => `<a class="hub-link" href="#item-${escape(i.id)}">${escape(i.title)}</a>`).join("")}</p>` : ""}
${changesHtml(e, roadmap)}
</article>`;
})
.join("\n");
}