Public: anyone can read this; the crew can change it.
Upgrade a shared forge to a dedicated one, keeping its data #17167
Check · Review · Land · Live — Its check is queued.
scout/forge:scout/17024-upgrade-a-shared-forge-to-a-dedicated-on → main 3 commits fork
10 files
changed +444
−8
src/http/forges_routes.ts +3
| @@ -12,6 +12,7 @@ import { forgeLinkForm, forgeRevokeConfirm, forgeLinkRevoke, forgeLinkSubmit, fo | ||
| 12 | 12 | import { billDownload } from "./api/forge_bill.ts"; |
| 13 | 13 | import { forgeRecoveryForm, forgeRecoverySubmit } from "../web/pages/forges.ts"; |
| 14 | 14 | import { forgeMachineForm, forgeMachineSubmit } from "../web/pages/forge_machine.ts"; |
| 15 | import { forgeUpgradeForm, forgeUpgradeSubmit } from "../web/pages/forge_upgrade.ts"; | |
| 15 | 16 | import { forgesRefusedPage } from "../web/pages/forges-refused.ts"; |
| 16 | 17 | import { forgeReachAllow, forgeReachLater, forgeReachRevoke } from "../web/pages/hosted-forges.ts"; |
| 17 | 18 | import { pricingDone, pricingOrder, pricingPage, receiptHtml, receiptPage, resendPage, resendSubmit } from "../web/pages/pricing.ts"; |
| @@ -42,6 +43,8 @@ export function forgesRoutes(router: Router<Handler>): void { | ||
| 42 | 43 | router.add("POST", "/forges/:name/sandbox", forgeSandboxSubmit); |
| 43 | 44 | router.add("GET", "/forges/:name/machine", forgeMachineForm); |
| 44 | 45 | router.add("POST", "/forges/:name/machine", forgeMachineSubmit); |
| 46 | router.add("GET", "/forges/:name/upgrade", forgeUpgradeForm); | |
| 47 | router.add("POST", "/forges/:name/upgrade", forgeUpgradeSubmit); | |
| 45 | 48 | // An admin's answers to what a hosted forge asked to reach (`web/pages/hosted-forges.ts`). |
| 46 | 49 | router.add("POST", "/forges/:name/reach/allow", forgeReachAllow); |
| 47 | 50 | router.add("POST", "/forges/:name/reach/later", forgeReachLater); |
src/http/lazy_lists.ts +2
| @@ -236,6 +236,8 @@ export const FORGES_ROUTES = [ | ||
| 236 | 236 | ["POST", "/forges/:name/sandbox"], |
| 237 | 237 | ["GET", "/forges/:name/machine"], |
| 238 | 238 | ["POST", "/forges/:name/machine"], |
| 239 | ["GET", "/forges/:name/upgrade"], | |
| 240 | ["POST", "/forges/:name/upgrade"], | |
| 239 | 241 | ["POST", "/forges/:name/reach/allow"], |
| 240 | 242 | ["POST", "/forges/:name/reach/later"], |
| 241 | 243 | ["POST", "/forges/:name/reach/revoke"], |
src/http/marks/forges.json +1
src/http/mcp/tools/forges.ts +14 −3
| @@ -8,6 +8,7 @@ import { clientRows, listedKept } from "../../../spawn/clients.ts"; | ||
| 8 | 8 | import { archiveForge, archivedForges, restoreForge } from "../../../spawn/archive.ts"; |
| 9 | 9 | import { CHILD_NAME } from "../../../spawn/placement.ts"; |
| 10 | 10 | import { checkMove } from "../../../spawn/move_check.ts"; |
| 11 | import { planUpgrade, upgradeShared } from "../../../actions/upgrade_shared.ts"; | |
| 11 | 12 | import { moveToMachine, planMove, planRecover, recoverForge } from "../../../spawn/move_machine.ts"; |
| 12 | 13 | import { emptiest, machineLines, silentMachines } from "../../../spawn/machine_load.ts"; |
| 13 | 14 | import { moveToCell } from "../../../spawn/move_cell.ts"; |
| @@ -20,10 +21,10 @@ const sentSays = (n: number) => (n === 0 ? "This forge has sent no forges yet." | ||
| 20 | 21 | export const tool: Tool = { |
| 21 | 22 | name: "forges", |
| 22 | 23 | listedTo: "admin", |
| 23 | doc: "the forges sent from here, one line each: \"name | state | version | billing\" (unopened links first), with `url` once as a pattern; `name`: that forge's whole row (address, whom for, apps, claimed, stage with stageAt and resend, last activity, claimed by and when, kept, archive reason, reachable, size, use, madeFrom, placement, where); `{ forge, plan?, dryRun? }` reads a forge's plan (small|medium|large); `plan` grants it by hand; `size` workshop raises a forge; `{ forge, sandbox: true }` reads what moving a forge into a sandbox would meet (hooks, command-running keys, size) and with `dryRun: false` moves it, proven, put back on failure (`acknowledge: true` when it was held for what its repositories hold); gift codes: `codes` true lists, `code` {plan, uses?, note?, expires?} makes (shown once), `revoke` id; planned unless `dryRun` is false; `archive` a name or names stops each, writes its data and ledger as one file to the backup destination, then removes it; `restore` a name brings an archived one back; `kind` refused: the last 20 refused first asks; `kind` clients lists each client in the page's words, with runs, pulls, tellAt while working; `action` resend + `forge`: previews, with `dryRun: false` replaces its link; `kind` machines: each machine's heartbeat (awake forges, memory, CPU), the silent ones named, and the emptiest, where a new forge goes; move + `forge` + `to` a machine (or `here`, the way back): copy, start, switch the router, receipt (unreachable under 60 s); recover + `forge` + `to`: the same from the bucket's last copy, previewed with the copy's time and what is lost", | |
| 24 | doc: "the forges sent from here, one line each: \"name | state | version | billing\" (unopened links first), with `url` once as a pattern; `name`: that forge's whole row (address, whom for, apps, claimed, stage, last activity, claimed by, kept, archive reason, reachable, size, use, madeFrom, placement, where); `{ forge, plan?, dryRun? }` reads a forge's plan (small|medium|large); `plan` grants it by hand; `size` workshop raises a forge; `{ forge, sandbox: true }` reads what moving a forge into a sandbox would meet (hooks, command-running keys, size) and with `dryRun: false` moves it, proven, put back on failure (`acknowledge: true` when it was held for what its repositories hold); gift codes: `codes` true lists, `code` {plan, uses?, note?, expires?} makes (shown once), `revoke` id; planned unless `dryRun` is false; `archive` a name or names stops each, writes its data and ledger as one file to the backup destination, then removes it; `restore` a name brings an archived one back; `kind` refused: the last 20 refused first asks; `kind` clients lists each client in the page's words, with runs, pulls, tellAt while working; `action` resend + `forge`: previews, with `dryRun: false` replaces its link; `kind` machines: each machine's heartbeat (awake forges, memory, CPU), the silent ones named, and the emptiest, where a new forge goes; move + `forge` + `to` a machine (or `here`, the way back): copy, start, switch the router, receipt (unreachable under 60 s); upgrade + `forge` + `plan` + `to` a machine: a shared forge moves there with its data, then the plan changes; recover + `forge` + `to`: the same from the bucket's last copy, previewed with the copy's time and what is lost", | |
| 24 | 25 | description: |
| 25 | "Forges sent from here (admin).", | |
| 26 | inputSchema: { type: "object", properties: { name: { type: "string" }, kind: { enum: ["refused", "clients", "machines"] }, action: { enum: ["resend", "move", "recover"] }, to: {}, forge: { type: "string" }, plan: { type: "string" }, codes: { type: "boolean" }, code: { type: "object" }, revoke: { type: "string" }, archive: { type: ["string", "array"], items: { type: "string" } }, restore: { type: "string" }, sandbox: { type: "boolean" }, size: { type: "string" }, acknowledge: { type: "boolean" }, dryRun: { type: "boolean" } } }, | |
| 26 | "Forges sent from here.", | |
| 27 | inputSchema: { type: "object", properties: { name: { type: "string" }, kind: { enum: ["refused", "clients", "machines"] }, action: { enum: ["resend", "move", "recover", "upgrade"] }, to: {}, forge: { type: "string" }, plan: { type: "string" }, codes: { type: "boolean" }, code: { type: "object" }, revoke: { type: "string" }, archive: { type: ["string", "array"], items: { type: "string" } }, restore: { type: "string" }, sandbox: { type: "boolean" }, size: { type: "string" }, acknowledge: { type: "boolean" }, dryRun: { type: "boolean" } } }, | |
| 27 | 28 | writes: true, |
| 28 | 29 | tier: "delete", |
| 29 | 30 | deletes: (args) => args["archive"] !== undefined, |
| @@ -33,6 +34,16 @@ export const tool: Tool = { | ||
| 33 | 34 | async run(ctx, user, args) { |
| 34 | 35 | if (!user.isAdmin) |
| 35 | 36 | return bad("forbidden", "only an admin of this forge sees the forges it sent"); |
| 37 | if (args["action"] === "upgrade") { | |
| 38 | const [forge, plan, to] = [String(args["forge"] ?? ""), String(args["plan"] ?? ""), String(args["to"] ?? "")]; | |
| 39 | if (args["dryRun"] === false) { | |
| 40 | if (!scopeAllows(ctx.auth.scope ?? "ro", "admin")) return bad("forbidden", "upgrading a forge needs an admin token"); | |
| 41 | const done = await upgradeShared(ctx.app, user, forge, plan, to); | |
| 42 | return done.ok ? good(done) : bad(done.kind, done.says); | |
| 43 | } | |
| 44 | const planned = await planUpgrade(ctx.app, user, forge, plan, to); | |
| 45 | return planned.ok ? good({ ...planned.plan, says: `${planned.plan.says} Send dryRun: false to do it.` }) : bad(planned.kind, planned.says); | |
| 46 | } | |
| 36 | 47 | if (args["action"] === "move" || args["action"] === "recover") { |
| 37 | 48 | const [forge, to] = [String(args["forge"] ?? ""), String(args["to"] ?? "")]; |
| 38 | 49 | if (args["action"] === "recover" && args["dryRun"] === false) { |
src/tui/screens/forges.ts +59 −1
| @@ -23,6 +23,8 @@ import { archiveForge, archivedForges, destinationWords, restoreForge } from ".. | ||
| 23 | 23 | import { writeClientsCsv } from "../../spawn/clients_csv.ts"; |
| 24 | 24 | import { claimedWords, keepWords } from "../../spawn/keep_words.ts"; |
| 25 | 25 | import { changeLink, revokePreview, ownCode, removeForge, resizeForge, stopForge } from "../../spawn/manage.ts"; |
| 26 | import { dedicatedPlans, planUpgrade, sharedForges, upgradeShared } from "../../actions/upgrade_shared.ts"; | |
| 27 | import { usdPerMonthWords } from "../../billing/money.ts"; | |
| 26 | 28 | import { machinesOf } from "../../spawn/machines.ts"; |
| 27 | 29 | import { emptiest, machineLines, sampleBeats } from "../../spawn/machine_load.ts"; |
| 28 | 30 | import { moveToCell } from "../../spawn/move_cell.ts"; |
| @@ -285,6 +287,61 @@ export function forgesScreen(ctx: Ctx, rows: readonly ClientRow[], session?: Ses | ||
| 285 | 287 | }), |
| 286 | 288 | ); |
| 287 | 289 | }; |
| 290 | // The page's "Upgrade to a dedicated forge", through the same actions (`planUpgrade`, | |
| 291 | // `upgradeShared`): the plan, machine, price before and after, then the receipt. | |
| 292 | const upgradeOne = (): void => { | |
| 293 | const user = session?.user; | |
| 294 | if (session === undefined || user?.isAdmin !== true) return; | |
| 295 | const app = session.app; | |
| 296 | const declared = machinesOf(app); | |
| 297 | const shared = sharedForges(app, rows); | |
| 298 | const items = rows.filter((r) => r.made && r.placement === "cell" && shared.has(r.name)).map((r) => ({ id: r.name, label: r.name, hint: "shared" })); | |
| 299 | if (declared.length === 0) return ctx.toast("No other machine is declared (FORGE_MACHINES)"); | |
| 300 | if (items.length === 0) return ctx.toast("No forge on the shared plan runs in a sandbox of its own"); | |
| 301 | ctx.push( | |
| 302 | pickerScreen(ctx, screen, { | |
| 303 | title: "Upgrade which shared forge?", | |
| 304 | items, | |
| 305 | onPick: (ids) => { | |
| 306 | const name = ids[0]; | |
| 307 | if (name === undefined) return; | |
| 308 | ctx.push( | |
| 309 | pickerScreen(ctx, screen, { | |
| 310 | title: `Upgrade ${name} to which plan?`, | |
| 311 | items: dedicatedPlans(app).map((p) => ({ id: p.key, label: p.name, hint: usdPerMonthWords(p.priceUsd) })), | |
| 312 | onPick: (picked) => { | |
| 313 | const plan = picked[0]; | |
| 314 | if (plan === undefined) return; | |
| 315 | ctx.push( | |
| 316 | pickerScreen(ctx, screen, { | |
| 317 | title: `Upgrade ${name} on which machine?`, | |
| 318 | items: declared.map((m) => ({ id: m.name, label: m.name, hint: m.root })), | |
| 319 | onPick: (to) => { | |
| 320 | const target = to[0]; | |
| 321 | if (target === undefined) return; | |
| 322 | void planUpgrade(app, user, name, plan, target).then((planned) => { | |
| 323 | if (!planned.ok) return ctx.toast(planned.says, "danger"); | |
| 324 | ctx.push( | |
| 325 | confirmScreen(ctx, screen, { | |
| 326 | title: `Upgrade ${name} to ${planned.plan.change.to}?`, | |
| 327 | body: [planned.plan.says, ...planned.plan.steps], | |
| 328 | actions: [{ label: "Upgrade it" }, { label: "Leave it" }], | |
| 329 | onChoose: (i) => { | |
| 330 | if (i === 0) void upgradeShared(app, user, name, plan, target).then((done) => ctx.toast(done.says, done.ok ? "success" : "danger")); | |
| 331 | }, | |
| 332 | }), | |
| 333 | ); | |
| 334 | }); | |
| 335 | }, | |
| 336 | }), | |
| 337 | ); | |
| 338 | }, | |
| 339 | }), | |
| 340 | ); | |
| 341 | }, | |
| 342 | }), | |
| 343 | ); | |
| 344 | }; | |
| 288 | 345 | // Each machine's heartbeat and the emptiest, where a new forge goes (the MCP `kind: machines`). |
| 289 | 346 | const machinesSeen = (): void => { |
| 290 | 347 | if (session?.user?.isAdmin !== true) return; |
| @@ -333,7 +390,7 @@ export function forgesScreen(ctx: Ctx, rows: readonly ClientRow[], session?: Ses | ||
| 333 | 390 | }; |
| 334 | 391 | const screen: Screen = { |
| 335 | 392 | title: "Forges you sent", |
| 336 | keys: [binding(["s"], "stop"), binding(["a"], "archive"), binding(["r"], "restore"), binding(["x"], "remove"), binding(["n"], "new link"), binding(["l"], "end a link"), binding(["u"], "undo an ended link"), binding(["o"], "own code or this forge's"), binding(["m"], "move"), binding(["g"], "move to a machine"), binding(["v"], "restore from the newest copy"), binding(["h"], "machines' heartbeats"), binding(["w"], "raise to xlarge"), binding(["f"], "state"), binding(["/"], "search"), binding(["c"], "csv"), binding(["esc"], "close")], | |
| 393 | keys: [binding(["s"], "stop"), binding(["a"], "archive"), binding(["r"], "restore"), binding(["x"], "remove"), binding(["n"], "new link"), binding(["l"], "end a link"), binding(["u"], "undo an ended link"), binding(["o"], "own code or this forge's"), binding(["m"], "move"), binding(["g"], "move to a machine"), binding(["v"], "restore from the newest copy"), binding(["e"], "upgrade a shared forge"), binding(["h"], "machines' heartbeats"), binding(["w"], "raise to xlarge"), binding(["f"], "state"), binding(["/"], "search"), binding(["c"], "csv"), binding(["esc"], "close")], | |
| 337 | 394 | render(area, s) { |
| 338 | 395 | const c = ctx.theme.c; |
| 339 | 396 | const w = Math.min(100, Math.max(30, area.w - 6)); |
| @@ -399,6 +456,7 @@ export function forgesScreen(ctx: Ctx, rows: readonly ClientRow[], session?: Ses | ||
| 399 | 456 | } else if (e.key === "m") sandboxOne(); |
| 400 | 457 | else if (e.key === "g") machineOne(false); |
| 401 | 458 | else if (e.key === "v") machineOne(true); |
| 459 | else if (e.key === "e") upgradeOne(); | |
| 402 | 460 | else if (e.key === "h") machinesSeen(); |
| 403 | 461 | else if (e.key === "w") raiseOne(); |
| 404 | 462 | else if (e.key === "x" && session !== undefined) |
src/web/pages/forge_upgrade.ts added +68
| @@ -0,0 +1,68 @@ | ||
| 1 | /** | |
| 2 | * Upgrade a shared forge to a dedicated one, on the page (#17024): `GET /forges/:name/upgrade` | |
| 3 | * names the dedicated plans and machines; with `?plan=&to=` it shows what would happen and what | |
| 4 | * the forge pays before and after, and asks. `POST` does it and shows the receipt. The words are | |
| 5 | * `actions/upgrade_shared.ts`'s, the same the MCP `forges` tool and the terminal say. | |
| 6 | */ | |
| 7 | ||
| 8 | import { dedicatedPlans, planUpgrade, upgradeShared } from "../../actions/upgrade_shared.ts"; | |
| 9 | import type { Ctx } from "../../http/context.ts"; | |
| 10 | import { usdPerMonthWords } from "../../billing/money.ts"; | |
| 11 | import { machinesOf } from "../../spawn/machines.ts"; | |
| 12 | import { notFoundPage, pageHead } from "../chrome.ts"; | |
| 13 | import { readForm } from "../form.ts"; | |
| 14 | import { html, type Html } from "../html.ts"; | |
| 15 | import { page } from "../layout.ts"; | |
| 16 | import { btn } from "../ui.ts"; | |
| 17 | ||
| 18 | const back = (name: string) => btn("Back to your forges", { href: `/forges#forge-${name}`, size: "sm" }); | |
| 19 | ||
| 20 | const wrap = (name: string, body: Html) => | |
| 21 | html`<div class="narrow-wide" data-forges>${pageHead(`Upgrade ${name} to a dedicated forge`)}<section class="settings-block">${body}<p class="mt">${back(name)}</p></section></div>`; | |
| 22 | ||
| 23 | export async function forgeUpgradeForm(ctx: Ctx): Promise<Response> { | |
| 24 | const user = ctx.auth.user; | |
| 25 | if (!user?.isAdmin) return notFoundPage(ctx); | |
| 26 | const name = ctx.params["name"] ?? ""; | |
| 27 | const plan = ctx.url.searchParams.get("plan") ?? ""; | |
| 28 | const to = ctx.url.searchParams.get("to") ?? ""; | |
| 29 | const planned = plan === "" || to === "" ? undefined : await planUpgrade(ctx.app, user, name, plan, to); | |
| 30 | const plans = dedicatedPlans(ctx.app); | |
| 31 | const machines = machinesOf(ctx.app).map((m) => m.name); | |
| 32 | const body = | |
| 33 | planned === undefined | |
| 34 | ? html`<form method="get" action="/forges/${name}/upgrade" data-upgrade-choose> | |
| 35 | <p>Move ${name} to a dedicated machine, keeping its data:</p> | |
| 36 | <select name="plan" aria-label="Plan">${plans.map((p) => html`<option value="${p.key}">${p.name}, ${usdPerMonthWords(p.priceUsd)}</option>`)}</select> | |
| 37 | <select name="to" aria-label="Machine">${machines.map((m) => html`<option value="${m}">${m}</option>`)}</select> | |
| 38 | ${btn("See what it would do", { size: "sm" })} | |
| 39 | </form>` | |
| 40 | : planned.ok | |
| 41 | ? html`<p data-preview>${planned.plan.says}</p> | |
| 42 | ${planned.plan.steps.map((s) => html`<p data-step>${s}</p>`)} | |
| 43 | <form method="post" action="/forges/${name}/upgrade"> | |
| 44 | <input type="hidden" name="plan" value="${plan}" /> | |
| 45 | <input type="hidden" name="to" value="${to}" /> | |
| 46 | ${btn(`Upgrade to ${planned.plan.change.to}`, { variant: "primary", title: "It stays on the shared plan if the move fails" })} | |
| 47 | </form>` | |
| 48 | : html`<p role="status" data-preview>${planned.says}</p>`; | |
| 49 | const response = page({ ctx, title: "Upgrade to a dedicated forge", body: wrap(name, body) }, planned !== undefined && !planned.ok ? (planned.kind === "not_found" ? 404 : 409) : 200); | |
| 50 | response.headers.set("cache-control", "no-store"); | |
| 51 | return response; | |
| 52 | } | |
| 53 | ||
| 54 | export async function forgeUpgradeSubmit(ctx: Ctx): Promise<Response> { | |
| 55 | const user = ctx.auth.user; | |
| 56 | if (!user?.isAdmin) return notFoundPage(ctx); | |
| 57 | const form = await readForm(ctx, "admin"); | |
| 58 | if (form instanceof Response) return form; | |
| 59 | const name = ctx.params["name"] ?? ""; | |
| 60 | const done = await upgradeShared(ctx.app, user, name, String(form.get("plan") ?? ""), String(form.get("to") ?? "")); | |
| 61 | const title = done.ok ? "Forge upgraded" : "Forge not upgraded"; | |
| 62 | const response = page( | |
| 63 | { ctx, title, body: html`<div class="narrow-wide" data-forges>${pageHead(title)}<section class="settings-block"><p role="status" data-upgraded="${done.ok ? "yes" : done.kind}">${done.says}</p><p class="mt">${back(name)}</p></section></div>` }, | |
| 64 | done.ok ? 200 : done.kind === "not_found" ? 404 : 409, | |
| 65 | ); | |
| 66 | response.headers.set("cache-control", "no-store"); | |
| 67 | return response; | |
| 68 | } |
src/web/pages/forges.ts +6 −2
| @@ -26,6 +26,7 @@ import { listChildren } from "../../actions/spawn.ts"; | ||
| 26 | 26 | import { ownCode, removeForge, resizeForge, stopForge, type Managed } from "../../spawn/manage.ts"; |
| 27 | 27 | import { sizesView } from "../../spawn/sizes.ts"; |
| 28 | 28 | import { readOwnCode } from "../../spawn/own_code.ts"; |
| 29 | import { sharedForges } from "../../actions/upgrade_shared.ts"; | |
| 29 | 30 | import { machinesOf } from "../../spawn/machines.ts"; |
| 30 | 31 | import { moveToCell } from "../../spawn/move_cell.ts"; |
| 31 | 32 | import { sealedAt } from "../../spawn/sealed.ts"; |
| @@ -92,7 +93,7 @@ function activityNote(r: ClientRow, seenOnRow: boolean, now: number): Html | nul | ||
| 92 | 93 | |
| 93 | 94 | const XLARGE_SAYS = `${sizeWords("xlarge")}. ${sizesView().sizes.find((x) => x.size === "xlarge")?.says ?? ""}`; |
| 94 | 95 | |
| 95 | export function forgeRow(r: ClientRow, now: number, reach?: ForgeReach, bill = false, kept?: string, machines = false): Html { | |
| 96 | export function forgeRow(r: ClientRow, now: number, reach?: ForgeReach, bill = false, kept?: string, machines = false, shared = false): Html { | |
| 96 | 97 | const state = claimState(r); |
| 97 | 98 | const daysLeft = state === "no" ? daysLeftWords(r.link, now) : null; |
| 98 | 99 | const seen = seenOf(r); |
| @@ -186,6 +187,8 @@ export function forgeRow(r: ClientRow, now: number, reach?: ForgeReach, bill = f | ||
| 186 | 187 | </form>` |
| 187 | 188 | : null}${r.made && r.placement === "cell" && machines |
| 188 | 189 | ? btn("Move to another machine", { size: "sm", href: `/forges/${r.name}/machine`, title: "See what it would do and the budget, then confirm; it stays where it is if any step fails" }) |
| 190 | : null}${r.made && r.placement === "cell" && machines && shared | |
| 191 | ? btn("Upgrade to a dedicated forge", { size: "sm", href: `/forges/${r.name}/upgrade`, title: "Copies its data to a dedicated machine and changes its plan; it stays shared if the move fails" }) | |
| 189 | 192 | : null}${r.made && r.size !== "xlarge" |
| 190 | 193 | ? html`<form method="post" action="/forges/${r.name}/size" class="inline"> |
| 191 | 194 | <input type="hidden" name="size" value="xlarge" /> |
| @@ -290,6 +293,7 @@ export async function forgesPage(ctx: Ctx): Promise<Response> { | ||
| 290 | 293 | // Sizes that together pass the machine's memory are said in one line; nothing is refused for it. |
| 291 | 294 | const hostedKept = readHosted(ctx.app.config.dataDir); |
| 292 | 295 | const machines = machinesOf(ctx.app).length > 0; |
| 296 | const sharedNames = machines ? sharedForges(ctx.app, rows) : new Set<string>(); | |
| 293 | 297 | const over = memoryOverLine(forgesMemory(ctx.app, memoryOf(rows))); |
| 294 | 298 | const rendering = performance.now(); |
| 295 | 299 | const action = |
| @@ -339,7 +343,7 @@ export async function forgesPage(ctx: Ctx): Promise<Response> { | ||
| 339 | 343 | : state !== null && rows.length === 0 |
| 340 | 344 | ? html`<p data-empty>${CLIENT_STATE_EMPTY[state]}. <a href="/forges?sort=${sort}">All forges</a></p>` |
| 341 | 345 | : html`<ul class="list setting-list"> |
| 342 | ${rows.map((r) => forgeRow(r, now, reachOf.get(r.name), claimsBill(ctx.app.db, user, r.billTo), keptWords(hostedKept, r.name, now), machines))} | |
| 346 | ${rows.map((r) => forgeRow(r, now, reachOf.get(r.name), claimsBill(ctx.app.db, user, r.billTo), keptWords(hostedKept, r.name, now), machines, sharedNames.has(r.name)))} | |
| 343 | 347 | </ul>`} |
| 344 | 348 | </section>`} |
| 345 | 349 | ${sealedLine(ctx)} |
new above
offline