Public: anyone can read this; the crew can change it.

Games survival step 3: quality-of-life mods tried on a copy first (graves, essential-commands, sleep, harvest, vein miner, styled-chat) #18145

opened this

Merged 6h 13m ago, live in production

mason/forge:mason/18089-games-survival-step-3-quality-of-life-mo → main 0 commits fork

  • Merged. mason/18089-games-survival-step-3-quality-of-life-mo was merged into main as f058287.

Review

Sign in to review this change.
7 files changed +188 −24
docs/features/game-mods.md +2 −1
@@ -10,6 +10,7 @@ The server's mods or plugins come from Modrinth, for its loader and game version
1010 - **Preview** picks the newest compatible version (a release when there is one) and resolves what it requires, recursively: "Adds Chunky 1.4.28; Adds ChunkyLib 1.0.2 (required by Chunky)". A project with no version for the server, a requirement with none, or two projects that say they are incompatible are refused with the reason. A bare slug already in `MODRINTH_PROJECTS` is pinned by the same change.
1111 - **Install and restart** is one commit on the commit you previewed: the lockfile `<compose dir>/modrinth/<service>.lock.json` (each project's version id, file path, url and sha512, and whether it was asked for or is a dependency) and the compose env made from it: `MODRINTH_PROJECTS` lists `slug:versionId` for every project and `MODRINTH_DOWNLOAD_DEPENDENCIES=none`, so the image fetches exactly the locked set. A proxy also gets `MINECRAFT_VERSION`, which its Modrinth step needs. On a proxy whose servers sleep, `MODRINTH_PROJECTS` also holds AutoStopper (`PG4gqnzX:EclCtvWk`, see [Games](games.md)): it is sleep's, so a Modrinth change carries it over as it is and never lists it as the proxy's own, and Warm again takes only that entry.
1212 - **Sets**: a named set installs in one preview and one commit. `set:survival` is the survival performance set for a Fabric server: Lithium, ScalableLux, Noisium and Chunky, each at its newest release for the server's Minecraft version, with what they require (Chunky needs Fabric API). It adds only what is missing, and a server on another loader is refused with the reason. The web Mods block shows it with a *Preview the set* button until it is installed; the terminal shows the same lines and `s` previews it; MCP `mods_install` takes `project: "set:survival"`.
13 - **Quality of life**: `set:quality` is graves (Universal Graves), Essential Commands, Styled Chat and Right Click Harvest for a Fabric server, installed like the survival set but optional by member: each is resolved alone, and one with no build for the server's Minecraft version (Right Click Harvest on 1.21.6) is left out with the reason ("Left out rightclickharvest: …") while the rest install; if none builds, it is refused. Essential Commands ships every command on; trimming it to /home, /spawn and /tpa is its config, which the owner sets, and the plan says so on a "Before players join" line, on the page and in the terminal. Each set shows a sentence on what it is for, and the web block offers *Preview the Quality of life set*, the terminal's key is `q`, MCP `mods_install` takes `project: "set:quality"`.
1314 - **Updates** post the locked sha512s to Modrinth's `/v2/version_files/update` (releases for the loader and version) and show "2 updates" as from → to, one click each or all.
1415 - **Remove** takes a project and what only it required; a dependency something else requires stays.
1516
@@ -28,7 +29,7 @@ The image does not check a pack's file hashes (its Modrinth project path does; i
2829 ## Where
2930
3031 - **Web:** `/games/<box>/<service>`, the Mods (or Plugins) block: updates, what is installed, Search, Preview, Install and restart; on a mod server, the Modpack block: the pack, its locked files, Search packs, Preview, Install pack and restart.
31 - **Terminal:** a service's screen, `m`: `/` search, `a` install by a result's number or a slug, `s` the survival performance set, `u` update all, `d` remove, `p` a modpack by slug; `y` commits the preview shown, `n` drops it (`src/tui/screens/game_mods.ts`).
32 - **Terminal:** a service's screen, `m`: `/` search, `a` install by a result's number or a slug, `s` the survival performance set, `q` the quality-of-life set, `u` update all, `d` remove, `p` a modpack by slug; `y` commits the preview shown, `n` drops it (`src/tui/screens/game_mods.ts`).
3233 - **MCP:** `games` with `mods`, `mods_search`, `mods_pack_search`, `mods_install`, `mods_update`, `mods_remove`, `mods_pack`; a change is planned until `dryRun: false`.
3334
3435 All three read and write through `src/games/mods.ts`, over the client in `src/games/modrinth.ts`.
src/games/mod_sets.ts +46 −1
@@ -9,9 +9,23 @@
99 export interface ModSet {
1010 readonly name: string;
1111 readonly title: string;
12 /** The terminal key that previews the set; unique among sets and the screen's other keys. */
13 readonly key: string;
14 /** One sentence that says what the set is for, ahead of its rows. */
15 readonly about: string;
1216 /** The Modrinth loader its projects are for; a server on another loader is refused. */
1317 readonly loader: string;
1418 readonly slugs: readonly string[];
19 /**
20 * Each project is tried alone and one with no build for the server is left out, with the reason,
21 * where a set that is not optional is refused whole (#18089).
22 */
23 readonly optional?: boolean;
24 /**
25 * What the owner must do about a member before players join, by slug; the plan says it on a line
26 * when that member is in it.
27 */
28 readonly cautions?: Readonly<Record<string, string>>;
1529 /** One line for each project: what it is for. */
1630 readonly why: readonly string[];
1731 }
@@ -22,6 +36,8 @@ export const SET_PREFIX = "set:";
2236 export const SURVIVAL: ModSet = Object.freeze({
2337 name: "survival",
2438 title: "Survival performance",
39 key: "s",
40 about: "Four mods that make a Fabric survival server cheaper to run without changing how it plays.",
2541 loader: "fabric",
2642 slugs: Object.freeze(["lithium", "scalablelux", "noisium", "chunky"]),
2743 why: Object.freeze([
@@ -32,10 +48,39 @@ export const SURVIVAL: ModSet = Object.freeze({
3248 ]),
3349 });
3450
51 /**
52 * Quality-of-life mods for a Fabric survival server (step 3 of #18059): graves, home/spawn/tpa
53 * commands, styled chat and right-click harvest. Optional: a mod that does not build for the
54 * server's Minecraft version (rightclickharvest on 1.21.6) is skipped and named, not a refusal.
55 * Essential Commands ships with every command on; its config is the owner's to trim to /home,
56 * /spawn and /tpa.
57 */
58 export const QUALITY: ModSet = Object.freeze({
59 name: "quality",
60 title: "Quality of life",
61 key: "q",
62 about: "Graves, home and spawn commands, styled chat and right-click harvest for a Fabric survival server.",
63 loader: "fabric",
64 optional: true,
65 slugs: Object.freeze(["universal-graves", "essential-commands", "styled-chat", "rightclickharvest"]),
66 cautions: Object.freeze({
67 "essential-commands": "Essential Commands installs with every command on: before players join, trim its config to /home, /spawn and /tpa.",
68 }),
69 why: Object.freeze([
70 "Universal Graves: a death leaves a grave with your items instead of a pile that despawns",
71 "Essential Commands: /home, /spawn and /tpa for players",
72 "Styled Chat: chat with colours and formatting",
73 "Right Click Harvest: right-click a ripe crop to harvest and replant it (skipped when it has no build for this version)",
74 ]),
75 });
76
77 /** Every set a `project` value can name. */
78 export const SETS: readonly ModSet[] = Object.freeze([SURVIVAL, QUALITY]);
79
3580 /** The set a `project` value names (`set:survival`), if there is one. */
3681 export function setNamed(ref: string): ModSet | undefined {
3782 const r = ref.trim().toLowerCase();
38 return r === `${SET_PREFIX}${SURVIVAL.name}` ? SURVIVAL : undefined;
83 return SETS.find((s) => r === `${SET_PREFIX}${s.name}`);
3984 }
4085
4186 /**
src/games/mods.ts +24 −7
@@ -20,7 +20,7 @@ import type { App } from "../app.ts";
2020 import type { User } from "../core/users.ts";
2121 import { commitCompose, composeDir, pluginUrls, readCompose, readRepoFile, serviceEnv, setServiceEnv } from "./compose.ts";
2222 import { byVersion, latestRelease, newestPack, packUpdate, readPack, resolve, targetOf, updates, type Locked, type LockedPack, type Result, type Target, type Version } from "./modrinth.ts";
23 import { missing as setMissing, setNamed, SET_PREFIX, type ModSet } from "./mod_sets.ts";
23 import { missing as setMissing, setNamed, SETS, SET_PREFIX, type ModSet } from "./mod_sets.ts";
2424 import { memoryRefusal, type BoxRoom } from "./box_memory.ts";
2525 import { AUTOSTOPPER } from "./sleep.ts";
2626 import { servicesOf, type GameBox } from "./store.ts";
@@ -200,7 +200,7 @@ export async function planInstall(app: App, m: Mods, service: string, ref: strin
200200 const wantedRef = ref.trim();
201201 if (wantedRef.toLowerCase().startsWith(SET_PREFIX)) {
202202 const set = setNamed(wantedRef);
203 return set === undefined ? { ok: false, error: `There is no set called ${wantedRef.slice(SET_PREFIX.length)}; the sets are ${SET_PREFIX}survival.` } : planSet(app, m, service, set);
203 return set === undefined ? { ok: false, error: `There is no set called ${wantedRef.slice(SET_PREFIX.length)}; the sets are ${SETS.map((x) => `${SET_PREFIX}${x.name}`).join(", ")}.` } : planSet(app, m, service, set);
204204 }
205205 if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,99}$/.test(wantedRef))
206206 return { ok: false, error: "Name a Modrinth project by its slug or id, like luckperms." };
@@ -247,18 +247,35 @@ async function planSet(app: App, m: Mods, service: string, set: ModSet): Promise
247247 if (missing.length === 0) return { ok: false, error: `The ${set.title.toLowerCase()} set is installed.` };
248248 const adopt = m.loose.filter(bareSlug).filter((s) => !missing.includes(s.toLowerCase()));
249249 const kept = m.loose.filter((e) => !bareSlug(e) || missing.includes(e.toLowerCase()));
250 const got = await resolve(app, m.target, m.lock, [
251 ...missing.map((s) => ({ project: find(m.lock, s)?.project ?? s, top: true })),
250 const asked = (slugs: readonly string[]) => [
251 ...slugs.map((s) => ({ project: find(m.lock, s)?.project ?? s, top: true })),
252252 ...adopt.map((s) => ({ project: s, top: true })),
253 ]);
253 ];
254 const skipped = new Map<string, string>();
255 let got: Result<Locked[]>;
256 if (set.optional !== true) got = await resolve(app, m.target, m.lock, asked(missing));
257 else {
258 // Each project alone, on what the ones before it locked: one with no build is left out.
259 got = await resolve(app, m.target, m.lock, asked([]));
260 for (const slug of missing) {
261 if (!got.ok) break;
262 const one = await resolve(app, m.target, got.value, [{ project: find(m.lock, slug)?.project ?? slug, top: true }]);
263 if (one.ok) got = one;
264 else skipped.set(slug, one.error);
265 }
266 if (got.ok && skipped.size === missing.length)
267 return { ok: false, error: `None of the ${set.title.toLowerCase()} set runs on ${m.target.label}: ${[...skipped].map(([k, v]) => `${k}: ${v}`).join(" ")}` };
268 }
254269 if (!got.ok) return got;
255270 const deps = got.value.filter((l) => !l.top && !m.lock.some((o) => o.project === l.project)).length;
256 const what = `the ${set.title.toLowerCase()} set (${missing.join(", ")})`;
271 const what = `the ${set.title.toLowerCase()} set (${missing.filter((x) => !skipped.has(x)).join(", ")})`;
257272 const withDeps = deps === 0 ? "" : ` and ${String(deps)} ${deps === 1 ? "dependency" : "dependencies"}`;
258273 return {
259274 ok: true,
260275 value: {
261 lines: diffLines(m, got.value, new Set(adopt)),
276 lines: [...diffLines(m, got.value, new Set(adopt)), ...[...skipped].map(([k, v]) => `Left out ${k}: ${v}`),
277 ...Object.entries(set.cautions ?? {}).filter(([k]) => missing.includes(k) && !skipped.has(k)).map(([, v]) => `Before players join: ${v}`),
278 ],
262279 lock: got.value,
263280 env: envFor(m, got.value, kept),
264281 message: `games: ${service} mods: add ${what}${withDeps}`,
src/http/mcp/tools/games.ts +1 −1

Diff not shown — a line 3,047 characters wide (limit 2,000). +1 −1

View file
src/tui/screens/game_mods.ts +6 −7
@@ -7,7 +7,7 @@
77 * shown and `n` drops it; `l` makes a link to the client pack for players and `x` ends every link.
88 */
99
10 import { offered, SET_PREFIX, SURVIVAL } from "../../games/mod_sets.ts";
10 import { offered, SETS, SET_PREFIX } from "../../games/mod_sets.ts";
1111 import { search, type Hit, type Result } from "../../games/modrinth.ts";
1212 import { commitPlan, modsOf, packUpdateOf, planInstall, planPack, planPackUpdate, planRemove, planUpdate, updatesOf, type Mods, type Plan } from "../../games/mods.ts";
1313 import { makePackLink, packRow, revokeLinks, type PackRow } from "../../games/client_pack.ts";
@@ -66,9 +66,7 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri
6666 ...(m.lock.length + m.loose.length + m.urls.length === 0 ? ["Nothing is installed."] : []),
6767 ...(players === undefined ? [] : [`players: ${players.open > 0 ? `${String(players.open)} link(s) open; x ends all. ` : ""}${players.can ? "l makes a link. " : ""}${players.words}`]),
6868 ...(link === "" ? [] : [`link (30 days, shown once): ${link}`]),
69 ...(offered(SURVIVAL, m.target, m.lock)
70 ? [`${SURVIVAL.title} set: ${SURVIVAL.slugs.join(", ")}; s previews it`, ...SURVIVAL.why.map((w) => ` ${w}`)]
71 : []),
69 ...SETS.filter((set) => offered(set, m.target, m.lock)).flatMap((set) => [`${set.title} set: ${set.about} ${set.slugs.join(", ")}; ${set.key} previews it`, ...set.why.map((w) => ` ${w}`)]),
7270 ...hits.map((h, i) => `${String(i + 1)}. ${h.title} (${h.slug}) ${h.fits ? `runs on ${m.target.gameVersion}` : h.why}`),
7371 `Uploading a jar is on the web only: /games/${box.name}/${service}.`,
7472 ];
@@ -92,7 +90,7 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri
9290 keys: [
9391 binding(["/"], "search Modrinth"),
9492 binding(["a"], "install"),
95 binding(["s"], `preview the ${SURVIVAL.title.toLowerCase()} set`),
93 ...SETS.map((set) => binding([set.key], `preview the ${set.title} set`)),
9694 binding(["u"], "update all"),
9795 binding(["d"], "remove"),
9896 binding(["p"], "modpack"),
@@ -135,9 +133,10 @@ export function gameModsScreen(f: Session, ctx: Ctx, box: GameBox, service: stri
135133 const ref = /^\d+$/.test(v) ? (hits[Number(v) - 1]?.slug ?? v) : v;
136134 return preview((m) => planInstall(f.app, m, service, ref));
137135 });
138 else if (e.key === "s") {
136 else if (SETS.some((set) => set.key === e.key)) {
137 const set = SETS.find((x) => x.key === e.key)!;
139138 if (!operator()) say(`You are not an operator of ${service}.`);
140 else void preview((m) => planInstall(f.app, m, service, `${SET_PREFIX}${SURVIVAL.name}`)).then(say);
139 else void preview((m) => planInstall(f.app, m, service, `${SET_PREFIX}${set.name}`)).then(say);
141140 } else if (e.key === "d") ask("Remove", "The slug of what to remove", (raw) => preview((m) => planRemove(m, service, raw.trim())));
142141 else if (e.key === "p") ask("Modpack", "A Modrinth modpack's slug", (raw) => preview((m) => planPack(f.app, m, service, raw.trim())));
143142 else if (e.key === "l" || e.key === "x") {
src/web/pages/games.ts +7 −4
@@ -8,7 +8,7 @@
88 */
99
1010 import { addPluginUrl, commitServiceEnv, composeServices, readCompose, serviceEnv } from "../../games/compose.ts";
11 import { offered, SET_PREFIX, SURVIVAL } from "../../games/mod_sets.ts";
11 import { offered, SETS, SET_PREFIX } from "../../games/mod_sets.ts";
1212 import { commitPlan, modsOf, packUpdateOf, planInstall, planPack, planPackUpdate, planRemove, planUpdate, updatesOf, type Mods, type Plan } from "../../games/mods.ts";
1313 import { search, searchPacks, type Hit, type Result } from "../../games/modrinth.ts";
1414 import { packRow } from "../../games/client_pack.ts";
@@ -897,9 +897,12 @@ function modsBlock(o: {
897897 }),
898898 ),
899899 ])}
900 ${o.act && offered(SURVIVAL, t, m.lock) && o.adding !== `${SET_PREFIX}${SURVIVAL.name}`
901 ? html`${rowList(SURVIVAL.why.map((w) => row({ title: w })))}
902 ${btn("Preview the set", { size: "sm", variant: "secondary", href: `${o.base}?add=${SET_PREFIX}${SURVIVAL.name}#mods`, label: `Preview installing the ${SURVIVAL.title.toLowerCase()} set` })}`
900 ${o.act
901 ? SETS.filter((set) => offered(set, t, m.lock) && o.adding !== `${SET_PREFIX}${set.name}`).map(
902 (set) => html`<p class="muted">${set.about}</p>
903 ${rowList(set.why.map((w) => row({ title: w })))}
904 ${btn(`Preview the ${set.title} set`, { size: "sm", variant: "secondary", href: `${o.base}?add=${SET_PREFIX}${set.name}#mods`, label: `Preview installing the ${set.title} set` })}`,
905 )
903906 : null}
904907 ${o.preview === undefined
905908 ? null
test/game-mods.test.ts +102 −3
@@ -22,6 +22,7 @@ import { packVerdict } from "../src/games/pack_check.ts";
2222 import { askPower } from "../src/games/power.ts";
2323 import { AUTOSTOPPER, commitPolicy } from "../src/games/sleep.ts";
2424 import { createForgeApp } from "../src/tui/forge.ts";
25 import { QUALITY, SETS } from "../src/games/mod_sets.ts";
2526 import { gameModsScreen } from "../src/tui/screens/game_mods.ts";
2627 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2728 import { quietLogs } from "./helpers/globals.ts";
@@ -149,6 +150,10 @@ const PROJECTS = [
149150 { id: "QTid0001", slug: "bad,slug", title: "Comma" },
150151 { id: "FNid0001", slug: "farfile", title: "FarFile" },
151152 { id: "LIid0001", slug: "lithium", title: "Lithium" },
153 { id: "UGid0001", slug: "universal-graves", title: "Universal Graves" },
154 { id: "ECid0001", slug: "essential-commands", title: "Essential Commands" },
155 { id: "SCid0001", slug: "styled-chat", title: "Styled Chat" },
156 { id: "RHid0001", slug: "rightclickharvest", title: "Right Click Harvest" },
152157 { id: "SLid0001", slug: "scalablelux", title: "ScalableLux" },
153158 { id: "NOid0001", slug: "noisium", title: "Noisium" },
154159 { id: "FPid0001", slug: "fabric-api", title: "Fabric API" },
@@ -200,6 +205,11 @@ const VERSIONS: V[] = [
200205 { id: "QTv00001", project: "QTid0001", number: "1.0", date: "2024-12-07", games: ["1.21.4"], loaders: PAPER, hash: "d" },
201206 { id: "FNv00001", project: "FNid0001", number: "1.0", date: "2024-12-08", games: ["1.21.4"], loaders: PAPER, hash: "e", filename: "../x.jar" },
202207 { id: "VPv00001", project: "VPid0001", number: "3.1", date: "2024-12-06", games: ["1.21.4", "1.21.3"], loaders: ["velocity"], hash: "c" },
208 { id: "UGv00001", project: "UGid0001", number: "3.9.0", date: "2025-02-01", games: ["1.21.4"], loaders: FABRIC, hash: "2a", deps: [{ project_id: "FPid0001", version_id: null, dependency_type: "required" }] },
209 { id: "ECv00001", project: "ECid0001", number: "0.5.0", date: "2025-02-02", games: ["1.21.4"], loaders: FABRIC, hash: "2b", deps: [{ project_id: "FPid0001", version_id: null, dependency_type: "required" }] },
210 { id: "SCv00001", project: "SCid0001", number: "2.8.0", date: "2025-02-03", games: ["1.21.4"], loaders: FABRIC, hash: "2c" },
211 // Built for a newer game version only.
212 { id: "RHv00001", project: "RHid0001", number: "4.5", date: "2025-02-04", games: ["1.21.8"], loaders: FABRIC, hash: "2d" },
203213 { id: "LIv00001", project: "LIid0001", number: "0.17.0", date: "2025-01-01", games: ["1.21.4"], loaders: FABRIC, hash: "1a" },
204214 { id: "SLv00001", project: "SLid0001", number: "0.1.5", date: "2025-01-02", games: ["1.21.4"], loaders: FABRIC, hash: "1b" },
205215 { id: "NOv00001", project: "NOid0001", number: "2.0", date: "2025-01-03", games: ["1.21.4"], loaders: FABRIC, hash: "1c" },
@@ -757,8 +767,8 @@ describe("the survival performance set", () => {
757767
758768 test("the page offers it, previews it, and one commit locks all five", async () => {
759769 const offered = await (await asAlice("/games/net/smp")).text();
760 expect(offered).toContain("Preview the set");
761 expect(offered).toContain("Preview the set");
770 expect(offered).toContain("Preview the Survival performance set");
771 expect(offered).toContain("Preview the Survival performance set");
762772 const preview = await (await asAlice("/games/net/smp?add=set:survival")).text();
763773 expect(preview).toContain("Adds Noisium 2.0");
764774 expect(preview).toContain("Install and restart");
@@ -771,7 +781,7 @@ describe("the survival performance set", () => {
771781 expect(lock.projects.map((p) => p.slug).sort()).toEqual(SLUGS);
772782 expect(lock.projects.every((p) => p.sha512.length === 128)).toBe(true);
773783 // Installed: no longer offered, and planning it again says so.
774 expect(await (await asAlice("/games/net/smp")).text()).not.toContain("Preview the set");
784 expect(await (await asAlice("/games/net/smp")).text()).not.toContain("Preview the Survival performance set");
775785 expect(await planInstall(app, await mods("smp"), "smp", "set:survival")).toMatchObject({ ok: false, error: expect.stringContaining("is installed") });
776786 });
777787
@@ -808,6 +818,95 @@ describe("the survival performance set", () => {
808818 });
809819 });
810820
821 describe("the quality-of-life set (#18089)", () => {
822 test("a plan locks what builds for the server and says what it left out and why", async () => {
823 const m = await mods("smp");
824 const planned = await planInstall(app, m, "smp", "set:quality");
825 if (!planned.ok) throw new Error(planned.error);
826 const slugs = planned.value.lock.map((l) => l.slug);
827 expect(slugs).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"]));
828 expect(slugs).not.toContain("rightclickharvest");
829 expect(planned.value.lines).toEqual(expect.arrayContaining(["Adds Universal Graves 3.9.0", "Left out rightclickharvest: Right Click Harvest has no version for Fabric 1.21.4."]));
830 expect(planned.value.message).not.toContain("rightclickharvest");
831 expect((await mods("smp")).lock.some((l) => l.slug === "styled-chat")).toBe(false);
832 });
833
834 test("Essential Commands' plan says to trim it before players join, on the page's preview and the terminal's", async () => {
835 const planned = await planInstall(app, await mods("smp"), "smp", "set:quality");
836 if (!planned.ok) throw new Error(planned.error);
837 expect(planned.value.lines).toEqual(expect.arrayContaining([expect.stringContaining("Before players join: Essential Commands installs with every command on")]));
838 const page = await (await asAlice("/games/net/smp?add=set:quality")).text();
839 expect(page).toContain("trim its config to /home, /spawn and /tpa");
840 });
841
842 test("two members that need Fabric API share one copy of it", async () => {
843 // The survival set above locked Fabric API already: plan on a lock without it.
844 const planned = await planInstall(app, { ...(await mods("smp")), lock: [] }, "smp", "set:quality");
845 if (!planned.ok) throw new Error(planned.error);
846 expect(planned.value.lock.filter((l) => l.slug === "fabric-api")).toHaveLength(1);
847 expect(planned.value.lines.filter((l) => l.startsWith("Adds Fabric API"))).toHaveLength(1);
848 expect(planned.value.message).toContain("and 1 dependency");
849 });
850
851 test("a member already installed is kept and not planned again", async () => {
852 const first = await planInstall(app, await mods("smp"), "smp", "styled-chat");
853 if (!first.ok) throw new Error(first.error);
854 const done = await commitPlan(app, alice, box, "smp", await mods("smp"), first.value);
855 if (!done.ok) throw new Error(done.error);
856 const planned = await planInstall(app, await mods("smp"), "smp", "set:quality");
857 if (!planned.ok) throw new Error(planned.error);
858 expect(planned.value.lines.some((l) => l.includes("Styled Chat"))).toBe(false);
859 expect(planned.value.message).not.toContain("styled-chat");
860 expect(planned.value.lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["styled-chat", "universal-graves", "essential-commands"]));
861 const removed = await planRemove(await mods("smp"), "smp", "styled-chat");
862 if (!removed.ok) throw new Error(removed.error);
863 const undone = await commitPlan(app, alice, box, "smp", await mods("smp"), removed.value);
864 if (!undone.ok) throw new Error(undone.error);
865 });
866
867 test("when no member builds for the server the set is refused, with each reason", async () => {
868 const m = await mods("smp");
869 const old = { ...m, lock: [], target: { ...m.target, gameVersion: "1.19.2", label: "Fabric 1.19.2" } };
870 const planned = await planInstall(app, old, "smp", "set:quality");
871 expect(planned.ok).toBe(false);
872 const said = planned.ok ? "" : String(planned.error);
873 expect(said).toContain("None of the quality of life set runs on Fabric 1.19.2");
874 for (const slug of QUALITY.slugs) expect(said).toContain(`${slug}:`);
875 });
876
877 test("each set has its own key, not one of the screen's, and the page labels every set alike", async () => {
878 expect(new Set(SETS.map((s) => s.key)).size).toBe(SETS.length);
879 expect(new Set(SETS.map((s) => s.name)).size).toBe(SETS.length);
880 const terminal = headlessTerminal(160, 40);
881 const { app: tui, session } = createForgeApp(app, { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: alice }, { terminal, exitHooks: false });
882 const screen = gameModsScreen(session, tui.ctx, box, "smp");
883 const owners = screen.keys.flatMap((b) => b.keys);
884 for (const set of SETS) expect(owners.filter((k) => k === set.key)).toHaveLength(1);
885 expect(QUALITY.cautions).toBeDefined();
886 const page = await (await asAlice("/games/net/smp")).text();
887 expect(page).toContain(`Preview the ${QUALITY.title} set`);
888 expect(page).not.toContain("Preview the set");
889 });
890
891 test("a Paper server is refused, and the page and terminal offer it beside the survival set", async () => {
892 expect(await planInstall(app, await mods("hub"), "hub", "set:quality")).toMatchObject({ ok: false, error: expect.stringContaining("Fabric servers") });
893 expect(await planInstall(app, await mods("smp"), "smp", "set:nothing")).toMatchObject({ ok: false, error: expect.stringContaining("set:survival, set:quality") });
894 const page = await (await asAlice("/games/net/smp")).text();
895 expect(page).toContain("Preview the Quality of life set");
896 const terminal = headlessTerminal(160, 40);
897 const { app: tui, session } = createForgeApp(app, { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user: alice }, { terminal, exitHooks: false });
898 tui.start();
899 tui.ctx.push(gameModsScreen(session, tui.ctx, box, "smp"));
900 await settleUntil(tui, "Quality of life set");
901 terminal.feed("q");
902 await settleUntil(tui, "Left out rightclickharvest");
903 terminal.feed("y");
904 await settleUntil(tui, "is installed");
905 expect((await mods("smp")).lock.map((l) => l.slug)).toEqual(expect.arrayContaining(["essential-commands", "styled-chat", "universal-graves"]));
906 tui.stop?.();
907 });
908 });
909
811910 describe("room on the box (#18025)", () => {
812911 // The hub sets no MEMORY: its heap is 1 GiB, so a stopped one needs 1536 MiB free.
813912 const said = (free: number, ago = 60_000): GameBox => ({ ...box, seenAt: new Date(Date.now() - ago).toISOString(), host: { memMiB: 8000, memUsedMiB: 8000 - free } });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs