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

Revert "Every issue and pull row shows its #N; titles and comment times link to themselves (#16418)" #16448

opened this

Check · Review · Land · Live — No review yet. Next: reviewer, no review yet.

Ready to land

revert-16419 → main 1 commit

Review

Sign in to review this change.
14 files changed +17 −222
docs/design/areas/pinpoint.md deleted −6
@@ -1,6 +0,0 @@
1 # Pinpointing
2
3 A row that stands for an issue or a pull leads its meta line with its number, `.row-num` (`#12 ·
4 just now`), at every width, so a person on a phone can say which one they mean
5 (`test/row-numbers.test.ts`). A page's own `#N` beside its title is a link to itself, and a
6 comment's time links to the comment's anchor (`.permalink`), each an address to copy or share.
docs/design/attention-budget.json +6 −8
@@ -63,29 +63,27 @@
6363 },
6464 "issues list": {
6565 "390": {
66 "words": 32,
66 "words": 30,
6767 "blocks": 7,
6868 "colours": 2
6969 },
7070 "1280": {
71 "words": 32,
71 "words": 30,
7272 "blocks": 7,
7373 "colours": 2
74 },
75 "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
74 }
7675 },
7776 "pulls list": {
7877 "390": {
79 "words": 26,
78 "words": 24,
8079 "blocks": 6,
8180 "colours": 1
8281 },
8382 "1280": {
84 "words": 26,
83 "words": 24,
8584 "blocks": 6,
8685 "colours": 1
87 },
88 "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
86 }
8987 },
9088 "runs": {
9189 "390": {
src/web/comments.ts +1 −3
@@ -27,8 +27,6 @@ export interface CommentCard {
2727 originKind?: IconName;
2828 /** The canonical URL at the origin, for "view on origin". */
2929 originUrl?: string | null;
30 /** The id the page gives this comment, so its time links to it: the address to share. */
31 anchor?: string;
3230 }
3331
3432 export function commentCard(card: CommentCard): Html {
@@ -44,7 +42,7 @@ export function commentCard(card: CommentCard): Html {
4442 return html`<div ${idAttr}class="comment-row">
4543 <div class="comment-head">
4644 ${byline}
47 <span class="muted">${card.verb} ${card.anchor === undefined ? time(card.at) : html`<a class="permalink" href="#${card.anchor}" title="This comment's address">${time(card.at)}</a>`}</span>
45 <span class="muted">${card.verb} ${time(card.at)}</span>
4846 ${when(
4947 card.originUrl != null && card.originUrl !== "",
5048 () => html`<span class="spacer"></span>
src/web/pages/thread.ts −1
@@ -512,7 +512,6 @@ export function threadComment(
512512 return html`<div class="tl-item" id="c-${id}" data-kind="comment" data-comment-id="${id}">
513513 <span class="tl-dot">${icon("comment")}</span>${commentCard({
514514 id,
515 anchor: `c-${id}`,
516515 author,
517516 mark: origin.mark,
518517 at,
src/web/studio/change.ts +1 −1
@@ -290,7 +290,7 @@ export function changeHead(
290290 const accounts = accountsByName(ctx.app.db, [pull.authorName, who ?? ""], repo.id);
291291 const marks = marksOf(accounts);
292292 return html`<div class="page-head">
293 <h1>${pull.title} <a class="num self" href="${changeHref(repoBase(repo), pull.number)}" title="This pull's address">#${pull.number}</a></h1>
293 <h1>${pull.title} <span class="num">#${pull.number}</span></h1>
294294 <div class="page-head-sub bar muted small">
295295 ${stateDot(
296296 pullState(pull),
src/web/studio/land_as_is.ts −1
@@ -113,7 +113,6 @@ export function landOnApp(ctx: Ctx, repo: Repo): Html | null {
113113 return listCard(
114114 green.map((pull) =>
115115 row({
116 num: pull.number,
117116 title: html`<a href="${changeHref(repoBase(repo), pull.number)}">${pull.title}</a>`,
118117 trail: html`<span class="bar">${landForm(repo, pull)}${when(previewOf(ctx.app, repo, pull), (href) => btn("Preview", { href, size: "sm" }))}</span>`,
119118 }),
src/web/studio/lists.ts −2
@@ -517,7 +517,6 @@ export async function tellsList(ctx: Ctx): Promise<Response> {
517517 rows.map(({ issue, info }) =>
518518 row({
519519 href: tellHref(base, issue.number),
520 num: issue.number,
521520 nav: true,
522521 lead: wordDot(info.word, info.note),
523522 title: titled(issue.title, labels.get(issue.id)),
@@ -693,7 +692,6 @@ export async function changesList(ctx: Ctx): Promise<Response> {
693692 rows.map(({ pull, info }) =>
694693 row({
695694 href: changeHref(base, pull.number),
696 num: pull.number,
697695 nav: true,
698696 lead: wordDot(info.word, info.note),
699697 title: titled(pull.title, labels.get(pull.id)),
src/web/studio/now.ts −5
@@ -256,7 +256,6 @@ export async function nowCard(
256256 );
257257 return row({
258258 href: tellHref(base, i.number),
259 num: i.number,
260259 nav: true,
261260 lead: avatar(who),
262261 title: i.title,
@@ -278,7 +277,6 @@ export async function nowCard(
278277 if (previewLinks)
279278 return row({
280279 nav: true,
281 num: p.number,
282280 lead: avatar(who),
283281 title: html`<a href="${changeHref(base, p.number)}">${p.title}</a>`,
284282 meta: html`${meta} · <a href="${base}/app/${previewEnv(p.number)}/open">Preview</a>`,
@@ -286,7 +284,6 @@ export async function nowCard(
286284 });
287285 return row({
288286 href: changeHref(base, p.number),
289 num: p.number,
290287 nav: true,
291288 lead: avatar(who),
292289 title: p.title,
@@ -303,7 +300,6 @@ export async function nowCard(
303300 );
304301 return row({
305302 href: tellHref(base, i.number),
306 num: i.number,
307303 nav: true,
308304 lead: avatar(who),
309305 title: i.title,
@@ -320,7 +316,6 @@ export async function nowCard(
320316 ...stuck.map((i) => {
321317 return row({
322318 lead: avatar("crew"),
323 num: i.number,
324319 title: html`<a href="${tellHref(base, i.number)}">${i.title}</a>`,
325320 // The invitation is a writer's (the shelf's rule, `ownerFacts`); the
326321 // fact — nobody has taken it — stays for everyone.
src/web/studio/tell.ts +3 −3
@@ -92,7 +92,7 @@ import {
9292 originGlyph,
9393 threadContext,
9494 } from "../pages/thread.ts";
95 import { changeHref, tellHref } from "./nouns.ts";
95 import { changeHref } from "./nouns.ts";
9696 import {
9797 knowPulls,
9898 knowRunPulls,
@@ -400,7 +400,7 @@ async function tellClosingPull(
400400 const base = repoBase(repo);
401401 const { word, note } = await pullWord(wordCtx, pull);
402402 return html`${listCard(
403 [row({ href: changeHref(base, pull.number), num: pull.number, title: pull.title, meta: html`${note}`, trail: wordBadge(word) })],
403 [row({ href: changeHref(base, pull.number), title: pull.title, meta: html`${note}`, trail: wordBadge(word) })],
404404 { head: html`${icon("pull")} <h2>Closes with</h2>` },
405405 )}${previewBlock(ctx, repo, pull)}`;
406406 }
@@ -539,7 +539,7 @@ async function studioTell(
539539 const accounts = accountsByName(db, [issue.authorName, issue.assigneeName ?? ""], repo.id);
540540 const marks = marksOf(accounts);
541541 const head = html`<div class="page-head">
542 <h1>${issue.title} <a class="num self" href="${tellHref(repoBase(repo), issue.number)}" title="This issue's address">#${issue.number}</a></h1>
542 <h1>${issue.title} <span class="num">#${issue.number}</span></h1>
543543 <div class="page-head-sub bar muted small">
544544 ${direction
545545 ? html`<span class="muted small"
src/web/ui.ts +2 −10
@@ -987,11 +987,6 @@ export interface RowOptions {
987987 href?: string;
988988 title: Html | string;
989989 meta?: Html;
990 /**
991 * The issue's or pull's number: `#N` first in the meta line, at every width, so a person can say
992 * which one they mean (`test/row-numbers.test.ts`).
993 */
994 num?: number;
995990 /** Facts about the row, one `dt`/`dd` pair each, in a `dl.row-facts` under the meta. With facts
996991 * the row's main column is a `<div>`, so the `dl` is valid HTML: not for a `fold` row, whose
997992 * `<summary>` takes phrasing only. */
@@ -1029,9 +1024,6 @@ export interface RowOptions {
10291024 tree?: { level: number; open: boolean };
10301025 }
10311026
1032 /** A row's `#N`, a span of its own so no width rule can take it without the test seeing. */
1033 const numOf = (n: number | undefined): Html | null => (n === undefined ? null : html`<span class="row-num">#${String(n)}</span>${raw(" · ")}`);
1034
10351027 /** One list row. `<a>` when it navigates, `<div>` when it holds its own
10361028 * controls, `<summary>` when it folds — the hover affordance follows
10371029 * automatically. */
@@ -1046,7 +1038,7 @@ export function row(o: RowOptions): Html {
10461038 ${o.titleAttr ? html`title="${o.titleAttr}"` : null}
10471039 >${o.title}</span
10481040 >
1049 ${o.meta || o.metaSlot || o.num !== undefined ? html`<span class="row-meta">${numOf(o.num)}${o.meta}</span>` : null}
1041 ${o.meta || o.metaSlot ? html`<span class="row-meta">${o.meta}</span>` : null}
10501042 <dl class="row-facts">${o.facts!.map((f) => html`<div><dt>${f.label}</dt><dd>${f.value}</dd></div>`)}</dl>
10511043 </div>` : html`<span class="row-main">
10521044 <span
@@ -1054,7 +1046,7 @@ export function row(o: RowOptions): Html {
10541046 ${o.titleAttr ? html`title="${o.titleAttr}"` : null}
10551047 >${o.title}</span
10561048 >
1057 ${o.meta || o.metaSlot || o.num !== undefined ? html`<span class="row-meta">${numOf(o.num)}${o.meta}</span>` : null}
1049 ${o.meta || o.metaSlot ? html`<span class="row-meta">${o.meta}</span>` : null}
10581050 </span>`}
10591051 ${o.trail && o.trail.text.trim() !== ""
10601052 ? html`<span class="row-trail">${o.trail}</span>`
test/changelog-depth.test.ts +1 −2
@@ -71,8 +71,7 @@ test("from /changelog each tap reaches the next step: wave, change, pull, conver
7171 const pull = await fetch(`${servers.url}${pullHref}`);
7272 expect(pull.status).toBe(200);
7373 const pullHtml = await pull.text();
74 // Its number beside the title is the link to the pull itself (#16418).
75 expect(pullHtml).toMatch(new RegExp(`<h1>Build ${number - 7000} <a class="num self" href="/alice/shop/pulls/${number}"[^>]*>#${number}</a></h1>`));
74 expect(pullHtml.replace(/\s+/g, "").includes(`<h1>Build${number - 7000}<spanclass="num">#${number}</span></h1>`)).toBe(true);
7675
7776 // 4. The same page holds the conversation: its opening post, which the pull's body wrote.
7877 const at = pullHtml.indexOf('id="conversation"');
test/keys-decide.test.ts +1 −1
@@ -132,5 +132,5 @@ test("the issues list the server draws carries data-nav rows, and the pulls list
132132 // The fixture has no open pull to draw; the row the pulls list builds is the one declared here.
133133 const lists = readFileSync(new URL("../src/web/studio/lists.ts", import.meta.url), "utf8");
134134 const pulls = lists.slice(lists.indexOf("export async function changesList"), lists.indexOf("export function isWorkingNow"));
135 expect(pulls).toMatch(/row\(\{\s*href: changeHref\(base, pull\.number\),(\s*num: pull\.number,)?\s*nav: true,/);
135 expect(pulls).toMatch(/row\(\{\s*href: changeHref\(base, pull\.number\),\s*nav: true,/);
136136 });
test/number-retired.test.ts +2 −3
@@ -58,8 +58,7 @@ test("the stylesheet no longer contains .number", () => {
5858
5959 test("the issue heading marks its number with .num", async () => {
6060 const page = await (await fetch(`${base}/n/r/issues/1`)).text();
61 // Marked with .num, and a link to the issue itself (#16418).
62 expect(page).toMatch(/<h1>a issue\s*<a class="num self" href="\/[^"]+\/issues\/1"[^>]*>#1<\/a><\/h1>/);
61 expect(page).toMatch(/<h1>a issue\s*<span class="num">#1<\/span><\/h1>/);
6362 expect(page).not.toContain('class="number"');
6463 });
6564
@@ -80,6 +79,6 @@ test("the pull heading marks its number with .num", () => {
8079 draftRun: null,
8180 };
8281 const head = String(changeHead({ app, auth: { user: undefined, scope: undefined, via: "none" } } as Ctx, repo, pull, null, undefined));
83 expect(head).toMatch(/<h1>a pull <a class="num self" href="\/[^"]+\/pulls\/2"[^>]*>#2<\/a><\/h1>/);
82 expect(head).toContain('<h1>a pull <span class="num">#2</span></h1>');
8483 expect(head).not.toContain('class="number"');
8584 });
test/row-numbers.test.ts deleted −176
@@ -1,176 +0,0 @@
1 /**
2 * A row that stands for an issue or a pull shows its `#N`, at every width: a person on a phone
3 * must be able to say which one they mean. Three ways it could go missing, each a check:
4 * a row drawn without its number, a style that hides the number under a breakpoint, and the
5 * list pages themselves (rendered for real, every row read for the number its link names).
6 * A page's own `#N` and a comment's time are links to themselves, to copy and share.
7 */
8 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
9 import { readdirSync, readFileSync } from "node:fs";
10 import { mkdtemp, rm } from "node:fs/promises";
11 import { tmpdir } from "node:os";
12 import { join } from "node:path";
13 import { openIssue } from "../src/actions/issues.ts";
14 import { openPull } from "../src/actions/pulls.ts";
15 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
16 import { createApp, type App } from "../src/app.ts";
17 import { createSession } from "../src/core/sessions.ts";
18 import { createUser } from "../src/core/users.ts";
19 import { serve, type Servers } from "../src/http/server.ts";
20
21 /** Every `.ts` file under `dir`, with its text. */
22 const sources = (dir: string): { path: string; text: string }[] =>
23 readdirSync(dir, { recursive: true, withFileTypes: true })
24 .filter((e) => e.isFile() && e.name.endsWith(".ts"))
25 .map((e) => {
26 const path = join(e.parentPath, e.name);
27 return { path, text: readFileSync(path, "utf8") };
28 });
29
30 /** Each `row({ … })` call's argument text, by brace counting. */
31 function rowCalls(text: string): string[] {
32 const out: string[] = [];
33 for (
34 let at = text.indexOf("row({");
35 at !== -1;
36 at = text.indexOf("row({", at + 1)
37 ) {
38 if (/[A-Za-z0-9_.]$/.test(text.slice(Math.max(0, at - 1), at))) continue;
39 let depth = 0;
40 let end = at + 4;
41 for (; end < text.length; end++) {
42 if (text[end] === "{") depth++;
43 else if (text[end] === "}" && --depth === 0) break;
44 }
45 out.push(text.slice(at, end + 1));
46 }
47 return out;
48 }
49
50 test("every row that opens an issue or a pull names its number (`num`)", () => {
51 const missing: string[] = [];
52 for (const { path, text } of sources("src/web"))
53 for (const call of rowCalls(text))
54 if (/\b(tellHref|changeHref)\(/.test(call) && !/\bnum:/.test(call))
55 missing.push(`${path}: ${call.slice(0, 80).replace(/\s+/g, " ")}`);
56 expect(missing).toEqual([]);
57 });
58
59 test("no style hides a row's number, at any width", () => {
60 const hiding: string[] = [];
61 for (const { path, text } of sources("src/web/style"))
62 for (const m of text.matchAll(/([^{}]*\.row-num[^{}]*)\{([^}]*)\}/g))
63 if (
64 /display\s*:\s*none|visibility\s*:\s*hidden|font-size\s*:\s*0|width\s*:\s*0/.test(
65 m[2]!,
66 )
67 )
68 hiding.push(`${path}: ${m[1]!.trim()}`);
69 expect(hiding).toEqual([]);
70 });
71
72 describe("the list pages, rendered", () => {
73 let dir: string;
74 let app: App;
75 let servers: Servers;
76 let cookie = "";
77
78 beforeAll(async () => {
79 dir = await mkdtemp(join(tmpdir(), "forge-row-numbers-"));
80 app = createApp({ dataDir: dir, port: 0 });
81 servers = await serve(app);
82 const made = await createUser(app.db, {
83 origin: "seed",
84 trusted: true,
85 username: "alice",
86 email: "[email protected]",
87 password: "a-good-passphrase",
88 adminIfFirst: true,
89 });
90 if (!made.ok) throw new Error(made.error);
91 const repo = await createRepo(app, made.value, {
92 name: "shop",
93 visibility: "public",
94 });
95 if (!repo.ok) throw new Error(String(repo.error));
96 await commitToBranch(app, made.value, repo.value, {
97 message: "Start",
98 files: [{ path: "README.md", content: "# shop\n" }],
99 });
100 await commitToBranch(app, made.value, repo.value, {
101 branch: "fix",
102 message: "Fix",
103 files: [{ path: "README.md", content: "# shop, fixed\n" }],
104 });
105 for (const title of [
106 "Prices show three decimals",
107 "Search ignores accents",
108 "Cart empties after sign-in",
109 ])
110 openIssue(app, made.value, repo.value, { title });
111 const pull = await openPull(app, made.value, repo.value, {
112 title: "Fix the readme",
113 baseBranch: "main",
114 headBranch: "fix",
115 });
116 if (!pull.ok) throw new Error(String(pull.error));
117 cookie = `forge_session=${createSession(app.db, made.value.id).token}`;
118 });
119
120 afterAll(async () => {
121 servers.stop();
122 app.close();
123 await rm(dir, { recursive: true, force: true });
124 });
125
126 const page = async (path: string): Promise<string> =>
127 (await fetch(`${servers.url}${path}`, { headers: { cookie } })).text();
128
129 test("every row of the issues and pulls lists shows the number its link names", async () => {
130 for (const [path, noun] of [
131 ["/alice/shop/issues", "issues"],
132 ["/alice/shop/pulls", "pulls"],
133 ] as const) {
134 const html = await page(path);
135 const rows = [
136 ...html.matchAll(
137 /<li(?:\s[^>]*)?>\s*<a\s+href="\/alice\/shop\/(issues|pulls)\/(\d+)"\s+class="row"[\s\S]*?<\/li>/g,
138 ),
139 ];
140 expect(rows.length).toBeGreaterThan(0);
141 for (const r of rows) {
142 expect(r[1]).toBe(noun);
143 expect(r[0]).toContain(`<span class="row-num">#${r[2]}</span>`);
144 }
145 }
146 });
147
148 test("an issue's and a pull's own #N link to themselves", async () => {
149 expect(await page("/alice/shop/issues/1")).toMatch(
150 /<h1>[^<]*<a class="num self" href="\/alice\/shop\/issues\/1"[^>]*>#1<\/a><\/h1>/,
151 );
152 expect(await page("/alice/shop/pulls/4")).toMatch(
153 /<h1>[^<]*<a class="num self" href="\/alice\/shop\/pulls\/4"[^>]*>#4<\/a><\/h1>/,
154 );
155 });
156
157 test("a comment's time links to the comment", async () => {
158 const posted = await fetch(
159 `${servers.url}/api/v1/repos/alice/shop/issues/1/comments`,
160 {
161 method: "POST",
162 headers: {
163 "content-type": "application/json",
164 authorization: `Basic ${btoa("alice:a-good-passphrase")}`,
165 },
166 body: JSON.stringify({ body: "Seen on an iPhone SE." }),
167 },
168 );
169 const comment = (await posted.json()) as { id: string };
170 const html = await page("/alice/shop/issues/1");
171 expect(html).toContain(`id="c-${comment.id}"`);
172 expect(html).toMatch(
173 new RegExp(`<a class="permalink" href="#c-${comment.id}"`),
174 );
175 });
176 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs