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

A pull and an issue open on what matters: a two-sentence summary and a filmstrip of the result first, the thread below and loaded as needed #13693

Merged opened this in answer to

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

Merged

mason/forge:mason/13654-a-pull-and-an-issue-open-on-what-matters → main 7 commits fork

  • Merged. mason/13654-a-pull-and-an-issue-open-on-what-matters was merged into main as 7fd75b3.

Review

Sign in to review this change.
20 files changed +521 −79
docs/features/thread-fold.md +13 −1
@@ -4,8 +4,20 @@ An issue's or a pull's conversation opens on what still needs someone: the openi
44
55 - What stays out of a fold: the newest comment and everything after it, and any entry marked `open` (`Entry.open`, `src/web/pages/thread.ts`). On a pull that is a request for changes that is its reviewer's newest verdict while the pull is open (`standingRequests`, `src/web/studio/change.ts`). A later plain comment from that reviewer does not withdraw it. An approval does. A standing entry splits the history into one fold before it and one after it. A run of fewer than two settled entries is not folded.
66 - Resolved line threads on Files already collapse to one line on their own (`src/web/diff-view.ts`). Issue comments have no thread or resolution state, so for an issue the newest comment is the visible question.
7 - Long threads: past the newest 50 comments the page still links `?all=1` ("Show N earlier items"). The fold only covers what is on the page.
7 - Long threads: past the newest 50 comments (8 on a pull, `threadWindow`) the page still links `?all=1` ("Show N earlier items"). The fold only covers what is on the page.
88 - Deep links: `#c-<id>` to a folded comment opens its fold and scrolls to it (`src/web/fold.ts`, appended to `shellJs`; it reads `location` only on a page that has a fold, and opens again on `hashchange`).
99 - Without JavaScript: `.tl-fold:has(:target)::details-content { content-visibility: visible; }` shows a fold's content while the linked comment is inside it. That needs `:has()` and `::details-content`: Chrome/Edge 131+, Safari 18.4+, Firefox 143+. In an older browser with script off, the link lands on the closed fold, and the comment is one click on its summary away. Nobody has checked this rule in a real browser yet. The test only checks that the rule ships.
1010 - Terminal and MCP: rendering only. The terminal and the API return whole threads, so they have nothing to fold.
1111 - Tests: `test/thread-window.test.ts`.
12
13 ## A pull opens on a summary and a filmstrip (#13654)
14
15 The top of a pull page, above any thread: the title, the one verdict, a summary beside a filmstrip, then the actions. Nothing there grows with the thread.
16
17 - **Summary.** The first sentences of the builder's description (markdown and headings stripped, 320 characters at most, `changedSentences` in `src/core/pulls.ts`), with a link to the notes. What was verified is the verdict line's, not said twice. Nothing is stored: it is read each time. `src/web/pages/pull-verdict.ts`.
18 - **Filmstrip.** The current head's pictures as one player (`src/web/pages/filmstrip.ts`): main's picture before the head's, stepping through pages, widths and themes, 24 frames at most, each with its caption. It opens still on the first frame; Previous, Next, Before ⇄ after and Play step it (Play pauses on hover or focus). The stage takes the first picture's ratio, so nothing is clipped and nothing shifts, on a phone too. A click opens the full-size picture. Without script the first frame shows. Older commits' pictures are not on the page: `?looks=all` opens the full block.
19 - **Thread.** A pull's page carries the opening post and the newest 8 comments (`PULL_THREAD_WINDOW`; an issue keeps 50); older ones are one link away (`?all=1`, `thread-fold.md`).
20 - **MCP.** `pull` returns `summary` first (what changed, then what the check said) and the newest 10 comments; older ones by `commentsNext`.
21 - **Terminal.** The pull screen's verdict row carries what changed after the verdict.
22 - Not done: loading older entries in place, search within a thread, per-round gists, the issue page's standing line (#13641).
23 - Tests: `test/filmstrip.test.ts`, `test/thread-window.test.ts`.
src/core/issues.ts +16 −2
@@ -770,6 +770,15 @@ export const EMBEDDED_COMMENTS = 50;
770770 /** How many timeline items a thread page shows before it folds the earlier ones behind `?all=1`. */
771771 export const THREAD_WINDOW = 50;
772772
773 /**
774 * A pull opens on its summary and pictures, so its thread shows only the newest 8 comments
775 * (#13654).
776 */
777 export const PULL_THREAD_WINDOW = 8;
778
779 /** The window of a thread of this kind. */
780 export const threadWindow = (kind: IssueKind): number => (kind === "pull" ? PULL_THREAD_WINDOW : THREAD_WINDOW);
781
773782 /**
774783 * Where a comment's own anchor lands on its thread page: `#c-<id>` when it
775784 * is among the newest comments the page shows, `?all=1#c-<id>` when it is
@@ -778,13 +787,18 @@ export const THREAD_WINDOW = 50;
778787 * THREAD_WINDOW comments, with the state lines between them riding along.
779788 * Both count the same thing, so the anchor always lands.
780789 */
781 export function commentAnchor(db: Database, issueId: string, commentId: string): string {
790 export function commentAnchor(
791 db: Database,
792 issueId: string,
793 commentId: string,
794 window: number = THREAD_WINDOW,
795 ): string {
782796 const after = db
783797 .query<{ n: number }, [string, string]>(
784798 "SELECT COUNT(*) AS n FROM comment WHERE issue_id = ?1 AND kind = 'comment' AND id > ?2",
785799 )
786800 .get(issueId, commentId)!.n;
787 return `${after >= THREAD_WINDOW ? "?all=1" : ""}#c-${commentId}`;
801 return `${after >= window ? "?all=1" : ""}#c-${commentId}`;
788802 }
789803
790804 export function listComments(
src/core/pulls.ts +78 −4
@@ -1135,7 +1135,9 @@ export interface Guarded {
11351135
11361136 export type MergePullError =
11371137 | MergeError
1138 /** A stranger's pull changes guarded paths: it does not land, whatever its review says (#9575). */
1138 /**
1139 * A stranger's pull changes guarded paths: it does not land, whatever its review says (#9575).
1140 */
11391141 | { readonly kind: "guarded"; readonly paths: readonly Guarded[] }
11401142 | "already_merged"
11411143 | "closed"
@@ -1422,10 +1424,16 @@ export const CLOSERS_REUSE_MS = process.env["NODE_ENV"] === "test" ? 0 : 300_000
14221424
14231425 const closersKept = new WeakMap<Database, Map<string, { at: number; sig: string; closers: Map<number, number> }>>();
14241426
1425 /** The merged-pull signature last read, and the write clock it was read at: nothing written since means the same signature. */
1427 /**
1428 * The merged-pull signature last read, and the write clock it was read at: nothing written since
1429 * means the same signature.
1430 */
14261431 const signatures = new WeakMap<Database, { clock: string; sig: string }>();
14271432
1428 /** How many pulls are merged and when the last was: one scan of `pull`, read again only after a write. */
1433 /**
1434 * How many pulls are merged and when the last was: one scan of `pull`, read again only after a
1435 * write.
1436 */
14291437 function mergedSignature(db: Database): string {
14301438 const clock = writeStamp(db);
14311439 const known = signatures.get(db);
@@ -1461,7 +1469,10 @@ export function mergedPullClosing(db: Database, repoId: string, number: number):
14611469 return pullNumber === undefined ? undefined : getPull(db, repoId, pullNumber);
14621470 }
14631471
1464 /** What `mergedPullClosing` was: the pull table asked per issue. Kept for the test that says the two agree. */
1472 /**
1473 * What `mergedPullClosing` was: the pull table asked per issue. Kept for the test that says the two
1474 * agree.
1475 */
14651476 export function mergedPullClosingScan(db: Database, repoId: string, number: number): Pull | undefined {
14661477 const rows = db
14671478 .query<{ number: number }, [string, string]>(
@@ -1554,3 +1565,66 @@ export function mergedPullsSince(
15541565 ids.map((id) => issues.get(id)).filter((i): i is Issue => i !== undefined),
15551566 );
15561567 }
1568
1569 // A pull's summary (#13654): two or three sentences saying what changed (the builder's note, the
1570 // pull's description) and what was verified (the check's state). Nothing is stored: it is read
1571 // from the two each time, so it is replaced when the head moves.
1572
1573 /** The most characters of the builder's note a summary keeps. */
1574 export const SUMMARY_CHARS = 320;
1575 const SENTENCES = 3;
1576
1577 /** Markdown reduced to the words a person reads. */
1578 function plain(body: string): string {
1579 return body
1580 .replace(/\r\n?/g, "\n")
1581 .replace(/```[\s\S]*?(```|$)/g, " ")
1582 .replace(/!\[[^\]]*\]\([^)]*\)/g, " ")
1583 .replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
1584 .replace(/^\s{0,3}#{1,6}[^\n]*(\n|$)/gm, "")
1585 .replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm, "")
1586 .replace(/^\s*>\s?/gm, "")
1587 .replace(/[*_`~]+/g, "")
1588 .replace(/<[^>]*>/g, " ")
1589 .replace(/\s+/g, " ")
1590 .trim();
1591 }
1592
1593 /** What the builder said changed: its first sentences, at most `SUMMARY_CHARS`. */
1594 export function changedSentences(body: string): string {
1595 const text = plain(body);
1596 if (text === "") return "";
1597 const parts = text.match(/.+?(?:[.!?]+(?=\s|$)|$)/g) ?? [text];
1598 let out = "";
1599 for (const part of parts.slice(0, SENTENCES)) {
1600 const next = `${out}${out === "" ? "" : " "}${part.trim()}`;
1601 if (next.length > SUMMARY_CHARS) {
1602 if (out === "") return `${next.slice(0, SUMMARY_CHARS).trimEnd()}…`;
1603 break;
1604 }
1605 out = next;
1606 }
1607 return out;
1608 }
1609
1610 /** What was verified, in a sentence, from the check's state. */
1611 export function verifiedSentence(checkState: string): string {
1612 switch (checkState) {
1613 case "ok":
1614 return "The check passed on this head.";
1615 case "failed":
1616 return "The check failed on this head.";
1617 case "cancelled":
1618 return "The check was stopped before it finished.";
1619 case "none":
1620 return "No check has run on this head yet.";
1621 default:
1622 return "The check is running on this head.";
1623 }
1624 }
1625
1626 /** The summary: what changed, then what was verified. Empty when the note says nothing. */
1627 export function pullSummary(body: string, checkState: string): string {
1628 const changed = changedSentences(body);
1629 return changed === "" ? verifiedSentence(checkState) : `${changed} ${verifiedSentence(checkState)}`;
1630 }
src/feed/items.ts +2 −2
@@ -13,7 +13,7 @@ import { listDecidedIn } from "../core/decisions.ts";
1313 import { audienceFilter } from "../core/event_audience.ts";
1414 import { listEventsVisibleTo, listTeamEventsFor, type ForgeEvent } from "../core/events.ts";
1515 import { getReview } from "../core/reviews.ts";
16 import { commentAnchor, getIssuesByIds, getIssuesByNumbers, numberKey, type Issue } from "../core/issues.ts";
16 import { commentAnchor, threadWindow, getIssuesByIds, getIssuesByNumbers, numberKey, type Issue } from "../core/issues.ts";
1717 import {
1818 listDetachedMirrors,
1919 listOrigins,
@@ -807,7 +807,7 @@ function fromEvent(
807807 const commentId = p["commentId"];
808808 const anchor =
809809 thread !== undefined && typeof commentId === "string"
810 ? commentAnchor(db, thread.id, commentId)
810 ? commentAnchor(db, thread.id, commentId, threadWindow(thread.kind))
811811 : "";
812812 return {
813813 ...common,
src/http/mcp/tools/pull.ts +10 −3
@@ -1,4 +1,5 @@
11 import { mayView } from "../../../core/sealed.ts";
2 import { pullSummary } from "../../../core/pulls.ts";
23 import { pullProposalOf } from "../../../core/proposal_token.ts";
34 import { resolveOid } from "../../../git/merge.ts";
45 import { getPull, pullDir, pullMergeState } from "../../../core/pulls.ts";
@@ -8,16 +9,21 @@ import { checkSummary } from "../../../core/runs.ts";
89 import { nextOfPull } from "../../../flow/next_actor.ts";
910 import { stepOfPull } from "../../../flow/path.ts";
1011 import { appView } from "../../../actions/apps.ts";
11 import { countThread, EMBEDDED_COMMENTS, listComments } from "../../../core/issues.ts";
12 import { countThread, listComments } from "../../../core/issues.ts";
1213 import { landingLine } from "../../../flow/landing_line.ts";
1314 import { pullLooks } from "../../../looks/readable.ts";
1415 import { isCrew } from "../../../core/agents.ts";
1516 import { markReaders } from "../../../crew/direct.ts";
1617 import { good, bad, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts";
1718
19 /**
20 * The comments `pull` carries by default: the summary comes first, older ones by `commentsNext`.
21 */
22 const PULL_COMMENTS = 10;
23
1824 export const tool: Tool = {
1925 name: "pull",
20 doc: "`{ repo, number }`: a pull's title, state, head and base, and for an open pull whether it merges into the base's current head (`mergeable`) and the paths that stop it (`conflicts`), and `next: { who, why }` (open only; who acts next: builder, reviewer, queue or person), `step: { step, why, done }` (check, review, land or live; null once closed unlanded), and `comments` (the newest 50: author, body, at, `untrusted` on an outsider's), `commentsTotal` and `commentsNext` (older: `GET …/issues/:number/comments?cursor=`), and `looks` (newest first: `{ id, width, says, by, commit, url, at }`, the same as `GET …/pulls/:number/looks`), and `eta: { minutes, says }` (approved open pull only, else null), and `check: { state, baseOid }`: the latest check's state and the base tip it was merged with (empty when it merged nothing), `checkStale` (the base has moved since that check) and `checkedAgainst` (that base tip, or null; the same as `GET …/pulls/:number`); `mergeable` and `conflicts` are the same fields as `GET …/pulls/:number`, `check` is `state` and `run.baseOid` from `GET …/pulls/:number/checks`; draws the `ui://forge/pull` card: `#N title`, state with check and conflicts while open, `head → base` linked to the pull, and the preview link when the pull has an environment",
26 doc: "`{ repo, number }`: a pull's title, state, head and base, `summary` (two or three sentences: what changed, what was verified), and for an open pull whether it merges into the base's current head (`mergeable`) and the paths that stop it (`conflicts`), and `next: { who, why }` (open only; who acts next: builder, reviewer, queue or person), `step: { step, why, done }` (check, review, land or live; null once closed unlanded), and `comments` (the newest 10: author, body, at, `untrusted` on an outsider's), `commentsTotal` and `commentsNext` (older: `GET …/issues/:number/comments?cursor=`), and `looks` (newest first: `{ id, width, says, by, commit, url, at }`, the same as `GET …/pulls/:number/looks`), and `eta: { minutes, says }` (approved open pull only, else null), and `check: { state, baseOid }`: the latest check's state and the base tip it was merged with (empty when it merged nothing), `checkStale` (the base has moved since that check) and `checkedAgainst` (that base tip, or null; the same as `GET …/pulls/:number`); `mergeable` and `conflicts` are the same fields as `GET …/pulls/:number`, `check` is `state` and `run.baseOid` from `GET …/pulls/:number/checks`; draws the `ui://forge/pull` card: `#N title`, state with check and conflicts while open, `head → base` linked to the pull, and the preview link when the pull has an environment",
2127 description:
2228 "A pull: title, state, head, base; open: `mergeable`, `conflicts`, `checkStale`, `checkedAgainst`, `check`.",
2329 inputSchema: {
@@ -49,10 +55,11 @@ export const tool: Tool = {
4955 const db = ctx.app.db;
5056 // Marked only for a crew agent, as the issue and the API do.
5157 const marking = user.kind === "agent" && isCrew(db, repo.id, user.id);
52 const rows = listComments(db, pull.id, { newest: true, limit: EMBEDDED_COMMENTS });
58 const rows = listComments(db, pull.id, { newest: true, limit: PULL_COMMENTS });
5359 const comments = marking ? markReaders(db, repo, rows) : rows;
5460 const total = countThread(db, pull.id);
5561 const answer = good({
62 summary: pullSummary(pull.body, check.state),
5663 comments: comments.map((c) => ({
5764 author: c.authorName,
5865 body: c.body,
src/tui/screens/pull.ts +14 −1
@@ -84,6 +84,7 @@ import { canVerdict } from "../../core/verdict.ts";
8484 import { reviewWords } from "../../actions/review_words.ts";
8585 import { verdictOf, type Verdict } from "../../web/pages/pull-verdict.ts";
8686 import { wallOf, wallPlain, type Wall } from "../../contract/policy.ts";
87 import { changedSentences } from "../../core/pulls.ts";
8788 import { checkSummary, type CheckSummary } from "../../core/runs.ts";
8889 import { err, ok } from "../../kernel/result.ts";
8990 import { getUsersByIds } from "../../core/users.ts";
@@ -1290,7 +1291,19 @@ export function pullScreen(
12901291 // Merged and closed pulls are told by the head line and the merge box.
12911292 if (verdictNow !== null && head!.h > 2 && detail?.issue.state === "open" && facts?.mergedAt === null) {
12921293 const at = dot(s, head!.x, head!.y + 2, c, verdictNow.tone === undefined ? {} : { tone: verdictNow.tone as Tone });
1293 s.text(at, head!.y + 2, truncate(` ${verdictNow.words}`, Math.max(0, edge - at)), style(c.fg, c.bg, BOLD), edge);
1294 const said = ` ${verdictNow.words}`;
1295 s.text(at, head!.y + 2, truncate(said, Math.max(0, edge - at)), style(c.fg, c.bg, BOLD), edge);
1296 // What changed beside the verdict, as on the page (#13654).
1297 const afterVerdict = at + said.length;
1298 const changed = changedSentences(detail.body);
1299 if (afterVerdict < edge && changed !== "")
1300 s.text(
1301 afterVerdict,
1302 head!.y + 2,
1303 truncate(` · ${changed}`, Math.max(0, edge - afterVerdict)),
1304 style(c.mutedFg, c.bg),
1305 edge,
1306 );
12941307 }
12951308 if (strangerLine !== "" && nextRow!.h > 0)
12961309 s.text(nextRow!.x, nextRow!.y, truncate(`next: ${strangerLine}`, nextRow!.w), style(c.mutedFg, c.bg), nextRow!.x + nextRow!.w);
src/web/pages/filmstrip.ts added +168
@@ -0,0 +1,168 @@
1 /**
2 * The pull's pictures as one compact player (#13654): main's page beside the head's, stepping
3 * through pages, widths and themes, one frame in view. Drawn from the looks the forge already
4 * stores: no video, no GIF. Older commits' pictures are not on the page; `?looks=all` opens the
5 * full block (`lookCard`). `frames` is plain data in, plain data out; `filmstrip` draws it.
6 */
7
8 import { previewEnv } from "../../apps/data.ts";
9 import type { AppRecord } from "../../core/apps.ts";
10 import {
11 DEFAULT_PAGE,
12 isAttached,
13 LOOK_SIZES,
14 looksForEnv,
15 lookUrl,
16 type Look,
17 type LookKind,
18 type LookTheme,
19 } from "../../core/looks.ts";
20 import type { Pull } from "../../core/pulls.ts";
21 import { canSeeOwnerFacts, type Repo } from "../../core/repos.ts";
22 import type { Ctx } from "../../http/context.ts";
23 import { repoBase } from "../chrome.ts";
24 import { html, type Html } from "../html.ts";
25 import { mayFetchLook, pictured } from "./looks.ts";
26
27 /** The most frames one player holds; the rest are one link away. */
28 export const MAX_FRAMES = 24;
29 const WIDTHS: readonly LookKind[] = ["phone", "narrow", "desktop"];
30 const THEMES: readonly LookTheme[] = ["light", "dark"];
31 const WORDS: Record<string, string> = { phone: "phone", narrow: "narrow phone", desktop: "desktop" };
32
33 export interface Frame {
34 readonly side: "main" | "this pull";
35 readonly look: Look;
36 readonly page: string;
37 readonly kind: LookKind;
38 readonly theme: LookTheme;
39 }
40
41 /** A frame's caption: which side, page, width and theme. */
42 export const caption = (f: Frame): string =>
43 `${f.side} · ${f.page} · ${WORDS[f.kind] ?? f.kind} · ${f.theme}`;
44
45 /**
46 * The head's frames in reading order: each page, each width, light then dark, main's picture
47 * before the head's where main has one. Only the newest commit's picture of each slot.
48 */
49 export function frames(
50 head: readonly Look[],
51 main: readonly Look[],
52 ): { readonly shown: Frame[]; readonly total: number } {
53 const taken = head.filter((l) => !isAttached(l) && l.error === null && l.kind !== "thumb");
54 const pages = [...new Set(taken.map((l) => l.page))].sort((a, b) =>
55 a === DEFAULT_PAGE ? -1 : b === DEFAULT_PAGE ? 1 : a.localeCompare(b),
56 );
57 const out: Frame[] = [];
58 for (const page of pages) {
59 const mine = taken.filter((l) => l.page === page);
60 const lightShown = pictured(mine.filter((l) => l.theme === "light"), "phone") ??
61 pictured(mine.filter((l) => l.theme === "light"), "desktop");
62 for (const theme of THEMES) {
63 // A dark picture is only of the commit the light ones are of.
64 const ofTheme = mine.filter(
65 (l) => l.theme === theme && (theme === "light" || lightShown === undefined || l.commitOid === lightShown.commitOid),
66 );
67 for (const kind of WIDTHS) {
68 const after = pictured(ofTheme, kind);
69 if (after === undefined) continue;
70 const before = pictured(
71 main.filter((l) => l.page === page && l.theme === theme && !isAttached(l)),
72 kind,
73 );
74 if (before !== undefined) out.push({ side: "main", look: before, page, kind, theme });
75 out.push({ side: "this pull", look: after, page, kind, theme });
76 }
77 }
78 }
79 return { shown: out.slice(0, MAX_FRAMES), total: out.length };
80 }
81
82 /** The player, or nothing when the viewer may see no picture. */
83 export function filmstrip(ctx: Ctx, repo: Repo, record: AppRecord, pull: Pull): Html {
84 const db = ctx.app.db;
85 const writer = canSeeOwnerFacts(db, repo, ctx.auth.user);
86 const mayHave = (l: Look): boolean => writer || mayFetchLook(ctx, repo, record, l);
87 const head = looksForEnv(db, record.id, previewEnv(pull.number), "any").filter(mayHave);
88 const main = looksForEnv(db, record.id, "production", "any").filter(mayHave);
89 const { shown, total } = frames(head, main);
90 if (shown.length === 0) return html``;
91 const base = repoBase(repo);
92 const rest = total - shown.length;
93 return html`<section class="stack stack-tight" id="look" data-filmstrip aria-label="Before and after pictures">
94 <div data-film-stage data-kind="${shown[0]!.kind}">
95 ${shown.map((f, i) => {
96 const url = lookUrl(base, f.look);
97 return html`<figure data-frame data-side="${f.side}"${i === 0 ? html`` : html` hidden`}>
98 <a class="look" href="${url}">
99 <img src="${url}" width="${LOOK_SIZES[f.kind].width}" height="${LOOK_SIZES[f.kind].height}" alt="${repo.name} ${caption(f)}" loading="${i === 0 ? "eager" : "lazy"}" decoding="async" />
100 </a>
101 <figcaption class="muted small">${caption(f)}</figcaption>
102 </figure>`;
103 })}
104 </div>
105 <p class="muted small" data-film-controls hidden>
106 <button type="button" class="btn" data-variant="link" data-size="sm" data-film="prev">Previous</button>
107 <button type="button" class="btn" data-variant="link" data-size="sm" data-film="flip">Before ⇄ after</button>
108 <button type="button" class="btn" data-variant="link" data-size="sm" data-film="next">Next</button>
109 <button type="button" class="btn" data-variant="link" data-size="sm" data-film="play" aria-pressed="false">Play</button>
110 <span data-film-count>1 of ${String(shown.length)}</span>
111 </p>
112 <p class="muted small">
113 <a href="${ctx.url.pathname}?looks=all#look">${rest > 0 ? `All ${String(total)} pictures` : "Every picture, full size"}</a>
114 </p>
115 </section>`;
116 }
117
118 /**
119 * The player's script: the page opens still on the first frame; Previous, Next and Before ⇄ after
120 * step by hand, and Play steps on a timer that hover or focus pauses.
121 */
122 export const filmstripJs = /* js */ `
123 (function () {
124 var root = document.querySelector('[data-filmstrip]');
125 if (!root) return;
126 var frames = root.querySelectorAll('[data-frame]');
127 var controls = root.querySelector('[data-film-controls]');
128 var count = root.querySelector('[data-film-count]');
129 var playBtn = root.querySelector('[data-film="play"]');
130 if (frames.length < 2 || !controls) return;
131 controls.hidden = false;
132 var at = 0, timer = 0, paused = false, wanted = false;
133 function show(n) {
134 at = (n + frames.length) % frames.length;
135 for (var i = 0; i < frames.length; i++) frames[i].hidden = i !== at;
136 count.textContent = (at + 1) + ' of ' + frames.length;
137 }
138 function tick() { if (!paused) show(at + 1); }
139 function play(on) {
140 wanted = on;
141 clearTimeout(timer);
142 if (on) timer = setTimeout(function again() { tick(); timer = setTimeout(again, 2200); }, 2200);
143 playBtn.setAttribute('aria-pressed', on ? 'true' : 'false');
144 playBtn.textContent = on ? 'Pause' : 'Play';
145 }
146 root.addEventListener('click', function (e) {
147 var b = e.target.closest ? e.target.closest('[data-film]') : null;
148 if (!b) return;
149 var what = b.getAttribute('data-film');
150 if (what === 'next') show(at + 1);
151 else if (what === 'prev') show(at - 1);
152 else if (what === 'play') play(!wanted);
153 else if (what === 'flip') {
154 // The same page, width and theme from the other side: the neighbour that shares the caption's tail.
155 var tail = function (i) { return frames[i].querySelector('figcaption').textContent.split(' · ').slice(1).join(' · '); };
156 var t = tail(at);
157 for (var d = 1; d < frames.length; d++) {
158 var j = (at + d) % frames.length;
159 if (tail(j) === t) { show(j); return; }
160 }
161 }
162 });
163 root.addEventListener('mouseenter', function () { paused = true; });
164 root.addEventListener('mouseleave', function () { paused = false; });
165 root.addEventListener('focusin', function () { paused = true; });
166 root.addEventListener('focusout', function () { paused = false; });
167 })();
168 `;
src/web/pages/pull-verdict.ts +14 −21
@@ -7,6 +7,7 @@
77 * `mergeBox` and `mergePull` ask, in the same order, so the line and the
88 * button never disagree.
99 */
10 import { changedSentences } from "../../core/pulls.ts";
1011 import type { Diff } from "../../git/diff.ts";
1112 import { html, when, type Html } from "../html.ts";
1213 import { btn, dot, type Tone } from "../ui.ts";
@@ -92,29 +93,21 @@ export function verdictLine(verdict: Verdict, show: { readonly action?: boolean
9293 </div>`;
9394 }
9495
95 /** The first paragraph of a description, as text. */
96 export function firstParagraph(body: string): string {
97 for (const part of body.replace(/\r\n?/g, "\n").split(/\n\s*\n/)) {
98 const text = part.trim();
99 if (text !== "") return text.length > 400 ? `${text.slice(0, 400).trimEnd()}…` : text;
100 }
101 return "";
102 }
103
10496 /**
105 * The change itself, once: the description's first paragraph and the total.
106 * The file list is the diff's own rows, one click away at `filesHref`.
97 * The change itself, once: the first sentences of the description (`changedSentences`; the verdict
98 * line above already says what was verified), a link to the notes, and the total. The file list is
99 * the diff's own rows, one click away at `filesHref`.
107100 */
108 export function changeSummary(body: string, diff: Diff | null, filesHref: string): Html {
109 const lead = firstParagraph(body);
101 export function changeSummary(body: string, diff: Diff | null, filesHref: string, notesHref: string): Html {
102 const lead = changedSentences(body);
110103 return html`<section class="mt" data-change>
111 ${when(lead, (text) => html`<p>${text}</p>`)}
112 ${when(
113 diff,
114 (d) => html`<p class="muted small">
115 <a href="${filesHref}">${d.files.length} file${d.files.length === 1 ? "" : "s"}</a> ·
116 <span class="mono">+${d.additions} −${d.deletions}</span>
117 </p>`,
118 )}
104 ${when(lead, (text) => html`<p data-summary>${text}</p>`)}
105 <p class="muted small">
106 <a href="${notesHref}">Notes</a>${when(
107 diff,
108 (d) => html` · <a href="${filesHref}">${d.files.length} file${d.files.length === 1 ? "" : "s"}</a> ·
109 <span class="mono">+${d.additions} −${d.deletions}</span>`,
110 )}
111 </p>
119112 </section>`;
120113 }
src/web/pages/thread.ts +3 −3
@@ -45,7 +45,7 @@ import {
4545 getIssue,
4646 labelsFor,
4747 listComments,
48 THREAD_WINDOW,
48 threadWindow,
4949 MAX_BODY,
5050 MAX_TITLE,
5151 } from "../../core/issues.ts";
@@ -409,7 +409,7 @@ export function conversation(
409409 entries.push(...forgeEntries(ctx, repo, issue));
410410 entries.push(...(options.extra ?? []));
411411 entries.sort((a, b) => (a.at < b.at ? -1 : a.at > b.at ? 1 : 0));
412 // The opening post and the newest THREAD_WINDOW comments with the state
412 // The opening post and the newest `threadWindow` comments with the state
413413 // changes between them; everything before the oldest of those waits behind
414414 // `?all=1` (a plain link, so it works without JavaScript). The cut is on
415415 // comments so that `commentAnchor` counts the very same thing and every
@@ -419,7 +419,7 @@ export function conversation(
419419 if (!everything) {
420420 let seen = 0;
421421 for (let i = entries.length - 1; i >= 0; i--) {
422 if (entries[i]!.comment && ++seen === THREAD_WINDOW) {
422 if (entries[i]!.comment && ++seen === threadWindow(issue.kind)) {
423423 hidden = i;
424424 break;
425425 }
src/web/studio/change.ts +12 −4
@@ -65,6 +65,7 @@ import {
6565 type Tone,
6666 } from "../ui.ts";
6767 import { previewBlock } from "../pages/apps.ts";
68 import { filmstrip, filmstripJs } from "../pages/filmstrip.ts";
6869 import { lookCard } from "../pages/looks.ts";
6970 import { approveHereCard, keptChange, pullChecksLineFor, reachLine, teamsCard, verdictFacts } from "../pages/pull.ts";
7071 import { landAsIs } from "./land_as_is.ts";
@@ -742,9 +743,13 @@ async function changeConversation(
742743 ${teamsCard(teamVerdicts(db, { ...pull, headOid }))}
743744 ${when(wall, (w) => wallCard(w, writer ? thread : undefined))}`,
744745 );
746 // The head's pictures as one player beside the summary; the full block, every picture at full
747 // size, only when asked for (`?looks=all`).
748 const showAllLooks = ctx.url.searchParams.get("looks") === "all";
745749 const look = tick(spent, "looks", () =>
746 when(record, (r) => lookCard(ctx, repo, r, pull, pull.headOid)),
750 showAllLooks ? when(record, (r) => lookCard(ctx, repo, r, pull, pull.headOid)) : html``,
747751 );
752 const film = tick(spent, "looks", () => when(record, (r) => filmstrip(ctx, repo, r, pull)));
748753 const reviewsAt = performance.now();
749754 const reviews = listReviews(db, pull.id);
750755 const reviewerMarks = marksByName(
@@ -789,7 +794,10 @@ async function changeConversation(
789794 const body = html`${pageHead.top}
790795 ${when(wave, (w) => crumbs([{ label: `Wave ${w.version}`, href: w.href }, { label: "This pull" }]))}
791796 ${verdictLine(verdict, { action: false })}
792 ${changeSummary(pull.body, totals, files)}
797 <div class="split" data-top>
798 <div>${changeSummary(pull.body, totals, files, "#conversation")}</div>
799 <aside>${film}</aside>
800 </div>
793801 ${when(siblings.length > 0, () =>
794802 html`<p class="muted small variant-link">
795803 <a href="${base}/variants/${pull.variantGroup ?? ""}"
@@ -803,7 +811,7 @@ async function changeConversation(
803811 ? landAsIs(ctx, repo, pull)
804812 : null}
805813 ${when(visionPreview, (v) => visionPreviewCard(v))}
806 ${look}
814 ${when(showAllLooks, () => look)}
807815 <div class="split">
808816 <div>
809817 ${talk.node}
@@ -835,7 +843,7 @@ async function changeConversation(
835843 crumbs: pageHead.crumbs,
836844 palette: pageHead.palette,
837845 body,
838 scriptJs: `${liveClientJs}\n${liveRegionsJs}`,
846 scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${filmstripJs}`,
839847 });
840848 // Each phase is named once, from what the laps added up to; render is what
841849 // is left of the page's own time, so the phases never exceed `app`.
src/web/style/components.ts +8
@@ -468,6 +468,14 @@ a.sha:hover { color: var(--accent); }
468468 .looks > [data-slot="desktop"] { flex: 1 1 320px; min-width: 0; max-width: 1280px; }
469469 .looks > figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
470470 .looks[data-compare] { gap: 20px; }
471 /* The stage takes the first picture's ratio (its kind's size), so the page never shifts; a picture of another ratio sits whole inside it. */
472 [data-filmstrip] [data-film-stage] { display: flex; width: 100%; aspect-ratio: 1280 / 800; }
473 [data-film-stage][data-kind="phone"] { aspect-ratio: 390 / 844; }
474 [data-film-stage][data-kind="narrow"] { aspect-ratio: 360 / 780; }
475 [data-filmstrip] figure[data-frame] { margin: 0; display: flex; flex-direction: column; gap: 6px; width: 100%; min-height: 0; }
476 [data-frame][hidden] { display: none; }
477 [data-frame] .look { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; }
478 [data-frame] .look img { width: 100%; height: 100%; object-fit: contain; object-position: top; }
471479 .looks[data-compare] > * { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
472480 @media (max-width: 640px) {
473481 .looks:not([data-compare]):not([data-look] .looks) { flex-direction: column; }
test/attach-look.test.ts +1 −1
@@ -90,7 +90,7 @@ describe("attaching a look to a pull", () => {
9090
9191 const page = async (cookie: string) =>
9292 (
93 await fetch(`${base}/alice/garden/pulls/${pull.number}`, {
93 await fetch(`${base}/alice/garden/pulls/${pull.number}?looks=all`, {
9494 headers: cookie === "" ? {} : { cookie },
9595 })
9696 ).text();
test/looks-language.test.ts +104 −4
@@ -1,4 +1,7 @@
1 /** The look under a pull's checks speaks the home page's language: a block under an h2, not a card; pictures still need read access. */
1 /**
2 * The look under a pull's checks speaks the home page's language: a block under an h2, not a card;
3 * pictures still need read access.
4 */
25 import { afterAll, beforeAll, expect, test } from "bun:test";
36 import { mkdtemp, rm } from "node:fs/promises";
47 import { tmpdir } from "node:os";
@@ -8,7 +11,10 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts";
811 import { createApp, type App } from "../src/app.ts";
912 import { previewEnv } from "../src/apps/data.ts";
1013 import { createApp as insertApp } from "../src/core/apps.ts";
11 import { recordLook } from "../src/core/looks.ts";
14 import { LOOK_SIZES, recordLook, type Look } from "../src/core/looks.ts";
15 import { changedSentences, pullSummary, SUMMARY_CHARS } from "../src/core/pulls.ts";
16 import { components as componentsCss } from "../src/web/style/components.ts";
17 import { caption, filmstripJs, frames, MAX_FRAMES } from "../src/web/pages/filmstrip.ts";
1218 import { createUser } from "../src/core/users.ts";
1319 import { serve, type Servers } from "../src/http/server.ts";
1420 import { quietLogs } from "./helpers/globals.ts";
@@ -57,7 +63,7 @@ afterAll(async () => {
5763 const main = (page: string) => page.slice(page.indexOf("<main"), page.indexOf("</main>"));
5864
5965 test("the look on a pull is a block under an h2, no card, pictures intact", async () => {
60 const m = main(await (await fetch(`${servers.url}/alice/garden/pulls/${publicPull}`)).text());
66 const m = main(await (await fetch(`${servers.url}/alice/garden/pulls/${publicPull}?looks=all`)).text());
6167 expect(m).toMatch(/<section class="settings-block" id="look"[^>]*>\s*<h2>Look<\/h2>/);
6268 const look = m.slice(m.indexOf('id="look"'));
6369 expect(look).toContain(`/${HEAD}/phone.png`);
@@ -68,6 +74,100 @@ test("the look on a pull is a block under an h2, no card, pictures intact", asyn
6874 test("a private repository's picture is a 404 to an outsider, and its pull page too", async () => {
6975 const url = `${servers.url}/alice/vault/looks/${previewEnv(privatePull)}/${HEAD}/phone.png`;
7076 expect((await fetch(url)).status).toBe(404);
71 const page = await fetch(`${servers.url}/alice/vault/pulls/${privatePull}`);
77 const page = await fetch(`${servers.url}/alice/vault/pulls/${privatePull}?looks=all`);
7278 expect(page.status).toBe(404);
7379 });
80
81 let n = 0;
82 const look = (page: string, kind: Look["kind"], theme: Look["theme"], commit = "c1"): Look =>
83 ({ id: `l${n++}`, page, kind, theme, commitOid: commit, error: null, attachedBy: null, note: null, createdAt: "2026-11-15T00:00:00Z", path: "p.png" }) as unknown as Look;
84
85 test("main's picture comes before the head's, each with a caption, light then dark", () => {
86 const head = [look("/", "phone", "light"), look("/", "phone", "dark"), look("/", "desktop", "light")];
87 const main = [look("/", "phone", "light", "m1")];
88 const { shown } = frames(head, main);
89 expect(shown.map(caption)).toEqual([
90 "main · / · phone · light",
91 "this pull · / · phone · light",
92 "this pull · / · desktop · light",
93 "this pull · / · phone · dark",
94 ]);
95 });
96
97 test("a long run of pictures is cut to the player's size and the total is kept", () => {
98 const head: Look[] = [];
99 for (let p = 0; p < 40; p++) head.push(look(`/p${p}`, "phone", "light"));
100 const { shown, total } = frames(head, []);
101 expect(shown.length).toBe(MAX_FRAMES);
102 expect(total).toBe(40);
103 });
104
105 test("a summary is the first three sentences, markdown stripped, then what was verified", () => {
106 const body = "# Title\n\nMoves **retry** into `retry.ts`. Deletes the old copy! Adds a test.\n\n- a fourth thing. Not shown.\n![pic](http://x/y.png)";
107 expect(changedSentences(body)).toBe("Moves retry into retry.ts. Deletes the old copy! Adds a test.");
108 expect(pullSummary("Fixes it.", "ok")).toBe("Fixes it. The check passed on this head.");
109 expect(pullSummary("Fixes it.", "failed")).toBe("Fixes it. The check failed on this head.");
110 });
111
112 test("a long note is cut, an empty one still says what was verified", () => {
113 expect(changedSentences("word ".repeat(200)).length).toBeLessThanOrEqual(SUMMARY_CHARS + 1);
114 expect(pullSummary("", "none")).toBe("No check has run on this head yet.");
115 expect(pullSummary("```\ncode only\n```", "running")).toBe("The check is running on this head.");
116 });
117
118 test("the stage takes its height from the picture's ratio, never a fixed height", () => {
119 for (const kind of ["phone", "narrow", "desktop"] as const) {
120 const { width, height } = LOOK_SIZES[kind];
121 expect(componentsCss).toContain(`aspect-ratio: ${width} / ${height}`);
122 }
123 expect(componentsCss).not.toMatch(/data-film-stage\][^{]*\{[^}]*\bheight: \d+px/);
124 });
125
126 /** A page of three frames and the controls, just enough DOM for the player's script. */
127 function player() {
128 const listeners: Record<string, (e: unknown) => void> = {};
129 const frame = (caption: string) => {
130 const cap = { textContent: caption };
131 return { hidden: true, querySelector: () => cap };
132 };
133 const frames = [
134 frame("main · / · phone · light"),
135 frame("this pull · / · phone · light"),
136 frame("this pull · / · desktop · light"),
137 ];
138 frames[0]!.hidden = false;
139 const attrs: Record<string, string> = {};
140 const play = { textContent: "Play", setAttribute: (k: string, v: string) => (attrs[k] = v) };
141 const count = { textContent: "" };
142 const controls = { hidden: true };
143 const root = {
144 querySelectorAll: () => frames,
145 querySelector: (q: string) =>
146 q.includes("controls") ? controls : q.includes("count") ? count : q.includes('"play"') ? play : null,
147 addEventListener: (name: string, fn: (e: unknown) => void) => (listeners[name] = fn),
148 };
149 const timers: (() => void)[] = [];
150 const run = new Function("document", "window", "setTimeout", "clearTimeout", filmstripJs);
151 run({ querySelector: () => root }, {}, (fn: () => void) => timers.push(fn), () => {});
152 const press = (what: string) =>
153 listeners["click"]!({ target: { closest: () => ({ getAttribute: () => what }) } });
154 return { frames, count, play, controls, timers, press, shown: () => frames.findIndex((f) => !f.hidden) };
155 }
156
157 test("the player opens still, steps by hand, flips between main and the pull, and plays only when asked", () => {
158 const p = player();
159 expect(p.controls.hidden).toBe(false);
160 expect(p.timers.length).toBe(0); // no autoplay
161 expect(p.shown()).toBe(0);
162 p.press("next");
163 expect(p.shown()).toBe(1);
164 expect(p.count.textContent).toBe("2 of 3");
165 p.press("prev");
166 p.press("flip"); // main's phone picture → the pull's, the same page, width and theme
167 expect(p.shown()).toBe(1);
168 p.press("flip");
169 expect(p.shown()).toBe(0);
170 p.press("play");
171 expect(p.timers.length).toBe(1);
172 expect(p.play.textContent).toBe("Pause");
173 });
test/looks.test.ts +24 −11
@@ -574,7 +574,7 @@ describe("the look", () => {
574574 const base = `/alice/hello`;
575575 const env = `pull-${pull.number}`;
576576 const page = await (
577 await web(`${base}/pulls/${pull.number}`, aliceCookie)
577 await web(`${base}/pulls/${pull.number}?looks=all`, aliceCookie)
578578 ).text();
579579 expect(page).toContain("<h2>Look</h2>");
580580 expect(page).toContain(`src="${base}/looks/${env}/${second}/phone.png?v=`);
@@ -718,7 +718,7 @@ describe("the look", () => {
718718 // The last good pictures stay, and the page says the head has moved
719719 // and why there is no picture of it.
720720 const page = await (
721 await web(`/alice/hello/pulls/${pull.number}`, aliceCookie)
721 await web(`/alice/hello/pulls/${pull.number}?looks=all`, aliceCookie)
722722 ).text();
723723 expect(page).toContain(`/looks/${env}/${second}/phone.png`);
724724 expect(page.replace(/\s+/g, " ")).toContain("the head has moved since");
@@ -737,7 +737,7 @@ describe("the look", () => {
737737 const rows = await pictured(env2, unpictured.commitOid);
738738 expect(rows.every((l) => l.error === "the browser fell over")).toBe(true);
739739 const none = await (
740 await web(`/alice/hello/pulls/${unpictured.pull.number}`, aliceCookie)
740 await web(`/alice/hello/pulls/${unpictured.pull.number}?looks=all`, aliceCookie)
741741 ).text();
742742 expect(none).toContain("<h2>Look</h2>");
743743 expect(none).toContain("No picture of");
@@ -844,7 +844,7 @@ describe("the look", () => {
844844 expect(looksForEnv(app.db, record.id, env)).toHaveLength(0);
845845 expect(existsSync(join(dataDir, "looks", record.id, env))).toBe(false);
846846 const page = await (
847 await web(`/alice/hello/pulls/${unpictured.pull.number}`, aliceCookie)
847 await web(`/alice/hello/pulls/${unpictured.pull.number}?looks=all`, aliceCookie)
848848 ).text();
849849 expect(page).not.toContain("<h2>Look</h2>");
850850 });
@@ -1006,7 +1006,7 @@ describe("the look", () => {
10061006 expect(boardCall).toBeDefined();
10071007
10081008 const page = await (
1009 await web(`/alice/hello/pulls/${opened.value.number}`, aliceCookie)
1009 await web(`/alice/hello/pulls/${opened.value.number}?looks=all`, aliceCookie)
10101010 ).text();
10111011 expect(page).toContain(`<p class="muted small">/</p>`);
10121012 expect(page).toContain(`<p class="muted small">/board</p>`);
@@ -1057,7 +1057,7 @@ describe("the look", () => {
10571057 expect(lookUrl("/alice/hello", darkPhone)).toContain("/phone-dark.png?v=");
10581058 // And it is on the pull page, as a link that works without script.
10591059 const darkPage = await (
1060 await web(`/alice/hello/pulls/${opened.value.number}`, aliceCookie)
1060 await web(`/alice/hello/pulls/${opened.value.number}?looks=all`, aliceCookie)
10611061 ).text();
10621062 expect(darkPage).toContain(
10631063 `<a class="look" data-slot="phone" href="/alice/hello/looks/${env}/${commitOid}/phone-dark.png?v=`,
@@ -1083,7 +1083,7 @@ describe("the look", () => {
10831083 path: `looks/${record.id}/${env}/${stale}-phone-dark.png`,
10841084 });
10851085 const after = await (
1086 await web(`/alice/hello/pulls/${opened.value.number}`, aliceCookie)
1086 await web(`/alice/hello/pulls/${opened.value.number}?looks=all`, aliceCookie)
10871087 ).text();
10881088 expect(after).not.toContain(stale);
10891089 expect(after).toContain(`${commitOid}/phone-dark.png?v=`);
@@ -1382,10 +1382,18 @@ describe("the look", () => {
13821382 expect((await web(at("desktop"), cookie)).status).toBe(200);
13831383 }
13841384 const pullPage = await (
1385 await web(`/alice/gallery/pulls/${opened.value.number}`, bobCookie)
1385 await web(`/alice/gallery/pulls/${opened.value.number}?looks=all`, bobCookie)
13861386 ).text();
13871387 expect(pullPage).toContain("<h2>Look</h2>");
13881388 expect(pullPage).toContain(`/alice/gallery/looks/${env}/${commit}/phone.png?v=`);
1389 // The default page carries the filmstrip, not the old block; ?looks=all carries the block
1390 // (#13654).
1391 const plain = await (await web(`/alice/gallery/pulls/${opened.value.number}`, bobCookie)).text();
1392 expect(plain).toContain("data-filmstrip");
1393 expect(plain).toMatch(/data-film-stage data-kind="(phone|desktop)"/);
1394 expect(plain).toContain(`/alice/gallery/looks/${env}/${commit}/phone.png?v=`);
1395 expect(plain).not.toContain("<h2>Look</h2>");
1396 expect(pullPage).toContain("data-filmstrip");
13891397 // A picture taken as the owner — every picture before #738 — stays the
13901398 // writers', even of a public app.
13911399 app.db
@@ -1394,9 +1402,14 @@ describe("the look", () => {
13941402 expect((await web(at("phone"), bobCookie)).status).toBe(404);
13951403 expect((await web(at("phone"), aliceCookie)).status).toBe(200);
13961404 const after = await (
1397 await web(`/alice/gallery/pulls/${opened.value.number}`, bobCookie)
1405 await web(`/alice/gallery/pulls/${opened.value.number}?looks=all`, bobCookie)
13981406 ).text();
13991407 expect(after).not.toContain("<h2>Look</h2>");
1408 // A viewer who may not fetch a picture is shown no frame of it either.
1409 const film = await (await web(`/alice/gallery/pulls/${opened.value.number}`, bobCookie)).text();
1410 expect(film).not.toContain("data-frame");
1411 expect(film).not.toContain("/looks/");
1412 expect(await (await web(`/alice/gallery/pulls/${opened.value.number}`, aliceCookie)).text()).toContain("data-frame");
14001413 });
14011414
14021415 test("a public app made private after its pictures were taken: a reader gets them no more, and no Look card; its writer still does (#845)", async () => {
@@ -1441,7 +1454,7 @@ describe("the look", () => {
14411454 expect((await web(at, bobCookie)).status).toBe(200);
14421455 const pull = opened.value;
14431456 const card = async (cookie: string) =>
1444 (await (await web(`/alice/vault/pulls/${pull.number}`, cookie)).text()).includes("<h2>Look</h2>");
1457 (await (await web(`/alice/vault/pulls/${pull.number}?looks=all`, cookie)).text()).includes("<h2>Look</h2>");
14451458 expect(await card(bobCookie)).toBe(true);
14461459 // Made private: the same files, asked again on every fetch.
14471460 app.db.query(`UPDATE app SET access = 'private' WHERE id = ?1`).run(galleryApp.id);
@@ -1473,7 +1486,7 @@ describe("the look", () => {
14731486 put(env, oid, "/solo");
14741487 put("production", mainOid, "/map");
14751488 const text = await (
1476 await web(`/alice/hello/pulls/${pull.number}`, aliceCookie)
1489 await web(`/alice/hello/pulls/${pull.number}?looks=all`, aliceCookie)
14771490 ).text();
14781491 const group = (page: string) =>
14791492 text.split(`<p class="muted small">${page}</p>`)[1]!.split("<section")[0]!;
test/mcp-pulls-pile.test.ts +13 −6
@@ -1,4 +1,7 @@
1 /** MCP `pulls` without `repo` (#7655): the pile across readable repositories; a pull's comments are one read. */
1 /**
2 * MCP `pulls` without `repo` (#7655): the pile across readable repositories; a pull's comments are
3 * one read.
4 */
25 import { afterAll, beforeAll, expect, test } from "bun:test";
36 import { mkdtemp, rm } from "node:fs/promises";
47 import { tmpdir } from "node:os";
@@ -72,6 +75,7 @@ beforeAll(async () => {
7275 for (const repo of [pub, priv])
7376 ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] }));
7477 green = await open(pub, ada, "green");
78 app.db.query("UPDATE issue SET body = ?1 WHERE id = ?2").run("# Retry\n\nMoves **retry** into `retry.ts`. Adds a test.", green.id);
7579 await open(priv, ada, "secret");
7680 const sealed = await open(pub, ada, "sealed", sam);
7781 await open(pub, ada, "third");
@@ -138,15 +142,18 @@ test("the outsider's comment is untrusted for a crew agent and unmarked for anyo
138142 expect("untrusted" in other.comments[0]).toBe(false);
139143 });
140144
141 test("past 50 comments the newest 50 come back with the total and the cursor of the older rest", async () => {
145 test("past 10 comments the newest 10 come back with the total and the cursor of the older rest", async () => {
142146 const ada = getUserByName(app.db, "ada")!;
143147 const ids: string[] = [];
144148 for (let n = 0; n < 54; n++)
145149 ids.push(ok(addComment(app.db, { issueId: green.id, authorId: ada.id, body: `c${n}` })).id);
146150 const { value } = await call(tok["ada"]!, "pull", { repo: "ada/svc", number: green.number });
147151 expect(value.commentsTotal).toBe(55);
148 expect(value.comments).toHaveLength(50);
149 expect(value.comments.map((c: any) => c.body)).toEqual(ids.slice(4).map((_, n) => `c${n + 4}`));
150 // The oldest comment returned is c4; its id is the cursor for the older rest.
151 expect(value.commentsNext).toBe(ids[4]!);
152 expect(value.comments).toHaveLength(10);
153 expect(value.comments.map((c: any) => c.body)).toEqual(ids.slice(44).map((_, n) => `c${n + 44}`));
154 // The oldest comment returned is c44; its id is the cursor for the older rest.
155 expect(value.commentsNext).toBe(ids[44]!);
156 // The summary comes with it, whatever the thread length, and before the comments.
157 expect(value.summary).toBe("Moves retry into retry.ts. Adds a test. The check passed on this head.");
158 expect(Object.keys(value).indexOf("summary")).toBeLessThan(Object.keys(value).indexOf("comments"));
152159 });
test/pull-looks-pair.test.ts +8 −5
@@ -1,4 +1,7 @@
1 /** The pull page sets main's look beside the head's, per page, width and theme; where main has none the head stands alone (#9669). */
1 /**
2 * The pull page sets main's look beside the head's, per page, width and theme; where main has none
3 * the head stands alone (#9669).
4 */
25 import { afterAll, beforeAll, expect, test } from "bun:test";
36 import { mkdtemp, rm } from "node:fs/promises";
47 import { tmpdir } from "node:os";
@@ -49,7 +52,7 @@ beforeAll(async () => {
4952 take(pr, HEAD, { kind: "desktop" }); // main has no desktop look
5053 pullNumber = o.value.number;
5154 servers = await serve(app);
52 page = await (await fetch(`${servers.url}/alice/garden/pulls/${o.value.number}`)).text();
55 page = await (await fetch(`${servers.url}/alice/garden/pulls/${o.value.number}?looks=all`)).text();
5356 }, 30_000);
5457
5558 afterAll(async () => {
@@ -94,7 +97,7 @@ test("an unpaired look stands alone, and every image keeps its size", () => {
9497 test("with no picture on main, the head stands alone under one line, no empty frame", async () => {
9598 expect(page).not.toContain("data-no-main");
9699 app.db.run("DELETE FROM look WHERE env = 'production'");
97 const text = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}`)).text();
100 const text = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}?looks=all`)).text();
98101 expect(text).toContain("main has no picture of this page yet.");
99102 expect(text).not.toContain("data-compare");
100103 expect(text).not.toContain(">this pull<");
@@ -129,10 +132,10 @@ test("one line over the pictures counts pages beside main and pages new to this
129132 take("production", MAIN, "/");
130133 take(previewEnv(pullNumber), HEAD, "/");
131134 take(previewEnv(pullNumber), HEAD, "/about");
132 const text = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}`)).text();
135 const text = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}?looks=all`)).text();
133136 expect(text).toContain("1 page beside main · 1 new to this pull");
134137 app.db.run("DELETE FROM look WHERE env = 'production'");
135 const none = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}`)).text();
138 const none = await (await fetch(`${servers.url}/alice/garden/pulls/${pullNumber}?looks=all`)).text();
136139 expect(none).toContain("main has no pictures yet.");
137140 expect(none).toContain("data-no-main");
138141 });
test/pull-page-phases.test.ts +1 −1
@@ -112,7 +112,7 @@ test("an open pull's page names each of its reads as a phase before render", asy
112112 const got = await timed();
113113 expect(got.names).toEqual([...PULL_PAGE_PHASES]);
114114 // What was seeded is drawn: the look, the preview and the check.
115 expect(got.body).toContain("<h2>Look</h2>");
115 expect(got.body).toContain("data-filmstrip");
116116 expect(got.body).toContain("<h2>Preview</h2>");
117117 expect(got.body).toContain('data-word="look"');
118118 const sum = got.names.reduce((t, n) => t + got.ms(n), 0);
test/pull-verdict.test.ts +1 −6
@@ -12,7 +12,7 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1212 import { createSession } from "../src/core/sessions.ts";
1313 import { createUser, type User } from "../src/core/users.ts";
1414 import { serve, type Servers } from "../src/http/server.ts";
15 import { firstParagraph, verdictOf, type VerdictInput } from "../src/web/pages/pull-verdict.ts";
15 import { verdictOf, type VerdictInput } from "../src/web/pages/pull-verdict.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
1717
1818 quietLogs();
@@ -141,8 +141,3 @@ test("verdictOf names what holds a pull, in the merge box's order", () => {
141141 expect(words({ merged: true })).toBe("Merged");
142142 expect(verdictOf({ ...base, mayMerge: false }, "/t").action).toBeNull();
143143 });
144
145 test("the description's first paragraph only", () => {
146 expect(firstParagraph("\n\nOne.\nStill one.\n\nTwo.")).toBe("One.\nStill one.");
147 expect(firstParagraph("")).toBe("");
148 });
test/thread-window.test.ts +28 −3
@@ -4,6 +4,9 @@ import { snappyFixture, type SnappyFixture } from "../bench/snappy.ts";
44 import { addComment, markQuestion, openIssue, setIssueState } from "../src/actions/issues.ts";
55 import { openPull } from "../src/actions/pulls.ts";
66 import { commitToBranch } from "../src/actions/repos.ts";
7 import { previewEnv } from "../src/apps/data.ts";
8 import { createApp as createAppRecord } from "../src/core/apps.ts";
9 import { recordLook } from "../src/core/looks.ts";
710
811 import { commentAnchor, getIssue, listComments, parseQuestion } from "../src/core/issues.ts";
912 import { foldJs } from "../src/web/fold.ts";
@@ -19,6 +22,7 @@ import { candidatesFor } from "../src/feed/items.ts";
1922 let f: SnappyFixture;
2023 let path = "";
2124 let ids: string[] = [];
25 let pullNumber = 0;
2226 let issue: NonNullable<ReturnType<typeof getIssue>>;
2327
2428 beforeAll(async () => {
@@ -121,21 +125,42 @@ test("a pull thread windows too, and the link keeps the page's other query", asy
121125 files: [{ path: "feature.txt", content: "yes\n" }],
122126 });
123127 expect(branched.ok).toBe(true);
124 const pull = await openPull(f.app, f.owner, repo, { title: "Feature", baseBranch: "main", headBranch: "feature" });
128 const pull = await openPull(f.app, f.owner, repo, { title: "Feature", body: "Adds a feature.", baseBranch: "main", headBranch: "feature" });
125129 if (!pull.ok) throw new Error(String(pull.error));
130 pullNumber = pull.value.number;
126131 for (let i = 0; i < 70; i++) {
127132 const added = addComment(f.app, f.owner, repo, pull.value, `pull comment ${i}`);
128133 if (!added.ok) throw new Error(String(added.error));
129134 }
130135 const url = `${f.base}/${repo.ownerName}/${repo.name}/pulls/${pull.value.number}`;
131136 const page = await (await fetch(`${url}?diff=0`, { headers: { cookie: f.ownerCookie } })).text();
132 expect(page).toContain("Show 20 earlier items");
137 expect(page).toContain("Show 62 earlier items");
133138 expect(page).toContain(`href="/${repo.ownerName}/${repo.name}/pulls/${pull.value.number}?diff=0&amp;all=1"`);
134 expect(page.match(/class="tl-item" id="c-/g)?.length).toBe(50);
139 expect(page.match(/class="tl-item" id="c-/g)?.length).toBe(8);
135140 const all = await (await fetch(`${url}?diff=0&all=1`, { headers: { cookie: f.ownerCookie } })).text();
136141 expect(all.match(/class="tl-item" id="c-/g)?.length).toBe(70);
137142 });
138143
144 test("a pull with 70 comments and 80 pictures opens on a summary and a filmstrip, under 60 KB (#13654)", async () => {
145 const repo = f.repos[0]!;
146 const pull = { number: pullNumber };
147 const record = createAppRecord(f.app.db, { repoId: repo.id, slug: "long", access: "public" });
148 if (!record.ok) throw new Error(record.error);
149 for (let p = 0; p < 40; p++)
150 for (const kind of ["phone", "desktop"] as const)
151 recordLook(f.app.db, {
152 appId: record.value.id, env: previewEnv(pull.number), commitOid: "a".repeat(40),
153 page: p === 0 ? "/" : `/page-${p}`, kind, path: "looks/x.png", takenAs: "nobody",
154 });
155 const url = `${f.base}/${repo.ownerName}/${repo.name}/pulls/${pull.number}`;
156 const body = await (await fetch(url, { headers: { cookie: f.ownerCookie } })).text();
157 expect(new TextEncoder().encode(body).length).toBeLessThan(60 * 1024);
158 expect(body).toContain("data-summary");
159 expect(body).toContain("data-filmstrip");
160 expect(body.match(/data-frame/g)?.length).toBe(24);
161 expect(body.match(/class="tl-item" id="c-/g)?.length).toBe(8);
162 });
163
139164 test("an open question stays out of the fold on an issue; a settled one folds", async () => {
140165 const repo = f.repos[0]!;
141166 const opened = openIssue(f.app, f.owner, repo, { title: "Asked", body: "asked" });
test/tui-pull-cost.test.ts +3 −1
@@ -49,7 +49,7 @@ test("the owner's pull screen carries the cost line, a reader's does not", async
4949 }
5050 const ask = openIssue(app, alice, repo, { title: "ask" });
5151 if (!ask.ok) throw new Error("issue");
52 const o = await openPull(app, alice, repo, { title: "Pull feat", body: `Closes #${ask.value.number}`, baseBranch: "main", headBranch: "feat" });
52 const o = await openPull(app, alice, repo, { title: "Pull feat", body: `Moves retry into retry.ts. Closes #${ask.value.number}`, baseBranch: "main", headBranch: "feat" });
5353 if (!o.ok) throw new Error(String(o.error));
5454 const number = o.value.number;
5555 const pullId = getPull(app.db, repo.id, number)!.id;
@@ -71,5 +71,7 @@ test("the owner's pull screen carries the cost line, a reader's does not", async
7171 expect(await screenText(alice)).toContain("cost: $0.30 tokens · 30 lane-min · 1.0 h waiting");
7272 const seen = await screenText(bob);
7373 expect(seen).toContain("Pull feat");
74 // The summary rides beside the verdict (#13654): what changed, not what the check said again.
75 expect(seen).toContain(`· Moves retry into retry.ts. Closes #${ask.value.number}`);
7476 expect(seen).not.toContain("lane-min");
7577 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs