From c1ffa17c87bcef7d2d564644123c3142c169b0d3 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:14:12 +0100 Subject: [PATCH] Hub: vote for roadmap items, report a bug and suggest something from the page Each item still to come gets a "Want it" button with its count; the Contribute tab gets a bug report form (the #horizon-bugs template, which the telemetry server opens as a GitHub issue and links back) and a suggestion form (to the private queue Kira relays), and a Contributors list that shows the Discord name of those who agreed on Kira (/contributors.json). The forms and buttons appear once the hub's server answers; until then the page points to GitHub and Discord. roadmap/README.md documents the intake API that Kira shares. Co-Authored-By: Claude Opus 5.5 --- roadmap/README.md | 29 ++++++++- tools/roadmap.py | 3 +- website/build.mjs | 19 +++++- website/src/contributors.js | 2 +- website/src/hub-page.js | 120 ++++++++++++++++++++++++++++++++++++ website/src/hub.html | 43 ++++++++++++- website/src/hub.js | 41 +++++++++++- website/src/hub.test.mjs | 22 ++++++- website/src/style.css | 25 +++++++- 9 files changed, 293 insertions(+), 11 deletions(-) diff --git a/roadmap/README.md b/roadmap/README.md index 55cf9d09f..22cde1a7d 100644 --- a/roadmap/README.md +++ b/roadmap/README.md @@ -54,8 +54,8 @@ Whoever moves the work (the orchestrator on each heartbeat, or anyone in their p `2026-43.md`): `# Title`, a paragraph or two for players, then `## Technical` and the same week for contributors, with its pull requests. `build` puts it into website/data/roadmap.json; the hub's Journal tab shows it among the releases, and `/data/journal.json` carries it to Kira's #updates and to X. -6. Suggestions from the website and Discord are read and triaged by the maintainers. A good one becomes an - item in a normal pull request; none is published automatically. +6. Suggestions from the website and Discord reach the maintainers' private channel through Kira (below). A good + one becomes an item in a normal pull request; none is published automatically. CI runs `tests/test_roadmap.py` (in the Python tests), which fails when ROADMAP.md is not what `build` writes or when the file breaks a rule; `python3 tools/roadmap.py check --offline` runs the same rules without GitHub. @@ -89,3 +89,28 @@ merged pull request, release, shipped item and weekly summary, newest first, the - `announce: true` (the item's `announce` key) asks Kira to post the shipped item on X too, with `post`. - `https://playhorizon.dev/data/roadmap.json` is `roadmap.toml` as JSON (`areas`, `items` with every key above, `overview`, the weekly summaries); an item's page is `https://playhorizon.dev/hub#`. + +## The intake: votes, bug reports, suggestions + +The hub's forms and vote buttons talk to the telemetry server (`https://telemetry.playhorizon.dev`, +`crates/horizon-telemetry-server`, `src/hub.rs` and `src/intake.rs`; its README lists the limits and settings). +Kira uses the same endpoints, so a bug or an idea goes the same way from the site and from Discord. + +| Endpoint | Body | Answer | +| --- | --- | --- | +| `POST /hub/vote` | `{"item": "", "voter": "", "up": true}` | `{"item", "votes"}`; `"up": false` takes the vote back | +| `GET /hub/votes` | | `{"votes": {"": n}}`, a minute old at most | +| `POST /hub/report` | `{"title", "did", "happened", "expected", "version"?, "system", "name"?}` | 201 `{"id", "issue": ""}`; 202 `{"id", "issue": null}` when GitHub was down (opened later) | +| `POST /hub/suggest` | `{"text", "item"?, "name"?}` | 202 `{"id"}` | +| `GET /hub/suggestions?after=` | `Authorization: Bearer ` | `{"suggestions": [{"id", "text", "item"?, "name"?, "created_at"}]}`, oldest first | + +- A report becomes an issue at once, labels `bug` and `from-website`, in the `#horizon-bugs` template (What I did, + What happened, What I expected, Horizon version, OS, CPU, GPU) with "Reported on playhorizon.dev". Every field + but the version and the name is required; mentions, `#123` references and HTML in people's text are made inert. +- Suggestions are never published. Kira polls `/hub/suggestions` with the last id it relayed and posts each one + to `#roadmap-suggestions`. +- Errors are `{"error": "…"}`: 400 names the field (`"did: 3 to 2000 characters"`), 429 means too many from that + address, 503 a full day or reports turned off (no GitHub token on the server). +- The page shows the forms and the buttons only once `GET /hub/votes` answers. Until then it points to GitHub and + Discord. It keeps a random voter id and the items it voted for in `localStorage` (`hub:voter`, `hub:voted`). + diff --git a/tools/roadmap.py b/tools/roadmap.py index fe97285ff..4bc439e4d 100644 --- a/tools/roadmap.py +++ b/tools/roadmap.py @@ -56,7 +56,8 @@ ITEM_KEYS = {"id", "title", "status", "area", "plain", "dev", "links", "focus", ISSUE = re.compile(r"#(\d+)$") ID = re.compile(r"[a-z0-9]+(-[a-z0-9]+)*$") # An item is the anchor playhorizon.dev/hub#: it can't take the name of a tab, a section or a heading. -RESERVED = {"main", "overview", "roadmap", "board", "journal", "contribute", "hub-data", *STATUSES} +RESERVED = {"main", "overview", "roadmap", "board", "journal", "contribute", "report", "suggest", "contributors", + "hub-data", *STATUSES} RESERVED_PREFIXES = ("h-", "tab-", "col-", "week-", "journal-") RELEASE = re.compile(r"(v\d[\w.]*|launcher@\d[\w.]*|launcher-v\d[\w.]*|website)$") MONTHS = ("January|February|March|April|June|July|August|September|October|November|December") diff --git a/website/build.mjs b/website/build.mjs index c3203891e..b766b3d79 100644 --- a/website/build.mjs +++ b/website/build.mjs @@ -16,7 +16,7 @@ import { machinesHtml, playersHtml } from "./src/bench.js"; import { CPUS, GPUS, singleThread } from "./src/hardware.js"; import { isGame, isLauncher, launcherVersion, newestFirst } from "./src/versions.js"; import { contributorsFrom, contributorsHtml } from "./src/contributors.js"; -import { areaFilterHtml, boardFilterHtml, boardFrom, boardHtml, helpWantedHtml, journalFrom, journalHtml, journalJson, overviewHtml, roadmapHtml, slimIssue } from "./src/hub.js"; +import { areaFilterHtml, boardFilterHtml, boardFrom, boardHtml, creditFrom, creditHtml, helpWantedHtml, journalFrom, journalHtml, journalJson, overviewHtml, roadmapHtml, slimIssue, suggestItemsHtml } from "./src/hub.js"; const site = dirname(fileURLToPath(import.meta.url)); const dist = join(site, "dist"); @@ -119,6 +119,18 @@ const hubLinked = new Map(hubLive.filter((i) => linked.has(i.n)).map((i) => [i.n const board = boardFrom(hubLive, roadmap); const journal = journalFrom(releases, hubLive, roadmap); +// The hub's server (crates/horizon-telemetry-server: votes, bug reports, suggestions), and Kira's list of the +// contributors who linked their Discord account and agreed to be credited (kira's /contributors.json). +const hubApi = process.env.HUB_API_URL || "https://telemetry.playhorizon.dev"; +let kiraCredit = {}; +try { + const res = await fetch(process.env.KIRA_CONTRIBUTORS_URL || "https://kira-production-500e.up.railway.app/contributors.json", { signal: AbortSignal.timeout(10000) }); + if (!res.ok) throw new Error(`${res.status} from Kira`); + kiraCredit = await res.json(); +} catch (e) { + console.warn(`hub: contributors' Discord names: ${e.message}`); +} + // --- The parity table ------------------------------------------------------------------ const status = section(readme, "Project status") ?? ""; @@ -332,7 +344,10 @@ const values = { HUB_BOARD: hubLive.length ? boardHtml(board, roadmap) : `

The board could not be loaded here.

`, HUB_BOARD_FILTER: boardFilterHtml(board, roadmap), HUB_JOURNAL: journalHtml(journal, roadmap) || unavailable, - HUB_DATA: JSON.stringify({ roadmap, live: [...hubLinked.values()] }).replace(/ { + try { + return JSON.parse(localStorage.getItem(key)) ?? fallback; + } catch { + return fallback; + } +}; +const save = (key, value) => { + try { + localStorage.setItem(key, JSON.stringify(value)); + } catch {} +}; +const post = (path, body) => fetch(`${data.api}${path}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }); + +// This browser's random id (one vote per item per browser) and the items it voted for. Nothing else identifies it. +function voter() { + let id = saved("hub:voter", ""); + if (typeof id !== "string" || id.length < 16) { + id = crypto.randomUUID ? crypto.randomUUID() : [...crypto.getRandomValues(new Uint8Array(16))].map((b) => b.toString(16).padStart(2, "0")).join(""); + save("hub:voter", id); + } + return id; +} +const mine = new Set(saved("hub:voted", [])); +let counts = null; // { item: votes } once the server answered; until then the buttons stay hidden + +function showVotes() { + if (!counts) return; + for (const button of document.querySelectorAll("[data-vote]")) { + const id = button.dataset.vote; + button.hidden = false; + button.setAttribute("aria-pressed", String(mine.has(id))); + button.querySelector(".hub-vote-label").textContent = mine.has(id) ? "Wanted" : "Want it"; + button.querySelector("[data-votes]").textContent = counts[id] ? String(counts[id]) : ""; + } +} + +async function vote(id) { + const up = !mine.has(id); + const apply = (on, step) => { + if (on) mine.add(id); + else mine.delete(id); + counts[id] = Math.max(0, (counts[id] || 0) + step); + save("hub:voted", [...mine]); + showVotes(); + }; + apply(up, up ? 1 : -1); + try { + const res = await post("/hub/vote", { item: id, voter: voter(), up }); + if (!res.ok) throw new Error(res.status); + counts[id] = (await res.json()).votes; + showVotes(); + } catch { + apply(!up, up ? -1 : 1); + } +} +document.addEventListener("click", (e) => { + const button = e.target.closest("[data-vote]"); + if (button && counts) vote(button.dataset.vote); +}); + +const LABELS = { title: "the title", did: "what you did", happened: "what happened", expected: "what you expected", version: "the version", system: "OS, CPU, GPU", text: "your idea", name: "your name" }; +// The server's answer in words: "did: 3 to 2000 characters" becomes "Check what you did: 3 to 2000 characters." +function trouble(code, answer) { + if (code === 429) return "Too many sent from your connection: try again in a few minutes."; + const said = typeof answer.error === "string" ? answer.error : ""; + const field = said.match(/^(\w+): (.+)$/); + if (code === 400 && field) return `Check ${LABELS[field[1]] || field[1]}: ${field[2]}.`; + return said ? `${said[0].toUpperCase()}${said.slice(1)}.` : "That didn't go through: try again in a moment."; +} + +function setUpForm(form, path, thanks) { + const status = form.querySelector("[data-status]"); + form.hidden = false; + form.parentElement.querySelector("[data-closed]").hidden = true; + form.addEventListener("submit", async (e) => { + e.preventDefault(); + if (!form.reportValidity()) return; + const button = form.querySelector('[type="submit"]'); + button.disabled = true; + status.textContent = "Sending…"; + try { + const res = await post(path, Object.fromEntries(new FormData(form))); + const answer = await res.json().catch(() => ({})); + if (res.ok) { + thanks(status, answer); + // A new report starts with the version filled in again; the name stays for the next one. + for (const field of form.querySelectorAll("textarea, input:not([name='version']):not([name='name'])")) field.value = ""; + } else status.textContent = trouble(res.status, answer); + } catch { + status.textContent = "Couldn't reach the server: try again, or use GitHub or Discord."; + } + button.disabled = false; + }); +} + +// The forms and the votes show once the server answers; without it the page points to GitHub and Discord. +async function connect() { + try { + // Revalidated: the server keeps the counts a minute, a browser's copy would miss this browser's own vote. + const res = await fetch(`${data.api}/hub/votes`, { cache: "no-cache" }); + if (!res.ok) return; + counts = (await res.json()).votes || {}; + } catch { + return; + } + showVotes(); + setUpForm(document.querySelector('[data-form="report"]'), "/hub/report", (status, answer) => { + const issue = typeof answer.issue === "string" && answer.issue.match(/^https:\/\/github\.com\/ludovic111\/horizon\/issues\/(\d+)$/); + status.innerHTML = issue ? `Thanks! It's issue #${issue[1]} on GitHub: follow it there.` : "Thanks! It will be on GitHub in a few minutes."; + }); + setUpForm(document.querySelector('[data-form="suggest"]'), "/hub/suggest", (status) => { + status.textContent = "Thanks! The maintainers read every suggestion."; + }); +} + setUpTheme(); setUpMenu(); +connect(); follow(); refresh().then(() => data.roadmap.items.some((i) => `#${i.id}` === location.hash) && follow()); diff --git a/website/src/hub.html b/website/src/hub.html index d4ba4600c..167ffc15e 100644 --- a/website/src/hub.html +++ b/website/src/hub.html @@ -90,7 +90,7 @@

Take a task

@@ -109,6 +109,41 @@
+
+

Report a bug

+

One bug per report: something that breaks, or doesn't play like vanilla. It becomes an issue on GitHub, public, and you get its link to follow it. Search the open bugs first.

+ +

Report it on GitHub or in #horizon-bugs on Discord, where Kira turns your post into an issue.

+
+
+

Suggest something

+

An idea for Horizon, or about something on the roadmap. The maintainers read every one, and the good ones become roadmap items. Nothing you send here is published.

+ +

Post it in #horizon-ideas on Discord, or send it to Kira with /suggest.

+

The rules

    @@ -119,6 +154,12 @@

The contributing guideCONTRIBUTING.md

+
+

Contributors

+

Everyone with commits in Horizon. On Discord, /link-github <your login> credit:True adds your Discord name next to yours.

+
    {{HUB_CREDIT}}
+

All contributors on GitHub

+

Not an official Minecraft product. Not approved by or associated with Mojang or Microsoft.

diff --git a/website/src/hub.js b/website/src/hub.js index d293b7250..f11668d8c 100644 --- a/website/src/hub.js +++ b/website/src/hub.js @@ -6,6 +6,7 @@ import { escape, inline } from "./markdown.js"; import { parts, plainItem, sections } from "./releases.js"; import { isGame, isLauncher } from "./versions.js"; +import { avatar } from "./contributors.js"; export const REPO = "ludovic111/horizon"; const issueUrl = (n) => `https://github.com/${REPO}/issues/${n}`; @@ -85,11 +86,16 @@ export function progress(item, live) { const areaName = (roadmap, id) => roadmap.areas.find((a) => a.id === id)?.name || id; +// An item's vote button: hidden until the page has the counts from the hub's server (hub-page.js). +export function voteHtml(item) { + return ``; +} + export function itemHtml(item, roadmap, live) { const done = item.status === "shipped"; const state = done ? "" : progress(item, live); return `
-

${escape(areaName(roadmap, item.area))}${done ? `${escape(item.shipped_in)}` : ""}${item.ongoing ? `Ongoing` : ""}

+

${escape(areaName(roadmap, item.area))}${done ? `${escape(item.shipped_in)}` : ""}${item.ongoing ? `Ongoing` : ""}${done ? "" : voteHtml(item)}

${escape(item.title)}

${inline(item.plain)}

${devHtml(item)}

@@ -160,7 +166,7 @@ export function overviewHtml(roadmap, live = new Map()) {

How to help

${inline(o.help_plain)}

${inline(o.help_dev)}

-

ContributeHelp wanted

+

ContributeHelp wantedReport a bugSuggest something

`; } @@ -418,3 +424,34 @@ export function journalHtml(entries, roadmap) { }) .join("\n"); } + +// --- Contribute: the suggestion form's items and the contributors ------------------------------------------------ + +// The suggestion form's "About" choices: the items still to come. +export function suggestItemsHtml(roadmap) { + const open = roadmap.items.filter((i) => i.status !== "shipped"); + return [``] + .concat(open.map((i) => ``)) + .join(""); +} + +// The contributors, from GitHub (contributors.js's list), with the Discord name of those who linked their accounts +// on Kira and agreed to be credited (Kira's /contributors.json: { contributors: [{ github, discord }] }). +export function creditFrom(github, kira) { + const discord = new Map( + (Array.isArray(kira?.contributors) ? kira.contributors : []) + .filter((c) => c && typeof c.github === "string" && typeof c.discord === "string") + .map((c) => [c.github.toLowerCase(), c.discord]), + ); + return github.map((c) => ({ ...c, discord: discord.get(c.login.toLowerCase()) || "" })); +} + +export function creditHtml(list) { + return list + .map((c) => { + const src = avatar(c.avatar_url); + const count = `${c.contributions.toLocaleString("en-US")} ${c.contributions === 1 ? "commit" : "commits"}`; + return `
  • ${src ? `` : ``}${escape(c.login)}${count}${c.discord ? ` · ${escape(c.discord)} on Discord` : ""}
  • `; + }) + .join(""); +} diff --git a/website/src/hub.test.mjs b/website/src/hub.test.mjs index d688489e9..4213d8a87 100644 --- a/website/src/hub.test.mjs +++ b/website/src/hub.test.mjs @@ -1,7 +1,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; -import { boardFrom, boardHtml, fixesIn, itemOf, journalFrom, journalHtml, journalJson, overviewHtml, progress, roadmapHtml, slimIssue } from "./hub.js"; +import { boardFrom, boardHtml, creditFrom, creditHtml, fixesIn, itemOf, journalFrom, journalHtml, journalJson, overviewHtml, progress, roadmapHtml, slimIssue, suggestItemsHtml } from "./hub.js"; const roadmap = JSON.parse(readFileSync(new URL("../data/roadmap.json", import.meta.url), "utf8")); @@ -137,3 +137,23 @@ test("journal.json is the flat feed Kira reads: merges, releases, shipped items, assert.match(e.url, /^https:\/\/(github\.com|playhorizon\.dev)\//, e.id); } }); + +test("items still to come take votes and suggestions; shipped ones don't", () => { + const html = roadmapHtml(roadmap); + for (const item of roadmap.items) { + assert.equal(html.includes(`data-vote="${item.id}"`), item.status !== "shipped", item.id); + assert.equal(suggestItemsHtml(roadmap).includes(`value="${item.id}"`), item.status !== "shipped", item.id); + } + // Hidden until the hub's server answers. + assert.ok(html.includes('aria-pressed="false" hidden>')); +}); + +test("the contributors carry the Discord name of those who agreed on Kira", () => { + const github = [{ login: "Alex", html_url: "https://github.com/Alex", avatar_url: "", contributions: 3 }, { login: "sam", html_url: "https://github.com/sam", avatar_url: "", contributions: 1 }]; + const kira = { contributors: [{ github: "alex", discord: "Alex " }, { github: 5 }, null] }; + const credit = creditFrom(github, kira); + assert.deepEqual(credit.map((c) => c.discord), ["Alex ", ""]); + const html = creditHtml(credit); + assert.ok(html.includes("3 commits · Alex <b> on Discord") && html.includes("1 commit")); + assert.deepEqual(creditFrom(github, "not json").map((c) => c.discord), ["", ""]); +}); diff --git a/website/src/style.css b/website/src/style.css index f32e24a30..1a23e79c8 100644 --- a/website/src/style.css +++ b/website/src/style.css @@ -645,7 +645,7 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou /* Releases: a filter, then every release as a panel that opens. */ .release-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; } -.release-filter .button[aria-pressed="true"], .hub-detail .button[aria-pressed="true"] { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); } +.release-filter .button[aria-pressed="true"], .hub-detail .button[aria-pressed="true"], .button.hub-vote[aria-pressed="true"] { background: var(--face); color: var(--on-face); box-shadow: inset 0 var(--block-bevel) 0 var(--face-bevel), inset 0 calc(-1 * var(--block-lip)) 0 var(--face-lip); } .release-count { margin: 16px 0 12px; } .release-list { display: grid; gap: 8px; } .release-list .release + .release { margin-top: 0; } @@ -826,3 +826,26 @@ code { border-radius: 0; background: var(--well); box-shadow: 0 0 0 1px var(--ou .hub-rows .row > a { grid-template-columns: var(--index) minmax(0, 1fr); } .hub-rows .row-meta { grid-column: 2; text-align: left; } } + +/* --- Hub: votes, the report and suggestion forms, the contributors ---------------------- */ +.hub-vote { margin-left: auto; } +.hub-vote-count { margin-left: -2px; } +.hub-vote-count:empty { display: none; } +.hub-form { display: grid; gap: 16px; max-width: 46rem; margin-top: 8px; } +.hub-form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } +.hub-field { display: grid; gap: 6px; font-size: var(--text-label); color: var(--ink-soft); } +.hub-field input, .hub-field textarea, .hub-field select { + width: 100%; min-height: 36px; padding: 8px 10px; font: var(--text-ui) / 1.4 var(--font); color: var(--ink); + background: var(--well); border: 0; box-shadow: 0 0 0 var(--block-outline) var(--outline); +} +.hub-field textarea { resize: vertical; } +.hub-field input:focus-visible, .hub-field textarea:focus-visible, .hub-field select:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; } +.hub-field input::placeholder, .hub-field textarea::placeholder { color: var(--muted); } +.hub-trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; } +.hub-form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; } +.hub-form-foot [data-status] { color: var(--ink); } +.hub-form-foot .button:disabled { opacity: 0.4; cursor: default; } +.hub-form-closed { color: var(--ink-soft); } +@media (max-width: 720px) { + .hub-form-pair { grid-template-columns: minmax(0, 1fr); } +}