Public: anyone can read this; the crew can change it.
A milestone's card at the front door says how many of its issues have landed and how many remain #15700
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15685-a-milestone-s-card-at-the-front-door-say → main 0 commits fork 2 threads · 2 unresolved
10 files
changed +137
−12
docs/features/milestone-card.md added +18
| @@ -0,0 +1,18 @@ | ||
| 1 | --- | |
| 2 | topic: Your apps | |
| 3 | row: A milestone card says what remains | |
| 4 | --- | |
| 5 | # A milestone's card | |
| 6 | ||
| 7 | A milestone's card on the front door (`/front`) and on an app's page says how far it | |
| 8 | has come: `1 of 3 landed, 2 to go`, with a bar one third full. The words are the | |
| 9 | card's second line; the bar is the same share, named for its milestone. | |
| 10 | ||
| 11 | - The card lists the biggest open milestones with work left, so it never reads | |
| 12 | `no issues yet` or `done <date>`; those two words appear where closed or empty | |
| 13 | milestones are listed: the milestones page and the MCP's milestone answer | |
| 14 | (`words` on each limb). | |
| 15 | - The numbers are the milestones page's own, read once per plan. | |
| 16 | ||
| 17 | Try it: open `/front`, find a milestone with a few child issues, close one, and | |
| 18 | reload: the count and the bar move. |
src/core/milestone_front.ts +16 −1
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | * its plan cache and a worker its own. |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | import type { Limb, Plan } from "./milestones.ts"; | |
| 9 | import type { Limb, Plan, Weight } from "./milestones.ts"; | |
| 10 | 10 | import type { Repo } from "./repos.ts"; |
| 11 | 11 | |
| 12 | 12 | /** How many milestones the front door names. */ |
| @@ -37,3 +37,18 @@ export function biggestOf(repos: readonly Repo[], count: number, planOf: (repo: | ||
| 37 | 37 | estimate: plan.milestone(limb.issue.number)?.estimate ?? "", |
| 38 | 38 | })); |
| 39 | 39 | } |
| 40 | ||
| 41 | /** | |
| 42 | * A milestone's standing in one sentence, the same on the front door and in the MCP's answer: | |
| 43 | * `12 of 20 landed, 8 to go`; `no issues yet`; `done 2026-11-20` for a closed one. | |
| 44 | */ | |
| 45 | export function landedWords(w: Weight, closed: { state: string; closedAt: string | null }): string { | |
| 46 | if (closed.state === "closed") | |
| 47 | return closed.closedAt ? `done ${closed.closedAt.slice(0, 10)}` : "done"; | |
| 48 | if (w.total === 0) return "no issues yet"; | |
| 49 | return `${w.done} of ${w.total} landed, ${Math.max(0, w.total - w.done)} to go`; | |
| 50 | } | |
| 51 | ||
| 52 | /** The share landed, a whole percentage; a milestone with no issues is 0. */ | |
| 53 | export const landedPercent = (w: Weight): number => | |
| 54 | w.total <= 0 ? 0 : Math.round((100 * Math.min(w.done, w.total)) / w.total); |
src/core/milestones.ts +2
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | * from it. |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | import { landedWords } from "./milestone_front.ts"; | |
| 16 | 17 | import { paceOf, type Pace } from "./pace.ts"; |
| 17 | 18 | import type { Database } from "bun:sqlite"; |
| 18 | 19 | import { writeStamp } from "./write_clock.ts"; |
| @@ -663,6 +664,7 @@ export function limbJson(limb: Limb): Record<string, unknown> { | ||
| 663 | 664 | name: limb.name, |
| 664 | 665 | state: limb.issue.state, |
| 665 | 666 | ...weightJson(limb.weight), |
| 667 | words: landedWords(limb.weight, limb.issue), | |
| 666 | 668 | deferred: limb.deferred, |
| 667 | 669 | ...(limb.deferredBecause === undefined |
| 668 | 670 | ? {} |
src/http/mcp/tools/milestones.ts +1 −1
| @@ -3,7 +3,7 @@ import { good, bad, type Tool, APP_ARG, planRepo, isAnswer } from "../shared.ts" | ||
| 3 | 3 | |
| 4 | 4 | export const tool: Tool = { |
| 5 | 5 | name: "milestones", |
| 6 | doc: "`{ app, issue? }`: how far each thing asked for is (and, with `issue`, whether you watch it: `watching`), from the dependency tree: the plan's limbs with their weights, or one milestone opened (who is building, what is blocked and on what, what merged in 7 days, an estimate, `closedPerDay` (14 days) and `paceDate`, and for an owner `spend`: dollars, changes landed ever, the costliest three issues)", | |
| 6 | doc: "`{ app, issue? }`: how far each thing asked for is (and, with `issue`, whether you watch it: `watching`), from the dependency tree: the plan's limbs with their weights and `words` (12 of 20 landed, 8 to go), or one milestone opened (who is building, what is blocked and on what, what merged in 7 days, an estimate, `closedPerDay` (14 days) and `paceDate`, and for an owner `spend`: dollars, changes landed ever, the costliest three issues)", | |
| 7 | 7 | description: |
| 8 | 8 | "How far each ask is. With `app`: top-level limbs, done/total, building, recent merges.", |
| 9 | 9 | inputSchema: { |
src/web/studio/milestone_lines.ts +4 −3
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | * milestone names and paces are the owner's working plan, not product words. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { biggestOf, FRONT_MILESTONES, type Line } from "../../core/milestone_front.ts"; | |
| 11 | import { biggestOf, FRONT_MILESTONES, landedPercent, landedWords, type Line } from "../../core/milestone_front.ts"; | |
| 12 | 12 | import type { Repo } from "../../core/repos.ts"; |
| 13 | 13 | import { PILLAR_DAYS } from "../../core/pillars.ts"; |
| 14 | 14 | import type { Ctx } from "../../http/context.ts"; |
| @@ -16,7 +16,7 @@ import { fragment } from "../layout.ts"; | ||
| 16 | 16 | import { notePhase, takeSessionTime } from "../../core/route_timing.ts"; |
| 17 | 17 | import { loadRepo, repoBase } from "../chrome.ts"; |
| 18 | 18 | import { html, type Html } from "../html.ts"; |
| 19 | import { row } from "../ui.ts"; | |
| 19 | import { meter, row } from "../ui.ts"; | |
| 20 | 20 | import type { User } from "../../core/users.ts"; |
| 21 | 21 | import { milestoneHref, planFor } from "../pages/milestones.ts"; |
| 22 | 22 | import { appReuse } from "./app_cache.ts"; |
| @@ -48,7 +48,7 @@ export function lineFacts(r: Line, scoped: boolean): string { | ||
| 48 | 48 | const w = r.limb.weight; |
| 49 | 49 | return [ |
| 50 | 50 | scoped ? "" : r.repo.name, |
| 51 | `${w.done} of ${w.total} done`, | |
| 51 | landedWords(w, r.limb.issue), | |
| 52 | 52 | w.merged > 0 ? `${w.merged} landed in ${PILLAR_DAYS} days` : "quiet this week", |
| 53 | 53 | r.estimate, |
| 54 | 54 | ] |
| @@ -66,6 +66,7 @@ function lines(rows: readonly Line[], scoped: boolean): Html | null { | ||
| 66 | 66 | href: milestoneHref(repoBase(r.repo), r.limb.issue.number), |
| 67 | 67 | title: r.limb.name, |
| 68 | 68 | meta: html`${lineFacts(r, scoped)}`, |
| 69 | trail: meter(landedPercent(r.limb.weight), `${r.limb.name}: share landed`), | |
outdated
Principle 1: this label repeats the words already in |
||
| 69 | 70 | }), |
| 70 | 71 | )} |
| 71 | 72 | </ul>`; |
test/front-milestones-private.test.ts +1 −1
| @@ -156,5 +156,5 @@ test("the terminal's Milestones screen lists the same: a guest is not offered it | ||
| 156 | 156 | expect(other).not.toContain("Hidden goal"); |
| 157 | 157 | const owner = await screen(alice); |
| 158 | 158 | expect(owner).toContain("Hidden goal"); |
| 159 | expect(owner).toContain("1 of 2 done"); | |
| 159 | expect(owner).toContain("1 of 2 landed, 1 to go"); | |
| 160 | 160 | }); |
test/helpers/ask-issue.ts added +11
| @@ -0,0 +1,11 @@ | ||
| 1 | /** An issue opened for a test: the issue, or a thrown error naming why not. */ | |
| 2 | import { openIssue } from "../../src/actions/issues.ts"; | |
| 3 | import type { App } from "../../src/app.ts"; | |
| 4 | import type { Repo } from "../../src/core/repos.ts"; | |
| 5 | import type { User } from "../../src/core/users.ts"; | |
| 6 | ||
| 7 | export function askIssue(app: App, user: User, repo: Repo, title: string) { | |
| 8 | const opened = openIssue(app, user, repo, { title }); | |
| 9 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 10 | return opened.value; | |
| 11 | } |
test/milestone-front-door.test.ts +4 −1
| @@ -89,7 +89,10 @@ test("the front door and an app's page carry live lines: name, done of total, mo | ||
| 89 | 89 | const text = await get(path); |
| 90 | 90 | expect(text).toContain(`data-live-src="${src}"`); |
| 91 | 91 | expect(text).toContain("Ship the front door"); |
| 92 | expect(text).toContain("1 of 3 done"); | |
| 92 | expect(text).toContain("1 of 3 landed, 2 to go"); | |
| 93 | // The bar is drawn once, one third full, named for its milestone; the words are said once. | |
| 94 | expect(text).toMatch(/<meter[^>]*value="33"[^>]*aria-label="Ship the front door: share landed"/); | |
| 95 | expect(text.split("1 of 3 landed, 2 to go").length).toBe(2); | |
| 93 | 96 | expect(text).toContain("1 landed in 7 days"); |
| 94 | 97 | } |
| 95 | 98 | const live = await get("/live/milestones"); |
test/milestone-landed-words.test.ts added +78
| @@ -0,0 +1,78 @@ | ||
| 1 | /** | |
| 2 | * A milestone card says how many issues landed and how many remain, in the same words everywhere | |
| 3 | * (#15685). | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtempSync, rmSync } from "node:fs"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { linkIssue } from "../src/actions/dependencies.ts"; | |
| 10 | import { createRepo } from "../src/actions/repos.ts"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { landedPercent, landedWords } from "../src/core/milestone_front.ts"; | |
| 13 | import { getIssueById, setIssueState } from "../src/core/issues.ts"; | |
| 14 | import { getRepoById } from "../src/core/repos.ts"; | |
| 15 | import { limbJson, readPlan } from "../src/core/milestones.ts"; | |
| 16 | import { createUser } from "../src/core/users.ts"; | |
| 17 | import { askIssue } from "./helpers/ask-issue.ts"; | |
| 18 | import { quietLogs } from "./helpers/globals.ts"; | |
| 19 | ||
| 20 | quietLogs(); | |
| 21 | ||
| 22 | const w = (done: number, total: number) => ({ total, done, open: total - done, building: 0, merged: 0, last: null }); | |
| 23 | const open = { state: "open", closedAt: null }; | |
| 24 | ||
| 25 | test("the words: counts, none, and done with its date", () => { | |
| 26 | expect(landedWords(w(12, 20), open)).toBe("12 of 20 landed, 8 to go"); | |
| 27 | expect(landedWords(w(0, 0), open)).toBe("no issues yet"); | |
| 28 | expect(landedWords(w(3, 3), { state: "closed", closedAt: "2026-11-20T10:00:00.000Z" })).toBe("done 2026-11-20"); | |
| 29 | expect(landedPercent(w(12, 20))).toBe(60); | |
| 30 | expect(landedPercent(w(0, 0))).toBe(0); | |
| 31 | }); | |
| 32 | ||
| 33 | let root = ""; | |
| 34 | let app: App; | |
| 35 | beforeAll(() => { | |
| 36 | root = mkdtempSync(join(tmpdir(), "forge-landed-")); | |
| 37 | app = createApp({ dataDir: root, port: 0 }); | |
| 38 | }); | |
| 39 | afterAll(() => { | |
| 40 | app.close(); | |
| 41 | rmSync(root, { recursive: true, force: true }); | |
| 42 | }); | |
| 43 | ||
| 44 | test("the MCP's limbs carry the words, and the reads do not grow with the milestones", async () => { | |
| 45 | const u = await createUser(app.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }); | |
| 46 | if (!u.ok) throw new Error("user"); | |
| 47 | const made = await createRepo(app, u.value, { name: "plan", visibility: "public" }); | |
| 48 | if (!made.ok) throw new Error("repo"); | |
| 49 | const repo = made.value; | |
| 50 | const fresh = () => getRepoById(app.db, repo.id)!; | |
| 51 | const mk = (title: string) => askIssue(app, u.value, fresh(), title); | |
| 52 | const queries = (): number => { | |
| 53 | let n = 0; | |
| 54 | const q = app.db.query.bind(app.db); | |
| 55 | (app.db as { query: unknown }).query = (...a: Parameters<typeof q>) => (n++, q(...a)); | |
| 56 | readPlan(app.db, fresh(), { spend: false }).limbs.map(limbJson); | |
| 57 | (app.db as { query: unknown }).query = q; | |
| 58 | return n; | |
| 59 | }; | |
| 60 | const milestone = (name: string, parts: number, closed: number) => { | |
| 61 | const g = mk(name); | |
| 62 | for (let i = 0; i < parts; i++) { | |
| 63 | const p = mk(`${name} ${i}`); | |
| 64 | linkIssue(app, u.value, fresh(), getIssueById(app.db, g.id)!, getIssueById(app.db, p.id)!); | |
| 65 | if (i < closed) setIssueState(app.db, p.id, "closed", "done"); | |
| 66 | } | |
| 67 | return g; | |
| 68 | }; | |
| 69 | milestone("First", 3, 1); | |
| 70 | const one = queries(); | |
| 71 | for (let i = 0; i < 19; i++) milestone(`M${i}`, 2, 1); | |
| 72 | const many = queries(); | |
| 73 | expect(many).toBe(one); | |
| 74 | const plan = readPlan(app.db, fresh(), { spend: false }); | |
| 75 | expect(plan.limbs.length).toBe(20); | |
| 76 | const first = plan.limbs.map(limbJson).find((l) => l["name"] === "First")!; | |
| 77 | expect(first["words"]).toBe("1 of 3 landed, 2 to go"); | |
| 78 | }); |
test/rebase-lane.test.ts +2 −5
| @@ -24,6 +24,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 24 | 24 | import { readConflictLane } from "../src/crew/conflict_room.ts"; |
| 25 | 25 | import { finishFields, ownBuilder } from "../src/crew/finishing.ts"; |
| 26 | 26 | import { serve } from "../src/http/server.ts"; |
| 27 | import { askIssue } from "./helpers/ask-issue.ts"; | |
| 27 | 28 | import { |
| 28 | 29 | conflictedPulls, |
| 29 | 30 | noteWaitingToFinish, |
| @@ -233,11 +234,7 @@ describe("the checks service starts a rebase's check before a newer build's", () | ||
| 233 | 234 | files: [{ path: "forge.json", content: JSON.stringify({ check: { run: `while [ ! -f ${go} ]; do sleep 0.05; done` } }) }], |
| 234 | 235 | }); |
| 235 | 236 | if (!pushed.ok) throw new Error(JSON.stringify(pushed.error)); |
| 236 | const ask = (title: string) => { | |
| 237 | const opened = openIssue(own, made.value, lane, { title }); | |
| 238 | if (!opened.ok) throw new Error(String(opened.error)); | |
| 239 | return opened.value; | |
| 240 | }; | |
| 237 | const ask = (title: string) => askIssue(own, made.value, lane, title); | |
| 241 | 238 | const rebased = ask("rebased"); |
| 242 | 239 | const built = ask("built"); |
| 243 | 240 | createRun(own.db, { repoId: lane.id, kind: "agent", issueId: rebased.id, reason: "conflict" }); |
new above
offline
Over 100 columns; wrap. Also no test asserts the rendered bar.