Public: anyone can read this; the crew can change it.
Empty words: move the studio and file renderers onto the shared table #15904
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/15903-empty-words-move-the-studio-and-file-ren → main 0 commits fork 3 threads · 3 unresolved
16 files
changed +81
−26
docs/features/empty-words.md +5
| @@ -11,3 +11,8 @@ One state is worded by its page on purpose: the commits page, when you have page | ||
| 11 | 11 | A filtered view (closed issues, one kind of event) passes its own title to `emptyList` and keeps the table's reason, if the kind has one. |
| 12 | 12 | Pages that still word their own "No …" line, as `empty({ title })` or a `<p class="… muted …">No …`, are counted in the ratchet at the top of `test/empty-words-all.test.ts`: the count may only fall. Try `/my-repos` on a fresh account, `/releases`, or `/root/fresh/forks`. |
| 13 | 13 | `test/empty-states.test.ts` and `test/empty-words-all.test.ts` hold every kind to its sentence, any reason to being more than the sentence, and any link to a place that exists. |
| 14 | ||
| 15 | The studio and file renderers draw theirs from the same table: `domains`, `dumps`, `jobs`, `holds`, | |
| 16 | `appList`, and the `preview`, `results`, `components` and `dependencies` of a rendered file. A | |
| 17 | `reason` is set only where the page does not already say what the list is; a `label` with no `href` | |
| 18 | means the page hands in its own place (a repository's settings, its drop); neither means no link. |
src/core/empty_words.ts +9 −1
| @@ -22,6 +22,15 @@ const TABLE = { | ||
| 22 | 22 | runs: { sentence: "No run is open.", label: "Start with an issue", href: "/issues" }, |
| 23 | 23 | apps: { sentence: "Nothing runs here yet.", label: "New app", href: "/apps/new" }, |
| 24 | 24 | waves: { sentence: "No waves yet.", label: "Tell the crew", href: "/tell" }, |
| 25 | domains: { sentence: "No verified domain yet.", reason: "Add one and check it in the app's settings first.", label: "App settings" }, | |
| 26 | dumps: { sentence: "No .sql file in the drop yet.", reason: "Put dump.sql in the app's drop (up to 16 MB).", label: "Open the drop" }, | |
| 27 | jobs: { sentence: "No job runs yet.", reason: "A run appears here when the app starts one with `job(…).start(…)`." }, | |
| 28 | holds: { sentence: "No file is held." }, | |
| 29 | appList: { sentence: "No apps yet." }, | |
| 30 | preview: { sentence: "No merged preview in this file." }, | |
| 31 | results: { sentence: "No results." }, | |
| 32 | components: { sentence: "No components." }, | |
| 33 | dependencies: { sentence: "No dependencies listed." }, | |
| 25 | 34 | people: { sentence: "Nobody has joined yet.", label: "Invite someone", href: "/admin/limits" }, |
| 26 | 35 | // Lists whose place exists only inside a page that already offers the next step (a form just |
| 27 | 36 | // below): no label, so no link. |
| @@ -69,7 +78,6 @@ export const NOTE_WORDS = { | ||
| 69 | 78 | nothingToApply: "Nothing to apply.", |
| 70 | 79 | noDescription: "No description.", |
| 71 | 80 | noDevicesDeclared: "No devices declared.", |
| 72 | noDependenciesListed: "No dependencies listed.", | |
| 73 | 81 | nothingIsWaitingToBeSent: "Nothing is waiting to be sent.", |
| 74 | 82 | nothingYet: "Nothing yet.", |
| 75 | 83 | noFlowLinesMatch: "No flow lines match.", |
src/web/empty_words.ts +9
| @@ -19,6 +19,15 @@ const ICONS = { | ||
| 19 | 19 | apps: "rocket", |
| 20 | 20 | people: "users", |
| 21 | 21 | waves: "activity", |
| 22 | domains: "globe", | |
| 23 | dumps: "repo", | |
| 24 | jobs: "clock", | |
| 25 | holds: "check", | |
| 26 | appList: "repo", | |
| 27 | preview: "search", | |
| 28 | results: "check", | |
| 29 | components: "search", | |
| 30 | dependencies: "search", | |
| 22 | 31 | releases: "activity", |
| 23 | 32 | appReleases: "tag", |
| 24 | 33 | variants: "branch", |
src/web/render/deps-manifest.ts +2 −2
| @@ -7,8 +7,8 @@ | ||
| 7 | 7 | * Every cell is escaped by the template; at most `ROW_CAP` rows per section. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { emptyList } from "../empty_words.ts"; | |
| 10 | 11 | import { html, type Html } from "../html.ts"; |
| 11 | import { emptyNote } from "../empty_words.ts"; | |
| 12 | 12 | import { fileSize } from "../ui.ts"; |
| 13 | 13 | import type { Json } from "./json-doc.ts"; |
| 14 | 14 | import type { Rendered, RenderInput } from "./renderers.ts"; |
| @@ -223,7 +223,7 @@ export function depsManifest(input: RenderInput): Rendered { | ||
| 223 | 223 | const more = s.total - s.rows.length; |
| 224 | 224 | return html`<h3>${s.title}</h3><div class="table-scroll"><table class="table" data-dense aria-label="${s.title}"><thead><tr>${s.columns.map((c) => html`<th scope="col">${c}</th>`)}</tr></thead><tbody>${rows}</tbody></table></div>${more > 0 ? html`<p class="muted small">${more} more not shown</p>` : html``}`; |
| 225 | 225 | }); |
| 226 | const content = html`<div class="package-view"><h2>${doc.title}</h2>${doc.facts.length > 0 ? html`<p class="muted small">${doc.facts.join(" · ")}</p>` : html``}${blocks.length > 0 ? blocks : emptyNote("noDependenciesListed")}</div>`; | |
| 226 | const content = html`<div class="package-view"><h2>${doc.title}</h2>${doc.facts.length > 0 ? html`<p class="muted small">${doc.facts.join(" · ")}</p>` : html``}${blocks.length > 0 ? blocks : emptyList("dependencies", { noAction: true })}</div>`; | |
| 227 | 227 | const n = doc.sections.reduce((a, s) => a + s.total, 0); |
| 228 | 228 | return { content, lines: 0, summary: `${n} ${n === 1 ? "entry" : "entries"} · ${fileSize(input.size)}` }; |
| 229 | 229 | } |
src/web/render/ora.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * type. A layer's size is the pixel size in its own PNG header. |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | import { emptyList } from "../empty_words.ts"; | |
| 9 | 10 | import { escapeHtml, html, raw } from "../html.ts"; |
| 10 | 11 | import { fileSize } from "../ui.ts"; |
| 11 | 12 | import { openPackage, tags, tidy, xmlAttr } from "./office-zip.ts"; |
| @@ -87,7 +88,7 @@ export function ora(input: RenderInput): Rendered { | ||
| 87 | 88 | const box = w !== null && h !== null ? ` width="${w}" height="${h}"` : ""; |
| 88 | 89 | const picture = |
| 89 | 90 | stack.preview === null |
| 90 | ? `<p class="muted small">No merged preview in this file.</p>` | |
| 91 | ? String(emptyList("preview", { noAction: true })) | |
| 91 | 92 | : `<img class="nb-img${w !== null && h !== null ? "" : " img-box"}" decoding="async" src="${stack.preview}" alt="Merged preview of ${escapeHtml(input.path.slice(input.path.lastIndexOf("/") + 1))}"${box}>`; |
| 92 | 93 | const more = stack.total > stack.layers.length ? `<p class="muted small">The first ${LAYERS} layers are shown.</p>` : ""; |
| 93 | 94 | const content = html`${raw(picture)} |
src/web/render/sarif.ts +2 −1
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | * file with no `runs` array, falls back to the source with the reason. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | import { emptyList } from "../empty_words.ts"; | |
| 13 | 14 | import { escapeHtml, html, raw } from "../html.ts"; |
| 14 | 15 | import { fileSize } from "../ui.ts"; |
| 15 | 16 | import type { Rendered, RenderInput } from "./renderers.ts"; |
| @@ -114,7 +115,7 @@ export function sarif(input: RenderInput): Rendered { | ||
| 114 | 115 | groups += `<h3>${escapeHtml(run.tool)} <span class="muted small">${n.toLocaleString()} ${n === 1 ? "result" : "results"}</span></h3>`; |
| 115 | 116 | groups += |
| 116 | 117 | shown.length === 0 |
| 117 | ? `<p class="muted small">No results.</p>` | |
| 118 | ? String(emptyList("results", { noAction: true })) | |
| 118 | 119 | : `<table class="table" data-dense aria-label="${escapeHtml(run.tool)} findings"><thead><tr><th scope="col">Level</th><th scope="col">Rule</th><th scope="col">Location</th><th scope="col">Message</th></tr></thead><tbody>${rows}</tbody></table>`; |
| 119 | 120 | } |
| 120 | 121 | const out = total - Math.min(total, RESULT_CAP); |
src/web/render/sbom.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * source. Every string is escaped. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { emptyList } from "../empty_words.ts"; | |
| 8 | 9 | import { escapeHtml, html, raw } from "../html.ts"; |
| 9 | 10 | import { fileSize } from "../ui.ts"; |
| 10 | 11 | import type { Rendered, RenderInput } from "./renderers.ts"; |
| @@ -76,7 +77,7 @@ export function sbom(input: RenderInput): Rendered { | ||
| 76 | 77 | const more = left > 0 ? `<p class="muted small">Showing ${COMPONENT_CAP.toLocaleString()} of ${total.toLocaleString()} components, ${left.toLocaleString()} left out. The rest is in the raw file.</p>` : ""; |
| 77 | 78 | const table = |
| 78 | 79 | total === 0 |
| 79 | ? `<p class="muted small">No components.</p>` | |
| 80 | ? String(emptyList("components", { noAction: true })) | |
| 80 | 81 | : `<div class="table-scroll"><table class="table" data-dense aria-label="Components"><thead><tr><th scope="col">Name</th><th scope="col">Version</th><th scope="col">Licence</th></tr></thead><tbody>${rows}</tbody></table></div>`; |
| 81 | 82 | return { |
| 82 | 83 | lines: 0, |
src/web/studio/cut_over.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * `actions/cutover.ts`'s, the same the MCP tool uses. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { emptyList } from "../empty_words.ts"; | |
| 10 | 11 | import { cutOver, cutOverMessage, undoCutOver, type CutOver } from "../../actions/cutover.ts"; |
| 11 | 12 | import { getAppByRepo } from "../../core/apps.ts"; |
| 12 | 13 | import { listDomains } from "../../core/domains.ts"; |
| @@ -65,7 +66,7 @@ function body(base: string, ctx: Ctx, repoName: string, shown: CutOver | undefin | ||
| 65 | 66 | return html`${pageHead("Cut over", { sub: `Move ${repoName}'s domain from the platform to this app.` })} |
| 66 | 67 | <section id="domains"> |
| 67 | 68 | ${domains.length === 0 |
| 68 | ? html`<p class="muted">No verified domain yet. Add one and check it in the <a href="${base}/settings/app">app's settings</a> first.</p>` | |
| 69 | ? emptyList("domains", { href: `${base}/settings/app` }) | |
| 69 | 70 | : html`<ul class="list"> |
| 70 | 71 | ${domains.map((d) => { |
| 71 | 72 | const cut = d.cutOverAt !== null; |
src/web/studio/data_move.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * the gate are `actions/migrate_data.ts`'s, the same the API, the MCP tool and the terminal use. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { emptyList } from "../empty_words.ts"; | |
| 11 | 12 | import { afterMoveWords, dataMoveState, moveData, moveMessage, undoMove, type MoveReceipt, type DataMoveState } from "../../actions/migrate_data.ts"; |
| 12 | 13 | import { lostKeys, skippedWords } from "../../apps/pg_dump.ts"; |
| 13 | 14 | import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; |
| @@ -86,7 +87,7 @@ function lastCard(state: DataMoveState): Html | null { | ||
| 86 | 87 | |
| 87 | 88 | function body(base: string, state: DataMoveState, shown: MoveReceipt | undefined): Html { |
| 88 | 89 | const form = state.files.length === 0 |
| 89 | ? html`<p class="muted">No <span class="mono">.sql</span> file in the drop yet. Put <span class="mono">dump.sql</span> in the app's <a href="${base}/drop">drop</a> (up to 16 MB).</p>` | |
| 90 | ? emptyList("dumps", { href: `${base}/drop` }) | |
| 90 | 91 | : html`<form method="post" action="${base}/data-move" class="row"> |
| 91 | 92 | <select class="input" name="dump" aria-label="Dump in the drop"> |
| 92 | 93 | ${state.files.map((f) => html`<option value="${f.name}">${f.name} (${fileSize(f.bytes)})</option>`)} |
src/web/studio/file_holds.ts +5 −4
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | * (`pages/file_holds.ts`), which is where the admin and same-origin checks are. |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | import { emptyList } from "../empty_words.ts"; | |
| 8 | 9 | import { listFileHolds } from "../../actions/file_holds.ts"; |
| 9 | 10 | import type { Repo } from "../../core/repos.ts"; |
| 10 | 11 | import { heldNow } from "../../crew/held.ts"; |
| @@ -26,11 +27,11 @@ export function fileHoldsCard(ctx: Ctx, repo: Repo, base: string): Html | null { | ||
| 26 | 27 | return html`<section class="settings-block" id="file-holds"> |
| 27 | 28 | <h2>Held files</h2> |
| 28 | 29 | <p class="muted small"> |
| 29 | No build starts on an issue that names a held path. Nothing already | |
| 30 | running is cut. | |
| 31 | </p> | |
| 30 | A build does not start on an issue that names a held path. Nothing already | |
| 31 | running is cut. | |
| 32 | </p> | |
| 32 | 33 | ${listed.value.length === 0 |
| 33 | ? html`<p class="muted" data-no-holds>No file is held.</p>` | |
| 34 | ? emptyList("holds", { noAction: true }) | |
| 34 | 35 | : html`<ul class="list setting-list"> |
| 35 | 36 | ${listed.value.map((h) => { |
| 36 | 37 | const kept = issuesOf(h.path); |
src/web/studio/home.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | * then the best of what is public (`actions/front.ts`). |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | import { emptyList } from "../empty_words.ts"; | |
| 9 | 10 | import { UPSTREAM_REPO } from "../../core/upstream.ts"; |
| 10 | 11 | import { SELF_HOST_NEEDS, selfHostCommands } from "../../core/self_host.ts"; |
| 11 | 12 | import { foundryHref } from "../../actions/foundry_door.ts"; |
| @@ -141,7 +142,7 @@ function yourApps(ctx: Ctx, user: User, apps = writableAppsOf(ctx, user)): Html | ||
| 141 | 142 | const archived = archivedAppCount(ctx); |
| 142 | 143 | const foundry = foundryHref(ctx.app, ctx.auth.user); |
| 143 | 144 | const list = html`${rows.length === 0 |
| 144 | ? html`<p class="muted small">No apps yet.</p>` | |
| 145 | ? emptyList("appList", { noAction: true }) | |
| 145 | 146 | : html`<ul class="list"> |
| 146 | 147 | ${rows} |
| 147 | 148 | </ul>`} |
src/web/studio/jobs.ts +2 −1
| @@ -10,6 +10,7 @@ | ||
| 10 | 10 | * `/:owner/:name/app/jobs/:id/:action`, same-origin checked by `readForm`. |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | import { emptyList } from "../empty_words.ts"; | |
| 13 | 14 | import { requireWriter } from "../../actions/access.ts"; |
| 14 | 15 | import { JOB_WORDS, jobRows, jobTimers, steerJob, type JobRunRow } from "../../actions/jobs.ts"; |
| 15 | 16 | import type { Repo } from "../../core/repos.ts"; |
| @@ -60,7 +61,7 @@ export async function jobsPage(ctx: Ctx): Promise<Response> { | ||
| 60 | 61 | const body = !rows.ok |
| 61 | 62 | ? empty({ icon: "alert", title: "The job runs could not be read", note: rows.error === "unreachable" ? JOB_WORDS.unreachable : "Try again in a moment." }) |
| 62 | 63 | : rows.value.length === 0 |
| 63 | ? empty({ icon: "clock", title: "No job runs yet", note: "A run appears here when the app starts one with `job(…).start(…)`." }) | |
| 64 | ? emptyList("jobs") | |
| 64 | 65 | : html`<table class="table"><thead><tr><th>Job</th><th>Key</th><th>Started</th><th>Where it is now</th><th></th></tr></thead> |
| 65 | 66 | <tbody>${rows.value.map((r) => runRow(base, r))}</tbody></table>`; |
| 66 | 67 | const rendering = performance.now(); |
test/empty-notes.test.ts −2
| @@ -26,8 +26,6 @@ const OWN_WORDS: Readonly<Record<string, number>> = { | ||
| 26 | 26 | "src/web/pages/waves.ts": 1, |
| 27 | 27 | "src/web/pages/sources.ts": 1, |
| 28 | 28 | "src/web/pages/contribute.ts": 1, |
| 29 | "src/web/studio/cut_over.ts": 1, | |
| 30 | "src/web/studio/data_move.ts": 1, | |
| 31 | 29 | }; |
| 32 | 30 | |
| 33 | 31 | test("the pages that still word their own empty note are the ones named, no more", async () => { |
test/empty-words-all.test.ts −8
| @@ -52,16 +52,8 @@ const OWN_WORDS: Readonly<Record<string, number>> = { | ||
| 52 | 52 | "src/web/pages/teams.ts": 1, |
| 53 | 53 | "src/web/pages/trusted.ts": 1, |
| 54 | 54 | "src/web/pages/visitors.ts": 1, |
| 55 | "src/web/render/ora.ts": 1, | |
| 56 | "src/web/render/sarif.ts": 1, | |
| 57 | "src/web/render/sbom.ts": 1, | |
| 58 | "src/web/studio/cut_over.ts": 1, | |
| 59 | "src/web/studio/data_move.ts": 1, | |
| 60 | 55 | "src/web/studio/explore.ts": 1, |
| 61 | "src/web/studio/file_holds.ts": 1, | |
| 62 | 56 | "src/web/studio/hold.ts": 1, |
| 63 | "src/web/studio/home.ts": 1, | |
| 64 | "src/web/studio/jobs.ts": 1, | |
| 65 | 57 | }; |
| 66 | 58 | const own = (src: string): number => [...src.matchAll(OWN_FORM)].length; |
| 67 | 59 |
test/empty-words-studio.test.ts added +34
| @@ -0,0 +1,34 @@ | ||
| 1 | /** | |
| 2 | * The studio and file renderers word their empty lists from `EMPTY_WORDS` (#15903): none of these | |
| 3 | * files writes its own "No …" paragraph, and each new kind draws its sentence, its reason and at | |
| 4 | * most one plain link. | |
| 5 | */ | |
| 6 | import { expect, test } from "bun:test"; | |
| 7 | import { EMPTY_WORDS, emptyList } from "../src/web/empty_words.ts"; | |
| 8 | ||
| 9 | const FILES = [ | |
| 10 | "studio/cut_over.ts", "studio/data_move.ts", "studio/home.ts", "studio/jobs.ts", "studio/file_holds.ts", | |
| 11 | "render/deps-manifest.ts", "render/ora.ts", "render/sarif.ts", "render/sbom.ts", | |
| 12 | ]; | |
| 13 | ||
| 14 | test("these files no longer word their own empty paragraph", async () => { | |
| 15 | for (const f of FILES) { | |
| 16 | const src = await Bun.file(new URL(`../src/web/${f}`, import.meta.url)).text(); | |
| 17 | expect(src.match(/<p class="muted[^"]*"[^>]*>No /g) ?? [], f).toEqual([]); | |
| 18 | expect(src, f).toContain("emptyList("); | |
| 19 | } | |
| 20 | }); | |
| 21 | ||
| 22 | test("each kind draws its sentence and reason, and a link only where a place is given", () => { | |
| 23 | const kinds: Parameters<typeof emptyList>[0][] = ["domains", "dumps", "jobs", "holds", "appList", "preview", "results", "components", "dependencies"]; | |
| 24 | for (const k of kinds) { | |
| 25 | const out = String(emptyList(k, { href: "/x/y" })); | |
| 26 | expect(out).toContain(EMPTY_WORDS[k].sentence); | |
| 27 | const w = EMPTY_WORDS[k]; | |
| 28 | if (w.reason !== undefined) expect(out).toContain(w.reason.replace(/'/g, "'")); | |
| 29 | expect((out.match(/<a\b/g) ?? []).length).toBe(w.label === undefined ? 0 : 1); | |
| 30 | expect(out).not.toContain('data-variant="primary"'); | |
| 31 | } | |
| 32 | expect(String(emptyList("domains", { href: "/a/settings/app" }))).toContain('href="/a/settings/app"'); | |
| 33 | expect(String(emptyList("dumps", { noAction: true }))).not.toContain("<a"); | |
| 34 | }); |
test/web-import-cost.test.ts +3 −2
| @@ -27,10 +27,11 @@ const ROOT = join(import.meta.dir, ".."); | ||
| 27 | 27 | const MODULES = ["src/web/style.ts", "src/web/client.ts", "src/web/asset.ts"]; |
| 28 | 28 | |
| 29 | 29 | /** Modules the static web must never pull in: the data graph and the pages. |
| 30 | * Of `src/apps/` only `env_phrase.ts` (plain words, type-only imports) is allowed, so | |
| 30 | * `src/core/empty_words.ts` (the plain-words table, no imports) is allowed too. Of `src/apps/` | |
outdated
A blank line landed inside the JSDoc block, and the line after it is overlong. Put the empty_words exception on its own wrapped line without the blank. |
||
| 31 | * only `env_phrase.ts` (plain words, type-only imports) is allowed, so | |
| 31 | 32 | * any path into the apps graph — `runtime.ts`, `data.ts`, … — fails. */ |
| 32 | 33 | const HEAVY = [ |
| 33 | /^src\/core\//, | |
| 34 | /^src\/core\/(?!empty_words\.ts$)/, | |
| 34 | 35 | /^src\/db\//, |
| 35 | 36 | /^src\/apps\/(?!env_phrase\.ts$)/, |
| 36 | 37 | /^src\/web\/pages\/board\.ts$/, |
new above
offline
Principle 8 and 2: the page's hint to put
dump.sqlin the drop (up to 16 MB) used to name the file type in monospace. The shared reason now carries it as plain text; acceptable, but make sure the reason reads as one sentence, since the.sqlmention is dropped.