Public: anyone can read this; the crew can change it.
Growth is one line the owner can see: open issues, open pulls and opened-vs-closed per day, beside the planner's pause switch #12869
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/12867-growth-is-one-line-the-owner-can-see-ope → main 6 commits fork 4 threads · 4 unresolved
10 files
changed +216
−27
docs/MCP.md +1 −1
| @@ -216,7 +216,7 @@ bytes in `tools/list`. After changing a tool run `bun scripts/mcp-table.ts`; | ||
| 216 | 216 | | `subscription_wake` | — | Admin: wake a resting subscription | 168 | |
| 217 | 217 | | `subscriptions` | — | Claude accounts: scopes, budgets | 158 | |
| 218 | 218 | | `sync` | — | Sync a mirror now; `originId` reconnects it | 197 | |
| 219 | | `system` | `csp`, `routes`, `footing`, `offsite`, `size`, `maintenance` | The forge machine now: CPU, memory, disk, network | 327 | | |
| 219 | | `system` | `csp`, `routes`, `footing`, `offsite`, `size`, `maintenance`, `growth` | The forge machine now: CPU, memory, disk, network | 361 | | |
| 220 | 220 | | `take_back` | — | Open the pull that undoes a shipped pull | 219 | |
| 221 | 221 | | `take_updates` | — | Take the parent forge's updates into a fork | 176 | |
| 222 | 222 | | `teams` | — | Crew teams for person admins: charter, dial (0–100) and member agents | 338 | |
docs/features/growth.md +7
| @@ -18,6 +18,13 @@ heard by the admins. | ||
| 18 | 18 | `GET /api/v1/repos/{owner}/{name}/growth?days=14` answers the same numbers (`days` 1 to 90), whether the planner |
| 19 | 19 | is paused, and what the caller may see. |
| 20 | 20 | |
| 21 | **In one line (#12867).** `/:owner/:name/next` and the terminal's Next up say the same sentence (`growthWords`): | |
| 22 | issues opened and closed this week and how many issues and pulls are open now. The MCP `system` tool with | |
| 23 | `{ kind: "growth", repo }` answers `{openIssues, openPulls, openedToday, closedToday, openedWeek, closedWeek}` | |
| 24 | (today is the UTC day; the week is seven UTC days) from the same read, for a reader of the repository only; a | |
| 25 | guest or a non-reader of a private repository gets a refusal, and sealed issues are left out for anyone who may | |
| 26 | not see them. Today's numbers are in that answer only; the page and terminal show the week. | |
| 27 | ||
| 21 | 28 | Closed-per-day has no index of its own: it walks the repository's rows through the existing `repo_id` index |
| 22 | 29 | (one made the retrospective's plan sort). Opened-per-day uses `issue_repo_created`. |
| 23 | 30 |
docs/features/next-up.md +1 −1
| @@ -17,7 +17,7 @@ | ||
| 17 | 17 | |
| 18 | 18 | **The chapter line (#12681):** under the title, once the repository has chapters, `Ranked for <open chapter>: <progress sentence>` (linked), or "No chapter is open" with a link to draft one; a repository that never drafted a chapter shows no line. The terminal's Next up screen does not show it yet. |
| 19 | 19 | |
| 20 | **The growth line (#12290):** under the title, two `dl` rows: *Week* (issues opened in the last seven days, who opened them, and how many closed: "2 issues opened (2 by owner), 0 closed.") and *Planner* (on, paused until a time in UTC, or paused until the owner switches it on). The owner (a person who administers the repository) also gets the switch in the Planner row: a button in a post form to the same `planner_switch` action as the queue page, sent back to `/next`, so the pause is one tap and the owner stays on the list. A reader sees both rows and no button. Both rows come from one read (`weekLine`), sealed issues left out for a viewer who may not see them. **Terminal:** Next up shows the same sentence (`growthWords`, `pauseSentence`) above the list, and the owner presses `p` to pause the planner until they switch it on, and `p` again to switch it on; for a reader and for an agent the key does nothing. | |
| 20 | **The growth line (#12290):** under the title, two `dl` rows: *Week* (issues opened in the last seven days, who opened them, how many closed, and what is open now: "2 issues opened (2 by owner), 0 closed. 2 open (2 issues, 0 pulls).", #12867: one row, so the numbers are said once) and *Planner* (on, paused until a time in UTC, or paused until the owner switches it on). The owner (a person who administers the repository) also gets the switch in the Planner row: a button in a post form to the same `planner_switch` action as the queue page, sent back to `/next`, so the pause is one tap and the owner stays on the list. A reader sees both rows and no button. Both rows come from one read (`weekLine`, which also counts open issues and pulls and what opened and closed today), sealed issues left out for a viewer who may not see them. **Terminal:** Next up shows the same sentence (`growthWords`, `pauseSentence`) above the list, and the owner presses `p` to pause the planner until they switch it on, and `p` again to switch it on; for a reader and for an agent the key does nothing. | |
| 21 | 21 | |
| 22 | 22 | ## The week is the sprint (#8704) |
| 23 | 23 |
src/core/growth.ts +74 −12
| @@ -14,7 +14,10 @@ import type { sealedScope } from "./sealed.ts"; | ||
| 14 | 14 | /** What `sealedScope` answered for the viewer. */ |
| 15 | 15 | export type Scope = ReturnType<typeof sealedScope>; |
| 16 | 16 | |
| 17 | /** `AND …` leaving out sealed rows the viewer may not see; `a` and `b` are the two parameter numbers it uses. */ | |
| 17 | /** | |
| 18 | * `AND …` leaving out sealed rows the viewer may not see; `a` and `b` are the two parameter | |
| 19 | * numbers it uses. | |
| 20 | */ | |
| 18 | 21 | const visible = (a: number, b: number): string => `AND (i.sealed = 0 OR ?${a} = 1 OR i.author_id = ?${b})`; |
| 19 | 22 | const visibleArgs = (scope: Scope): [number, string] => [scope.sealed === true ? 1 : 0, scope.sealedBy ?? ""]; |
| 20 | 23 | |
| @@ -156,46 +159,73 @@ export function growth(db: Database, repo: { id: string; ownerId: string }, days | ||
| 156 | 159 | return { days: list, open: { issues: openIssues, pulls: openPulls }, perDay, daysQueued, growingRun, sentences, suggest }; |
| 157 | 160 | } |
| 158 | 161 | |
| 159 | /** The week in one read (#12290): issues opened (by who), closed, and when the pause lifts. */ | |
| 162 | /** | |
| 163 | * The week in one read (#12290): issues opened (by who), closed, what is open, and when the pause | |
| 164 | * lifts. | |
| 165 | */ | |
| 160 | 166 | export interface WeekLine { |
| 161 | 167 | readonly opened: number; |
| 162 | 168 | readonly closed: number; |
| 163 | 169 | readonly by: Readonly<Record<Who, number>>; |
| 170 | /** Open issues and open pulls now (#12867). */ | |
| 171 | readonly openIssues: number; | |
| 172 | readonly openPulls: number; | |
| 173 | /** Issues opened and closed since 00:00 UTC today (#12867). */ | |
| 174 | readonly openedToday: number; | |
| 175 | readonly closedToday: number; | |
| 164 | 176 | /** The raw pause time; null when none is set. The caller decides whether it is past. */ |
| 165 | 177 | readonly pause: string | null; |
| 166 | 178 | } |
| 167 | 179 | |
| 168 | 180 | /** |
| 169 | * What the line at the top of /next needs, in one statement: opened by who, closed, and the | |
| 170 | * planner's pause row, joined with UNION ALL, so the page pays one read, not four. | |
| 181 | * What the line at the top of /next needs, in one statement: opened by who, closed, the open | |
| 182 | * counts, opened and closed per UTC day (today is one of them), and the planner's pause row, | |
| 183 | * joined with UNION ALL, so the page pays one read, not four. | |
| 171 | 184 | */ |
| 172 | 185 | export function weekLine(db: Database, repo: { id: string; ownerId: string }, days: number, now: Date, scope: Scope = {}): WeekLine { |
| 173 | 186 | const from = `${windowDays(now, days)[0]}T00:00:00.000Z`; |
| 187 | const today = now.toISOString().slice(0, 10); | |
| 174 | 188 | const [all, mine] = visibleArgs(scope); |
| 175 | 189 | const rows = db |
| 176 | .query<{ t: string; k: string; c: number }, [string, string, string, number, string]>( | |
| 190 | .query<{ t: string; k: string; c: number }, [string, string, string, number, string, string]>( | |
| 177 | 191 | `SELECT 'o' AS t, ${WHO_SQL} AS k, COUNT(*) AS c |
| 178 | 192 | FROM issue i LEFT JOIN repo_crew rc ON rc.repo_id = i.repo_id AND rc.user_id = i.author_id |
| 179 | 193 | WHERE i.repo_id = ?1 AND i.kind = 'issue' AND i.created_at >= ?2 ${visible(4, 5)} GROUP BY k |
| 180 | 194 | UNION ALL |
| 181 | SELECT 'c', '', COUNT(*) FROM issue i | |
| 182 | WHERE i.repo_id = ?1 AND i.kind = 'issue' AND i.closed_at IS NOT NULL AND i.closed_at >= ?2 ${visible(4, 5)} | |
| 195 | SELECT 'c', substr(i.closed_at, 1, 10), COUNT(*) FROM issue i | |
| 196 | WHERE i.repo_id = ?1 AND i.kind = 'issue' AND i.closed_at IS NOT NULL AND i.closed_at >= ?2 ${visible(4, 5)} GROUP BY 2 | |
| 197 | UNION ALL | |
| 198 | SELECT 'd', '', COUNT(*) FROM issue i | |
| 199 | WHERE i.repo_id = ?1 AND i.kind = 'issue' AND i.created_at >= ?6 ${visible(4, 5)} | |
| 200 | UNION ALL | |
| 201 | SELECT 'n', i.kind, COUNT(*) FROM issue i | |
| 202 | WHERE i.repo_id = ?1 AND i.state = 'open' ${visible(4, 5)} GROUP BY i.kind | |
| 183 | 203 | UNION ALL |
| 184 | 204 | SELECT 'p', until, 0 FROM planner_pause WHERE repo_id = ?1 AND ?3 <> '' AND ?2 <> ''`, |
| 185 | 205 | ) |
| 186 | .all(repo.id, from, repo.ownerId, all, mine); | |
| 206 | .all(repo.id, from, repo.ownerId, all, mine, `${today}T00:00:00.000Z`); | |
| 187 | 207 | const by: Record<Who, number> = { owner: 0, people: 0, planner: 0, builders: 0, watchers: 0 }; |
| 188 | 208 | let opened = 0; |
| 189 | 209 | let closed = 0; |
| 210 | let closedToday = 0; | |
| 211 | let openedToday = 0; | |
| 212 | let openIssues = 0; | |
| 213 | let openPulls = 0; | |
| 190 | 214 | let pause: string | null = null; |
| 191 | 215 | for (const r of rows) { |
| 192 | 216 | if (r.t === "o") { |
| 193 | 217 | by[r.k as Who] += r.c; |
| 194 | 218 | opened += r.c; |
| 195 | } else if (r.t === "c") closed = r.c; | |
| 196 | else pause = r.k; | |
| 219 | } else if (r.t === "c") { | |
| 220 | closed += r.c; | |
| 221 | if (r.k === today) closedToday += r.c; | |
| 222 | } else if (r.t === "d") openedToday = r.c; | |
| 223 | else if (r.t === "n") { | |
| 224 | if (r.k === "issue") openIssues = r.c; | |
| 225 | else openPulls = r.c; | |
| 226 | } else pause = r.k; | |
| 197 | 227 | } |
| 198 | return { opened, closed, by, pause }; | |
| 228 | return { opened, closed, by, openIssues, openPulls, openedToday, closedToday, pause }; | |
| 199 | 229 | } |
| 200 | 230 | |
| 201 | 231 | /** The pause as `pausedUntil` reads it: a time already past is no pause. */ |
| @@ -207,7 +237,10 @@ export interface Aged { | ||
| 207 | 237 | readonly openedAt: string; |
| 208 | 238 | } |
| 209 | 239 | |
| 210 | /** The oldest open pull and the oldest open issue no run has started on: what age looks like, honestly. */ | |
| 240 | /** | |
| 241 | * The oldest open pull and the oldest open issue no run has started on: what age looks like, | |
| 242 | * honestly. | |
| 243 | */ | |
| 211 | 244 | export function oldest(db: Database, repoId: string, scope: Scope = {}): { pull: Aged | null; issue: Aged | null } { |
| 212 | 245 | const one = (kind: "issue" | "pull", unstarted: boolean): Aged | null => { |
| 213 | 246 | const r = db |
| @@ -222,3 +255,32 @@ export function oldest(db: Database, repoId: string, scope: Scope = {}): { pull: | ||
| 222 | 255 | }; |
| 223 | 256 | return { pull: one("pull", false), issue: one("issue", true) }; |
| 224 | 257 | } |
| 258 | ||
| 259 | /** | |
| 260 | * The owner's one line (#12867): what is open now, and what opened and closed today and in the | |
| 261 | * last 7 UTC days. | |
| 262 | */ | |
| 263 | export interface Counts { | |
| 264 | readonly openIssues: number; | |
| 265 | readonly openPulls: number; | |
| 266 | readonly openedToday: number; | |
| 267 | readonly closedToday: number; | |
| 268 | readonly openedWeek: number; | |
| 269 | readonly closedWeek: number; | |
| 270 | } | |
| 271 | ||
| 272 | /** The counts from the week's one read: the week window is `weekLine`'s `days`, so ask for 7. */ | |
| 273 | export function countsOf(w: WeekLine): Counts { | |
| 274 | return { | |
| 275 | openIssues: w.openIssues, openPulls: w.openPulls, openedToday: w.openedToday, | |
| 276 | closedToday: w.closedToday, openedWeek: w.opened, closedWeek: w.closed, | |
| 277 | }; | |
| 278 | } | |
| 279 | ||
| 280 | /** | |
| 281 | * The counts for a repository over the last 7 UTC days: one `weekLine` read. Sealed issues the | |
| 282 | * viewer may not see are left out. | |
| 283 | */ | |
| 284 | export function growthCounts(db: Database, repo: { id: string; ownerId: string }, now: Date, scope: Scope = {}): Counts { | |
| 285 | return countsOf(weekLine(db, repo, 7, now, scope)); | |
| 286 | } |
src/http/mcp/tools/system.ts +11 −4
Diff not shown — a line 2,277 characters wide (limit 2,000). +11 −4
View filesrc/web/pages/next_growth.ts +6 −3
| @@ -12,11 +12,14 @@ import { btn } from "../ui.ts"; | ||
| 12 | 12 | |
| 13 | 13 | export const GROWTH_DAYS = 7; |
| 14 | 14 | |
| 15 | /** "This week: 5 issues opened (3 by owner, 2 by planner), 2 closed." Same words in every door. */ | |
| 16 | export function growthWords(w: Pick<WeekLine, "opened" | "closed" | "by">): string { | |
| 15 | /** | |
| 16 | * "This week: 5 issues opened (3 by owner, 2 by planner), 2 closed. 304 open (300 issues, 4 | |
| 17 | * pulls)." Same words in every door (#12867). | |
| 18 | */ | |
| 19 | export function growthWords(w: Pick<WeekLine, "opened" | "closed" | "by" | "openIssues" | "openPulls">): string { | |
| 17 | 20 | const by = WHO.map((x) => ({ x, n: w.by[x] })).filter((y) => y.n > 0); |
| 18 | 21 | const who = by.length === 0 ? "" : ` (${by.map((y) => `${y.n} by ${y.x}`).join(", ")})`; |
| 19 | return `This week: ${w.opened} ${w.opened === 1 ? "issue" : "issues"} opened${who}, ${w.closed} closed.`; | |
| 22 | return `This week: ${w.opened} ${w.opened === 1 ? "issue" : "issues"} opened${who}, ${w.closed} closed. ${w.openIssues + w.openPulls} open (${w.openIssues} ${w.openIssues === 1 ? "issue" : "issues"}, ${w.openPulls} ${w.openPulls === 1 ? "pull" : "pulls"}).`; | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | export function growthLine(w: WeekLine, until: string | null, owner: boolean, base: string, back: string = `${base}/next`): Html { |
outdated
Design principle 1: the Week row above already says what opened and closed this week, and this row says it again. Fold open, opened and closed into one row (and drop the optional counts parameter: make it required). |
test/growth-counts.test.ts added +111
| @@ -0,0 +1,111 @@ | ||
| 1 | /** The owner's one growth line (#12867): the counts, the /next row and the `system` kind. */ | |
| 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 3 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 4 | import { tmpdir } from "node:os"; | |
| 5 | import { join } from "node:path"; | |
| 6 | import { createApp, type App } from "../src/app.ts"; | |
| 7 | import { openIssue } from "../src/actions/issues.ts"; | |
| 8 | import { createRepo } from "../src/actions/repos.ts"; | |
| 9 | import { createSession } from "../src/core/sessions.ts"; | |
| 10 | import { createToken } from "../src/core/tokens.ts"; | |
| 11 | import { createUser, type User } from "../src/core/users.ts"; | |
| 12 | import type { Repo } from "../src/core/repos.ts"; | |
| 13 | import { growthCounts } from "../src/core/growth.ts"; | |
| 14 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 15 | ||
| 16 | let dir: string; | |
| 17 | let app: App; | |
| 18 | let servers: Servers; | |
| 19 | let alice: User; | |
| 20 | let repo: Repo; | |
| 21 | let cookie: string; | |
| 22 | const now = new Date(); | |
| 23 | ||
| 24 | beforeAll(async () => { | |
| 25 | dir = await mkdtemp(join(tmpdir(), "forge-growth-counts-")); | |
| 26 | app = createApp({ dataDir: dir, port: 0 }); | |
| 27 | servers = await serve(app); | |
| 28 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 29 | if (!made.ok) throw new Error(made.error); | |
| 30 | alice = made.value; | |
| 31 | cookie = `forge_session=${createSession(app.db, alice.id).token}`; | |
| 32 | const r = await createRepo(app, alice, { name: "g", visibility: "public" }); | |
| 33 | if (!r.ok) throw new Error(JSON.stringify(r.error)); | |
| 34 | repo = r.value; | |
| 35 | for (const t of ["One", "Two", "Three", "Four"]) if (!openIssue(app, alice, repo, { title: t }).ok) throw new Error("issue"); | |
| 36 | const iso = (d: Date) => d.toISOString(); | |
| 37 | const day = 86_400_000; | |
| 38 | // #1 closed today; #2 opened and closed three days ago; #3 opened ten days ago, still open. | |
| 39 | app.db.query("UPDATE issue SET state='closed', closed_at=?1 WHERE repo_id=?2 AND number=1").run(iso(now), repo.id); | |
| 40 | app.db.query("UPDATE issue SET state='closed', created_at=?1, closed_at=?1 WHERE repo_id=?2 AND number=2").run(iso(new Date(now.getTime() - 3 * day)), repo.id); | |
| 41 | app.db.query("UPDATE issue SET created_at=?1 WHERE repo_id=?2 AND number=3").run(iso(new Date(now.getTime() - 10 * day)), repo.id); | |
| 42 | }); | |
| 43 | ||
| 44 | afterAll(async () => { | |
| 45 | await servers.stop(); | |
| 46 | app.close(); | |
| 47 | await rm(dir, { recursive: true, force: true }); | |
| 48 | }); | |
| 49 | ||
| 50 | test("the counts match a hand count", () => { | |
| 51 | const c = growthCounts(app.db, repo, now); | |
| 52 | // Open: #3 and #4. Opened today: #1, #4. Opened this week: #1, #2, #4. | |
| 53 | // Closed today: #1. Closed this week: #1, #2. | |
| 54 | expect(c).toEqual({ openIssues: 2, openPulls: 0, openedToday: 2, closedToday: 1, openedWeek: 3, closedWeek: 2 }); | |
| 55 | }); | |
| 56 | ||
| 57 | test("/next says it in the Week row, once", async () => { | |
| 58 | const page = await (await fetch(`${servers.url}/alice/g/next`, { headers: { cookie } })).text(); | |
| 59 | expect(page).toContain("<dt>Week</dt><dd>3 issues opened (3 by owner), 2 closed. 2 open (2 issues, 0 pulls).</dd>"); | |
| 60 | expect(page).not.toContain("data-growth-counts"); | |
| 61 | }); | |
| 62 | ||
| 63 | const call = async (bearer: string | null, repoName: string) => { | |
| 64 | const res = await fetch(`${servers.url}/mcp`, { | |
| 65 | method: "POST", | |
| 66 | headers: { "content-type": "application/json", accept: "application/json, text/event-stream", ...(bearer ? { authorization: `Bearer ${bearer}` } : {}) }, | |
| 67 | body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "system", arguments: { kind: "growth", repo: repoName } } }), | |
| 68 | }); | |
| 69 | return res.json() as Promise<any>; | |
| 70 | }; | |
| 71 | ||
| 72 | test("a guest and a non-reader get nothing from kind growth on a private repo", async () => { | |
| 73 | const r = await createRepo(app, alice, { name: "secret", visibility: "private" }); | |
| 74 | if (!r.ok) throw new Error("repo"); | |
| 75 | expect(openIssue(app, alice, r.value, { title: "Hidden" }).ok).toBe(true); | |
| 76 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" }); | |
| 77 | if (!made.ok) throw new Error(made.error); | |
| 78 | const bob = createToken(app.db, made.value.id, "rw", "rw"); | |
| 79 | for (const body of [await call(null, "alice/secret"), await call(bob.token, "alice/secret")]) { | |
| 80 | expect(JSON.stringify(body)).not.toContain("openIssues"); | |
| 81 | expect(body.result?.isError === true || body.error !== undefined).toBe(true); | |
| 82 | } | |
| 83 | // The owner reads it. | |
| 84 | const own = createToken(app.db, alice.id, "rw", "rw"); | |
| 85 | expect(JSON.parse((await call(own.token, "alice/secret")).result.content[0].text).openIssues).toBe(1); | |
| 86 | }); | |
| 87 | ||
| 88 | test("sealed issues are left out for a reader who may not see them", async () => { | |
| 89 | const r = await createRepo(app, alice, { name: "mixed", visibility: "public" }); | |
| 90 | if (!r.ok) throw new Error("repo"); | |
| 91 | for (const t of ["Plain", "Sealed"]) if (!openIssue(app, alice, r.value, { title: t }).ok) throw new Error("issue"); | |
| 92 | app.db.query("UPDATE issue SET sealed=1 WHERE repo_id=?1 AND number=2").run(r.value.id); | |
| 93 | const made = await createUser(app.db, { origin: "seed", trusted: true, username: "carol", email: "[email protected]", password: "a-good-passphrase" }); | |
| 94 | if (!made.ok) throw new Error(made.error); | |
| 95 | const carol = createToken(app.db, made.value.id, "rw", "rw"); | |
| 96 | const seen = JSON.parse((await call(carol.token, "alice/mixed")).result.content[0].text); | |
| 97 | expect(seen).toMatchObject({ openIssues: 1, openedToday: 1, openedWeek: 1 }); | |
| 98 | const own = createToken(app.db, alice.id, "rw", "rw"); | |
| 99 | expect(JSON.parse((await call(own.token, "alice/mixed")).result.content[0].text)).toMatchObject({ openIssues: 2, openedWeek: 2 }); | |
| 100 | }); | |
| 101 | ||
| 102 | test("system kind growth answers the same numbers", async () => { | |
| 103 | const token = createToken(app.db, alice.id, "rw", "rw"); | |
| 104 | const res = await fetch(`${servers.url}/mcp`, { | |
| 105 | method: "POST", | |
| 106 | headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${token.token}` }, | |
| 107 | body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "system", arguments: { kind: "growth", repo: "alice/g" } } }), | |
| 108 | }); | |
| 109 | const body: any = await res.json(); | |
| 110 | expect(JSON.parse(body.result.content[0].text)).toEqual(growthCounts(app.db, repo, new Date())); | |
| 111 | }); |
test/next-growth.test.ts +3 −4
| @@ -48,7 +48,7 @@ const get = async (c?: string) => (await fetch(`${servers.url}/alice/g/next`, { | ||
| 48 | 48 | |
| 49 | 49 | test("the owner sees the growth sentence, the planner on, and the link to pause it", async () => { |
| 50 | 50 | const page = await get(cookie); |
| 51 | expect(page).toContain("<dt>Week</dt><dd>2 issues opened (2 by owner), 0 closed.</dd>"); | |
| 51 | expect(page).toContain("<dt>Week</dt><dd>2 issues opened (2 by owner), 0 closed. 2 open (2 issues, 0 pulls).</dd>"); | |
| 52 | 52 | expect(page).toContain("The planner is on."); |
| 53 | 53 | // The switch is a post form on this page, sent back here, not a link away. |
| 54 | 54 | expect(page).toMatch(/<form method="post" action="\/alice\/g\/queue\/planner" data-planner-form>/); |
| @@ -96,9 +96,8 @@ test("a timed pause says until when, in UTC", async () => { | ||
| 96 | 96 | |
| 97 | 97 | test("the sentence counts closes and names a planner opener", () => { |
| 98 | 98 | const none = { owner: 0, people: 0, planner: 0, builders: 0, watchers: 0 }; |
| 99 | expect(growthWords({ opened: 5, closed: 2, by: { ...none, owner: 3, planner: 2 } })).toBe("This week: 5 issues opened (3 by owner, 2 by planner), 2 closed."); | |
| 100 | expect(growthWords({ opened: 1, closed: 1, by: { ...none, planner: 1 } })).toBe("This week: 1 issue opened (1 by planner), 1 closed."); | |
| 101 | expect(growthWords({ opened: 0, closed: 0, by: none })).toBe("This week: 0 issues opened, 0 closed."); | |
| 99 | expect(growthWords({ opened: 5, closed: 2, openIssues: 300, openPulls: 4, by: { ...none, owner: 3, planner: 2 } })).toBe("This week: 5 issues opened (3 by owner, 2 by planner), 2 closed. 304 open (300 issues, 4 pulls)."); | |
| 100 | expect(growthWords({ opened: 1, closed: 1, openIssues: 1, openPulls: 1, by: { ...none, planner: 1 } })).toBe("This week: 1 issue opened (1 by planner), 1 closed. 2 open (1 issue, 1 pull)."); | |
| 102 | 101 | }); |
| 103 | 102 | |
| 104 | 103 | test("weekLine counts the week's closes and leaves out older ones, in one read", () => { |
test/pages-budget.test.ts +1 −1
| @@ -50,7 +50,7 @@ const DEFAULT = { statements: 60, git: 8 }; | ||
| 50 | 50 | /** Pages that cost more today, with the most they may: lower these, never raise them. */ |
| 51 | 51 | const HEAVIER: Record<string, { statements?: number; git?: number }> = { |
| 52 | 52 | "/:owner/:name/issues/:number": { statements: 70 }, |
| 53 | "/:owner/:name/next": { statements: 65 }, // +1: the growth line, one read for the week and the planner pause (#12290) | |
| 53 | "/:owner/:name/next": { statements: 65 }, // +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867) | |
outdated
The comment above this table says lower these, never raise them. Revert to 65 along with the page budget. |
||
| 54 | 54 | "/:owner/:name/pulls/:number": { statements: 114 }, // +1: the desk hold on the pull, one read of the notes that link it (#12536); +1: whether a repository is the forge's own copy, one read of the source setting for the tell box (#12037); +1: the paused sentence, one read of a queued paused run on the pull (#12010); +1: the header Talk count (#10327); +1: the landing line (#10860); +1: whether a reviewer is seated, read only when Require review is off and the pull would otherwise wait on one; the page loads no crew besides (#11666) |
| 55 | 55 | "/api/v1/asks": { statements: 61 }, // +1: the stopped apps someone asked for, one read of the viewer's archived repositories (#12277) |
| 56 | 56 | "/board": { statements: 72 }, // +1: the forge-copy read for the tell box (#12037); +1: the vitals read the database's growth (#12025); +6: the money line (#510) — one settings read, then the month's and the 30 days' meter, storage and ledger reads; constant in the number of apps |
test/tui-next-growth.test.ts +1 −1
| @@ -71,7 +71,7 @@ afterAll(async () => { | ||
| 71 | 71 | test("the owner sees the line, pauses with p, and switches on with p again", async () => { |
| 72 | 72 | const h = boot(alice); |
| 73 | 73 | await h.toNext(); |
| 74 | expect(h.text()).toContain("This week: 2 issues opened (2 by owner), 0 closed. The planner is on."); | |
| 74 | expect(h.text()).toContain("This week: 2 issues opened (2 by owner), 0 closed. 2 open (2 issues, 0 pulls). The planner is on."); | |
| 75 | 75 | expect(h.text()).toContain("pause planner"); |
| 76 | 76 | await h.press("p"); |
| 77 | 77 | expect(pausedUntil(forge.db, repo.id, new Date())).not.toBeNull(); |
new above
offline
Both doors: nothing in src/tui/ shows these words, and no docs/features/ how-to exists. Add the terminal screen/line using countsWords, and the doc. Also openedToday/closedToday are computed but shown nowhere; either show them or drop them (the box asks for them in the data, so keep them in the MCP answer at least).