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
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13654-a-pull-and-an-issue-open-on-what-matters → main 7 commits fork
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 | ||
| 4 | 4 | |
| 5 | 5 | - 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. |
| 6 | 6 | - 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. | |
| 8 | 8 | - 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`). |
| 9 | 9 | - 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. |
| 10 | 10 | - Terminal and MCP: rendering only. The terminal and the API return whole threads, so they have nothing to fold. |
| 11 | 11 | - 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; | ||
| 770 | 770 | /** How many timeline items a thread page shows before it folds the earlier ones behind `?all=1`. */ |
| 771 | 771 | export const THREAD_WINDOW = 50; |
| 772 | 772 | |
| 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 | ||
| 773 | 782 | /** |
| 774 | 783 | * Where a comment's own anchor lands on its thread page: `#c-<id>` when it |
| 775 | 784 | * is among the newest comments the page shows, `?all=1#c-<id>` when it is |
| @@ -778,13 +787,18 @@ export const THREAD_WINDOW = 50; | ||
| 778 | 787 | * THREAD_WINDOW comments, with the state lines between them riding along. |
| 779 | 788 | * Both count the same thing, so the anchor always lands. |
| 780 | 789 | */ |
| 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 { | |
| 782 | 796 | const after = db |
| 783 | 797 | .query<{ n: number }, [string, string]>( |
| 784 | 798 | "SELECT COUNT(*) AS n FROM comment WHERE issue_id = ?1 AND kind = 'comment' AND id > ?2", |
| 785 | 799 | ) |
| 786 | 800 | .get(issueId, commentId)!.n; |
| 787 | return `${after >= THREAD_WINDOW ? "?all=1" : ""}#c-${commentId}`; | |
| 801 | return `${after >= window ? "?all=1" : ""}#c-${commentId}`; | |
| 788 | 802 | } |
| 789 | 803 | |
| 790 | 804 | export function listComments( |
src/core/pulls.ts +78 −4
| @@ -1135,7 +1135,9 @@ export interface Guarded { | ||
| 1135 | 1135 | |
| 1136 | 1136 | export type MergePullError = |
| 1137 | 1137 | | 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 | */ | |
| 1139 | 1141 | | { readonly kind: "guarded"; readonly paths: readonly Guarded[] } |
| 1140 | 1142 | | "already_merged" |
| 1141 | 1143 | | "closed" |
| @@ -1422,10 +1424,16 @@ export const CLOSERS_REUSE_MS = process.env["NODE_ENV"] === "test" ? 0 : 300_000 | ||
| 1422 | 1424 | |
| 1423 | 1425 | const closersKept = new WeakMap<Database, Map<string, { at: number; sig: string; closers: Map<number, number> }>>(); |
| 1424 | 1426 | |
| 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 | */ | |
| 1426 | 1431 | const signatures = new WeakMap<Database, { clock: string; sig: string }>(); |
| 1427 | 1432 | |
| 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 | */ | |
| 1429 | 1437 | function mergedSignature(db: Database): string { |
| 1430 | 1438 | const clock = writeStamp(db); |
| 1431 | 1439 | const known = signatures.get(db); |
| @@ -1461,7 +1469,10 @@ export function mergedPullClosing(db: Database, repoId: string, number: number): | ||
| 1461 | 1469 | return pullNumber === undefined ? undefined : getPull(db, repoId, pullNumber); |
| 1462 | 1470 | } |
| 1463 | 1471 | |
| 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 | */ | |
| 1465 | 1476 | export function mergedPullClosingScan(db: Database, repoId: string, number: number): Pull | undefined { |
| 1466 | 1477 | const rows = db |
| 1467 | 1478 | .query<{ number: number }, [string, string]>( |
| @@ -1554,3 +1565,66 @@ export function mergedPullsSince( | ||
| 1554 | 1565 | ids.map((id) => issues.get(id)).filter((i): i is Issue => i !== undefined), |
| 1555 | 1566 | ); |
| 1556 | 1567 | } |
| 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"; | ||
| 13 | 13 | import { audienceFilter } from "../core/event_audience.ts"; |
| 14 | 14 | import { listEventsVisibleTo, listTeamEventsFor, type ForgeEvent } from "../core/events.ts"; |
| 15 | 15 | 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"; | |
| 17 | 17 | import { |
| 18 | 18 | listDetachedMirrors, |
| 19 | 19 | listOrigins, |
| @@ -807,7 +807,7 @@ function fromEvent( | ||
| 807 | 807 | const commentId = p["commentId"]; |
| 808 | 808 | const anchor = |
| 809 | 809 | thread !== undefined && typeof commentId === "string" |
| 810 | ? commentAnchor(db, thread.id, commentId) | |
| 810 | ? commentAnchor(db, thread.id, commentId, threadWindow(thread.kind)) | |
| 811 | 811 | : ""; |
| 812 | 812 | return { |
| 813 | 813 | ...common, |
src/http/mcp/tools/pull.ts +10 −3
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { mayView } from "../../../core/sealed.ts"; |
| 2 | import { pullSummary } from "../../../core/pulls.ts"; | |
| 2 | 3 | import { pullProposalOf } from "../../../core/proposal_token.ts"; |
| 3 | 4 | import { resolveOid } from "../../../git/merge.ts"; |
| 4 | 5 | import { getPull, pullDir, pullMergeState } from "../../../core/pulls.ts"; |
| @@ -8,16 +9,21 @@ import { checkSummary } from "../../../core/runs.ts"; | ||
| 8 | 9 | import { nextOfPull } from "../../../flow/next_actor.ts"; |
| 9 | 10 | import { stepOfPull } from "../../../flow/path.ts"; |
| 10 | 11 | import { appView } from "../../../actions/apps.ts"; |
| 11 | import { countThread, EMBEDDED_COMMENTS, listComments } from "../../../core/issues.ts"; | |
| 12 | import { countThread, listComments } from "../../../core/issues.ts"; | |
| 12 | 13 | import { landingLine } from "../../../flow/landing_line.ts"; |
| 13 | 14 | import { pullLooks } from "../../../looks/readable.ts"; |
| 14 | 15 | import { isCrew } from "../../../core/agents.ts"; |
| 15 | 16 | import { markReaders } from "../../../crew/direct.ts"; |
| 16 | 17 | import { good, bad, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts"; |
| 17 | 18 | |
| 19 | /** | |
| 20 | * The comments `pull` carries by default: the summary comes first, older ones by `commentsNext`. | |
| 21 | */ | |
| 22 | const PULL_COMMENTS = 10; | |
| 23 | ||
| 18 | 24 | export const tool: Tool = { |
| 19 | 25 | 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", | |
| 21 | 27 | description: |
| 22 | 28 | "A pull: title, state, head, base; open: `mergeable`, `conflicts`, `checkStale`, `checkedAgainst`, `check`.", |
| 23 | 29 | inputSchema: { |
| @@ -49,10 +55,11 @@ export const tool: Tool = { | ||
| 49 | 55 | const db = ctx.app.db; |
| 50 | 56 | // Marked only for a crew agent, as the issue and the API do. |
| 51 | 57 | 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 }); | |
| 53 | 59 | const comments = marking ? markReaders(db, repo, rows) : rows; |
| 54 | 60 | const total = countThread(db, pull.id); |
| 55 | 61 | const answer = good({ |
| 62 | summary: pullSummary(pull.body, check.state), | |
| 56 | 63 | comments: comments.map((c) => ({ |
| 57 | 64 | author: c.authorName, |
| 58 | 65 | body: c.body, |
src/tui/screens/pull.ts +14 −1
| @@ -84,6 +84,7 @@ import { canVerdict } from "../../core/verdict.ts"; | ||
| 84 | 84 | import { reviewWords } from "../../actions/review_words.ts"; |
| 85 | 85 | import { verdictOf, type Verdict } from "../../web/pages/pull-verdict.ts"; |
| 86 | 86 | import { wallOf, wallPlain, type Wall } from "../../contract/policy.ts"; |
| 87 | import { changedSentences } from "../../core/pulls.ts"; | |
| 87 | 88 | import { checkSummary, type CheckSummary } from "../../core/runs.ts"; |
| 88 | 89 | import { err, ok } from "../../kernel/result.ts"; |
| 89 | 90 | import { getUsersByIds } from "../../core/users.ts"; |
| @@ -1290,7 +1291,19 @@ export function pullScreen( | ||
| 1290 | 1291 | // Merged and closed pulls are told by the head line and the merge box. |
| 1291 | 1292 | if (verdictNow !== null && head!.h > 2 && detail?.issue.state === "open" && facts?.mergedAt === null) { |
| 1292 | 1293 | 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 | ); | |
| 1294 | 1307 | } |
| 1295 | 1308 | if (strangerLine !== "" && nextRow!.h > 0) |
| 1296 | 1309 | 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 @@ | ||
| 7 | 7 | * `mergeBox` and `mergePull` ask, in the same order, so the line and the |
| 8 | 8 | * button never disagree. |
| 9 | 9 | */ |
| 10 | import { changedSentences } from "../../core/pulls.ts"; | |
| 10 | 11 | import type { Diff } from "../../git/diff.ts"; |
| 11 | 12 | import { html, when, type Html } from "../html.ts"; |
| 12 | 13 | import { btn, dot, type Tone } from "../ui.ts"; |
| @@ -92,29 +93,21 @@ export function verdictLine(verdict: Verdict, show: { readonly action?: boolean | ||
| 92 | 93 | </div>`; |
| 93 | 94 | } |
| 94 | 95 | |
| 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 | ||
| 104 | 96 | /** |
| 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`. | |
| 107 | 100 | */ |
| 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); | |
| 110 | 103 | 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> | |
| 119 | 112 | </section>`; |
| 120 | 113 | } |
src/web/pages/thread.ts +3 −3
| @@ -45,7 +45,7 @@ import { | ||
| 45 | 45 | getIssue, |
| 46 | 46 | labelsFor, |
| 47 | 47 | listComments, |
| 48 | THREAD_WINDOW, | |
| 48 | threadWindow, | |
| 49 | 49 | MAX_BODY, |
| 50 | 50 | MAX_TITLE, |
| 51 | 51 | } from "../../core/issues.ts"; |
| @@ -409,7 +409,7 @@ export function conversation( | ||
| 409 | 409 | entries.push(...forgeEntries(ctx, repo, issue)); |
| 410 | 410 | entries.push(...(options.extra ?? [])); |
| 411 | 411 | 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 | |
| 413 | 413 | // changes between them; everything before the oldest of those waits behind |
| 414 | 414 | // `?all=1` (a plain link, so it works without JavaScript). The cut is on |
| 415 | 415 | // comments so that `commentAnchor` counts the very same thing and every |
| @@ -419,7 +419,7 @@ export function conversation( | ||
| 419 | 419 | if (!everything) { |
| 420 | 420 | let seen = 0; |
| 421 | 421 | 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)) { | |
| 423 | 423 | hidden = i; |
| 424 | 424 | break; |
| 425 | 425 | } |
src/web/studio/change.ts +12 −4
| @@ -65,6 +65,7 @@ import { | ||
| 65 | 65 | type Tone, |
| 66 | 66 | } from "../ui.ts"; |
| 67 | 67 | import { previewBlock } from "../pages/apps.ts"; |
| 68 | import { filmstrip, filmstripJs } from "../pages/filmstrip.ts"; | |
| 68 | 69 | import { lookCard } from "../pages/looks.ts"; |
| 69 | 70 | import { approveHereCard, keptChange, pullChecksLineFor, reachLine, teamsCard, verdictFacts } from "../pages/pull.ts"; |
| 70 | 71 | import { landAsIs } from "./land_as_is.ts"; |
| @@ -742,9 +743,13 @@ async function changeConversation( | ||
| 742 | 743 | ${teamsCard(teamVerdicts(db, { ...pull, headOid }))} |
| 743 | 744 | ${when(wall, (w) => wallCard(w, writer ? thread : undefined))}`, |
| 744 | 745 | ); |
| 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"; | |
| 745 | 749 | 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``, | |
| 747 | 751 | ); |
| 752 | const film = tick(spent, "looks", () => when(record, (r) => filmstrip(ctx, repo, r, pull))); | |
| 748 | 753 | const reviewsAt = performance.now(); |
| 749 | 754 | const reviews = listReviews(db, pull.id); |
| 750 | 755 | const reviewerMarks = marksByName( |
| @@ -789,7 +794,10 @@ async function changeConversation( | ||
| 789 | 794 | const body = html`${pageHead.top} |
| 790 | 795 | ${when(wave, (w) => crumbs([{ label: `Wave ${w.version}`, href: w.href }, { label: "This pull" }]))} |
| 791 | 796 | ${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> | |
| 793 | 801 | ${when(siblings.length > 0, () => |
| 794 | 802 | html`<p class="muted small variant-link"> |
| 795 | 803 | <a href="${base}/variants/${pull.variantGroup ?? ""}" |
| @@ -803,7 +811,7 @@ async function changeConversation( | ||
| 803 | 811 | ? landAsIs(ctx, repo, pull) |
| 804 | 812 | : null} |
| 805 | 813 | ${when(visionPreview, (v) => visionPreviewCard(v))} |
| 806 | ${look} | |
| 814 | ${when(showAllLooks, () => look)} | |
| 807 | 815 | <div class="split"> |
| 808 | 816 | <div> |
| 809 | 817 | ${talk.node} |
| @@ -835,7 +843,7 @@ async function changeConversation( | ||
| 835 | 843 | crumbs: pageHead.crumbs, |
| 836 | 844 | palette: pageHead.palette, |
| 837 | 845 | body, |
| 838 | scriptJs: `${liveClientJs}\n${liveRegionsJs}`, | |
| 846 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${filmstripJs}`, | |
| 839 | 847 | }); |
| 840 | 848 | // Each phase is named once, from what the laps added up to; render is what |
| 841 | 849 | // 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); } | ||
| 468 | 468 | .looks > [data-slot="desktop"] { flex: 1 1 320px; min-width: 0; max-width: 1280px; } |
| 469 | 469 | .looks > figure { margin: 0; display: flex; flex-direction: column; gap: 6px; } |
| 470 | 470 | .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; } | |
| 471 | 479 | .looks[data-compare] > * { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; } |
| 472 | 480 | @media (max-width: 640px) { |
| 473 | 481 | .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", () => { | ||
| 90 | 90 | |
| 91 | 91 | const page = async (cookie: string) => |
| 92 | 92 | ( |
| 93 | await fetch(`${base}/alice/garden/pulls/${pull.number}`, { | |
| 93 | await fetch(`${base}/alice/garden/pulls/${pull.number}?looks=all`, { | |
| 94 | 94 | headers: cookie === "" ? {} : { cookie }, |
| 95 | 95 | }) |
| 96 | 96 | ).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 | */ | |
| 2 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -8,7 +11,10 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | ||
| 8 | 11 | import { createApp, type App } from "../src/app.ts"; |
| 9 | 12 | import { previewEnv } from "../src/apps/data.ts"; |
| 10 | 13 | 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"; | |
| 12 | 18 | import { createUser } from "../src/core/users.ts"; |
| 13 | 19 | import { serve, type Servers } from "../src/http/server.ts"; |
| 14 | 20 | import { quietLogs } from "./helpers/globals.ts"; |
| @@ -57,7 +63,7 @@ afterAll(async () => { | ||
| 57 | 63 | const main = (page: string) => page.slice(page.indexOf("<main"), page.indexOf("</main>")); |
| 58 | 64 | |
| 59 | 65 | 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()); | |
| 61 | 67 | expect(m).toMatch(/<section class="settings-block" id="look"[^>]*>\s*<h2>Look<\/h2>/); |
| 62 | 68 | const look = m.slice(m.indexOf('id="look"')); |
| 63 | 69 | 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 | ||
| 68 | 74 | test("a private repository's picture is a 404 to an outsider, and its pull page too", async () => { |
| 69 | 75 | const url = `${servers.url}/alice/vault/looks/${previewEnv(privatePull)}/${HEAD}/phone.png`; |
| 70 | 76 | 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`); | |
| 72 | 78 | expect(page.status).toBe(404); |
| 73 | 79 | }); |
| 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"; | |
| 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", () => { | ||
| 574 | 574 | const base = `/alice/hello`; |
| 575 | 575 | const env = `pull-${pull.number}`; |
| 576 | 576 | const page = await ( |
| 577 | await web(`${base}/pulls/${pull.number}`, aliceCookie) | |
| 577 | await web(`${base}/pulls/${pull.number}?looks=all`, aliceCookie) | |
| 578 | 578 | ).text(); |
| 579 | 579 | expect(page).toContain("<h2>Look</h2>"); |
| 580 | 580 | expect(page).toContain(`src="${base}/looks/${env}/${second}/phone.png?v=`); |
| @@ -718,7 +718,7 @@ describe("the look", () => { | ||
| 718 | 718 | // The last good pictures stay, and the page says the head has moved |
| 719 | 719 | // and why there is no picture of it. |
| 720 | 720 | const page = await ( |
| 721 | await web(`/alice/hello/pulls/${pull.number}`, aliceCookie) | |
| 721 | await web(`/alice/hello/pulls/${pull.number}?looks=all`, aliceCookie) | |
| 722 | 722 | ).text(); |
| 723 | 723 | expect(page).toContain(`/looks/${env}/${second}/phone.png`); |
| 724 | 724 | expect(page.replace(/\s+/g, " ")).toContain("the head has moved since"); |
| @@ -737,7 +737,7 @@ describe("the look", () => { | ||
| 737 | 737 | const rows = await pictured(env2, unpictured.commitOid); |
| 738 | 738 | expect(rows.every((l) => l.error === "the browser fell over")).toBe(true); |
| 739 | 739 | 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) | |
| 741 | 741 | ).text(); |
| 742 | 742 | expect(none).toContain("<h2>Look</h2>"); |
| 743 | 743 | expect(none).toContain("No picture of"); |
| @@ -844,7 +844,7 @@ describe("the look", () => { | ||
| 844 | 844 | expect(looksForEnv(app.db, record.id, env)).toHaveLength(0); |
| 845 | 845 | expect(existsSync(join(dataDir, "looks", record.id, env))).toBe(false); |
| 846 | 846 | 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) | |
| 848 | 848 | ).text(); |
| 849 | 849 | expect(page).not.toContain("<h2>Look</h2>"); |
| 850 | 850 | }); |
| @@ -1006,7 +1006,7 @@ describe("the look", () => { | ||
| 1006 | 1006 | expect(boardCall).toBeDefined(); |
| 1007 | 1007 | |
| 1008 | 1008 | 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) | |
| 1010 | 1010 | ).text(); |
| 1011 | 1011 | expect(page).toContain(`<p class="muted small">/</p>`); |
| 1012 | 1012 | expect(page).toContain(`<p class="muted small">/board</p>`); |
| @@ -1057,7 +1057,7 @@ describe("the look", () => { | ||
| 1057 | 1057 | expect(lookUrl("/alice/hello", darkPhone)).toContain("/phone-dark.png?v="); |
| 1058 | 1058 | // And it is on the pull page, as a link that works without script. |
| 1059 | 1059 | 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) | |
| 1061 | 1061 | ).text(); |
| 1062 | 1062 | expect(darkPage).toContain( |
| 1063 | 1063 | `<a class="look" data-slot="phone" href="/alice/hello/looks/${env}/${commitOid}/phone-dark.png?v=`, |
| @@ -1083,7 +1083,7 @@ describe("the look", () => { | ||
| 1083 | 1083 | path: `looks/${record.id}/${env}/${stale}-phone-dark.png`, |
| 1084 | 1084 | }); |
| 1085 | 1085 | 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) | |
| 1087 | 1087 | ).text(); |
| 1088 | 1088 | expect(after).not.toContain(stale); |
| 1089 | 1089 | expect(after).toContain(`${commitOid}/phone-dark.png?v=`); |
| @@ -1382,10 +1382,18 @@ describe("the look", () => { | ||
| 1382 | 1382 | expect((await web(at("desktop"), cookie)).status).toBe(200); |
| 1383 | 1383 | } |
| 1384 | 1384 | 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) | |
| 1386 | 1386 | ).text(); |
| 1387 | 1387 | expect(pullPage).toContain("<h2>Look</h2>"); |
| 1388 | 1388 | 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"); | |
| 1389 | 1397 | // A picture taken as the owner — every picture before #738 — stays the |
| 1390 | 1398 | // writers', even of a public app. |
| 1391 | 1399 | app.db |
| @@ -1394,9 +1402,14 @@ describe("the look", () => { | ||
| 1394 | 1402 | expect((await web(at("phone"), bobCookie)).status).toBe(404); |
| 1395 | 1403 | expect((await web(at("phone"), aliceCookie)).status).toBe(200); |
| 1396 | 1404 | 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) | |
| 1398 | 1406 | ).text(); |
| 1399 | 1407 | 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"); | |
| 1400 | 1413 | }); |
| 1401 | 1414 | |
| 1402 | 1415 | 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", () => { | ||
| 1441 | 1454 | expect((await web(at, bobCookie)).status).toBe(200); |
| 1442 | 1455 | const pull = opened.value; |
| 1443 | 1456 | 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>"); | |
| 1445 | 1458 | expect(await card(bobCookie)).toBe(true); |
| 1446 | 1459 | // Made private: the same files, asked again on every fetch. |
| 1447 | 1460 | app.db.query(`UPDATE app SET access = 'private' WHERE id = ?1`).run(galleryApp.id); |
| @@ -1473,7 +1486,7 @@ describe("the look", () => { | ||
| 1473 | 1486 | put(env, oid, "/solo"); |
| 1474 | 1487 | put("production", mainOid, "/map"); |
| 1475 | 1488 | const text = await ( |
| 1476 | await web(`/alice/hello/pulls/${pull.number}`, aliceCookie) | |
| 1489 | await web(`/alice/hello/pulls/${pull.number}?looks=all`, aliceCookie) | |
| 1477 | 1490 | ).text(); |
| 1478 | 1491 | const group = (page: string) => |
| 1479 | 1492 | 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 | */ | |
| 2 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -72,6 +75,7 @@ beforeAll(async () => { | ||
| 72 | 75 | for (const repo of [pub, priv]) |
| 73 | 76 | ok(await commitToBranch(app, ada, repo, { message: "seed", files: [{ path: "a.txt", content: "a\n" }] })); |
| 74 | 77 | 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); | |
| 75 | 79 | await open(priv, ada, "secret"); |
| 76 | 80 | const sealed = await open(pub, ada, "sealed", sam); |
| 77 | 81 | await open(pub, ada, "third"); |
| @@ -138,15 +142,18 @@ test("the outsider's comment is untrusted for a crew agent and unmarked for anyo | ||
| 138 | 142 | expect("untrusted" in other.comments[0]).toBe(false); |
| 139 | 143 | }); |
| 140 | 144 | |
| 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 () => { | |
| 142 | 146 | const ada = getUserByName(app.db, "ada")!; |
| 143 | 147 | const ids: string[] = []; |
| 144 | 148 | for (let n = 0; n < 54; n++) |
| 145 | 149 | ids.push(ok(addComment(app.db, { issueId: green.id, authorId: ada.id, body: `c${n}` })).id); |
| 146 | 150 | const { value } = await call(tok["ada"]!, "pull", { repo: "ada/svc", number: green.number }); |
| 147 | 151 | 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")); | |
| 152 | 159 | }); |
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 | */ | |
| 2 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 6 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 7 | import { tmpdir } from "node:os"; |
| @@ -49,7 +52,7 @@ beforeAll(async () => { | ||
| 49 | 52 | take(pr, HEAD, { kind: "desktop" }); // main has no desktop look |
| 50 | 53 | pullNumber = o.value.number; |
| 51 | 54 | 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(); | |
| 53 | 56 | }, 30_000); |
| 54 | 57 | |
| 55 | 58 | afterAll(async () => { |
| @@ -94,7 +97,7 @@ test("an unpaired look stands alone, and every image keeps its size", () => { | ||
| 94 | 97 | test("with no picture on main, the head stands alone under one line, no empty frame", async () => { |
| 95 | 98 | expect(page).not.toContain("data-no-main"); |
| 96 | 99 | 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(); | |
| 98 | 101 | expect(text).toContain("main has no picture of this page yet."); |
| 99 | 102 | expect(text).not.toContain("data-compare"); |
| 100 | 103 | 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 | ||
| 129 | 132 | take("production", MAIN, "/"); |
| 130 | 133 | take(previewEnv(pullNumber), HEAD, "/"); |
| 131 | 134 | 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(); | |
| 133 | 136 | expect(text).toContain("1 page beside main · 1 new to this pull"); |
| 134 | 137 | 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(); | |
| 136 | 139 | expect(none).toContain("main has no pictures yet."); |
| 137 | 140 | expect(none).toContain("data-no-main"); |
| 138 | 141 | }); |
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 | ||
| 112 | 112 | const got = await timed(); |
| 113 | 113 | expect(got.names).toEqual([...PULL_PAGE_PHASES]); |
| 114 | 114 | // 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"); | |
| 116 | 116 | expect(got.body).toContain("<h2>Preview</h2>"); |
| 117 | 117 | expect(got.body).toContain('data-word="look"'); |
| 118 | 118 | 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"; | ||
| 12 | 12 | import { createSession } from "../src/core/sessions.ts"; |
| 13 | 13 | import { createUser, type User } from "../src/core/users.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 17 | |
| 18 | 18 | quietLogs(); |
| @@ -141,8 +141,3 @@ test("verdictOf names what holds a pull, in the merge box's order", () => { | ||
| 141 | 141 | expect(words({ merged: true })).toBe("Merged"); |
| 142 | 142 | expect(verdictOf({ ...base, mayMerge: false }, "/t").action).toBeNull(); |
| 143 | 143 | }); |
| 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"; | ||
| 4 | 4 | import { addComment, markQuestion, openIssue, setIssueState } from "../src/actions/issues.ts"; |
| 5 | 5 | import { openPull } from "../src/actions/pulls.ts"; |
| 6 | 6 | 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"; | |
| 7 | 10 | |
| 8 | 11 | import { commentAnchor, getIssue, listComments, parseQuestion } from "../src/core/issues.ts"; |
| 9 | 12 | import { foldJs } from "../src/web/fold.ts"; |
| @@ -19,6 +22,7 @@ import { candidatesFor } from "../src/feed/items.ts"; | ||
| 19 | 22 | let f: SnappyFixture; |
| 20 | 23 | let path = ""; |
| 21 | 24 | let ids: string[] = []; |
| 25 | let pullNumber = 0; | |
| 22 | 26 | let issue: NonNullable<ReturnType<typeof getIssue>>; |
| 23 | 27 | |
| 24 | 28 | beforeAll(async () => { |
| @@ -121,21 +125,42 @@ test("a pull thread windows too, and the link keeps the page's other query", asy | ||
| 121 | 125 | files: [{ path: "feature.txt", content: "yes\n" }], |
| 122 | 126 | }); |
| 123 | 127 | 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" }); | |
| 125 | 129 | if (!pull.ok) throw new Error(String(pull.error)); |
| 130 | pullNumber = pull.value.number; | |
| 126 | 131 | for (let i = 0; i < 70; i++) { |
| 127 | 132 | const added = addComment(f.app, f.owner, repo, pull.value, `pull comment ${i}`); |
| 128 | 133 | if (!added.ok) throw new Error(String(added.error)); |
| 129 | 134 | } |
| 130 | 135 | const url = `${f.base}/${repo.ownerName}/${repo.name}/pulls/${pull.value.number}`; |
| 131 | 136 | 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"); | |
| 133 | 138 | expect(page).toContain(`href="/${repo.ownerName}/${repo.name}/pulls/${pull.value.number}?diff=0&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); | |
| 135 | 140 | const all = await (await fetch(`${url}?diff=0&all=1`, { headers: { cookie: f.ownerCookie } })).text(); |
| 136 | 141 | expect(all.match(/class="tl-item" id="c-/g)?.length).toBe(70); |
| 137 | 142 | }); |
| 138 | 143 | |
| 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 | ||
| 139 | 164 | test("an open question stays out of the fold on an issue; a settled one folds", async () => { |
| 140 | 165 | const repo = f.repos[0]!; |
| 141 | 166 | 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 | ||
| 49 | 49 | } |
| 50 | 50 | const ask = openIssue(app, alice, repo, { title: "ask" }); |
| 51 | 51 | 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" }); | |
| 53 | 53 | if (!o.ok) throw new Error(String(o.error)); |
| 54 | 54 | const number = o.value.number; |
| 55 | 55 | 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 | ||
| 71 | 71 | expect(await screenText(alice)).toContain("cost: $0.30 tokens · 30 lane-min · 1.0 h waiting"); |
| 72 | 72 | const seen = await screenText(bob); |
| 73 | 73 | 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}`); | |
| 74 | 76 | expect(seen).not.toContain("lane-min"); |
| 75 | 77 | }); |
new above
offline