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

Empty words: move the studio and file renderers onto the shared table #15904

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/15903-empty-words-move-the-studio-and-file-ren → main 0 commits fork 3 threads · 3 unresolved

  • Merged. mason/15903-empty-words-move-the-studio-and-file-ren was merged into main as 80cfdb1.

Review

Sign in to review this change.
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
1111 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.
1212 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`.
1313 `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 = {
2222 runs: { sentence: "No run is open.", label: "Start with an issue", href: "/issues" },
2323 apps: { sentence: "Nothing runs here yet.", label: "New app", href: "/apps/new" },
2424 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." },
2534 people: { sentence: "Nobody has joined yet.", label: "Invite someone", href: "/admin/limits" },
2635 // Lists whose place exists only inside a page that already offers the next step (a form just
2736 // below): no label, so no link.
@@ -69,7 +78,6 @@ export const NOTE_WORDS = {
6978 nothingToApply: "Nothing to apply.",
7079 noDescription: "No description.",
7180 noDevicesDeclared: "No devices declared.",
72 noDependenciesListed: "No dependencies listed.",
7381 nothingIsWaitingToBeSent: "Nothing is waiting to be sent.",
7482 nothingYet: "Nothing yet.",
7583 noFlowLinesMatch: "No flow lines match.",
src/web/empty_words.ts +9
@@ -19,6 +19,15 @@ const ICONS = {
1919 apps: "rocket",
2020 people: "users",
2121 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",
2231 releases: "activity",
2332 appReleases: "tag",
2433 variants: "branch",
src/web/render/deps-manifest.ts +2 −2
@@ -7,8 +7,8 @@
77 * Every cell is escaped by the template; at most `ROW_CAP` rows per section.
88 */
99
10 import { emptyList } from "../empty_words.ts";
1011 import { html, type Html } from "../html.ts";
11 import { emptyNote } from "../empty_words.ts";
1212 import { fileSize } from "../ui.ts";
1313 import type { Json } from "./json-doc.ts";
1414 import type { Rendered, RenderInput } from "./renderers.ts";
@@ -223,7 +223,7 @@ export function depsManifest(input: RenderInput): Rendered {
223223 const more = s.total - s.rows.length;
224224 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``}`;
225225 });
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>`;
227227 const n = doc.sections.reduce((a, s) => a + s.total, 0);
228228 return { content, lines: 0, summary: `${n} ${n === 1 ? "entry" : "entries"} · ${fileSize(input.size)}` };
229229 }
src/web/render/ora.ts +2 −1
@@ -6,6 +6,7 @@
66 * type. A layer's size is the pixel size in its own PNG header.
77 */
88
9 import { emptyList } from "../empty_words.ts";
910 import { escapeHtml, html, raw } from "../html.ts";
1011 import { fileSize } from "../ui.ts";
1112 import { openPackage, tags, tidy, xmlAttr } from "./office-zip.ts";
@@ -87,7 +88,7 @@ export function ora(input: RenderInput): Rendered {
8788 const box = w !== null && h !== null ? ` width="${w}" height="${h}"` : "";
8889 const picture =
8990 stack.preview === null
90 ? `<p class="muted small">No merged preview in this file.</p>`
91 ? String(emptyList("preview", { noAction: true }))
9192 : `<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}>`;
9293 const more = stack.total > stack.layers.length ? `<p class="muted small">The first ${LAYERS} layers are shown.</p>` : "";
9394 const content = html`${raw(picture)}
src/web/render/sarif.ts +2 −1
@@ -10,6 +10,7 @@
1010 * file with no `runs` array, falls back to the source with the reason.
1111 */
1212
13 import { emptyList } from "../empty_words.ts";
1314 import { escapeHtml, html, raw } from "../html.ts";
1415 import { fileSize } from "../ui.ts";
1516 import type { Rendered, RenderInput } from "./renderers.ts";
@@ -114,7 +115,7 @@ export function sarif(input: RenderInput): Rendered {
114115 groups += `<h3>${escapeHtml(run.tool)} <span class="muted small">${n.toLocaleString()} ${n === 1 ? "result" : "results"}</span></h3>`;
115116 groups +=
116117 shown.length === 0
117 ? `<p class="muted small">No results.</p>`
118 ? String(emptyList("results", { noAction: true }))
118119 : `<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>`;
119120 }
120121 const out = total - Math.min(total, RESULT_CAP);
src/web/render/sbom.ts +2 −1
@@ -5,6 +5,7 @@
55 * source. Every string is escaped.
66 */
77
8 import { emptyList } from "../empty_words.ts";
89 import { escapeHtml, html, raw } from "../html.ts";
910 import { fileSize } from "../ui.ts";
1011 import type { Rendered, RenderInput } from "./renderers.ts";
@@ -76,7 +77,7 @@ export function sbom(input: RenderInput): Rendered {
7677 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>` : "";
7778 const table =
7879 total === 0
79 ? `<p class="muted small">No components.</p>`
80 ? String(emptyList("components", { noAction: true }))
8081 : `<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>`;
8182 return {
8283 lines: 0,
src/web/studio/cut_over.ts +2 −1
@@ -7,6 +7,7 @@
77 * `actions/cutover.ts`'s, the same the MCP tool uses.
88 */
99
10 import { emptyList } from "../empty_words.ts";
1011 import { cutOver, cutOverMessage, undoCutOver, type CutOver } from "../../actions/cutover.ts";
1112 import { getAppByRepo } from "../../core/apps.ts";
1213 import { listDomains } from "../../core/domains.ts";
@@ -65,7 +66,7 @@ function body(base: string, ctx: Ctx, repoName: string, shown: CutOver | undefin
6566 return html`${pageHead("Cut over", { sub: `Move ${repoName}'s domain from the platform to this app.` })}
6667 <section id="domains">
6768 ${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` })
6970 : html`<ul class="list">
7071 ${domains.map((d) => {
7172 const cut = d.cutOverAt !== null;
src/web/studio/data_move.ts +2 −1
@@ -8,6 +8,7 @@
88 * the gate are `actions/migrate_data.ts`'s, the same the API, the MCP tool and the terminal use.
99 */
1010
11 import { emptyList } from "../empty_words.ts";
1112 import { afterMoveWords, dataMoveState, moveData, moveMessage, undoMove, type MoveReceipt, type DataMoveState } from "../../actions/migrate_data.ts";
1213 import { lostKeys, skippedWords } from "../../apps/pg_dump.ts";
1314 import { notePhase, takeSessionTime } from "../../core/route_timing.ts";
@@ -86,7 +87,7 @@ function lastCard(state: DataMoveState): Html | null {
8687
8788 function body(base: string, state: DataMoveState, shown: MoveReceipt | undefined): Html {
8889 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` })

Principle 8 and 2: the page's hint to put dump.sql in 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 .sql mention is dropped.

9091 : html`<form method="post" action="${base}/data-move" class="row">
9192 <select class="input" name="dump" aria-label="Dump in the drop">
9293 ${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 @@
55 * (`pages/file_holds.ts`), which is where the admin and same-origin checks are.
66 */
77
8 import { emptyList } from "../empty_words.ts";
89 import { listFileHolds } from "../../actions/file_holds.ts";
910 import type { Repo } from "../../core/repos.ts";
1011 import { heldNow } from "../../crew/held.ts";
@@ -26,11 +27,11 @@ export function fileHoldsCard(ctx: Ctx, repo: Repo, base: string): Html | null {
2627 return html`<section class="settings-block" id="file-holds">
2728 <h2>Held files</h2>
2829 <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>
3233 ${listed.value.length === 0
33 ? html`<p class="muted" data-no-holds>No file is held.</p>`
34 ? emptyList("holds", { noAction: true })
3435 : html`<ul class="list setting-list">
3536 ${listed.value.map((h) => {
3637 const kept = issuesOf(h.path);
src/web/studio/home.ts +2 −1
@@ -6,6 +6,7 @@
66 * then the best of what is public (`actions/front.ts`).
77 */
88
9 import { emptyList } from "../empty_words.ts";
910 import { UPSTREAM_REPO } from "../../core/upstream.ts";
1011 import { SELF_HOST_NEEDS, selfHostCommands } from "../../core/self_host.ts";
1112 import { foundryHref } from "../../actions/foundry_door.ts";
@@ -141,7 +142,7 @@ function yourApps(ctx: Ctx, user: User, apps = writableAppsOf(ctx, user)): Html
141142 const archived = archivedAppCount(ctx);
142143 const foundry = foundryHref(ctx.app, ctx.auth.user);
143144 const list = html`${rows.length === 0
144 ? html`<p class="muted small">No apps yet.</p>`
145 ? emptyList("appList", { noAction: true })
145146 : html`<ul class="list">
146147 ${rows}
147148 </ul>`}
src/web/studio/jobs.ts +2 −1
@@ -10,6 +10,7 @@
1010 * `/:owner/:name/app/jobs/:id/:action`, same-origin checked by `readForm`.
1111 */
1212
13 import { emptyList } from "../empty_words.ts";
1314 import { requireWriter } from "../../actions/access.ts";
1415 import { JOB_WORDS, jobRows, jobTimers, steerJob, type JobRunRow } from "../../actions/jobs.ts";
1516 import type { Repo } from "../../core/repos.ts";
@@ -60,7 +61,7 @@ export async function jobsPage(ctx: Ctx): Promise<Response> {
6061 const body = !rows.ok
6162 ? empty({ icon: "alert", title: "The job runs could not be read", note: rows.error === "unreachable" ? JOB_WORDS.unreachable : "Try again in a moment." })
6263 : 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")
6465 : 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>
6566 <tbody>${rows.value.map((r) => runRow(base, r))}</tbody></table>`;
6667 const rendering = performance.now();
test/empty-notes.test.ts −2
@@ -26,8 +26,6 @@ const OWN_WORDS: Readonly<Record<string, number>> = {
2626 "src/web/pages/waves.ts": 1,
2727 "src/web/pages/sources.ts": 1,
2828 "src/web/pages/contribute.ts": 1,
29 "src/web/studio/cut_over.ts": 1,
30 "src/web/studio/data_move.ts": 1,
3129 };
3230
3331 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>> = {
5252 "src/web/pages/teams.ts": 1,
5353 "src/web/pages/trusted.ts": 1,
5454 "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,
6055 "src/web/studio/explore.ts": 1,
61 "src/web/studio/file_holds.ts": 1,
6256 "src/web/studio/hold.ts": 1,
63 "src/web/studio/home.ts": 1,
64 "src/web/studio/jobs.ts": 1,
6557 };
6658 const own = (src: string): number => [...src.matchAll(OWN_FORM)].length;
6759
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, "&#39;"));
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, "..");
2727 const MODULES = ["src/web/style.ts", "src/web/client.ts", "src/web/asset.ts"];
2828
2929 /** 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
3132 * any path into the apps graph — `runtime.ts`, `data.ts`, … — fails. */
3233 const HEAVY = [
33 /^src\/core\//,
34 /^src\/core\/(?!empty_words\.ts$)/,
3435 /^src\/db\//,
3536 /^src\/apps\/(?!env_phrase\.ts$)/,
3637 /^src\/web\/pages\/board\.ts$/,

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs