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

A fork's page lists its last ten follows of upstream: when, how many commits, and whether it merged #16619

Merged opened this

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

Merged

scout/forge:scout/16306-a-fork-s-page-lists-its-last-ten-follows → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/16306-a-fork-s-page-lists-its-last-ten-follows was merged into main as 7d09344.

Review

Sign in to review this change.
8 files changed +362 −6
docs/features/fork-follow-history.md added +24
@@ -0,0 +1,24 @@
1 ---
2 topic: Backups and moving
3 row: A fork's last ten follows of its upstream
4 ---
5 # A fork's last ten follows of its upstream
6
7 A fork's page lists what its last ten follows of the upstream did, newest first, under the following card. Each line is one take.
8
9 - **Merged:** code came in. The line says how many commits it brought.
10 - **Nothing new:** the fork checked and was level.
11 - **Conflicted:** both sides changed the same files. The line links the pull or issue where the crew holds it. When the hold is not recorded, it says: "Which pull or issue holds it is not recorded."
12
13 A fork that has not followed yet says when the next follow is due. A fork that does not follow says that following is off.
14
15 ## Where
16
17 - **Fork's page:** the list under the following card (`src/web/pages/following.ts`, `historyList`).
18 - **Terminal:** the forks screen on a fork shows "Recent follows" under the follow lines (`src/tui/screens/forks.ts`, `historyRows`).
19
20 ## How it is read
21
22 The lines come from stored events, the same ones as the last follow (`docs/features/fork-last-follow.md`): a push marked `followed`, and a `fork.followed` event for a check of nothing new or a conflict (`followHistory` in `src/core/last_follow.ts`). Two pushes marked `followed` that start from the same tip, or end at the same one, are one take recorded twice, and show once.
23
24 The commit count is `git rev-list --count from..to` for a take's range. A range never changes, so each count is read once and kept in memory (up to 1000, `src/actions/follow_history.ts`); a page view reads git only for a range it has not seen. A restart only means each count is read again.
src/actions/follow_history.ts added +75
@@ -0,0 +1,75 @@
1 /**
2 * A fork's last ten follows of its upstream, for the following card: when, how many commits, and
3 * how it went. Builds on the one-line last follow (`core/last_follow.ts`): the same events, more
4 * of them, and a commit count for each take of code. A range never changes, so its count is read
5 * by git once and kept; a page view reads git only for a range it has not seen.
6 */
7
8 import type { App } from "../app.ts";
9 import { followHistory, type FollowEntry } from "../core/last_follow.ts";
10 import { forkFollowMode } from "../core/fork_follow.ts";
11 import type { Repo } from "../core/repos.ts";
12 import { getFollow } from "../core/upstream_follow.ts";
13 import { runGit } from "../git/env.ts";
14 import { repoDir } from "../git/repos.ts";
15 import { FOLLOW_EVERY_MS } from "./upstream_follow.ts";
16
17 export interface FollowRecord extends FollowEntry {
18 /** Commits taken; null when none were or git cannot say. */
19 readonly commits: number | null;
20 }
21
22 export interface FollowHistory {
23 readonly entries: readonly FollowRecord[];
24 /** Said when there are no entries: when the next follow is due, or that following is off. */
25 readonly empty: string;
26 }
27
28 /** The empty state: "off" for a fork that does not follow, else when the clock next checks. */
29 export function emptyWords(off: boolean, checkedAt: string | null | undefined, now: number = Date.now()): string {
30 if (off) return "Following is off: this fork does not follow its upstream.";
31 const last = checkedAt === null || checkedAt === undefined ? Number.NaN : Date.parse(checkedAt);
32 const due = Number.isFinite(last) ? last + FOLLOW_EVERY_MS : now;
33 if (due <= now) return "No follows yet. The next follow is due now.";
34 const minutes = Math.max(1, Math.ceil((due - now) / 60_000));
35 return `No follows yet. The next follow is due in ${minutes} minute${minutes === 1 ? "" : "s"}.`;
36 }
37
38 /**
39 * Counts by repository directory and range, at most `COUNTS_KEPT`; a range's count never changes.
40 */
41 const countsByApp = new WeakMap<App, Map<string, number>>();
42 const COUNTS_KEPT = 1000;
outdated

A git log per entry on every page render (up to ten). Store the commit count when the follow is recorded, or cache by range (a range is immutable). Capped at 1000 silently too: say '1000+' or count with rev-list --count.

43
44 async function commitsIn(app: App, dir: string, from: string, to: string): Promise<number | null> {
45 let counts = countsByApp.get(app);
46 if (counts === undefined) countsByApp.set(app, (counts = new Map()));
47 const key = `${dir}\0${from}..${to}`;
48 const known = counts.get(key);
49 if (known !== undefined) return known;
50 const r = await runGit(["rev-list", "--count", `${from}..${to}`], { cwd: dir });
51 const n = r.ok ? Number.parseInt(r.value.trim(), 10) : Number.NaN;
52 if (!Number.isInteger(n)) return null;
53 if (counts.size >= COUNTS_KEPT) counts.clear();
54 counts.set(key, n);
55 return n;
56 }
57
58 /** The words a follow's line says, for the page and the terminal alike. */
59 export function entryWords(e: FollowRecord): { title: string; note: string } {
60 const title = e.outcome === "merged" ? "Merged" : e.outcome === "conflict" ? "Conflicted" : "Nothing new";
61 if (e.outcome === "merged") return { title, note: e.commits === null ? "" : `${e.commits} commit${e.commits === 1 ? "" : "s"}` };
62 if (e.outcome === "conflict" && e.on === null) return { title, note: "Which pull or issue holds it is not recorded." };
63 return { title, note: "" };
64 }
65
66 export async function followHistoryOf(app: App, repo: Repo, now: number = Date.now()): Promise<FollowHistory> {
67 const dir = repoDir(app.reposRoot, repo.ownerName, repo.name);
68 const entries = await Promise.all(
69 followHistory(app.db, repo.id).map(
70 async (e): Promise<FollowRecord> => ({ ...e, commits: e.range === null ? null : await commitsIn(app, dir, e.range.from, e.range.to) }),
71 ),
72 );
73 const off = forkFollowMode(app.db, repo.id) === "dont-follow";
74 return { entries, empty: emptyWords(off, getFollow(app.db, repo.id)?.checkedAt, now) };
75 }
src/core/last_follow.ts +60
@@ -70,3 +70,63 @@ function parseFollow(at: string, payload: string): LastFollow | null {
7070 : null,
7171 };
7272 }
73
74 /** One line of a fork's follow history: a take of code is `merged`. */
75 export interface FollowEntry {
76 readonly outcome: "merged" | FollowOutcome;
77 readonly at: string;
78 readonly on: LastFollow["on"];
79 /** The fork's default branch before and after, for a take of code; null otherwise. */
80 readonly range: { readonly from: string; readonly to: string } | null;
81 }
82
83 /** How many follows the page lists. */
84 export const HISTORY_LIMIT = 10;
85
86 const OID = /^[0-9a-f]{40}$|^[0-9a-f]{64}$/;
87 const oid = (v: unknown): v is string => typeof v === "string" && OID.test(v);
88
89 /**
90 * The newest follows of a repository, newest first: each `fork.followed` event (nothing new or a
91 * conflict) and each push marked `followed` (code taken). One indexed read of its own events.
92 *
93 * One take is one line. Two pushes marked `followed` that start from the same tip, or end at the
94 * same one, are one take recorded twice (two follows racing to move the same branch); the newer
95 * stands and the older is dropped.
96 */
97 export function followHistory(db: Database, repoId: string, limit = HISTORY_LIMIT): FollowEntry[] {
98 const want = Math.max(1, Math.min(limit, 50));
99 const rows = db
100 .query<{ kind: string; at: string; payload: string }, [string, string, number]>(
101 `SELECT kind, created_at AS at, payload FROM event
102 WHERE repo_id = ?1 AND (kind = ?2 OR (kind = 'push' AND json_extract(payload, '$.followed') IS NOT NULL))
103 ORDER BY seq DESC LIMIT ?3`,
104 )
105 .all(repoId, FOLLOWED_EVENT, want * 3);
106 const out: FollowEntry[] = [];
107 const froms = new Set<string>();
108 const tos = new Set<string>();
109 for (const r of rows) {
110 if (out.length >= want) break;
111 if (r.kind === FOLLOWED_EVENT) {
112 const f = parseFollow(r.at, r.payload);
113 if (f !== null) out.push({ outcome: f.outcome, at: f.at, on: f.on, range: null });
114 continue;
115 }
116 let update: { oldOid?: unknown; newOid?: unknown } | undefined;
117 try {
118 update = (JSON.parse(r.payload) as { updates?: { oldOid?: unknown; newOid?: unknown }[] }).updates?.[0];
119 } catch {
120 continue;
121 }
122 const from = update?.oldOid;
123 const to = update?.newOid;
124 if (oid(from) && oid(to)) {
125 if (froms.has(from) || tos.has(to)) continue;
126 froms.add(from);
127 tos.add(to);
128 out.push({ outcome: "merged", at: r.at, on: null, range: { from, to } });
129 } else out.push({ outcome: "merged", at: r.at, on: null, range: null });
130 }
131 return out;
132 }
src/tui/screens/forks.ts +23 −1
@@ -24,6 +24,7 @@ import {
2424 import { FOLLOW_CHOICES, FOLLOW_PHRASE, FOLLOWS_NOTHING, followChoiceLine, proposeRefusalWords } from "../../actions/follow_words.ts";
2525 import { upstreamCounts } from "../../actions/upstream_counts.ts";
2626 import { FOLLOW_MODE_REFUSALS, convergeWords, followModeOf, followStanding, followWords, lastModeChange, setFollowMode, takeOrTell, takeWords } from "../../actions/follow.ts";
27 import { entryWords, followHistoryOf, type FollowHistory } from "../../actions/follow_history.ts";
2728 import { incomingOf, type Incoming } from "../../actions/follow_incoming.ts";
2829 import { convergeFollowed, followedAs, followedOf } from "../../actions/upstream_sync.ts";
2930 import { crewResolvesWords, setCrewResolving, upstreamLabel } from "../../actions/upstream_follow.ts";
@@ -182,6 +183,25 @@ export function incomingLines(incoming: Incoming | undefined): string[] {
182183 ];
183184 }
184185
186 /** A fork's last ten follows of upstream, one line each: the outcome, then the commits and when. */
187 export function historyRows(history: FollowHistory | undefined, parent: Repo): ForkRow[] {
188 if (history === undefined) return [];
189 if (history.entries.length === 0) return [{ repo: parent, name: ` ${history.empty}`, words: "", heading: "" }];
190 return [
191 { repo: parent, name: " Recent follows", words: "", heading: "" },
192 ...history.entries.map((e) => {
193 const { title, note } = entryWords(e);
194 const held = e.on === null ? "" : `${e.on.kind} #${e.on.number}`;
195 return {
196 repo: parent,
197 name: ` ${title}`,
198 words: [note === "" || e.on !== null ? "" : note, held, agoWords(e.at)].filter((w) => w !== "").join(" · "),
199 heading: "",
200 };
201 }),
202 ];
203 }
204
185205 export function forksScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
186206 let ranked: ForkRanking | undefined;
187207 let tree: ForkNode[] = [];
@@ -198,6 +218,7 @@ export function forksScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
198218 let followed: ReturnType<typeof followedAs> | undefined;
199219 let address: UpstreamFollow | undefined;
200220 let open: Pull | undefined;
221 let history: FollowHistory | undefined;
201222 let mode: ForkFollowMode | undefined;
202223 let undo: { was: ForkFollowMode; at: string } | undefined;
203224 /** The one plain line the page and MCP say: how this fork follows, and when it last took. */
@@ -284,7 +305,8 @@ export function forksScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
284305 failed = getRepoById(f.db, repo.id)?.origin?.fetchError ?? "";
285306 mode = relation === undefined ? undefined : await followModeOf(f.app, repo);
286307 undo = mode === undefined ? undefined : lastModeChange(f.app, repo, mode);
287 following = followingRows(relation, converge, mode, undo);
308 history = relation === undefined ? undefined : await followHistoryOf(f.app, repo);
309 following = [...followingRows(relation, converge, mode, undo), ...(relation === undefined ? [] : historyRows(history, relation.parent))];
288310 const here = forkOffers(f.db, repo, f.user);
289311 const sizes = await offerSizes(f.app, repo, here.map((o) => o.number));
290312 offered = here.map((o) => ({
src/web/pages/following.ts +23 −1
@@ -43,6 +43,7 @@ import { loadRepo, notFoundPage, repoBase, signInFirst } from "../chrome.ts";
4343 import { rejoinableParent, undoableSever } from "../../actions/sever_undo.ts";
4444 import { convergeWords, followModeOf, lastModeChange, takeOrTell, takeWords } from "../../actions/follow.ts";
4545 import { FOLLOW_WORD, FOLLOWS_NOTHING, HIDDEN_FORK_WORD, proposeRefusalWords } from "../../actions/follow_words.ts";
46 import { entryWords, followHistoryOf, type FollowHistory } from "../../actions/follow_history.ts";
4647 import { incomingOf, type Incoming } from "../../actions/follow_incoming.ts";
4748 import { openProposal, proposeUpstream } from "../../actions/upstream.ts";
4849 import { convergeFollowed, followedAs, followedOf } from "../../actions/upstream_sync.ts";
@@ -50,7 +51,7 @@ import { proposesViaFork } from "../../origins/fork-route.ts";
5051 import { field, readForm } from "../form.ts";
5152 import { html, when, type Html } from "../html.ts";
5253 import { flashOrJson } from "../layout.ts";
53 import { badge, btn, icon, row, time, type Tone } from "../ui.ts";
54 import { badge, btn, icon, row, rowList, time, type Tone } from "../ui.ts";
5455 import { disconnectedOn } from "./frozen.ts";
5556
5657 /** The first node (parents before children) the viewer owns and is not looking at. */
@@ -122,6 +123,8 @@ export interface Following {
122123 readonly mode: ForkFollowMode;
123124 /** What an update would bring, newest first and capped; absent when level. */
124125 readonly incoming: Incoming | undefined;
126 /** The last ten follows of the upstream, newest first (`followHistoryOf`). */
127 readonly history: FollowHistory;
125128 }
126129
127130 /** Everything the card needs, for a repo that follows something. */
@@ -155,6 +158,7 @@ export async function followingOf(
155158 releases,
156159 mode: await followModeOf(ctx.app, repo),
157160 incoming: await incomingOf(ctx.app.reposRoot, repo, relation),
161 history: await followHistoryOf(ctx.app, repo),
158162 };
159163 }
160164
@@ -316,6 +320,23 @@ function incomingList(incoming: Incoming): Html {
316320 </ul>`;
317321 }
318322
323 /** The last ten follows: the outcome, then when and how many commits; a conflict links its hold. */
324 export function historyList(history: FollowHistory, base: string): Html {
325 if (history.entries.length === 0)
326 return html`<p class="muted small" data-follow-history-empty>${history.empty}</p>`;
327 return rowList(history.entries.map((e) => {
outdated

Principle 7 and 3: the row title mixes outcome and count with middle-dot text, and a role=region landmark wraps a list that is already a list. Keep the outcome as the title, put the count and time in meta, and drop the region. A conflict with no recorded hold shows nothing; say 'held in the crew's pull is not recorded' in plain words (principle 8).

328 const { title, note } = entryWords(e);
329 const link =
330 e.on === null
331 ? null
332 : html`<a href="${base}/${e.on.kind === "pull" ? "pulls" : "issues"}/${e.on.number}">${e.on.kind} #${e.on.number}</a>`;
333 return row({
334 title: html`<span data-follow-outcome="${e.outcome}">${title}</span>`,
335 meta: html`${time(e.at)} ${link ?? (note === "" ? null : html`<span class="muted">${note}</span>`)}`,
336 });
337 }), { label: "Recent follows of upstream" });
338 }
339
319340 /**
320341 * The card on a fork's home. `studio` swaps nothing but the words for the
321342 * crew's part; the mechanics are one and the same.
@@ -513,6 +534,7 @@ export function followingCard(
513534 <div class="bar"><h2>${head}</h2></div>
514535 <div class="stack">${prose}</div>
515536 ${following.incoming === undefined ? null : incomingList(following.incoming)}
537 ${historyList(following.history, base)}
516538 ${when(
517539 rows.length > 0,
518540 () => html`<ul class="list">
src/web/ui.ts +5 −2
@@ -956,8 +956,11 @@ export function messageText(text: string): Html {
956956 * The one list of rows: in a card (`listCard`), or bare on a settings page, read as lines
957957 * (principle 7), when `bare` is set.
958958 */
959 export function rowList(rows: Html[], o: { bind?: string | undefined; more?: number | undefined; bare?: boolean } = {}): Html {
960 return html`<ul class="list${o.bare === true ? " setting-list" : ""}"${listAttr(o.bind, o.more)}>
959 export function rowList(
960 rows: Html[],
961 o: { bind?: string | undefined; more?: number | undefined; bare?: boolean; label?: string } = {},
962 ): Html {
963 return html`<ul class="list${o.bare === true ? " setting-list" : ""}"${listAttr(o.bind, o.more)}${o.label === undefined ? null : html` aria-label="${o.label}"`}>
961964 ${rows}
962965 </ul>`;
963966 }
test/fork-follow-history.test.ts added +145
@@ -0,0 +1,145 @@
1 /**
2 * A fork's follow history lists its last ten follows of the upstream, newest first: each take of
outdated

This header describes the earlier 'Last took' line, not this list. Rewrite it for the history. Also add a test for the double-merged-line case once fixed, and for the terminal screen.

3 * code (a push marked followed) as Merged with its commit count, each check that found nothing
4 * new, and each conflict with the pull or issue holding it, or a plain line when none is
5 * recorded. One take is one line. Read from stored rows on the page and in the terminal's forks
6 * screen; the count is read from git once per range.
7 */
8 import { afterAll, beforeAll, expect, test } from "bun:test";
9 import { mkdtemp, rm } from "node:fs/promises";
10 import { tmpdir } from "node:os";
11 import { join } from "node:path";
12 import { takeOrTell } from "../src/actions/follow.ts";
13 import { addToCrew, createAgent } from "../src/actions/crew.ts";
14 import { emptyWords, followHistoryOf } from "../src/actions/follow_history.ts";
15 import { FOLLOW_EVERY_MS } from "../src/actions/upstream_follow.ts";
16 import { setForkFollowMode } from "../src/core/fork_follow.ts";
17 import { commitToBranch, createRepo, forkRepo } from "../src/actions/repos.ts";
18 import { createApp, type App } from "../src/app.ts";
19 import { followHistory } from "../src/core/last_follow.ts";
20 import { historyRows } from "../src/tui/screens/forks.ts";
21 import { entryWords } from "../src/actions/follow_history.ts";
22 import { getRepoById, type Repo } from "../src/core/repos.ts";
23 import { createUser, type User } from "../src/core/users.ts";
24 import { serve, type Servers } from "../src/http/server.ts";
25 import { promote } from "./helpers/members.ts";
26
27 let dataDir = "";
28 let app: App;
29 let servers: Servers;
30 let alice: User;
31 let bob: User;
32 let carol: User;
33 let parent: Repo;
34
35 const must = <T>(r: { ok: true; value: T } | { ok: false; error: unknown }): T => {
36 if (!r.ok) throw new Error(JSON.stringify(r.error));
37 return r.value;
38 };
39 const fresh = (r: Repo): Repo => getRepoById(app.db, r.id)!;
40 const commit = async (who: User, repo: Repo, path: string, content: string) =>
41 must(await commitToBranch(app, who, repo, { message: `${who.username}: ${path}`, files: [{ path, content }] }));
42
43 beforeAll(async () => {
44 dataDir = await mkdtemp(join(tmpdir(), "forge-last-follow-"));
45 app = createApp({ dataDir, port: 0 });
46 servers = await serve(app);
47 // One after the other: the first account made is the admin, and a race would pick either.
48 const both: User[] = [];
49 for (const [i, username] of ["alice", "bob", "carol"].entries()) {
50 const made = must(
51 await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@f.dev`, password: "a-good-passphrase", adminIfFirst: i === 0 }),
52 );
53 promote(app.db, made);
54 both.push(made);
55 }
56 alice = both[0]!;
57 bob = both[1]!;
58 carol = both[2]!;
59 parent = must(await createRepo(app, alice, { name: "game", visibility: "public" }));
60 await commit(alice, parent, "README.md", "# game\n");
61 }, 30_000);
62
63 afterAll(async () => {
64 servers.stop();
65 app.close();
66 await rm(dataDir, { recursive: true, force: true });
67 });
68
69
70 test("the empty state says when the next follow is due, or that following is off", async () => {
71 const now = Date.parse("2026-01-01T00:00:00Z");
72 expect(emptyWords(true, null, now)).toMatch(/Following is off/);
73 expect(emptyWords(false, null, now)).toMatch(/due now/);
74 const checked = new Date(now - 10 * 60_000).toISOString();
75 expect(emptyWords(false, checked, now)).toBe(`No follows yet. The next follow is due in ${FOLLOW_EVERY_MS / 60_000 - 10} minutes.`);
76 const fork = must(await forkRepo(app, bob, fresh(parent), "game-empty", { visibility: "public" }));
77 expect((await followHistoryOf(app, fresh(fork))).entries).toEqual([]);
78 expect((await followHistoryOf(app, fresh(fork))).empty).toMatch(/^No follows yet/);
79 setForkFollowMode(app.db, fork.id, "dont-follow");
80 expect((await followHistoryOf(app, fresh(fork))).empty).toMatch(/Following is off/);
81 const page = await (await fetch(`${servers.url}/bob/game-empty`)).text();
82 expect(page).toContain("data-follow-history-empty");
83 });
84
85 test("the last ten follows, newest first: commits taken, outcome, and where a conflict is held", async () => {
86 const fork = must(await forkRepo(app, carol, fresh(parent), "game-hist", { visibility: "public" }));
87 must(await takeOrTell(app, carol, fresh(fork)));
88 await commit(alice, parent, "h1.txt", "1\n");
89 await commit(alice, parent, "h2.txt", "2\n");
90 must(await takeOrTell(app, carol, fresh(fork)));
91 await commit(carol, fork, "README.md", "# carol\n");
92 await commit(alice, parent, "README.md", "# alice\n");
93 must(await createAgent(app, alice, { username: "bot2", brief: "Be brief." }));
94 expect(addToCrew(app, carol, fresh(fork), "bot2").ok).toBe(true);
95 expect((await takeOrTell(app, carol, fresh(fork))).ok).toBe(false);
96
97 const h = await followHistoryOf(app, fresh(fork));
98 expect(h.entries[0]!.outcome).toBe("conflict");
99 expect(h.entries.at(-1)!.outcome).toBe("nothing_new");
100 const merged = h.entries.filter((e) => e.outcome === "merged");
101 expect(merged.length).toBeGreaterThan(0);
102 expect(merged.every((e) => e.commits !== null && e.commits > 0)).toBe(true);
103 expect(Math.max(...merged.map((e) => e.commits!))).toBe(2);
104 expect(h.entries[0]!.on).not.toBeNull();
105 const page = await (await fetch(`${servers.url}/carol/game-hist`)).text();
106 expect(page).toMatch(/data-follow-outcome="conflict"[^>]*>[\s\S]*?Conflicted[\s\S]*?href="\/carol\/game-hist\/(pulls|issues)\/\d+"/);
107 expect(page).toMatch(/data-follow-outcome="merged"[^>]*>Merged<[\s\S]*?\d+ commits?/);
108 expect(page).toMatch(/data-follow-outcome="nothing_new"[^>]*>Nothing new/);
109 expect(page).not.toContain("data-follow-history-empty");
110 expect(page).not.toContain('role="region" aria-label="Recent follows');
111 expect(page).toContain('aria-label="Recent follows of upstream"');
112 // The terminal says the same lines.
113 const lines = historyRows(h, parent).map((r) => `${r.name} ${r.words}`).join("\n");
114 expect(lines).toMatch(/Recent follows[\s\S]*Conflicted[\s\S]*Merged\s+2 commits[\s\S]*Nothing new/);
115
116 // Only ten are kept, the newest ones.
117 for (let i = 0; i < 12; i++) app.bus.append({ kind: "fork.followed", repoId: fork.id, payload: { outcome: "nothing_new" } });
118 const ten = followHistory(app.db, fork.id);
119 expect(ten).toHaveLength(10);
120 expect(ten.every((e) => e.outcome === "nothing_new")).toBe(true);
121 // A payload that is not an outcome is skipped, never drawn.
122 app.bus.append({ kind: "fork.followed", repoId: fork.id, payload: { outcome: "<script>" } });
123 expect(followHistory(app.db, fork.id).every((e) => e.outcome === "nothing_new")).toBe(true);
124 });
125
126
127 test("one take is one line: two pushes marked followed from the same tip are one take", async () => {
128 const fork = must(await createRepo(app, bob, { name: "game-twice", visibility: "public" }));
129 const o = (c: string) => c.repeat(40);
130 const push = (from: string, to: string) =>
131 app.bus.append({ kind: "push", repoId: fork.id, payload: { updates: [{ ref: "refs/heads/main", oldOid: from, newOid: to }], followed: "alice/game" } });
132 push(o("a"), o("b"));
133 push(o("a"), o("c"));
134 push(o("c"), o("d"));
135 const merged = followHistory(app.db, fork.id).filter((e) => e.outcome === "merged");
136 // Newest first: c..d, then a..c; a..b is the same take as a..c, said once.
137 expect(merged.map((e) => `${e.range!.from[0]}${e.range!.to[0]}`)).toEqual(["cd", "ac"]);
138 });
139
140 test("a conflict with no recorded hold says so in plain words", () => {
141 const e = { outcome: "conflict" as const, at: "2026-01-01T00:00:00Z", on: null, range: null, commits: null };
142 expect(entryWords(e).note).toBe("Which pull or issue holds it is not recorded.");
143 expect(entryWords({ ...e, on: { kind: "pull", number: 3 } }).note).toBe("");
144 expect(entryWords({ ...e, outcome: "merged", commits: 1 })).toEqual({ title: "Merged", note: "1 commit" });
145 });
test/tui-forks-offers.test.ts +7 −2
@@ -131,8 +131,13 @@ describe("the forks screen lists the offers a fork sent upstream", () => {
131131 expect(text).toMatch(/sent #2 Took\s+taken/);
132132 expect(text).toMatch(/sent #3 Refused\s+declined/);
133133 // Enter on a sent row opens that pull on the upstream.
134 // Two rows of following precede the sent ones: down to #3, then Enter.
135 terminal.feed("jjj\r");
134 // Rows of following and history precede the sent ones, newest first: five downs reach #2, then
135 // Enter.
136 for (let i = 0; i < 5; i++) {
137 terminal.feed("j");
138 await settleApp(tui);
139 }
140 terminal.feed("\r");
136141 const deadline = Date.now() + 10_000;
137142 for (;;) {
138143 await settleApp(tui);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs