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

Pinpoint, part 2: copyable comment links, Reply in line threads, linked diff lines, a sign-in hint on not-found (#16423) #16427

Merged opened this

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

Merged

fix/pinpoint-2 → main 0 commits 1 thread · 1 unresolved

  • Merged. fix/pinpoint-2 was merged into main as e234e74.

Review

Sign in to review this change.
17 files changed +419 −41
docs/design/areas/pinpoint.md +2
@@ -4,3 +4,5 @@ A row that stands for an issue or a pull leads its meta line with its number, `.
44 just now`), at every width, so a person on a phone can say which one they mean
55 (`test/row-numbers.test.ts`). A page's own `#N` beside its title is a link to itself, and a
66 comment's time links to the comment's anchor (`.permalink`), each an address to copy or share.
7
8 - `.dl-bar`: the bar a tapped diff line opens on a touch screen, under that line: Copy link and Comment, held in view when the diff scrolls sideways.
docs/features/pinpoint.md added +32
@@ -0,0 +1,32 @@
1 ---
2 topic: Ship and undo
3 row: Every comment and diff line has its own address
4 ---
5
6 # Pointing at one thing
7
8 Every comment, every changed line and every number has an address you can send.
9
10 ## On the page
11
12 - **A comment:** its time is a link to itself (`#c-<id>` on an issue, `#rc-<id>` on a pull's
13 line comment). With script on, **Copy link** beside it copies the full address.
14 - **A diff line:** its number is a link to that line (`#d-<file>-R<line>`). The page opens
15 scrolled to it, with the line marked. The `+` beside the number comments on that line, and a
16 line comment's thread has **Reply** under it. On a phone the lines keep their reading size:
17 tap anywhere on a line to select it (its address goes in the bar) and a bar opens under it
18 with **Copy link** and **Comment**, each a full thumb target.
19 - **A reference in a comment:** `#12` links to issue or pull 12 of the repository, and
20 `src/cart.ts:31` links to that line of the file on the default branch. Inside code it stays
21 code.
22 - **A link into a private repository, signed out:** the page reads the same as a missing one,
23 and **sign in** brings you back to the address you opened.
24
25 ## In the terminal
26
27 Open a pull, go to its diff tab, put the cursor on a line and press `c`: the comment is anchored
28 to that line, and its thread shows under it, as on the page. The terminal has no addresses to
29 copy; it walks to the line instead.
30
31 `src/web/comments.ts` (permalinks and references) and `src/web/diff-view.ts` (line addresses)
32 draw the page; `src/tui/screens/pull.ts` is the terminal's side.
src/web/chrome.ts +8 −1
@@ -88,10 +88,17 @@ export function notFoundPage(ctx: Ctx, opts: { plain?: boolean; noEcho?: boolean
8888 if (typed) return typed;
8989 if (opts.signedOut === true || (!opts.plain && ctx.auth.user === undefined)) {
9090 // A signed-out visitor learns one thing: it is not here; two ways on, and nothing of the path.
91 // A link someone shared may be to a private repository: the same words, and the same page, for a
92 // missing one and a private one (the 404 parity holds), with one more way on: signing in.
9193 const id = requestId();
94 const get = !opts.plain && (ctx.request.method === "GET" || ctx.request.method === "HEAD");
95 // Signing in comes back to this address: the visitor's own, the same words whether the repository
96 // is private or missing, so the parity holds (`returnTo`, checked as a path on this forge).
97 const back = withReturn("/signin", opts.noEcho === true ? undefined : returnTo(ctx));
98 const signIn = get ? html`<p class="muted">If it's private, <a href="${back}">sign in</a>.</p>` : html``;
9299 const res = leanPage(
93100 "Not found",
94 html`<h1>That page is not here.</h1><p>${btn("Home", { href: "/", variant: "primary" })} ${btn("Search", { href: "/search" })}</p>`,
101 html`<h1>That page is not here.</h1>${signIn}<p>${btn("Home", { href: "/", variant: "primary" })} ${btn("Search", { href: "/search" })}</p>`,
95102 404,
96103 );
97104 res.headers.set("x-request-id", id);
src/web/client.ts +46 −1
@@ -1365,6 +1365,51 @@ export const moduleLoaderJs = /* js */ `
13651365 }
13661366 `;
13671367
1368 /**
1369 * A diff line on a touch screen (#16427): the pages that draw a diff carry it, not the shell.
1370 */
1371 export const diffTapJs = /* js */ `
1372 // ---- a diff line on a touch screen: the whole row is the target ----
1373 // A thumb cannot hit a line number at reading size, so a tap anywhere on a line selects it (its
1374 // address in the bar, the line marked) and opens one bar under it: Copy link and Comment, each a
1375 // full-size button. The rows keep their height; without script the number is still the link.
1376 (function () {
1377 var doc = document;
1378 if (doc.querySelector('.diff-table') && window.matchMedia && matchMedia('(pointer: coarse)').matches) {
1379 doc.addEventListener('click', function (e) {
1380 var t = e.target;
1381 if (!t || !t.closest || t.closest('a, button, input, textarea, summary, .dl-bar')) return;
1382 var tr = t.closest('.diff-table tr.dl[id]');
1383 if (!tr) return;
1384 doc.querySelectorAll('.diff-table tr[data-hl]').forEach(function (r) { r.removeAttribute('data-hl'); });
1385 var old = doc.querySelector('.dl-bar');
1386 if (old) old.parentNode.removeChild(old);
1387 history.replaceState(history.state, '', '#' + tr.id);
1388 tr.setAttribute('data-hl', '');
1389 var bar = doc.createElement('tr');
1390 bar.className = 'dl-bar';
1391 var td = doc.createElement('td');
1392 td.colSpan = tr.children.length;
1393 var link = doc.createElement('a');
1394 link.id = 'dl-bar-link'; link.href = '#' + tr.id; link.hidden = true;
1395 var copy = doc.createElement('button');
1396 copy.type = 'button'; copy.className = 'btn'; copy.setAttribute('data-copy', 'dl-bar-link'); copy.textContent = 'Copy link';
1397 var hold = doc.createElement('span');
1398 hold.appendChild(link); hold.appendChild(copy);
1399 var say = tr.querySelector('a.dn-comment[aria-label]');
1400 if (say) {
1401 var go = doc.createElement('a');
1402 go.className = 'btn'; go.href = say.getAttribute('href'); go.textContent = 'Comment';
1403 hold.appendChild(go);
1404 }
1405 td.appendChild(hold);
1406 bar.appendChild(td);
1407 tr.parentNode.insertBefore(bar, tr.nextSibling);
1408 });
1409 }
1410 })();
1411 `;
1412
13681413 const shellCore = /* js */ `
13691414 (function () {
13701415 var doc = document;
@@ -1443,7 +1488,7 @@ const shellCore = /* js */ `
14431488 done(selectText(src) ? 'Selected — press Ctrl/Cmd+C' : 'Copy it by hand');
14441489 }
14451490 if (!navigator.clipboard) { fallback(); return; }
1446 navigator.clipboard.writeText((src.value !== undefined ? src.value : src.textContent).trim()).then(function () {
1491 navigator.clipboard.writeText((src.tagName === 'A' ? src.href : src.value !== undefined ? src.value : src.textContent).trim()).then(function () {
14471492 done('Copied');
14481493 }, fallback);
14491494 });
src/web/comments.ts +57 −4
@@ -7,9 +7,9 @@
77
88 import type { Mark } from "../core/marks.ts";
99 import { emptyNote } from "./empty_words.ts";
10 import { html, when, type Html } from "./html.ts";
10 import { html, raw, when, type Html } from "./html.ts";
1111 import { renderMarkdown } from "./markdown.ts";
12 import { originTag, popout, time, userLink, type IconName } from "./ui.ts";
12 import { btn, originTag, popout, time, userLink, type IconName } from "./ui.ts";
1313
1414 export interface CommentCard {
1515 /** "" for the opener (the issue/PR body), which has no comment row. */
@@ -29,6 +29,57 @@ export interface CommentCard {
2929 originUrl?: string | null;
3030 /** The id the page gives this comment, so its time links to it: the address to share. */
3131 anchor?: string;
32 /** The repository the comment is in: `#N` and `path:line` in its body link there (`linkRefs`). */
33 refs?: Refs;
34 }
35
36 export interface Refs {
37 /** The repository's base path (`/owner/name`). */
38 readonly base: string;
39 /** The branch a `path:line` is read on. */
40 readonly ref: string;
41 }
42
43 /** Tags inside which no text becomes a link: one already, and code. */
44 const INERT_OPEN = /^<(a|code|pre)\b/i;
45 const INERT_CLOSE = /^<\/(a|code|pre)>/i;
46
47 /**
48 * A rendered body with what names a thing in this repository made its link, where it is
49 * unambiguous: `#12` (an issue or pull, `/issues/12` answers both) and `src/cart.ts:30` or
50 * `src/cart.ts#L30` (that line on the default branch). Text in a link, code or a code block stays
51 * as it is; a bare "line 14" names no file and is left alone.
52 */
53 export function linkRefs(body: Html, refs: Refs): Html {
54 let inert = 0;
55 return raw(
56 body.text
57 .split(/(<[^>]+>)/)
58 .map((part) => {
59 if (part.startsWith("<")) {
60 if (INERT_OPEN.test(part)) inert++;
61 else if (INERT_CLOSE.test(part)) inert = Math.max(0, inert - 1);
62 return part;
63 }
64 if (inert > 0) return part;
65 return part
66 .replace(/(^|[\s(])#(\d{1,7})\b/g, (_, pre: string, n: string) => `${pre}<a href="${refs.base}/issues/${n}">#${n}</a>`)
67 .replace(
68 /(^|[\s(])((?:[\w.-]+\/)*[\w-]+\.[A-Za-z0-9]{1,8})(?::|#L)(\d{1,6})\b/g,
69 (_, pre: string, path: string, line: string) =>
70 `${pre}<a href="${refs.base}/blob/${encodeURIComponent(refs.ref)}/${path.split("/").map(encodeURIComponent).join("/")}#L${line}">${path}:${line}</a>`,
71 );
72 })
73 .join(""),
74 );
75 }
76
77 /**
78 * A comment's time as the link to it, and beside it a Copy link button (the link's address; with
79 * no script, the link itself is there to long-press). `anchor` is the id the page gives the comment.
80 */
81 export function permalink(anchor: string, at: string): Html {
82 return html`<a class="permalink" id="cl-${anchor}" href="#${anchor}" title="This comment's address">${time(at)}</a> ${btn("Copy link", { size: "sm", variant: "ghost", type: "button", copy: `cl-${anchor}`, label: "Copy this comment's link", extra: "js-only" })}`;
3283 }
3384
3485 export function commentCard(card: CommentCard): Html {
@@ -36,7 +87,9 @@ export function commentCard(card: CommentCard): Html {
3687 const bodyHtml =
3788 card.body.trim() === ""
3889 ? emptyNote("noDescription")
39 : renderMarkdown(card.body);
90 : card.refs === undefined
91 ? renderMarkdown(card.body)
92 : linkRefs(renderMarkdown(card.body), card.refs);
4093 const byline =
4194 card.originAuthor != null && card.originAuthor !== ""
4295 ? originTag(card.originAuthor, card.originKind ?? "globe")
@@ -44,7 +97,7 @@ export function commentCard(card: CommentCard): Html {
4497 return html`<div ${idAttr}class="comment-row">
4598 <div class="comment-head">
4699 ${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>
100 <span class="muted">${card.verb} ${card.anchor === undefined ? time(card.at) : permalink(card.anchor, card.at)}</span>
48101 ${when(
49102 card.originUrl != null && card.originUrl !== "",
50103 () => html`<span class="spacer"></span>
src/web/diff-view.ts +37 −10
@@ -22,8 +22,9 @@ import { composeLine } from "./code.ts";
2222 import type { Token } from "./highlight.ts";
2323 import { escapeHtml, html, raw, when, type Html } from "./html.ts";
2424 import { urlPath } from "./pages/explorer.ts";
25 import { btn, card, disclosure, empty, icon, time, userLink } from "./ui.ts";
25 import { btn, card, disclosure, empty, icon, listCard, row, time, userLink } from "./ui.ts";
2626 import { renderMarkdown } from "./markdown.ts";
27 import { permalink } from "./comments.ts";
2728 import { wordDiff, type Segment } from "./worddiff.ts";
2829
2930 /** Highlighted tokens per side for a file, keyed by path in a SyntaxMap. */
@@ -258,14 +259,15 @@ function renderRow(row: Row, ctx: RowCtx): Html {
258259 const side: Side = row.kind === "del" ? "old" : "new";
259260 const lineNo = side === "old" ? row.oldNumber : row.newNumber;
260261
262 // The line's own address: its number is the link to it, on the side a comment anchors to.
263 const rowId = lineNo === null ? undefined : lineAnchor(path, side, lineNo);
261264 const gutter = (n: number | null, isAnchorSide: boolean) => {
262265 if (n === null) return html`<td class="dn"></td>`;
263 if (!opts.reviewBase || !isAnchorSide)
264 return html`<td class="dn">${n}</td>`;
266 if (!isAnchorSide || rowId === undefined) return html`<td class="dn">${n}</td>`;
267 const self = html`<a class="dn-comment" href="#${rowId}" title="This line's address">${n}</a>`;
268 if (!opts.reviewBase) return html`<td class="dn">${self}</td>`;
265269 const href = `${opts.reviewPage ?? opts.reviewBase}?rc=${encodeURIComponent(path)}~${side}~${n}#rc`;
266 return html`<td class="dn">
267 <a class="dn-comment" href="${href}" title="Comment on this line">${n}</a>
268 </td>`;
270 return html`<td class="dn">${self}<a class="dn-comment" href="${href}" title="Comment on this line" aria-label="Comment on line ${n}">+</a></td>`;
269271 };
270272
271273 // `.dc` is `white-space: pre`, so the cell's contents are assembled here,
@@ -278,7 +280,7 @@ function renderRow(row: Row, ctx: RowCtx): Html {
278280 row.noNewline,
279281 () => html`<span class="nonl" title="No newline at end of file">↵</span>`,
280282 )}`;
281 const rowHtml = html`<tr class="dl" data-k="${row.kind}">
283 const rowHtml = html`<tr class="dl" data-k="${row.kind}"${rowId === undefined ? null : html` id="${rowId}"`}>
282284 ${gutter(row.oldNumber, side === "old")}${gutter(
283285 row.newNumber,
284286 side === "new",
@@ -314,10 +316,10 @@ function reviewRows(
314316 const currentHash = hashLine(currentText);
315317 const thread = comments.map((c) => {
316318 const outdated = c.lineHash !== currentHash;
317 return html`<div class="comment-row">
319 return html`<div class="comment-row" id="rc-${c.id}">
318320 <div class="comment-head muted small">
319321 ${userLink(c.authorName, { mark: opts.marks?.get(c.authorName) })}
320 ${time(c.createdAt)}
322 ${permalink(`rc-${c.id}`, c.createdAt)}
321323 ${when(
322324 outdated,
323325 () => html`<span class="badge" data-variant="danger">outdated</span>`,
@@ -396,7 +398,7 @@ function reviewRows(
396398 )}`,
397399 toggle ? { foot: toggle } : {},
398400 )
399 : html`<div class="dc-thread">${thread}${toggle}</div>`;
401 : html`<div class="dc-thread">${thread}${reply(opts, path, side, line, isActive)}${toggle}</div>`;
400402
401403 return html`<tr>
402404 <td class="dn"></td>
@@ -405,6 +407,30 @@ function reviewRows(
405407 </tr>`;
406408 }
407409
410 /**
411 * Answer a line's thread where it is: a comment on the same line joins its thread (the same form a
412 * new line comment posts). Folded, so the thread stays short; none while the line's own form is open.
413 */
414 function reply(opts: DiffViewOptions, path: string, side: Side, line: number, open: boolean): Html | null {
415 if (!opts.reviewBase || open) return null;
416 return html`<details class="dc-reply">
417 <summary class="btn" data-size="sm" data-variant="ghost">Reply</summary>
418 <form class="comment-form" data-submit-key method="post" action="${opts.reviewBase}/review">
419 <input type="hidden" name="path" value="${path}" />
420 <input type="hidden" name="side" value="${side}" />
421 <input type="hidden" name="line" value="${line}" />
422 <label class="sr-only" for="rr-${lineAnchor(path, side, line)}">Reply on this line</label>
423 <textarea class="input" id="rr-${lineAnchor(path, side, line)}" name="body" rows="3" data-grow placeholder="Reply" required></textarea>
424 <div class="form-actions">${btn("Reply", { size: "sm", variant: "primary", type: "submit" })}</div>
425 </form>
426 </details>`;
427 }
428
429 /** A diff line's id: its file's anchor, then `R<n>` on the new side or `L<n>` on the old. */
430 export function lineAnchor(path: string, side: Side, line: number): string {
431 return `${pathAnchor(path)}-${side === "new" ? "R" : "L"}${String(line)}`;
432 }
433
408434 /**
409435 * Resolve, or take it back. A writer may settle any thread; so may whoever
410436 * commented in it — the reviewer who raised a point is exactly the person
@@ -584,6 +610,7 @@ export function renderDiff(
584610 changed <span class="add">+${diff.additions}</span>
585611 <span class="del">−${diff.deletions}</span>
586612 </div>
613 ${when(shown.length > 1, () => listCard(shown.map((f) => row({ href: `#${fileAnchor(f)}`, title: html`<span class="mono">${f.path}</span>` }))))}
587614 ${shown.map((file) => fileView(file, opts))}
588615 ${when(
589616 hidden > 0,
src/web/pages/commits.ts +3 −2
@@ -10,6 +10,7 @@
1010 * list can do neither, so the live browse pages by cursor and says so.
1111 */
1212
13 import { diffTapJs } from "../client.ts";
1314 import { immutableWhenAddressed } from "../../http/addressed.ts";
1415 import { checkOfCommit, verdictsOfCommits } from "../../actions/runs.ts";
1516 import type { CommitCheck } from "../../checks/commit_check.ts";
@@ -261,7 +262,7 @@ export async function commitsPage(ctx: Ctx): Promise<Response> {
261262 palette: scope.palette,
262263 body: html`${scopeHeader(ctx, scope, "commits")}${switcher}
263264 ${noCommits(num > 1)} ${liveMount({ repo: base })}`,
264 scriptJs: liveClientJs,
265 scriptJs: `${liveClientJs}\n${diffTapJs}`,
265266 styleCss: COMMITS_CSS,
266267 });
267268 notePhase(ctx.request, "render", performance.now() - rendering);
@@ -289,7 +290,7 @@ export async function commitsPage(ctx: Ctx): Promise<Response> {
289290 crumbs: scope.crumbs,
290291 palette: scope.palette,
291292 body,
292 scriptJs: liveClientJs,
293 scriptJs: `${liveClientJs}\n${diffTapJs}`,
293294 styleCss: COMMITS_CSS,
294295 });
295296 notePhase(ctx.request, "render", performance.now() - rendering);
src/web/pages/pull.ts +5 −9
@@ -101,7 +101,7 @@ import { waitingOnTeams } from "../../core/teams_words.ts";
101101 import { teamsHolding, teamVerdicts, type TeamVerdict } from "../../core/issue_teams.ts";
102102 import { html, raw, when, type Html } from "../html.ts";
103103 import { flashTo, fragment, page, redirect } from "../layout.ts";
104 import { liveRegionsJs } from "../client.ts";
104 import { diffTapJs, liveRegionsJs } from "../client.ts";
105105 import { liveClientJs, liveMount } from "../live.ts";
106106 import {
107107 avatar,
@@ -1211,7 +1211,7 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> {
12111211 ${crewActivityCard(ctx, repo, pull)}
12121212 </aside>
12131213 </div>
1214 <div class="mt">${keptRender(renderKey, () => renderDiff(diff, diffOptions))}</div>
1214 <div class="mt" id="diff">${keptRender(renderKey, () => renderDiff(diff, diffOptions))}</div>
12151215 ${liveMount({ repo: base })}`;
12161216
12171217 const response = page({
@@ -1245,7 +1245,7 @@ export async function pullFilesPage(ctx: Ctx): Promise<Response> {
12451245 ],
12461246 body,
12471247 styleCss: labelCss([...allLabels, ...applied]),
1248 scriptJs: `${liveClientJs}\n${liveRegionsJs}`,
1248 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${diffTapJs}`,
12491249 });
12501250 const { diff: diffMs, git, checks, reviews } = spent;
12511251 notePhase(ctx.request, "diff", diffMs, diffHit);
@@ -1309,11 +1309,6 @@ export async function pullCommentSubmit(ctx: Ctx): Promise<Response> {
13091309 : flashTo(ctx, `${dest}#conversation`, { message: "Comment posted." });
13101310 }
13111311
1312 /** Match the diff viewer's per-file anchor id, so the redirect lands there. */
1313 function fileHashAnchor(path: string): string {
1314 return "d-" + path.replace(/[^a-zA-Z0-9]+/g, "-");
1315 }
1316
13171312 // POST /:owner/:name/pulls/:number/review — a comment anchored to a diff line.
13181313 export async function pullReviewSubmit(ctx: Ctx): Promise<Response> {
13191314 const found = pullContext(ctx);
@@ -1361,7 +1356,8 @@ export async function pullReviewSubmit(ctx: Ctx): Promise<Response> {
13611356 : "That review comment could not be saved.",
13621357 });
13631358 }
1364 return flashTo(ctx, `${dest}#${fileHashAnchor(anchor.path)}`, {
1359 // It lands on the comment itself (`diff-view.ts`: `rc-<id>`), the address it now has.
1360 return flashTo(ctx, `${dest}#rc-${added.value.id}`, {
13651361 message: "Review comment added.",
13661362 });
13671363 }
src/web/pages/thread.ts +6 −1
@@ -64,7 +64,7 @@ import {
6464 type User,
6565 } from "../../core/users.ts";
6666 import type { Ctx } from "../../http/context.ts";
67 import { commentCard } from "../comments.ts";
67 import { commentCard, type Refs } from "../comments.ts";
6868 import { comeBack } from "../come_back.ts";
6969 import { backTo, field, kept, readForm, refusedHere } from "../form.ts";
7070 import { html, raw, when, type Html } from "../html.ts";
@@ -383,6 +383,7 @@ export function conversation(
383383 originAuthor: c.originAuthor,
384384 originKind: glyph,
385385 mark: marks.get(c.authorName),
386 refs: { base: repoBase(repo), ref: repo.defaultBranch },
386387 question: {
387388 state: c.question,
388389 ...(mayAsk(c.authorId) ? { action: `${repoBase(repo)}/issues/${issue.number}/comments/${c.id}/question` } : {}),
@@ -470,6 +471,7 @@ export function conversation(
470471 originAuthor: issue.originAuthor,
471472 originKind: glyph,
472473 originUrl: issue.originUrl,
474 refs: { base: repoBase(repo), ref: repo.defaultBranch },
473475 }),
474476 );
475477
@@ -495,6 +497,7 @@ export function threadComment(
495497 originKind?: Glyph;
496498 mark?: Mark | undefined;
497499 question?: { state: QuestionState | null; action?: string };
500 refs?: Refs;
498501 } = {},
499502 ): Html {
500503 // Only a question that is open or settled carries a control: an ordinary comment is not given a
@@ -524,6 +527,7 @@ export function threadComment(
524527 ...(origin.originKind === undefined
525528 ? {}
526529 : { originKind: origin.originKind }),
530 ...(origin.refs === undefined ? {} : { refs: origin.refs }),
527531 })}${flag}
528532 </div>`;
529533 }
@@ -561,6 +565,7 @@ export function threadFragment(ctx: Ctx, kind: "issue" | "pull"): Response {
561565 originAuthor: c.originAuthor,
562566 originKind: glyph,
563567 mark: marks.get(c.authorName),
568 refs: { base: repoBase(repo), ref: repo.defaultBranch },
564569 }),
565570 )}`;
566571 return new Response(inlineIcons(fragment.text), {
src/web/style/content.ts +3 −5
@@ -803,12 +803,10 @@ img.img-box, .prose img.img-box, .tell-picture.img-box { display: block; width:
803803 .dh .dc::before { content: ""; }
804804 .nonl { color: var(--del-fg); opacity: .7; padding-left: 8px; }
805805 .dl:target .dc, .dl[data-hl] .dc { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--attn) 55%, transparent); }
806 /* line-number doubles as the comment affordance */
807 .dn-comment {
808 color: var(--faint); display: block; position: relative;
809 transition: background-color 100ms var(--ease), color 100ms var(--ease);
810 }
806 .dn-comment { color: var(--faint); display: inline-block; }
811807 .dn-comment:hover { color: var(--accent-fg); background: var(--accent); border-radius: 4px; }
808 .dl-bar td { padding: 4px 8px; background: var(--muted); }

Design lint fails on this class: .dl-bar is not a named component. Name it in docs/design/areas/pinpoint.md (a code span is enough) and re-run bun scripts/design-lint.ts.

809 .dl-bar span { position: sticky; left: 8px; display: inline-flex; gap: 8px; font-family: var(--font); }
812810 /* review comments ride under their line, full width */
813811 .dc-review {
814812 padding: 8px 12px; background: var(--muted);
test/changelog-depth.test.ts +2 −1
@@ -79,7 +79,8 @@ test("from /changelog each tap reaches the next step: wave, change, pull, conver
7979 expect(at).toBeGreaterThan(0);
8080 const conversation = pullHtml.slice(at);
8181 expect(conversation).toContain("opened this");
82 expect(conversation).toMatch(/Closes #\d+/);
82 // "Closes #N" in the body links to the issue it closes (#16423).
83 expect(conversation).toMatch(/Closes <a href="\/alice\/shop\/issues\/\d+">#\d+<\/a>/);
8384 } finally {
8485 servers.stop();
8586 app.close();
test/diff-edge-cases.test.ts +2 −1
@@ -271,7 +271,8 @@ describe("diff engine + resource edge cases", () => {
271271
272272 test("multi-hunk file: second hunk's line numbers are exactly correct (no off-by-one)", async () => {
273273 // Invariant: each hunk's rows carry the line numbers from its own header.
274 const text = await (await page("multihunk")).text();
274 // A line's number is a link to the line (its own address); read the number it says.
275 const text = (await (await page("multihunk")).text()).replace(/<a class="dn-comment" href="#[^"]*" title="This line's address">(\d+)<\/a>/g, "$1");
275276 // Word-diff highlighting splits row text into per-token <span>s, so we
276277 // can't search for the literal phrase; instead find each token and
277278 // check the nearest preceding `<td class="dn">N</td>` line-number cell.
test/not-found-page.test.ts +4 −3
@@ -66,17 +66,18 @@ test("the API's 404 stays JSON", async () => {
6666 expect(typeof ((await res.json()) as { error: unknown }).error).toBe("string");
6767 });
6868
69 test("a signed-out visitor gets one sentence and exactly two links: home and search", async () => {
69 test("a signed-out visitor gets one sentence, a sign-in in case it is private, and two ways on: home and search", async () => {
7070 const res = await fetch(`${servers.url}/nope/gone`);
7171 const body = await res.text();
7272 expect(new TextEncoder().encode(body).length).toBeLessThan(3000);
7373 expect(res.status).toBe(404);
7474 const m = main(body);
7575 expect(m).toContain("That page is not here.");
76 expect([...m.matchAll(/<a\s[^>]*href="([^"]*)"/g)].map((x) => x[1])).toEqual(["/", "/search"]);
76 // The sign-in comes back to the visitor's own address, encoded in its link and nowhere else.
77 expect([...m.matchAll(/<a\s[^>]*href="([^"]*)"/g)].map((x) => x[1])).toEqual(["/signin?next=%2Fnope%2Fgone", "/", "/search"]);
7778 expect(m).not.toContain("<form");
7879 expect(m).not.toContain("Sign in");
79 expect(m).not.toContain("gone");
80 expect(m.replace("next=%2Fnope%2Fgone", "")).not.toContain("gone");
8081 expect(res.headers.get("x-content-type-options")).toBe("nosniff");
8182 expect(res.headers.get("content-security-policy")).toContain("default-src 'none'");
8283 });
test/not-found-way-on.test.ts +3 −1
@@ -55,7 +55,9 @@ test("a signed-out 404 is one sentence and two links, home and search, with the
5555 expect(m).toContain("That page is not here.");
5656 expect(m.match(/class="btn/g)?.length).toBe(2);
5757 expect(m).toContain('href="/search"');
58 expect(m).not.toContain("secret");
58 // The path is only in the sign-in's way back, encoded: the visitor's own address.
59 expect(m).toContain('href="/signin?next=%2Falice%2Fsecret"');
60 expect(m.replace("next=%2Falice%2Fsecret", "")).not.toContain("secret");
5961 expect(res.headers.get("x-request-id")).toMatch(/^[0-9a-f]{8}$/);
6062 for (const h of ["content-security-policy", "x-content-type-options", "referrer-policy"]) expect(res.headers.get(h)).toBeTruthy();
6163 });
test/row-numbers.test.ts +1 −1
@@ -170,7 +170,7 @@ describe("the list pages, rendered", () => {
170170 const html = await page("/alice/shop/issues/1");
171171 expect(html).toContain(`id="c-${comment.id}"`);
172172 expect(html).toMatch(
173 new RegExp(`<a class="permalink" href="#c-${comment.id}"`),
173 new RegExp(`<a class="permalink" id="cl-c-${comment.id}" href="#c-${comment.id}"`),
174174 );
175175 });
176176 });
test/web-ui.test.ts +4 −1
@@ -463,8 +463,11 @@ describe("web ui", () => {
463463 const hidden = await (await fetch(`${base}/kim/secret`)).text();
464464 const absent = await (await fetch(`${base}/kim/nothing`)).text();
465465
466 const main = (t: string) => t.slice(t.indexOf("<main"), t.indexOf("</main>")).replaceAll(/<code>[0-9a-f]{8}<\/code>/g, "<code>ID</code>");
466 // Each page's sign-in comes back to its own address (the only place a path is said), so the two
467 // are compared with that way back set aside.
468 const main = (t: string) => t.slice(t.indexOf("<main"), t.indexOf("</main>")).replaceAll(/<code>[0-9a-f]{8}<\/code>/g, "<code>ID</code>").replace(/\/signin\?next=%2Fkim%2F(?:secret|nothing)"/, '/signin?next=HERE"');
467469 expect(main(hidden)).toBe(main(absent));
470 expect(main(hidden)).toContain('/signin?next=HERE"');
468471 expect(main(absent)).toContain("That page is not here.");
469472 expect(main(absent)).not.toContain("secret");
470473 expect(main(absent)).not.toContain("nothing");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs