Public: anyone can read this; the crew can change it.
Every empty list says what it is waiting for in one sentence, from one table #13312
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13293-every-empty-list-says-what-it-is-waiting → main 4 commits fork 7 threads · 7 unresolved
docs/features/README.md +1
| @@ -17,6 +17,7 @@ A new note gets a row here (`test/feature-orphans.test.ts`). | ||
| 17 | 17 | Read with the guide page [](../guide-what-a-forge-is.md). |
| 18 | 18 | |
| 19 | 19 | - [](feed-look.md) |
| 20 | - [](empty-words.md) | |
| 20 | 21 | - [](readme-description.md) |
| 21 | 22 | - [](arcade-carts.md) |
| 22 | 23 | - [](changelog.md) |
docs/features/empty-words.md added +17
| @@ -0,0 +1,17 @@ | ||
| 1 | # Empty lists | |
| 2 | ||
| 3 | The board, inbox, runs, apps and people lists word their empty state from one table, | |
| 4 | `EMPTY_WORDS` in `src/core/empty_words.ts`: one plain sentence and one link each. | |
| 5 | ||
| 6 | - **Web:** a page draws it with `emptyList(kind)` (`src/web/empty_words.ts`). The link is a plain | |
| 7 | link, never a primary button, so an empty state adds no second accent. A page may name where the | |
| 8 | link goes (a repository's own issues), or pass `noAction` when the viewer cannot take it or the | |
| 9 | page already offers it (apps: the header has "New app"; boards: "Make a board" sits just below). | |
| 10 | - **Terminal:** the boards, runs, apps and inbox screens take their empty title from the same | |
| 11 | `sentence`; they keep their own key hints as the body, because a terminal has keys, not links. | |
| 12 | The people screen is never empty (the signed-in admin is always one). | |
| 13 | - "Invite someone" goes to `/admin/limits`, where invite links are minted; the people page is | |
| 14 | admin-only, so only an admin ever sees it. | |
| 15 | ||
| 16 | A new list that can be empty gets a row in the table, not its own words. | |
| 17 | `test/empty-states.test.ts` walks the lists and holds each to its sentence and its link. |
src/core/empty_words.ts added +24
| @@ -0,0 +1,24 @@ | ||
| 1 | /** | |
| 2 | * What an empty list is waiting for (#13293): one plain sentence and one link per list, from this | |
| 3 | * table alone, for both doors. The web draws it with `emptyList(kind)` (`src/web/empty_words.ts`); | |
| 4 | * the terminal's empty screens take their title from `sentence`. `test/empty-states.test.ts` walks | |
| 5 | * every kind and holds each to its sentence and its single link. | |
| 6 | */ | |
| 7 | ||
| 8 | export type EmptyKind = "board" | "inbox" | "runs" | "apps" | "people"; | |
| 9 | ||
| 10 | export interface EmptyWords { | |
| 11 | /** One sentence, plain words, ending in a full stop. */ | |
| 12 | 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; | |
| 16 | } | |
| 17 | ||
| 18 | export const EMPTY_WORDS: Readonly<Record<EmptyKind, EmptyWords>> = { | |
| 19 | board: { sentence: "No board yet.", label: "Start from a question", href: "/boards/data" }, | |
| 20 | inbox: { sentence: "Nothing is waiting on you.", label: "Tell the crew something", href: "/tell" }, | |
| 21 | runs: { sentence: "No run is open.", label: "Start with an issue", href: "/issues" }, | |
| 22 | apps: { sentence: "Nothing runs here yet.", label: "New app", href: "/apps/new" }, | |
| 23 | people: { sentence: "Nobody has joined yet.", label: "Invite someone", href: "/admin/limits" }, | |
| 24 | }; |
src/tui/screens/apps_crew.ts +2 −1
| @@ -15,6 +15,7 @@ import { fill, len, split } from "../ui/layout.ts"; | ||
| 15 | 15 | import { style } from "../term/style.ts"; |
| 16 | 16 | import { truncate } from "../term/width.ts"; |
| 17 | 17 | import { emptyState } from "../ui/widgets.ts"; |
| 18 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 18 | 19 | import { aboutScreen } from "./about.ts"; |
| 19 | 20 | import { ListState, drawList, type ListRow } from "./common.ts"; |
| 20 | 21 | import type { PaletteEntry } from "./entries.ts"; |
| @@ -63,7 +64,7 @@ export function appsCrewScreen(f: Session, ctx: Ctx): Screen { | ||
| 63 | 64 | const [head, body] = split(area, "v", [len(1), fill(1)]); |
| 64 | 65 | if (rows === undefined) return; |
| 65 | 66 | if (rows.length === 0) { |
| 66 | emptyState(s, body!, c, { title: "No apps yet." }); | |
| 67 | emptyState(s, body!, c, { title: EMPTY_WORDS.apps.sentence }); | |
| 67 | 68 | return; |
| 68 | 69 | } |
| 69 | 70 | s.text(head!.x, head!.y, truncate("enter opens the app", head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
src/tui/screens/asked.ts +11 −4
| @@ -29,13 +29,16 @@ import { binding } from "../app/keys.ts"; | ||
| 29 | 29 | import type { Session } from "../session.ts"; |
| 30 | 30 | import { split, fill, len } from "../ui/layout.ts"; |
| 31 | 31 | import { emptyState, type Tone } from "../ui/widgets.ts"; |
| 32 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 32 | 33 | import { style } from "../term/style.ts"; |
| 33 | 34 | import { truncate } from "../term/width.ts"; |
| 34 | 35 | import { ListState, drawList, hitList, metaOf, openOnWeb, relTime, type ListRow } from "./common.ts"; |
| 35 | 36 | import { issueScreen } from "./issue.ts"; |
| 36 | 37 | import { local } from "./where.ts"; |
| 37 | 38 | |
| 38 | /** One line of plain text: a typed thought may carry newlines or escapes the terminal must not obey. */ | |
| 39 | /** | |
| 40 | * One line of plain text: a typed thought may carry newlines or escapes the terminal must not obey. | |
| 41 | */ | |
| 39 | 42 | const plain = (text: string): string => |
| 40 | 43 | // eslint-disable-next-line no-control-regex |
| 41 | 44 | text.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").trim(); |
| @@ -64,7 +67,10 @@ function toneOf(flagged: boolean, state: string): { tone?: Tone } { | ||
| 64 | 67 | return state === "building" ? { tone: "attn" } : {}; |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | /** Where it went and what it repeats or takes back, in /asked's words (`whereItWent`, `thoughtNotes`). */ | |
| 70 | /** | |
| 71 | * Where it went and what it repeats or takes back, in /asked's words (`whereItWent`, | |
| 72 | * `thoughtNotes`). | |
| 73 | */ | |
| 68 | 74 | function thoughtLine(t: StreamThought): AskedLine { |
| 69 | 75 | const where = whereItWent(t).map((x) => `${x.lead}${x.text}`); |
| 70 | 76 | const notes = thoughtNotes(t).map((n) => `${n.text} ${relTime(n.at)}`); |
| @@ -204,7 +210,8 @@ export function askedLines( | ||
| 204 | 210 | const repos = askedRepos(db, viewer, null); |
| 205 | 211 | return { |
| 206 | 212 | thoughts: thoughtStream(db, viewer, { limit: 50 }).map(thoughtLine), |
| 207 | // MCP's order, not /asked's needs-the-owner grouping: the title names the order, so the rows keep it. | |
| 213 | // MCP's order, not /asked's needs-the-owner grouping: the title names the order, so the rows | |
| 214 | // keep it. | |
| 208 | 215 | asks: askedIn(db, repos, view).map(askLine), |
| 209 | 216 | }; |
| 210 | 217 | } |
| @@ -251,7 +258,7 @@ export function askedScreen(f: Session, ctx: Ctx): Screen { | ||
| 251 | 258 | s.text(head!.x, head!.y, truncate(sentence, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 252 | 259 | if (lines.length === 0) { |
| 253 | 260 | emptyState(s, body!, c, { |
| 254 | title: "Nothing asked yet", | |
| 261 | title: EMPTY_WORDS.inbox.sentence, | |
Non-blocking: this screen is what you told the crew and what became of it, not what waits on you. 'Nothing is waiting on you.' over 'What you tell the crew shows up here' reads as two different lists. Use a sentence that matches the screen (principle 8: plain words). |
||
| 255 | 262 | body: "What you tell the crew shows up here, with what became of it.", |
| 256 | 263 | }); |
| 257 | 264 | return; |
src/tui/screens/boards.ts +24 −13
| @@ -3,12 +3,13 @@ | ||
| 3 | 3 | * keeps, then one board's panels as text. It reads through the same |
| 4 | 4 | * `listAllBoards` and `showBoard` the page and the API do, so the gate is the |
| 5 | 5 | * action's (an agent or anyone else is told nothing); the palette offers the |
| 6 | * door only to that person. `n` makes a board, `c` copies the marked one, `e` renames it and `g` sets | |
| 7 | * its range (`changeBoard`; `home` still jumps to the top), and `D` deletes it after `y/n` | |
| 8 | * (`actions/boards.ts`, as the page does). Otherwise reading, but for pins: a chart is not drawn, a panel is said | |
| 9 | * as its title, chart, size and the query that feeds it, then what `panelData` reads for it | |
| 10 | * (the page's and the API's door): a time panel's last bucket and its step, else its row count. `[`/`]` mark a panel, | |
| 11 | * `p` pins or unpins it to home and `<`/`>` move a pinned one (`actions/board-pins.ts`). | |
| 6 | * door only to that person. `n` makes a board, `c` copies the marked one, `e` renames it and `g` | |
| 7 | * sets its range (`changeBoard`; `home` still jumps to the top), and `D` deletes it after `y/n` | |
| 8 | * (`actions/boards.ts`, as the page does). Otherwise reading, but for pins: a chart is not drawn, a | |
| 9 | * panel is said as its title, chart, size and the query that feeds it, then what `panelData` reads | |
| 10 | * for it (the page's and the API's door): a time panel's last bucket and its step, else its row | |
| 11 | * count. `[`/`]` mark a panel, `p` pins or unpins it to home and `<`/`>` move a pinned one | |
| 12 | * (`actions/board-pins.ts`). | |
| 12 | 13 | */ |
| 13 | 14 | |
| 14 | 15 | import { formatValue } from "../../boards/chart.ts"; |
| @@ -21,12 +22,15 @@ import { binding } from "../app/keys.ts"; | ||
| 21 | 22 | import type { Session } from "../session.ts"; |
| 22 | 23 | import { split, fill, len } from "../ui/layout.ts"; |
| 23 | 24 | import { emptyState } from "../ui/widgets.ts"; |
| 25 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 24 | 26 | import { style } from "../term/style.ts"; |
| 25 | 27 | import { truncate } from "../term/width.ts"; |
| 26 | 28 | import { ListState, Scroll, drawList, promptScreen, drawLines, hitList, hitScroll, metaOf, plural, runAsync, type ListRow } from "./common.ts"; |
| 27 | 29 | import type { PaletteEntry } from "./entries.ts"; |
| 28 | 30 | |
| 29 | /** One line of plain text: a title or a query value may carry escapes the terminal must not obey. */ | |
| 31 | /** | |
| 32 | * One line of plain text: a title or a query value may carry escapes the terminal must not obey. | |
| 33 | */ | |
| 30 | 34 | export const plain = (text: string): string => |
| 31 | 35 | // eslint-disable-next-line no-control-regex |
| 32 | 36 | text.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").trim(); |
| @@ -56,7 +60,10 @@ export async function boardRows(session: Session): Promise<BoardRow[]> { | ||
| 56 | 60 | export const stepWords = (s: number): string => |
| 57 | 61 | s % 86_400 === 0 ? `${s / 86_400}d` : s % 3600 === 0 ? `${s / 3600}h` : s % 60 === 0 ? `${s / 60}m` : `${s}s`; |
| 58 | 62 | |
| 59 | /** What a panel's data says in one line: its last bucket and step, its row count, or why it was refused. */ | |
| 63 | /** | |
| 64 | * What a panel's data says in one line: its last bucket and step, its row count, or why it was | |
| 65 | * refused. | |
| 66 | */ | |
| 60 | 67 | export function dataLine(d: PanelData): string { |
| 61 | 68 | if (!d.ok) return `refused: ${plain(d.error)}`; |
| 62 | 69 | if (d.step === null) return plural(d.rows.length, "row"); |
| @@ -127,9 +134,10 @@ export function boardScreen(ctx: Ctx, f: Session, slug: string, first: Board): S | ||
| 127 | 134 | await read(); |
| 128 | 135 | }; |
| 129 | 136 | /** |
| 130 | * Remove the panel asked about as the web's Remove does; pins are left as `changeBoard` leaves them. | |
| 131 | * `changeBoard` removes by index, so the board is read again first: when another door moved or removed | |
| 132 | * panels and `index` no longer holds `title`, nothing is removed and the screen shows the board as it is. | |
| 137 | * Remove the panel asked about as the web's Remove does; pins are left as `changeBoard` leaves | |
| 138 | * them. `changeBoard` removes by index, so the board is read again first: when another door moved | |
| 139 | * or removed panels and `index` no longer holds `title`, nothing is removed and the screen shows | |
| 140 | * the board as it is. | |
| 133 | 141 | */ |
| 134 | 142 | const drop = (index: number, title: string): void => |
| 135 | 143 | runAsync(ctx, async () => { |
| @@ -252,7 +260,10 @@ export function boardsScreen(f: Session, ctx: Ctx): Screen { | ||
| 252 | 260 | }); |
| 253 | 261 | // The gate is `changeBoard`'s, read once as the board screen's is. |
| 254 | 262 | const mayEdit = f.user?.isAdmin === true && f.user.kind !== "agent"; |
| 255 | /** Prompt for a new value of the row's board and apply it as the board page's Rename and Settings do. */ | |
| 263 | /** | |
| 264 | * Prompt for a new value of the row's board and apply it as the board page's Rename and Settings | |
| 265 | * do. | |
| 266 | */ | |
| 256 | 267 | const edit = (row: BoardRow, what: "title" | "range"): void => { |
| 257 | 268 | ctx.push( |
| 258 | 269 | promptScreen(ctx, screen, { |
| @@ -290,7 +301,7 @@ export function boardsScreen(f: Session, ctx: Ctx): Screen { | ||
| 290 | 301 | s.text(head!.x, head!.y, truncate(headline, head!.w), style(asking ? c.fg : c.mutedFg, c.bg), head!.x + head!.w); |
| 291 | 302 | if (rows.length === 0) { |
| 292 | 303 | emptyState(s, body!, c, { |
| 293 | title: "No boards yet", | |
| 304 | title: EMPTY_WORDS.board.sentence, | |
| 294 | 305 | body: "Press n to make one.", |
| 295 | 306 | }); |
| 296 | 307 | return; |
src/tui/screens/runs.ts +2 −1
| @@ -21,6 +21,7 @@ import { style } from "../term/style.ts"; | ||
| 21 | 21 | import { truncate } from "../term/width.ts"; |
| 22 | 22 | import { fill, len, split } from "../ui/layout.ts"; |
| 23 | 23 | import { emptyState } from "../ui/widgets.ts"; |
| 24 | import { EMPTY_WORDS } from "../../core/empty_words.ts"; | |
| 24 | 25 | import { confirmScreen } from "./common.ts"; |
| 25 | 26 | import { RunList, maySteer, openRunLog, runTitle, steerPrompt } from "./runlist.ts"; |
| 26 | 27 | |
| @@ -151,7 +152,7 @@ export function runsScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 151 | 152 | ); |
| 152 | 153 | if (list.runs.length === 0) { |
| 153 | 154 | emptyState(s, body!, c, { |
| 154 | title: loaded ? "No runs" : "Reading…", | |
| 155 | title: loaded ? EMPTY_WORDS.runs.sentence : "Reading…", | |
| 155 | 156 | body: loaded |
| 156 | 157 | ? at === 0 |
| 157 | 158 | ? "Nothing has run here yet." |
src/web/empty_words.ts added +38
| @@ -0,0 +1,38 @@ | ||
| 1 | /** | |
| 2 | * The web's door onto the empty-list table (#13293, `src/core/empty_words.ts`): a page that draws a | |
| 3 | * list of none calls `emptyList(kind)`; it never words its own. The link is a plain link, so an | |
outdated
Cites test/empty-words.test.ts which does not exist; point it at test/empty-states.test.ts. |
||
| 4 | * empty state never adds a second accent to a page that already has one. | |
| 5 | * `test/empty-states.test.ts` walks every kind and holds each to its sentence and its single link. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { Html } from "./html.ts"; | |
| 9 | import { EMPTY_WORDS, type EmptyKind } from "../core/empty_words.ts"; | |
| 10 | import { btn, empty, type IconName } from "./ui.ts"; | |
| 11 | ||
| 12 | export { EMPTY_WORDS, type EmptyKind }; | |
| 13 | ||
| 14 | const ICONS: Readonly<Record<EmptyKind, IconName>> = { | |
| 15 | board: "activity", | |
| 16 | inbox: "check", | |
| 17 | runs: "bot", | |
| 18 | apps: "repo", | |
| 19 | people: "users", | |
| 20 | }; | |
| 21 | ||
| 22 | export interface EmptyOptions { | |
| 23 | /** Where the action goes, when it is not the table's (a repository's own issues, say). */ | |
| 24 | href?: string; | |
| 25 | /** Leave the link out: the viewer cannot take the action, or the page already offers it. */ | |
| 26 | noAction?: boolean; | |
| 27 | bind?: string | undefined; | |
| 28 | } | |
| 29 | ||
| 30 | export function emptyList(kind: EmptyKind, o: EmptyOptions = {}): Html { | |
| 31 | const w = EMPTY_WORDS[kind]; | |
| 32 | return empty({ | |
| 33 | icon: ICONS[kind], | |
| 34 | title: w.sentence, | |
| 35 | ...(o.noAction ? {} : { action: btn(w.label, { href: o.href ?? w.href, variant: "link" }) }), | |
| 36 | bind: o.bind, | |
| 37 | }); | |
| 38 | } |
src/web/pages/apps.ts +4 −1
| @@ -94,6 +94,7 @@ import { | ||
| 94 | 94 | terminalLine, |
| 95 | 95 | field as formField, |
| 96 | 96 | } from "../ui.ts"; |
| 97 | import { emptyList } from "../empty_words.ts"; | |
| 97 | 98 | |
| 98 | 99 | // ---- what the viewer can see ---- |
| 99 | 100 | |
| @@ -262,7 +263,9 @@ export async function appsList(ctx: Ctx): Promise<Response> { | ||
| 262 | 263 | <a href="/apps?archived=1">${archivedCount} archived</a> |
| 263 | 264 | </p>` |
| 264 | 265 | : null} |
| 265 | ${shown.length === 0 | |
| 266 | ${shown.length === 0 && !archivedView && !live | |
| 267 | ? emptyList("apps", { noAction: true }) | |
outdated
Principle 1/5: header already has primary 'New app'; pass noAction here or the page says it twice with two accents. |
||
| 268 | : shown.length === 0 | |
| 266 | 269 | ? html`<section class="stack"> |
| 267 | 270 | <p><strong>${archivedView |
| 268 | 271 | ? "Nothing is archived" |
src/web/pages/boards-view.ts +12 −4
| @@ -19,6 +19,7 @@ import { notFoundPage, signInFirst } from "../chrome.ts"; | ||
| 19 | 19 | import { html, when, type Html } from "../html.ts"; |
| 20 | 20 | import { fragment, page } from "../layout.ts"; |
| 21 | 21 | import { btn, chartFrame, confirmAction, field, selectField } from "../ui.ts"; |
| 22 | import { emptyList } from "../empty_words.ts"; | |
| 22 | 23 | import { fold, reading, readingFailed, readingJs } from "../figure.ts"; |
| 23 | 24 | import { formatValue } from "../../boards/chart.ts"; |
| 24 | 25 | import { flowPanel, outAsked } from "./flow-panel.ts"; |
| @@ -30,7 +31,10 @@ import { drawnPanel, panelData, runFor, type PanelDrawn } from "../../boards/pan | ||
| 30 | 31 | import { readParams } from "../../boards/params.ts"; |
| 31 | 32 | import { paramsOf, queryFields } from "./boards.ts"; |
| 32 | 33 | |
| 33 | /** The events the panels' queries read (runs, pulls, checks, issues, usage): any of them may change a chart. */ | |
| 34 | /** | |
| 35 | * The events the panels' queries read (runs, pulls, checks, issues, usage): any of them may change | |
| 36 | * a chart. | |
| 37 | */ | |
| 34 | 38 | const READS = "run.queued,run.started,run.finished,pull.*,check.*,issue.*,usage.*"; |
| 35 | 39 | |
| 36 | 40 | const sizes = (max: number, word: string, now: number) => |
| @@ -46,7 +50,10 @@ export function drawPanel( | ||
| 46 | 50 | at: PanelAt, |
| 47 | 51 | aside: Html | null = null, |
| 48 | 52 | run: typeof runFor = runFor, |
| 49 | /** The panel as a worker read and drew it (`flow/pages.ts`); without it the rows are read and drawn here, for a direct caller. */ | |
| 53 | /** | |
| 54 | * The panel as a worker read and drew it (`flow/pages.ts`); without it the rows are read and | |
| 55 | * drawn here, for a direct caller. | |
| 56 | */ | |
| 50 | 57 | drawn: PanelDrawn = drawnPanel(panel, panelData(app.db, board, panel, {}, Date.now(), run)), |
| 51 | 58 | ): Html { |
| 52 | 59 | const q = paramsOf(panel.query, panel.chart); |
| @@ -132,7 +139,7 @@ export async function boardsList(ctx: Ctx): Promise<Response> { | ||
| 132 | 139 | const boards = html`<section class="bd-block" id="boards-all" aria-labelledby="boards-all-h"> |
| 133 | 140 | <header class="bd-head"><h2 id="boards-all-h">Your boards</h2><p class="bd-sub">A board is a page of charts over the forge's own numbers, saved as a file in forge/boards.</p></header> |
| 134 | 141 | ${listed.value.length === 0 |
| 135 | ? html`<p class="muted">No board yet. Make one below, or start from a question on <a href="/boards/data">Explore the data</a>.</p>` | |
| 142 | ? emptyList("board", { noAction: true }) | |
| 136 | 143 | : html`<ul class="bd-boards"> |
| 137 | 144 | ${listed.value.map( |
| 138 | 145 | ({ slug, board }) => html`<li class="tile"><a href="/boards/${slug}" class="tile-link" data-nav tabindex="-1"> |
| @@ -246,7 +253,8 @@ export async function boardShow(ctx: Ctx): Promise<Response> { | ||
| 246 | 253 | if (ctx.url.searchParams.has("wait")) { |
| 247 | 254 | return waitAnswer(await boardPicture(ctx.app, slug, LONG_WAIT_MS)); |
| 248 | 255 | } |
| 249 | // The board's file and every panel's rows are read by a worker and kept: no query and no git on this thread. | |
| 256 | // The board's file and every panel's rows are read by a worker and kept: no query and no git on | |
| 257 | // this thread. | |
| 250 | 258 | const picture = await timePhaseAsync(ctx.request, "picture", () => boardPicture(ctx.app, slug)); |
| 251 | 259 | if (picture === undefined || isFailed(picture)) { |
| 252 | 260 | return page({ |
src/web/pages/people.ts +4 −1
| @@ -23,6 +23,7 @@ import { isLocalPath } from "../flash.ts"; | ||
| 23 | 23 | import { html } from "../html.ts"; |
| 24 | 24 | import { flashTo, page } from "../layout.ts"; |
| 25 | 25 | import { btn, empty, time, userLink } from "../ui.ts"; |
| 26 | import { emptyList } from "../empty_words.ts"; | |
| 26 | 27 | import { accountSections } from "./origins.ts"; |
| 27 | 28 | |
| 28 | 29 | /** |
| @@ -102,7 +103,9 @@ export function peoplePage(ctx: Ctx): Response { | ||
| 102 | 103 | ${filters} |
| 103 | 104 | ${ |
| 104 | 105 | rows.length === 0 |
| 105 | ? empty({ icon: "users", title: only === null ? "Nobody has joined yet." : "Nobody here." }) | |
| 106 | ? only === null | |
| 107 | ? emptyList("people") | |
| 108 | : empty({ icon: "users", title: "Nobody here." }) | |
| 106 | 109 | : html`<div class="table-scroll" data-people> |
| 107 | 110 | <table class="table" id="people"> |
| 108 | 111 | <thead><tr><th>Person</th><th></th></tr></thead> |
src/web/studio/asks_page.ts +44 −12
| @@ -51,6 +51,7 @@ import { | ||
| 51 | 51 | import { html, type Html } from "../html.ts"; |
| 52 | 52 | import { noteLine } from "./note.ts"; |
| 53 | 53 | import { page, redirect } from "../layout.ts"; |
| 54 | import { emptyList } from "../empty_words.ts"; | |
| 54 | 55 | import { btn, card, disclosure, icon, row } from "../ui.ts"; |
| 55 | 56 | import { |
| 56 | 57 | askAnchor, |
| @@ -193,7 +194,10 @@ function acts(ctx: Ctx, d: Decision): Html { | ||
| 193 | 194 | return html`<div class="bar mt">${primary}${others}</div>`; |
| 194 | 195 | } |
| 195 | 196 | |
| 196 | /** What the crew advised on a pull waiting for a person, in one plain line; nothing when it wrote none. */ | |
| 197 | /** | |
| 198 | * What the crew advised on a pull waiting for a person, in one plain line; nothing when it wrote | |
| 199 | * none. | |
| 200 | */ | |
| 197 | 201 | const adviceLine = (d: Decision): Html | null => |
| 198 | 202 | d.recommendation === undefined |
| 199 | 203 | ? null |
| @@ -250,7 +254,10 @@ const rowHead = (kind: Decision["kind"], n: number): string => { | ||
| 250 | 254 | return `${line.charAt(0).toUpperCase()}${line.slice(1)}`; |
| 251 | 255 | }; |
| 252 | 256 | |
| 253 | /** The flash's own query keys: dropped from the page a decision returns to, so Undo does not carry them. */ | |
| 257 | /** | |
| 258 | * The flash's own query keys: dropped from the page a decision returns to, so Undo does not carry | |
| 259 | * them. | |
| 260 | */ | |
| 254 | 261 | const FLASH_KEYS = ["muted", "listened"] as const; |
| 255 | 262 | |
| 256 | 263 | /** This page as a path and query without the flash, for a form's `back`. */ |
| @@ -276,7 +283,10 @@ function withFlash(back: string, key: (typeof FLASH_KEYS)[number], repoId: strin | ||
| 276 | 283 | return `${path}?${q.toString()}`; |
| 277 | 284 | } |
| 278 | 285 | |
| 279 | /** "Muted owner/name" or "Listening to owner/name again", with Undo, when the page was reached from a mute or listen. */ | |
| 286 | /** | |
| 287 | * "Muted owner/name" or "Listening to owner/name again", with Undo, when the page was reached from | |
| 288 | * a mute or listen. | |
| 289 | */ | |
| 280 | 290 | function muteFlash(ctx: Ctx, user: NonNullable<Ctx["auth"]["user"]>): Html | null { |
| 281 | 291 | for (const key of FLASH_KEYS) { |
| 282 | 292 | const id = ctx.url.searchParams.get(key); |
| @@ -407,7 +417,10 @@ function rowCard(ctx: Ctx, r: AskRow<Decision>, picked: ReadonlySet<string>): Ht | ||
| 407 | 417 | ); |
| 408 | 418 | } |
| 409 | 419 | |
| 410 | /** The forge is degraded: an alert line, marked in the danger tone, under its head; Health on its own row so it never wraps into the sentence. */ | |
| 420 | /** | |
| 421 | * The forge is degraded: an alert line, marked in the danger tone, under its head; Health on its | |
| 422 | * own row so it never wraps into the sentence. | |
| 423 | */ | |
| 411 | 424 | export const forgeCard = (d: ForgeNeed): Html => |
| 412 | 425 | html`<section class="stack"> |
| 413 | 426 | <h2>The forge</h2> |
| @@ -426,7 +439,10 @@ export const asleepCard = (a: Asleep): Html => | ||
| 426 | 439 | <div class="bar">${btn("Open it", { href: `/${a.repo.ownerName}/${a.repo.name}`, size: "sm" })}</div> |
| 427 | 440 | </section>`; |
| 428 | 441 | |
| 429 | /** What sits above the asks after a bulk step: a preview to confirm, a receipt, or why nothing was done. */ | |
| 442 | /** | |
| 443 | * What sits above the asks after a bulk step: a preview to confirm, a receipt, or why nothing was | |
| 444 | * done. | |
| 445 | */ | |
| 430 | 446 | export interface AsksTop { |
| 431 | 447 | readonly banner: Html; |
| 432 | 448 | /** The asks the preview is about, kept ticked. */ |
| @@ -502,7 +518,9 @@ function undoSlot(ctx: Ctx, user: User | undefined): Html | null { | ||
| 502 | 518 | return last === undefined ? null : undoBar(receiptOf(last), last.id, "kept for a day"); |
| 503 | 519 | } |
| 504 | 520 | |
| 505 | /** One bar: what was done, and, when it can be taken back, the Undo (a same-origin POST) and a note. */ | |
| 521 | /** | |
| 522 | * One bar: what was done, and, when it can be taken back, the Undo (a same-origin POST) and a note. | |
| 523 | */ | |
| 506 | 524 | function undoBar(say: string, operationId?: string, note?: string): Html { |
| 507 | 525 | if (operationId === undefined) return html`<p class="bar small" role="status">${say}</p>`; |
| 508 | 526 | return html`<form class="bar" method="post" action="/asks/bulk/${operationId}/undo" role="status"> |
| @@ -562,7 +580,7 @@ export function needsYouSection( | ||
| 562 | 580 | const count = rows.length + needs.length + asleep.length; |
| 563 | 581 | if (count === 0 && top === undefined) |
| 564 | 582 | return { |
| 565 | body: html`<h2 id="asks-sentence" class="sr-only">${askSentence(0)}</h2>${filtered}${silencedNote}${asideNote}${undo}`, | |
| 583 | body: html`<h2 id="asks-sentence" class="sr-only">${askSentence(0)}</h2>${emptyList("inbox")}${filtered}${silencedNote}${asideNote}${undo}`, | |
| 566 | 584 | scriptJs: "", |
| 567 | 585 | }; |
| 568 | 586 | // The forge's own health first, then the few asks that matter most; |
| @@ -726,7 +744,9 @@ function receiptTop(ctx: Ctx, opId: string): AsksTop | undefined { | ||
| 726 | 744 | }; |
| 727 | 745 | } |
| 728 | 746 | |
| 729 | /** POST /asks/bulk — the preview on this screen, or with `apply` the deed, then its receipt here. */ | |
| 747 | /** | |
| 748 | * POST /asks/bulk — the preview on this screen, or with `apply` the deed, then its receipt here. | |
| 749 | */ | |
| 730 | 750 | export async function asksBulkSubmit(ctx: Ctx): Promise<Response> { |
| 731 | 751 | if (!ctx.auth.user) return signInFirst(ctx); |
| 732 | 752 | const form = await readForm(ctx, "rw"); |
| @@ -804,7 +824,10 @@ export async function asksDecide(ctx: Ctx): Promise<Response> { | ||
| 804 | 824 | return redirect(`/asks?decided=${done.value.id}#asks-bulk-result`); |
| 805 | 825 | } |
| 806 | 826 | |
| 807 | /** POST /asks/give-back — hand a handed-over pull back to the builder that opened it; its card leaves. */ | |
| 827 | /** | |
| 828 | * POST /asks/give-back — hand a handed-over pull back to the builder that opened it; its card | |
| 829 | * leaves. | |
| 830 | */ | |
| 808 | 831 | export async function asksGiveBack(ctx: Ctx): Promise<Response> { |
| 809 | 832 | if (!ctx.auth.user) return signInFirst(ctx); |
| 810 | 833 | const form = await readForm(ctx, "rw"); |
| @@ -817,7 +840,10 @@ export async function asksGiveBack(ctx: Ctx): Promise<Response> { | ||
| 817 | 840 | return redirect(backTo(form, "/asks")); |
| 818 | 841 | } |
| 819 | 842 | |
| 820 | /** POST /asks/proposal/:id/(approve|redirect|later|again) — one wave proposal, then back to the page the person came from. */ | |
| 843 | /** | |
| 844 | * POST /asks/proposal/:id/(approve|redirect|later|again) — one wave proposal, then back to the page | |
| 845 | * the person came from. | |
| 846 | */ | |
| 821 | 847 | export function asksProposal(verb: ProposalVerb) { |
| 822 | 848 | return async (ctx: Ctx): Promise<Response> => { |
| 823 | 849 | if (!ctx.auth.user) return signInFirst(ctx); |
| @@ -864,7 +890,10 @@ export async function asksListen(ctx: Ctx): Promise<Response> { | ||
| 864 | 890 | return redirect(only === undefined ? back : withFlash(back, "listened", only)); |
| 865 | 891 | } |
| 866 | 892 | |
| 867 | /** POST /asks/mute — the viewer mutes one repository they can read: its asks leave their home, inbox and phone. */ | |
| 893 | /** | |
| 894 | * POST /asks/mute — the viewer mutes one repository they can read: its asks leave their home, inbox | |
| 895 | * and phone. | |
| 896 | */ | |
| 868 | 897 | export async function asksMute(ctx: Ctx): Promise<Response> { |
| 869 | 898 | if (!ctx.auth.user) return signInFirst(ctx); |
| 870 | 899 | const form = await readForm(ctx, "rw"); |
| @@ -878,7 +907,10 @@ export async function asksMute(ctx: Ctx): Promise<Response> { | ||
| 878 | 907 | return redirect(withFlash(asksBack(form), "muted", repo.id)); |
| 879 | 908 | } |
| 880 | 909 | |
| 881 | /** POST /asks/filter — `do` (hide_app_day, hide_app, show_app, hide_kind, show_kind, clear) with `repo` or `kind`: one tap, saved for the viewer. */ | |
| 910 | /** | |
| 911 | * POST /asks/filter — `do` (hide_app_day, hide_app, show_app, hide_kind, show_kind, clear) with | |
| 912 | * `repo` or `kind`: one tap, saved for the viewer. | |
| 913 | */ | |
| 882 | 914 | export async function asksFilter(ctx: Ctx): Promise<Response> { |
| 883 | 915 | if (!ctx.auth.user) return signInFirst(ctx); |
| 884 | 916 | const form = await readForm(ctx, "rw"); |
src/web/studio/lists.ts +7 −2
| @@ -56,6 +56,7 @@ import { | ||
| 56 | 56 | seg, |
| 57 | 57 | time, |
| 58 | 58 | } from "../ui.ts"; |
| 59 | import { emptyList } from "../empty_words.ts"; | |
| 59 | 60 | import type { Run, RunState } from "../../core/runs.ts"; |
| 60 | 61 | import { actorsFor, issuesFor, runTitleFrom } from "../pages/runs.ts"; |
| 61 | 62 | import { originGlyph } from "../pages/thread.ts"; |
| @@ -348,7 +349,9 @@ function closedWord(issue: Issue): { word: Word; note: string } { | ||
| 348 | 349 | : { word: "done", note: "closed as done" }; |
| 349 | 350 | } |
| 350 | 351 | |
| 351 | /** Whether the list is open and narrowed by a label alone: the rows the labels page's number counts. */ | |
| 352 | /** | |
| 353 | * Whether the list is open and narrowed by a label alone: the rows the labels page's number counts. | |
| 354 | */ | |
| 352 | 355 | function byLabelOnly(f: ListFacets): boolean { |
| 353 | 356 | return f.label !== "" && atRest({ ...f, label: "" }); |
| 354 | 357 | } |
| @@ -849,7 +852,9 @@ export async function runsListPage(ctx: Ctx, repo: Repo): Promise<Response> { | ||
| 849 | 852 | const rendering = performance.now(); |
| 850 | 853 | const list = |
| 851 | 854 | rows.length === 0 |
| 852 | ? empty({ | |
| 855 | ? filter === undefined | |
| 856 | ? emptyList("runs", { href: `${base}/issues`, bind }) | |
| 857 | : empty({ | |
| 853 | 858 | icon: "bot", |
| 854 | 859 | title: emptyNote( |
| 855 | 860 | filter, |
test/empty-states.test.ts +34 −2
| @@ -1,4 +1,7 @@ | ||
| 1 | /** A fresh account's blank list pages are never a dead end: every empty state carries a link (#10938). */ | |
| 1 | /** | |
| 2 | * A fresh account's blank list pages are never a dead end: every empty state carries a link | |
| 3 | * (#10938). | |
| 4 | */ | |
| 2 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -8,6 +11,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 8 | 11 | import { createSession } from "../src/core/sessions.ts"; |
| 9 | 12 | import { createUser } from "../src/core/users.ts"; |
| 10 | 13 | import { serve, type Servers } from "../src/http/server.ts"; |
| 14 | import { EMPTY_WORDS, emptyList } from "../src/web/empty_words.ts"; | |
| 11 | 15 | |
| 12 | 16 | let dir: string; |
| 13 | 17 | let app: App; |
| @@ -30,7 +34,9 @@ afterAll(async () => { | ||
| 30 | 34 | await rm(dir, { recursive: true, force: true }); |
| 31 | 35 | }); |
| 32 | 36 | |
| 33 | const LISTS = ["/root/fresh/issues", "/root/fresh/pulls", "/root/fresh/runs", "/apps", "/settings/people", "/boards", "/notes"]; | |
| 37 | // /apps and /boards are not here: their page already carries the one door ("New app", "Make a | |
| 38 | // board"). | |
| 39 | const LISTS = ["/root/fresh/issues", "/root/fresh/pulls", "/root/fresh/runs", "/settings/people", "/notes"]; | |
| 34 | 40 | |
| 35 | 41 | /** Every `.empty` block in a page, whole: matched by div depth, so a nested |
| 36 | 42 | * div in the part never cuts it short. */ |
| @@ -95,3 +101,29 @@ test("each list's one link says its own next step, in one sentence", async () => | ||
| 95 | 101 | expect(b).not.toContain("Tell the crew"); |
| 96 | 102 | expect((b!.match(/<p\b/g) ?? []).length).toBe(1); |
| 97 | 103 | }); |
| 104 | ||
outdated
Trailing comment glued to the end of the pages line; put it on its own line above. |
||
| 105 | test("the five lists take their empty sentence from one table, each with a single link", async () => { | |
| 106 | // people: the signed-in admin is always one, so test/keys-people-list.test.ts holds its sentence | |
| 107 | const pages: Record<string, string> = { board: "/boards", inbox: "/asks", runs: "/root/fresh/runs", apps: "/apps" }; | |
| 108 | for (const [kind, path] of Object.entries(pages)) { | |
| 109 | const w = EMPTY_WORDS[kind as keyof typeof EMPTY_WORDS]; | |
| 110 | const blocks = emptyBlocks(await (await fetch(servers.url + path, { headers: { cookie } })).text()); | |
| 111 | const mine = blocks.filter((b) => b.includes(w.sentence)); | |
| 112 | expect(mine.length).toBe(1); | |
| 113 | // apps and board: the page already offers the door, so the empty state does not say it twice. | |
| 114 | const once = kind === "apps" || kind === "board"; | |
| 115 | expect(links(mine[0]!).length).toBe(once ? 0 : 1); | |
| 116 | if (!once) expect(links(mine[0]!)[0]!.endsWith(`|${w.label}`)).toBe(true); | |
| 117 | expect(mine[0]).not.toContain('data-variant="primary"'); | |
| 118 | expect((mine[0]!.match(/<p\b/g) ?? []).length).toBe(1); | |
| 119 | } | |
| 120 | }); | |
| 121 | ||
| 122 | test("emptyList takes its link from the table unless the page names one, and can leave it out", () => { | |
| 123 | expect(String(emptyList("apps"))).toContain('href="/apps/new"'); | |
| 124 | expect(String(emptyList("runs", { href: "/a/b/issues" }))).toContain('href="/a/b/issues"'); | |
| 125 | expect(String(emptyList("people", { noAction: true }))).not.toMatch(/<a\s/); | |
| 126 | const people = String(emptyList("people")); | |
| 127 | expect(people).toContain(EMPTY_WORDS.people.sentence); | |
| 128 | expect(people.match(/<a\s/g)?.length).toBe(1); | |
| 129 | }); |
test/tui-asked.test.ts +1 −1
| @@ -118,7 +118,7 @@ describe("the asked screen", () => { | ||
| 118 | 118 | |
| 119 | 119 | test("a guest sees nothing", async () => { |
| 120 | 120 | const text = await screenText(); |
| 121 | expect(text).toContain("Nothing asked yet"); | |
| 121 | expect(text).toContain("Nothing is waiting on you."); | |
| 122 | 122 | expect(text).not.toContain("make the lobby louder"); |
| 123 | 123 | expect(text).not.toContain("bob's private idea"); |
| 124 | 124 | }); |
Both doors: say whether the terminal uses this table; if it has empty lists, it should.