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

Every list page that says "nothing here" says why and offers one next step, from one table of empty words #15873

Merged opened this

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

Merged

scout/forge:scout/15851-every-list-page-that-says-nothing-here-s → main 0 commits fork 8 threads · 8 unresolved

  • Merged. scout/15851-every-list-page-that-says-nothing-here-s was merged into main as 5b6d5a8.

Review

Sign in to review this change.
24 files changed +249 −74
docs/features/empty-words.md +10 −18
@@ -1,21 +1,13 @@
11 ---
2 topic: What a forge is
3 row: Empty lists
2 topic: When something is wrong
3 row: Empty lists say why
44 ---
5 # Empty lists
5 # Empty lists say why
66
7 The board, inbox, runs, apps and people lists word their empty state from one table,
8 `EMPTY_WORDS` in `src/core/empty_words.ts`: one plain sentence and one link each.
9
10 - **Web:** a page draws it with `emptyList(kind)` (`src/web/empty_words.ts`). The link is a plain
11 link, never a primary button, so an empty state adds no second accent. A page may name where the
12 link goes (a repository's own issues), or pass `noAction` when the viewer cannot take it or the
13 page already offers it (apps: the header has "New app"; boards: "Make a board" sits just below).
14 - **Terminal:** the boards, runs, apps and inbox screens take their empty title from the same
15 `sentence`; they keep their own key hints as the body, because a terminal has keys, not links.
16 The people screen is never empty (the signed-in admin is always one).
17 - "Invite someone" goes to `/admin/limits`, where invite links are minted; the people page is
18 admin-only, so only an admin ever sees it.
19
20 A new list that can be empty gets a row in the table, not its own words.
21 `test/empty-states.test.ts` walks the lists and holds each to its sentence and its link.
7 Every list page that has nothing to show draws one sentence and at most one next step, all from one table: `EMPTY_WORDS` in `src/core/empty_words.ts`. The web reads it through `emptyList(kind)` (`src/web/empty_words.ts`); the terminal reads the same table for the sentence (`src/tui/screens/*`, `emptyState`), so a screen never words its own.
8 A reason line is opt-in per kind: only where the page does not already say what the list is (releases, forks, commits, displays), since nothing explains itself twice. A link is opt-in too: a kind names an href only where that place exists unscoped (`/new`, `/tell`); a repository's list hands in its own (`emptyList("builds", { href })`), and with none the state draws no link. An origin's list read live passes its own `note`.
9 Kinds: board, inbox, runs, apps, people, waves, builds, releases, forks, repos, commits, displays, issues, pulls, branches, labels, events. The terminal's repositories, forks, releases and displays screens read the same words; `NO_RELEASES_YET` and `DISPLAYS_NOTE` are the table's reasons, not copies.
10 One state is worded by its page on purpose: the commits page, when you have paged past the end of a history that has commits, says so itself ("No commits on this page"); that is a place in a list, not an empty list.
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 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 `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.
src/core/empty_words.ts +35 −4
@@ -5,14 +5,34 @@
55 * every kind and holds each to its sentence and its single link.

Entries carry hrefs like /branches, /fork, /issues/new that do not exist unscoped; most are only ever used with noAction. Make href/label optional and drop the false ones.

66 */
77
8 export type EmptyKind = "board" | "inbox" | "runs" | "apps" | "people" | "waves";
8 export type EmptyKind = "board" | "inbox" | "runs" | "apps" | "people" | "waves"
9 | "builds"
10 | "releases"
11 | "forks"
12 | "repos"
13 | "commits"
14 | "displays"
15 | "issues"
16 | "pulls"
17 | "branches"
18 | "labels"
19 | "events";
920
1021 export interface EmptyWords {
1122 /** One sentence, plain words, ending in a full stop. */
1223 readonly sentence: string;
13 /** The one action, and where it goes when the page does not say otherwise. */
14 readonly label: string;
15 readonly href: string;
24 /**
25 * Why it is empty, in one calm sentence, only where the page does not already say it: a list that
26 * names what it is carries none (nothing explains itself twice).
27 */
28 readonly reason?: string;
29 /** The one action's words, only where one exists. */
30 readonly label?: string;
31 /**
32 * Where the action goes, only where that place exists unscoped; a repository's list hands in its
33 * own (`emptyList(kind, { href })`), and a label with no href and none handed in draws no link.
34 */
outdated

Principle 1: the forks reason is two clauses long and explains the concept twice. Cut it to one sentence, e.g. 'A fork is a copy that can send changes back here.'

35 readonly href?: string;
outdated

Principle 1/8: 'Repositories you can write to are listed here.' restates the sentence and does not say why it is empty or what puts something here. Try: 'A repository appears here once you create one or are given write access.'

1636 }
1737
1838 export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = {
@@ -22,4 +42,15 @@ export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = {
2242 apps: { sentence: "Nothing runs here yet.", label: "New app", href: "/apps/new" },
2343 waves: { sentence: "No waves yet.", label: "Tell the crew", href: "/tell" },
2444 people: { sentence: "Nobody has joined yet.", label: "Invite someone", href: "/admin/limits" },
45 builds: { sentence: "No builds yet.", label: "Pin one from a branch" },
46 releases: { sentence: "No releases yet.", reason: "A pull landed on the forge's own repository is recorded here." },
47 forks: { sentence: "No forks yet.", reason: "A fork is a copy under another name that can propose changes back here, and follows this one until it has work of its own." },
48 repos: { sentence: "No repositories yet.", label: "New repository", href: "/new" },
49 commits: { sentence: "No commits yet.", reason: "Push a branch and its history shows up here." },
50 issues: { sentence: "No issues yet." },
51 pulls: { sentence: "No pulls yet." },
52 branches: { sentence: "No branches yet." },
53 labels: { sentence: "No labels yet." },
54 events: { sentence: "No events yet." },
55 displays: { sentence: "No displays yet.", reason: "Add a display.json to a repository's default branch to make one." },
2556 };
src/display/known.ts +2 −1
@@ -16,6 +16,7 @@
1616
1717 import type { App } from "../app.ts";
1818 import { listAdminOwnedRepos, listEveryRepo, readableRepoIds, repoDatesFor, type Repo } from "../core/repos.ts";
19 import { EMPTY_WORDS } from "../core/empty_words.ts";
1920 import type { User } from "../core/users.ts";
2021 import { listBuildPins } from "../git/builds.ts";
2122 import { repoDir } from "../git/repos.ts";
@@ -315,7 +316,7 @@ export async function withoutDisplay(app: App, repos: readonly Repo[]): Promise<
315316 /** What a display is; the page and the terminal screen say it once, above the list. */
316317 export const DISPLAYS_SENTENCE = "A display is a showcase screen for a repository: its pinned demos, laid out as a shelf, grid or graph, to open full screen.";
317318 /** How to make one; the empty state of the page and of the terminal screen. */
318 export const DISPLAYS_NOTE = "Add a display.json to a repository's default branch to make one.";
319 export const DISPLAYS_NOTE = EMPTY_WORDS.displays.reason ?? "";
319320 /** The link text for a display whose file does not parse. */
320321 export const INVALID_TITLE = "display.json is invalid";
321322 /** Said while a cold list is still reading; an empty cold answer says only this, never "No displays". */
src/release/words.ts +3 −1
@@ -5,6 +5,8 @@
55 * the sha; the terminal with `plain`, joining the parts as they are.
66 */
77
8 import { EMPTY_WORDS } from "../core/empty_words.ts";
9
810 /** A template tag: the page's `html`, or `plain` for the terminal. */
911 export type Tag<T, V> = (strings: TemplateStringsArray, ...values: V[]) => T;
1012
@@ -19,7 +21,7 @@ export function liveSince<T, V>(tag: Tag<T, V>, sha: V, since: V): T {
1921 }
2022
2123 /** What the empty releases view says will fill it. */
22 export const NO_RELEASES_YET = "A pull landed on the forge's own repository is recorded here.";
24 export const NO_RELEASES_YET = EMPTY_WORDS.releases.reason ?? "";
2325
2426 /** Why a kept release offers no rollback: it is the one serving. */
2527 export const ALREADY_LIVE = "This release is the one serving; there is nothing to roll back to.";
src/tui/screens/builds.ts +2 −1
@@ -8,6 +8,7 @@
88 * which check again.
99 */
1010
11 import { EMPTY_WORDS } from "../../core/empty_words.ts";
1112 import { setCart } from "../../actions/build_cart.ts";
1213 import { deletePin, notePin, pinBuild } from "../../actions/builds.ts";
1314 import { canRead, canWrite, type Repo } from "../../core/repos.ts";
@@ -25,7 +26,7 @@ import { shotsScreen } from "./shots.ts";
2526 import { ListState, ago, confirmScreen, metaOf, promptScreen } from "./common.ts";
2627
2728 export const NOT_FOUND_LINE = "No such repository";
28 export const NO_BUILDS_LINE = "No builds pinned yet.";
29 export const NO_BUILDS_LINE = EMPTY_WORDS.builds.sentence;
2930 export const DELETED_LINE = "Deleted that pin; its commit and notes stay.";
3031
3132 /** What a refused or failed action reads as. */
src/tui/screens/commits.ts +2 −1
@@ -20,6 +20,7 @@ import { fill, len, split } from "../ui/layout.ts";
2020 import type { Tokens } from "../ui/theme.ts";
2121 import { numberWidth, renderFileDiff } from "../ui/diff.ts";
2222 import type { KeyEvent } from "../term/input.ts";
23 import { EMPTY_WORDS } from "../../core/empty_words.ts";
2324 import { card, emptyState } from "../ui/widgets.ts";
2425 import type { Session } from "../session.ts";
2526 import {
@@ -135,7 +136,7 @@ export function commitsScreen(
135136 );
136137 if (commits.length === 0) {
137138 emptyState(s, body!, c, {
138 title: loaded ? "No commits" : "Reading…",
139 title: loaded ? EMPTY_WORDS.commits.sentence : "Reading…",
139140 body: loaded
140141 ? `Nothing has landed on ${ref} yet.`
141142 : `Reading the log of ${ref}`,
src/tui/screens/dashboard.ts +2 −1
@@ -101,6 +101,7 @@ import type { Tokens } from "../ui/theme.ts";
101101 import { truncate } from "../term/width.ts";
102102 import { beside, fill, len, split } from "../ui/layout.ts";
103103 import { icon, type IconSet } from "../ui/icons.ts";
104 import { EMPTY_WORDS } from "../../core/empty_words.ts";
104105 import { card, emptyState } from "../ui/widgets.ts";
105106 import type { Session } from "../session.ts";
106107 import {
@@ -1787,7 +1788,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
17871788 const on = focus === "repos";
17881789 if (rows.length === 0) {
17891790 emptyState(s, r, c, {
1790 title: f.signedIn ? "No repositories yet" : "Nothing public yet",
1791 title: f.signedIn ? EMPTY_WORDS.repos.sentence : "Nothing public yet",
17911792 body: f.signedIn
17921793 ? "Press n for a new repository, or / to find one."
17931794 : "Press s to sign in, or / to find one.",
src/tui/screens/forks.ts +3 −2
@@ -40,6 +40,7 @@ import { binding } from "../app/keys.ts";
4040 import { style } from "../term/style.ts";
4141 import { truncate, wrap } from "../term/width.ts";
4242 import { fill, len, split } from "../ui/layout.ts";
43 import { EMPTY_WORDS } from "../../core/empty_words.ts";
4344 import { emptyState } from "../ui/widgets.ts";
4445 import type { Session } from "../session.ts";
4546 import { issueScreen } from "./issue.ts";
@@ -398,8 +399,8 @@ export function forksScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
398399 }
399400 if (list.length === 0) {
400401 emptyState(s, body!, c, {
401 title: ranked === undefined ? "Reading…" : "No forks yet",
402 body: "",
402 title: ranked === undefined ? "Reading…" : EMPTY_WORDS.forks.sentence,
403 body: ranked === undefined ? "" : EMPTY_WORDS.forks.reason ?? "",
403404 });
404405 return;
405406 }
src/tui/screens/releases.ts +2 −1
@@ -19,6 +19,7 @@ import type { Session } from "../session.ts";
1919 import { style } from "../term/style.ts";
2020 import { truncate } from "../term/width.ts";
2121 import { fill, len, split } from "../ui/layout.ts";
22 import { EMPTY_WORDS } from "../../core/empty_words.ts";
2223 import { emptyState } from "../ui/widgets.ts";
2324 import { ListState, confirmScreen, drawList, hitList, ago, metaOf, runAsync, type ListRow } from "./common.ts";
2425
@@ -112,7 +113,7 @@ export function releasesScreen(f: Session, ctx: Ctx): Screen {
112113 s.text(head!.x, head!.y, truncate([liveText(f), journeyText(f)].filter((x) => x !== undefined).join(" · "), head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
113114 if (lines.length === 0) {
114115 emptyState(s, body!, c, {
115 title: loaded ? "No releases yet" : "Reading…",
116 title: loaded ? EMPTY_WORDS.releases.sentence : "Reading…",
116117 body: NO_RELEASES_YET,
117118 });
118119 return;
src/tui/screens/repolist.ts +2 −1
@@ -3,6 +3,7 @@
33 * write, from `listReposWritableTo`. Enter opens one as the dashboard does.
44 */
55
6 import { EMPTY_WORDS } from "../../core/empty_words.ts";
67 import { listReposWritableTo, type Repo } from "../../core/repos.ts";
78 import type { Ctx, Screen } from "../app/app.ts";
89 import { binding } from "../app/keys.ts";
@@ -25,7 +26,7 @@ export function repoListScreen(f: Session, ctx: Ctx): Screen {
2526 const c = ctx.theme.c;
2627 const repos = read();
2728 const [head, list] = split(area, "v", [len(1), fill(1)]);
28 const text = repos.length === 0 ? "No repositories yet." : `${repos.length} repositories you may write`;
29 const text = repos.length === 0 ? EMPTY_WORDS.repos.sentence : `${repos.length} repositories you may write`;
2930 s.text(head!.x, head!.y, truncate(text, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
3031 const rows: ListRow[] = repos.map((r) => ({ title: `${r.ownerName}/${r.name}` }));
3132 drawList(s, list!, c, state, rows);
src/web/empty_words.ts +23 −2
@@ -18,6 +18,17 @@ const ICONS: Readonly<Record<EmptyKind, IconName>> = {
1818 apps: "repo",
1919 people: "users",
2020 waves: "activity",
21 builds: "pin",
22 releases: "activity",
23 forks: "fork",
24 repos: "repo",
25 commits: "commit",
26 displays: "pin",
27 issues: "issue",
28 pulls: "pull",
29 branches: "branch",
30 labels: "tag",
31 events: "activity",
2132 };
2233
2334 export interface EmptyOptions {
@@ -25,15 +36,25 @@ export interface EmptyOptions {
2536 href?: string;
2637 /** Leave the link out: the viewer cannot take the action, or the page already offers it. */
2738 noAction?: boolean;
39 /** A filtered view names its filter ("No closed issues"); the reason stays the table's. */
40 title?: string;
41 /** A list whose reason is its own (an origin's list, read live) hands it in. */
42 note?: string;
43 /** A page that has its own action (a link back to the unfiltered list) hands it in. */
44 action?: Html;
2845 bind?: string | undefined;
2946 }
3047
3148 export function emptyList(kind: EmptyKind, o: EmptyOptions = {}): Html {
3249 const w = EMPTY_WORDS[kind];
50 const note = o.note ?? w.reason;
51 const href = o.href ?? w.href;
52 const action = o.action ?? (o.noAction || w.label === undefined || href === undefined ? undefined : btn(w.label, { href, variant: "link" }));
outdated

Principle 1: a reason line under every sentence is a second explanation on lists that already say what they are. Make it opt-in per kind, not universal.

3353 return empty({
3454 icon: ICONS[kind],
35 title: w.sentence,
36 ...(o.noAction ? {} : { action: btn(w.label, { href: o.href ?? w.href, variant: "link" }) }),
55 title: o.title ?? w.sentence,
56 ...(note === undefined ? {} : { note }),
57 ...(action === undefined ? {} : { action }),
3758 bind: o.bind,
3859 });
3960 }
src/web/pages/branches.ts +2 −6
@@ -15,6 +15,7 @@
1515 * are readable and nothing more, which is the whole rule of a live browse.
1616 */
1717
18 import { emptyList } from "../empty_words.ts";
1819 import { createBranch, deleteBranch } from "../../actions/branches.ts";
1920 import type { Repo } from "../../core/repos.ts";
2021 import { notePhase, takeSessionTime, timePhaseAsync } from "../../core/route_timing.ts";
@@ -33,7 +34,6 @@ import { localScope } from "../scope.ts";
3334 import {
3435 badge,
3536 btn,
36 empty,
3737 field,
3838 icon,
3939 selectField,
@@ -291,11 +291,7 @@ export async function renderBranches(
291291 ? html`<p class="small"><a href="${scope.base}/builds">Builds</a></p>`
292292 : null}
293293 ${rows.length === 0
294 ? empty({
295 icon: "branch",
296 title: "No branches yet",
297 note: "Push one, or create the first from the form above.",
298 })
294 ? emptyList("branches", { noAction: true })
299295 : html`<h2 class="mt">
300296 ${rows.length} branch${rows.length === 1 ? "" : "es"}
301297 ${when(
src/web/pages/browse.ts +3 −2
@@ -25,6 +25,7 @@
2525 * labels and authors instead.
2626 */
2727
28 import { emptyList } from "../empty_words.ts";
2829 import { binaryRefusal } from "../render/opens_with.ts";
2930 import { mirrorJobFor, startMirrorJob } from "../../actions/origins.ts";
3031 import { forkOrigin } from "../../actions/contribute.ts";
@@ -648,8 +649,8 @@ async function browseThreadList(
648649
649650 const list =
650651 items.length === 0
651 ? empty({
652 icon: kind === "issue" ? "issue" : "pull",
652 ? emptyList(kind === "issue" ? "issues" : "pulls", {
653 noAction: true,
653654 title:
654655 query.state === "closed"
655656 ? `No closed ${segment}`
src/web/pages/builds.ts +2 −1
@@ -27,6 +27,7 @@ import { backTo, field as formValue, readForm } from "../form.ts";
2727 import { isLocalPath } from "../flash.ts";
2828 import { html, when, type Html } from "../html.ts";
2929 import { flashTo, page } from "../layout.ts";
30 import { emptyList } from "../empty_words.ts";
3031 import { btn, field, row, selectField, time } from "../ui.ts";
3132
3233 /**
@@ -99,7 +100,7 @@ export function buildsList(
99100 ${when(nodes.length > 0, () => html`<a href="${base}/iterations?layout=tree">Iterations</a>`)}
100101 </p>
101102 ${nodes.length === 0
102 ? html`<p class="muted">No builds yet.${canPin ? html` Pin one from <a href="${base}/branches">a branch</a> to make it.` : null}</p>`
103 ? emptyList("builds", canPin ? { href: `${base}/branches` } : { noAction: true })
103104 : html`<ul class="list builds">${nodes.map((n) => buildRow(base, n, canPreview, canDelete))}</ul>`}`;
104105 }
105106
src/web/pages/commits.ts +4 −7
@@ -40,6 +40,7 @@ import {
4040 sha,
4141 time,
4242 } from "../ui.ts";
43 import { emptyList } from "../empty_words.ts";
4344 import {
4445 pathCrumbs,
4546 refMenu,
@@ -204,13 +205,9 @@ export function historyBar(
204205 }
205206
206207 export const noCommits = (later: boolean): Html =>
207 empty({
208 icon: "commit",
209 title: later ? "No commits on this page" : "No commits yet",
210 note: later
211 ? "You have paged past the end of this history."
212 : "Push a branch and its history shows up here.",
213 });
208 later
209 ? empty({ icon: "commit", title: "No commits on this page", note: "You have paged past the end of this history." })
210 : emptyList("commits", { noAction: true });
214211
215212 // ---- the local pages ----
216213
src/web/pages/displays.ts +3 −3
@@ -7,12 +7,12 @@
77 */
88
99 import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts";
10 import { DISPLAYS_NOTE, DISPLAYS_READING, DISPLAYS_SENTENCE, INVALID_TITLE, LIST_WAIT_MS, listedDisplaysWithin, listWait } from "../../display/known.ts";
10 import { DISPLAYS_READING, DISPLAYS_SENTENCE, INVALID_TITLE, LIST_WAIT_MS, listedDisplaysWithin, listWait } from "../../display/known.ts";
1111 import type { Ctx } from "../../http/context.ts";
1212 import { pageHead, repoBase, signInFirst } from "../chrome.ts";
1313 import { html } from "../html.ts";
1414 import { page } from "../layout.ts";
15 import { empty } from "../ui.ts";
15 import { emptyList } from "../empty_words.ts";
1616
1717 const LAYOUT_WORD = { shelf: "Shelf", grid: "Grid", graph: "Graph" } as const;
1818
@@ -33,7 +33,7 @@ export async function displaysPage(ctx: Ctx): Promise<Response> {
3333 ${rows.length === 0 && !complete
3434 ? null
3535 : rows.length === 0
36 ? empty({ icon: "pin", title: "No displays", note: DISPLAYS_NOTE })
36 ? emptyList("displays", { noAction: true })
3737 : html`<div class="table-scroll" role="region" tabindex="0" aria-label="Displays">
3838 <table class="table" data-dense data-by="displays">
3939 <thead>
src/web/pages/events.ts +4 −3
@@ -9,6 +9,7 @@
99 * links to it). Server-rendered, no script.
1010 */
1111
12 import { emptyList } from "../empty_words.ts";
1213 import { EVENTS_LIMIT_DEFAULT, eventsPage, validEventsCursor, validEventsKind } from "../../core/events_page.ts";
1314 import type { ForgeEvent } from "../../core/events.ts";
1415 import { getUsersByIds } from "../../core/users.ts";
@@ -20,7 +21,7 @@ import { pushedBranch } from "../feeds.ts";
2021 import { html, type Html } from "../html.ts";
2122 import { page } from "../layout.ts";
2223 import { localScope } from "../scope.ts";
23 import { avatar, btn, empty, listCard, pager, row, time } from "../ui.ts";
24 import { avatar, btn, listCard, pager, row, time } from "../ui.ts";
2425
2526 /** Where an event has a page: its issue or pull, a push's commits. */
2627 function linkOf(base: string, event: ForgeEvent): string | undefined {
@@ -74,8 +75,8 @@ export function eventsList(ctx: Ctx): Response {
7475 <div class="mt">
7576 ${read.items.length === 0
7677 ? kind === null
77 ? empty({ icon: "activity", title: "No events yet", note: "Pushes, merges and deploys land here." })
78 : empty({ icon: "activity", title: `No ${kind} events`, action: allEvents })
78 ? emptyList("events", { noAction: true })
79 : emptyList("events", { title: `No ${kind} events`, action: allEvents })
7980 : eventRows(ctx, base, narrow, read.items)}
8081 </div>
8182 ${pager({
src/web/pages/labels.ts +3 −6
@@ -5,6 +5,7 @@
55 * and the gate are settings.ts's; this module holds only what labels need.
66 */
77
8 import { emptyList } from "../empty_words.ts";
89 import { LABEL_WORDS } from "../../actions/label_words.ts";
910 import { createLabel, deleteLabel, updateLabel } from "../../actions/repos.ts";
1011 import { listLabels, openLabelUse, type Label, type LabelUse } from "../../core/issues.ts";
@@ -14,7 +15,7 @@ import { repoBase, repoNotFound } from "../chrome.ts";
1415 import { field, type Form } from "../form.ts";
1516 import { html, type Html } from "../html.ts";
1617 import { flashTo } from "../layout.ts";
17 import { btn, confirmAction, empty, labelChip, labelCss, row } from "../ui.ts";
18 import { btn, confirmAction, labelChip, labelCss, row } from "../ui.ts";
1819 import { adminForm } from "../admin_form.ts";
1920 import { settingsPageResponse, timedAdminRepo } from "./settings.ts";
2021 import { BIND, countAttr } from "../bind.ts";
@@ -101,11 +102,7 @@ export function labelsPage(ctx: Ctx): Response {
101102
102103 const list =
103104 labels.length === 0
104 ? empty({
105 icon: "tag",
106 title: "No labels yet",
107 note: "Labels are this repository's work queue — a handful is usually enough.",
108 })
105 ? emptyList("labels", { noAction: true })
109106 : html`<ul class="list setting-list">
110107 ${labels.map((l) => labelRow(base, l, counts.get(l.id)))}
111108 </ul>`;
src/web/pages/my-repos.ts +3 −2
@@ -9,7 +9,8 @@ import type { Ctx } from "../../http/context.ts";
99 import { repoBase, signInFirst } from "../chrome.ts";
1010 import { html } from "../html.ts";
1111 import { page } from "../layout.ts";
12 import { btn, empty, listCard, row } from "../ui.ts";
12 import { emptyList } from "../empty_words.ts";
13 import { btn, listCard, row } from "../ui.ts";
1314
1415 // GET /repos
1516 export function myReposPage(ctx: Ctx): Response {
@@ -20,7 +21,7 @@ export function myReposPage(ctx: Ctx): Response {
2021 const repos = listReposWritableTo(ctx.app.db, user, { limit: 200, withoutArchived: true });
2122 const body =
2223 repos.length === 0
23 ? empty({ icon: "repo", title: "No repositories yet", action: btn("New repository", { href: "/new", variant: "primary" }) })
24 ? emptyList("repos")

The primary button became a plain link, which is correct under principle 5. On this page the link is the only way to start, and "New repository" is easy to miss as a bare link under two lines of text. Check it at 360px, where the touch target should be at least 44px tall.

2425 : listCard(
2526 repos.map((r) =>
2627 row({ href: repoBase(r), nav: true, title: html`<span class="truncate">${r.ownerName}/${r.name}</span>` }),
src/web/pages/releases.ts +3 −2
@@ -15,11 +15,12 @@ import { lastProof, proofNotice, proveAgain } from "../../release/prove.ts";
1515 import { listReleases } from "../../release/record.ts";
1616 import { releaseStories } from "../../release/story.ts";
1717 import { BOOTED, canRollBackTo, mayRead, mayRollBack, rollBackTo } from "../../release/gate.ts";
18 import { journeyLine, liveSince, NO_RELEASES_YET } from "../../release/words.ts";
18 import { journeyLine, liveSince } from "../../release/words.ts";
1919 import { notFoundPage, signInFirst, NOT_ADMIN_HERE, SIGN_IN_TO_DO, forbiddenPage } from "../chrome.ts";
2020 import { readForm } from "../form.ts";
2121 import { html, when, type Html } from "../html.ts";
2222 import { flashTo, page } from "../layout.ts";
23 import { emptyList } from "../empty_words.ts";
2324 import { badge, btn, row, sha, time } from "../ui.ts";
2425 import { holdAs, liftAs } from "../../keeper/hold.ts";
2526 import { releaseNowAs } from "../../keeper/now.ts";
@@ -137,7 +138,7 @@ export async function releasesPage(ctx: Ctx): Promise<Response> {
137138 }
138139 const body =
139140 rows.length === 0
140 ? html`<p class="mt muted">No releases yet. ${NO_RELEASES_YET}</p>`
141 ? emptyList("releases", { noAction: true })
141142 : html`<ul class="list setting-list">${rows}</ul>`;
142143 const response = page({
143144 ctx,
src/web/pages/repo.ts +2 −6
@@ -140,6 +140,7 @@ import {
140140 time,
141141 copyField,
142142 } from "../ui.ts";
143 import { emptyList } from "../empty_words.ts";
143144 import { BIND, countAttr, listAttr } from "../bind.ts";
144145
145146 const MAX_RENDER_BYTES = 1_000_000;
@@ -219,12 +220,7 @@ export async function forksPage(ctx: Ctx): Promise<Response> {
219220 <h2${countAttr(BIND.rest)}>${forks.length} fork${forks.length === 1 ? "" : "s"}</h2>
220221 </div>
221222 ${lineage.size === 1
222 ? empty({
223 icon: "fork",
224 title: "No forks yet",
225 note: "A fork is a copy under another name that can propose changes back here, and follows this one until it has work of its own.",
226 bind: BIND.rest,
227 })
223 ? emptyList("forks", { noAction: true, bind: BIND.rest })
228224 : html`${forkRanking(ranked, new Map(tree.map((n) => [n.repo.id, n])), BIND.rest, forkModes, (fork, parent) => keptBehind(ctx.app, fork, parent), forkFollowed)}
229225 <h3 class="mt">The family, by who follows whom</h3>
230226 ${lineageCard(lineage, repo.id, ctx.auth.user?.id)}`}`;
src/web/pages/waves.ts +1 −1
@@ -116,7 +116,7 @@ export async function wavesPage(ctx: Ctx): Promise<Response> {
116116 action: html`<form method="post" action="${repoBase(repo)}/tell">
117117 <input type="hidden" name="text" value="${FIRST_WAVE_TELL}" />
118118 <input type="hidden" name="from" value="${repoBase(repo)}/waves" />
119 ${btn(EMPTY_WORDS.waves.label, { variant: "primary" })}
119 ${btn(EMPTY_WORDS.waves.label ?? "", { variant: "primary" })}

Non-blocking: label ?? "" would draw an empty button if the waves label were ever dropped. Give waves a required label (or a narrower type) so the table cannot produce it.

120120 </form>`,
121121 }
122122 : {}),
test/empty-words-all.test.ts added +130
@@ -0,0 +1,130 @@
1 /**
2 * One table of empty words (#15851): every empty state a page registers has an entry (a sentence; a
3 * reason and one link only where they add something and the place exists), and a page that words
4 * its own "No …" empty state is named below until it moves.
5 */
6 import { expect, test } from "bun:test";
7 import { readdirSync, readFileSync, statSync } from "node:fs";
8 import { join } from "node:path";
9 import { EMPTY_WORDS } from "../src/core/empty_words.ts";
10
11 const walk = (dir: string): string[] =>
12 readdirSync(dir).flatMap((f) => {
13 const p = join(dir, f);
14 return statSync(p).isDirectory() ? walk(p) : p.endsWith(".ts") ? [p] : [];
15 });
16 const files = walk("src/web").map((p) => [p, readFileSync(p, "utf8")] as const);
17
18 // A page's own "No …" empty state, in either form: empty({ title: "No …" }) (one line or several)
19 // or an inline <p class="… muted …">No …</p>, whatever classes sit beside muted and whatever
20 // follows. The table below is a ratchet: a file may hold no more than its count, and must name the
outdated

This exemption list has about 20 pages, which is the issue's own box 1 left undone. It is acceptable only if each page has a follow-up issue; link them in the pull.

21 // count exactly, so moving one to emptyList(kind) shrinks it and a new one fails. A new empty state
22 // goes in src/core/empty_words.ts and is drawn with emptyList(kind).
23 const OWN_FORM = /empty\(\{\s*(?:icon: [^,]+,\s*)?title: [`"]No |empty\("No |<p class="(?:[^"]* )?muted(?: [^"]*)?">\s*No /g;
24 // What is left is split into #15899 (admin, system), #15900 (boards, bets, flows), #15901
25 // (repository pages), #15902 (apps, forges) and #15903 (studio, renderers); #15851 waits for them.
26 const OWN_WORDS: Readonly<Record<string, number>> = {
27 "src/web/comments.ts": 1,
28 "src/web/diff-view.ts": 1,
29 "src/web/pages/account.ts": 2,
30 "src/web/pages/accounts.ts": 1,
31 "src/web/pages/admin-limits.ts": 1,
32 "src/web/pages/app_releases.ts": 1,
33 "src/web/pages/app_templates.ts": 1,
34 "src/web/pages/app_variants.ts": 1,
35 "src/web/pages/audit.ts": 1,
36 "src/web/pages/bets.ts": 3,
37 "src/web/pages/billing.ts": 2,
38 "src/web/pages/boards-gates.ts": 1,
39 "src/web/pages/boards-held.ts": 1,
40 "src/web/pages/boards-holds.ts": 1,
41 "src/web/pages/boards.ts": 1,
42 "src/web/pages/browse.ts": 1,
43 "src/web/pages/build_shots.ts": 1,
44 "src/web/pages/capacity.ts": 1,
45 "src/web/pages/cloud.ts": 3,
46 "src/web/pages/commits.ts": 1,
outdated

The regex only catches empty({ title: "No ..." }) on a single line. A <p class="muted">No ... line, or a multi-line empty(), slips through, so box 2 is only partly enforced. Match the inline form too.

47 "src/web/pages/contribute.ts": 1,
48 "src/web/pages/data_view.ts": 3,
49 "src/web/pages/display.ts": 1,
50 "src/web/pages/economics.ts": 1,
51 "src/web/pages/family.ts": 1,
52 "src/web/pages/features.ts": 1,
53 "src/web/pages/flags.ts": 1,
54 "src/web/pages/flow-panel.ts": 1,
55 "src/web/pages/flows-all.ts": 1,
56 "src/web/pages/forges-refused.ts": 1,
57 "src/web/pages/grants.ts": 1,
58 "src/web/pages/hosted-forges.ts": 2,
59 "src/web/pages/inventory.ts": 1,
60 "src/web/pages/issues.ts": 1,
61 "src/web/pages/looks.ts": 1,
62 "src/web/pages/notes.ts": 1,
63 "src/web/pages/origin-flow.ts": 1,
64 "src/web/pages/origins.ts": 1,
65 "src/web/pages/packs.ts": 2,
66 "src/web/pages/pull.ts": 1,
67 "src/web/pages/reports.ts": 1,
68 "src/web/pages/runners.ts": 1,
69 "src/web/pages/settings.ts": 1,
70 "src/web/pages/sources.ts": 1,
71 "src/web/pages/system.ts": 6,
72 "src/web/pages/talk_preview.ts": 3,
73 "src/web/pages/teams.ts": 1,
74 "src/web/pages/trusted.ts": 1,
75 "src/web/pages/visitors.ts": 1,
76 "src/web/pages/waves.ts": 1,
77 "src/web/render/deps-manifest.ts": 1,
78 "src/web/render/ora.ts": 1,
79 "src/web/render/sarif.ts": 1,
80 "src/web/render/sbom.ts": 1,
81 "src/web/settings/devices.ts": 1,
82 "src/web/studio/cut_over.ts": 1,
83 "src/web/studio/data_move.ts": 1,
84 "src/web/studio/explore.ts": 1,
85 "src/web/studio/file_holds.ts": 1,
86 "src/web/studio/hold.ts": 1,
87 "src/web/studio/home.ts": 1,
88 "src/web/studio/jobs.ts": 1,
89 };
90 const own = (src: string): number => [...src.matchAll(OWN_FORM)].length;
91
92 test("every emptyList(kind) a page registers has an entry in the table", () => {
93 const missing: string[] = [];
94 for (const [p, src] of files) {
95 for (const m of src.matchAll(/emptyList\(\s*"([^"]+)"/g)) {
96 if (!(m[1]! in EMPTY_WORDS)) missing.push(`${p}: emptyList("${m[1]}") has no entry in src/core/empty_words.ts`);
97 }
98 }
99 expect(missing).toEqual([]);
100 });
101
102 test("every entry has a sentence; a reason is one more sentence, never the sentence again", () => {
103 for (const [kind, w] of Object.entries(EMPTY_WORDS)) {
104 expect(`${kind}: ${/\.$/.test(w.sentence)}`).toBe(`${kind}: true`);
105 if (w.reason !== undefined) {
106 expect(`${kind}: ${w.reason.length > 10 && /\.$/.test(w.reason) && w.reason !== w.sentence}`).toBe(`${kind}: true`);
107 }
108 }
109 });
110
111 // The unscoped places an empty state may send someone; a repository's list hands in its own href.
112 const UNSCOPED = new Set(["/boards/data", "/tell", "/issues", "/apps/new", "/admin/limits", "/new"]);
113
114 test("a link is a label and a place that exists; no default href points nowhere", () => {
115 for (const [kind, w] of Object.entries(EMPTY_WORDS)) {
116 if (w.href !== undefined) {
117 expect(`${kind}: ${w.label !== undefined && UNSCOPED.has(w.href)}`).toBe(`${kind}: true`);
118 }
119 }
120 });
121
122 test("a page does not word more bare 'No …' empty states than it is named for", () => {
123 const over = files.filter(([p, src]) => own(src) > (OWN_WORDS[p] ?? 0)).map(([p, src]) => `${p}: ${own(src)} > ${OWN_WORDS[p] ?? 0}`);
124 expect(over).toEqual([]);
125 });
126
127 test("a page that moved to the table is off the list of own words", () => {
128 const moved = files.filter(([p, src]) => own(src) < (OWN_WORDS[p] ?? 0)).map(([p, src]) => `${p}: ${own(src)} < ${OWN_WORDS[p]}`);
129 expect(moved).toEqual([]);
130 });
test/releases-page.test.ts +3 −2
@@ -163,9 +163,10 @@ describe("the releases page", () => {
163163 const res = await fetch(`${s.url}/releases`, { headers: { cookie } });
164164 expect(res.status).toBe(200);
165165 const body = await res.text();
166 const at = body.indexOf('<p class="mt muted">No releases yet. ');
166 const at = body.indexOf('<div class="empty"');
167167 expect(at).toBeGreaterThan(-1);
168 const line = body.slice(at, body.indexOf("</p>", at));
168 const line = body.slice(at, body.indexOf("</div>", at));
169 expect(line).toContain("No releases yet.");
169170 expect(line.replaceAll("&#39;", "'")).toContain(NO_RELEASES_YET);
170171 // After the keeper panel, only the muted line: no list, no card.
171172 const rest = body.slice(at, body.indexOf("</main>"));

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs