Skip to content
Myr

Merge build/1002

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by oscabriel · committed by oscabriel · parents 51f046c, 0f7c1c9 · Browse files · 8 files+377 added−85 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+377 added−85 removed

  • tests:+213 added−1 removed
  • other:+164 added−84 removed

8 files+377 added−85 removed

modified:apps/cli/src/local/why.ts+19 added-7 removed
1/**2 * `<cli> why <path>:<line>`: which landing put a line there, and why. git3 * blame names the commit; the platform's landing record names the ask, the4 * accountable author, every credit and the verdict. A commit the platform5 * did not land is said to be none of its landings, with the trailers its6 * author wrote. A verdict note fetched from the platform rides along, but3 * blame names the commit; the platform's landing record names the ask (the4 * one it answers, or the one an ask's opening opened), the accountable5 * author, every credit and the verdict. A commit the platform did not land6 * is said to be none of its landings, with the trailers its author wrote. A verdict note fetched from the platform rides along, but7 * the landing record is the source.8 */9import { notesRef } from "@repo/git/notes";10import { parseTrailers } from "@repo/git/trailers";
249 unmodified lines
260 ...verdict.lanes.map(({ lane, result }) => `${lane} ${result}`),261 ].join(", "),262});263264const landingRows = (landing: LandingView): readonly Row[] => [265 landing.ask === undefined264/**265 * The ask a landing links: the one it answers ("Ask"), else the one it266 * opened ("Opened": an opening answers nothing), else none.267 */268const askRow = (landing: LandingView): Row => {269 if (landing.ask !== undefined) {270 return { code: true, label: "Ask", value: landing.ask };271 }272273 return landing.opened === undefined274 ? { label: "Ask", value: "none (a decider's own landing)" }267 : { code: true, label: "Ask", value: landing.ask },275 : { code: true, label: "Opened", value: landing.opened };276};277278const landingRows = (landing: LandingView): readonly Row[] => [279 askRow(landing),280 { label: "Author", value: landing.author },281 ...landing.credits.map(({ handle, role }) => ({282 label: role,283 value: handle,
140 unmodified lines
modified:apps/cli/test/local/why.test.ts+42 added
33 unmodified lines
34 Path,35 Ref,36 Runtime,37 Schema,38 Struct,39} from "effect";40import { CliOutput } from "effect/cli";41import { RpcTest } from "effect/rpc";42import { TestConsole } from "effect/testing";
265 unmodified lines
308 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))309 );310311 it.live(312 'names the ask a line\'s landing opened in an "Opened" row, and no ask it answers',313 () =>314 Effect.gen(function* () {315 const { dir } = yield* aRepo;316317 const opening = platform(({ sha }) =>318 Effect.succeed({319 landing: {320 ...Struct.omit(landingOf(sha), ["ask"]),321 opened: AskId.make("format-ordinal"),322 },323 })324 );325326 const agent = yield* run(327 dir,328 ["src/week.ts:3", "--project", "datekit"],329 opening,330 OutputForAgent331 );332333 expect(agent.code).toBe(0);334 expect(agent.out.split("\n")).toStrictEqual(335 expect.arrayContaining(["- Opened: `format-ordinal`"])336 );337 expect(agent.out).not.toContain("- Ask:");338339 const person = yield* run(340 dir,341 ["src/week.ts:3", "--project", "datekit"],342 opening343 );344345 expect(person.code).toBe(0);346 expect(person.out.split("\n").map((line) => line.trim())).toStrictEqual(347 expect.arrayContaining(["Opened: format-ordinal"])348 );349 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))350 );351352 it.live(353 "says a commit the platform did not land is none of its landings, and lists the trailers it carries",354 () =>355 Effect.gen(function* () {356 const { dir, second } = yield* aRepo;
211 unmodified lines
modified:apps/web/e2e/why.e2e.ts+9 added-5 removed
modified:apps/web/src/features/project/landings.tsx+56 added-50 removed
modified:apps/web/src/features/why/range-summary.tsx+58 added-21 removed
1/**2 * One range's line of "why", shared by the server's table and the3 * browser's annotation rows: for a landing, "<subject> · <author> · <n>4 * credits · <verdict>", linking the commit, the ask, its answer and the5 * author; for a commit the project adopted, "<subject> · <author> · before6 * adoption". Then where to go from here: the file before this commit, and3 * browser's annotation rows: for a landing, "<subject> · <ask> answer ·4 * <author> · <n> credits · <verdict>", linking the commit, the ask, its5 * answer and the author (an ask's opening reads "Open ask <ask>" instead,6 * linking the ask alone: it answers nothing); for a commit the project7 * adopted, "<subject> · <author> · before adoption". Then where to go from here: the file before this commit, and8 * the propose form about the range's first line. `LandingDetails` is the9 * whole landing, for the line dialog.10 */11import type { WhyView } from "@repo/protocol/domain/code";
4 unmodified lines
16import { answerPath, askPath } from "../ask/ask-page.tsx";17import { commitHref, shortSha } from "../code/paths.ts";18import { CreditTrailers } from "../shared/credits.tsx";19import { HandleLink } from "../shared/handle.tsx";19import { creditWords, priorHref, proposeHref, verdictWords } from "./rows.ts";20import type { WhyRow } from "./rows.ts";20import {21 askOf,22 creditWords,23 priorHref,24 proposeHref,25 verdictWords,26} from "./rows.ts";27import type { LandingAsk, WhyRow } from "./rows.ts";2829const LINK = "decoration-rule underline hover:decoration-current";3031const ID = "font-mono text-[0.8125rem]";
3 unmodified lines
35 ·36 </span>37);3832/** The ask a landing answers, with its answer's page. */39/** The ask a landing links, as its id linking the ask's page. */40const AskLink = ({41 linked,42 project,43}: {44 readonly linked: LandingAsk;45 readonly project: ProjectName;46}) => (47 <a className={`${ID} ${LINK}`} href={askPath(project, linked.ask)}>48 {linked.ask}49 </a>50);5152/**53 * The ask a landing links: "<ask> answer" for the one it answers, with its54 * answer's page; "Open ask <ask>" for the one it opened, which has none.55 */56const AskLinks = ({34 landing,57 linked,58 project,59}: {37 readonly landing: LandingView;60 readonly linked: LandingAsk;61 readonly project: ProjectName;39}) =>40 landing.ask === undefined ? null : (62}) => {63 const ask = <AskLink linked={linked} project={project} />;6465 return linked.kind === "opened" ? (66 <span>Open ask {ask}</span>67 ) : (68 <>42 <a className={`${ID} ${LINK}`} href={askPath(project, landing.ask)}>43 {landing.ask}44 </a>45 <a className={LINK} href={answerPath(project, landing.ask)}>69 {ask}70 <a className={LINK} href={answerPath(project, linked.ask)}>71 answer72 </a>73 </>74 );75};7677/** "· <author> · before adoption", for a commit the project adopted. */78const Adopted = ({ author }: { readonly author: string }) => (79 <>
3 unmodified lines
83 <span className="text-muted-foreground">before adoption</span>84 </>85);8661/** "· <ask> answer · <author> · <n> credits · <verdict>", for a landing. */87/**88 * "· <ask> answer · <author> · <n> credits · <verdict>" for a landing, or89 * "· Open ask <ask> · …" for an ask's opening.90 */91const Landed = ({92 landing,93 project,94}: {95 readonly landing: LandingView;96 readonly project: ProjectName;97}) => {98 const verdict = Option.getOrUndefined(verdictWords(landing));99 const linked = Option.getOrUndefined(askOf(landing));100101 return (102 <>73 {landing.ask === undefined ? null : (103 {linked === undefined ? null : (104 <>105 {DOT}76 <AskLinks landing={landing} project={project} />106 <AskLinks linked={linked} project={project} />107 </>108 )}109 {DOT}110 <HandleLink handle={landing.author} />
85 unmodified lines
196 readonly landing: LandingView;197 readonly project: ProjectName;198}) => {199 const verdict = verdictWords(landing);200 const linked = Option.getOrUndefined(askOf(landing));201202 return (203 <div className="flex flex-col gap-3 text-sm">204 <dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1">174 {landing.ask === undefined ? null : (205 {linked === undefined ? null : (206 <>176 <dt className={LABEL}>Ask</dt>207 <dt className={LABEL}>208 {linked.kind === "opened" ? "Opened ask" : "Ask"}209 </dt>210 <dd className="flex gap-2">211 {linked.kind === "opened" ? (212 <AskLink linked={linked} project={project} />213 ) : (178 <AskLinks landing={landing} project={project} />214 <AskLinks linked={linked} project={project} />215 )}216 </dd>217 </>218 )}219 <dt className={LABEL}>Author</dt>
30 unmodified lines
modified:apps/web/src/features/why/rows.ts+22 added-1 removed
4 unmodified lines
5 */6import type { CommitView, WhyRange, WhyView } from "@repo/protocol/domain/code";7import type { LandingView } from "@repo/protocol/domain/landing";8import { Outcome } from "@repo/protocol/domain/outcome";9import type { ProjectName } from "@repo/protocol/ids";9import type { AskId, ProjectName } from "@repo/protocol/ids";10import { Option } from "effect";1112import { whyHref } from "../code/paths.ts";13
30 unmodified lines
44/** A range as a reader says it: "line 4", or "lines 1–3". */45export const linesWords = ({ end, start }: WhyRange) =>46 start === end ? `line ${start}` : `lines ${start}–${end}`;4748/**49 * The ask a landing links, and how: the one it answers, or the one it50 * opened (a migrate family's parent). An opening answers nothing, so it51 * has no answer page and its link never reads as an answer.52 */53export type LandingAsk =54 | { readonly kind: "answers"; readonly ask: AskId }55 | { readonly kind: "opened"; readonly ask: AskId };5657/** Which ask `landing` links and how; none for a decider's own landing or an adoption. */58export const askOf = (landing: LandingView): Option.Option<LandingAsk> => {59 if (landing.ask !== undefined) {60 return Option.some({ ask: landing.ask, kind: "answers" });61 }6263 return Option.map(64 Option.fromUndefinedOr(landing.opened),65 (ask): LandingAsk => ({ ask, kind: "opened" })66 );67};6869/** A count of credit as a reader says it. */70export const creditWords = (count: number) =>71 `${count} ${count === 1 ? "credit" : "credits"}`;72
31 unmodified lines
added:apps/web/test/landings.test.tsx+67 added
1/**2 * A project's landings list, rendered to HTML: each landing's subject says3 * what it is and links the ask it answers or the ask it opened; one that4 * did neither reads as what it is.5 */6import { describe, expect, it } from "@effect/vitest";7import type { LandingView } from "@repo/protocol/domain/landing";8import { AskId, LandedSha } from "@repo/protocol/ids";9import { Struct } from "effect";1011import { LandingList } from "../src/features/project/landings.tsx";12import { landing, markupOf, now, plainText } from "./ask-fixtures.ts";1314/** Every `href` in `markup`, in order. */15const hrefsOf = (markup: string) =>16 [...markup.matchAll(/href="(?<href>[^"]*)"/gu)].map(17 (match) => match.groups?.href ?? ""18 );1920/** The markup of the list item for the landing `sha`. */21const itemOf = (markup: string, sha: string) =>22 new RegExp(`<li\\b[^>]*data-landing="${sha}"[^>]*>[\\s\\S]*?</li>`, "u").exec(23 markup24 )?.[0] ?? "";2526/** `landing` without the ask it answers: a decider's own landing. */27const unasked: LandingView = {28 ...Struct.omit(landing, ["ask"]),29 sha: LandedSha.make("e".repeat(40)),30};3132/** An ask's opening: it opened `format-ordinal` and answers nothing. */33const opening: LandingView = {34 ...unasked,35 opened: AskId.make("format-ordinal"),36 sha: LandedSha.make("f".repeat(40)),37};3839const markup = markupOf(40 <LandingList landings={[landing, opening, unasked]} now={now} />41);4243describe("a project's landings list", () => {44 it('reads an opening as "Open ask <id>", linking the ask it opened', () => {45 const item = itemOf(markup, opening.sha);4647 expect(plainText(item)).toContain("Open ask format-ordinal");48 expect(plainText(item)).not.toContain("Landed without an ask");49 expect(hrefsOf(item)).toContain("/datekit/asks/format-ordinal");50 });5152 it("reads a landing that answers an ask as its answer, linking the ask", () => {53 const item = itemOf(markup, landing.sha);5455 expect(plainText(item)).toContain("Answer parse-iso-week");56 expect(hrefsOf(item)).toContain("/datekit/asks/parse-iso-week");57 });5859 it("still reads a landing with neither as landed without an ask, linking none", () => {60 const item = itemOf(markup, unasked.sha);6162 expect(plainText(item)).toContain("Landed without an ask");63 expect(64 hrefsOf(item).filter((href) => href.includes("/asks/"))65 ).toStrictEqual([]);66 });67});
modified:apps/web/test/why.test.tsx+104 added-1 removed
5 unmodified lines
6 * answer, its commit and its people; the browser's drawing is Pierre's7 * (`<diffs-container>`), loaded only there.8 */9import { describe, expect, it } from "@effect/vitest";10import { WhyView } from "@repo/protocol/domain/code";10import { CommitView, WhyView } from "@repo/protocol/domain/code";11import { LandingView } from "@repo/protocol/domain/landing";12import { Outcome } from "@repo/protocol/domain/outcome";13import { LandedSha, ProjectName } from "@repo/protocol/ids";14import { Schema } from "effect";15import type { ReactElement } from "react";16import { renderToStaticMarkup } from "react-dom/server";1718import { LandingDetails } from "../src/features/why/range-summary.tsx";19import { WhyCode } from "../src/features/why/why-code.tsx";20import { WhyLines } from "../src/features/why/why-view.tsx";2122const markupOf = (element: ReactElement) => renderToStaticMarkup(element);
172 unmodified lines
195 ).toContain("binary or too large");196 });197});198199const OPENED = "6".repeat(40);200201/**202 * `src/format.ts` where lines 1–2 came from an ask's opening: a landing203 * with `opened` and no `ask`, so it answers nothing.204 */205const opening = Schema.decodeSync(WhyView)({206 at: AT,207 commits: [208 {209 author: signature("Ines", "2026-10-07T10:00:00.000Z"),210 body: "",211 committer: signature("platform", "2026-10-07T10:00:00.000Z"),212 parents: [LANDED],213 sha: OPENED,214 subject: "Open format-ordinal",215 trailers: [],216 tree: "9".repeat(40),217 },218 ...view.commits.map((commit) => Schema.encodeSync(CommitView)(commit)),219 ],220 landings: [221 ...view.landings.map((landing) => Schema.encodeSync(LandingView)(landing)),222 {223 assisted: [],224 author: "ines-v",225 credits: [{ handle: "ines-v", role: "Signed-off-by" }],226 landedAt: "2026-10-07T10:00:00.000Z",227 opened: "format-ordinal",228 parent: LANDED,229 project: "datekit",230 sha: OPENED,231 },232 ],233 path: "src/format.ts",234 ranges: [235 { end: 1, sha: LANDED, start: 1 },236 { end: 3, sha: OPENED, start: 2 },237 { end: 4, sha: IMPORTED, start: 4 },238 ],239});240241const opened = (242 <WhyLines project={datekit} rev="main" text={TEXT} view={opening} />243);244245describe("the why page's row for an ask's opening", () => {246 it('links the ask it opened and reads "Open ask", with no answer link', () => {247 const row = rowOf(markupOf(opened), "2-3");248249 expect(textOf(row)).toContain("Open ask format-ordinal");250 expect(textOf(row)).toContain("ines-v");251 expect(textOf(row)).toContain("1 credit");252 expect(hrefsOf(row)).toContain("/datekit/asks/format-ordinal");253 expect(254 hrefsOf(row).filter((href) => href.includes("/answers/"))255 ).toStrictEqual([]);256 });257258 it("keeps an answering landing's ask and answer links, and an adopted commit's words", () => {259 const markup = markupOf(opened);260261 expect(hrefsOf(rowOf(markup, "1-1"))).toStrictEqual(262 expect.arrayContaining([263 "/datekit/asks/parse-iso-week",264 "/datekit/answers/parse-iso-week",265 ])266 );267 expect(textOf(rowOf(markup, "1-1"))).not.toContain("Open ask");268 expect(textOf(rowOf(markup, "4-4"))).toContain("before adoption");269 });270});271272/** The line dialog's landing, rendered; nothing for no landing. */273const detailsOf = (landing: LandingView | undefined) =>274 landing === undefined275 ? ""276 : markupOf(<LandingDetails landing={landing} project={datekit} />);277278describe("a line's landing, in the line dialog", () => {279 it("names the ask an opening opened, linking it, and no answer", () => {280 const markup = detailsOf(281 opening.landings.find(({ sha }) => sha === OPENED)282 );283284 expect(textOf(markup)).toContain("Opened ask format-ordinal");285 expect(hrefsOf(markup)).toContain("/datekit/asks/format-ordinal");286 expect(287 hrefsOf(markup).filter((href) => href.includes("/answers/"))288 ).toStrictEqual([]);289 });290291 it("names the ask an answering landing answers, with its answer", () => {292 const markup = detailsOf(view.landings[0]);293294 expect(textOf(markup)).toContain("Ask parse-iso-week");295 expect(textOf(markup)).not.toContain("Opened ask");296 expect(hrefsOf(markup)).toContain("/datekit/answers/parse-iso-week");297 });298});299300describe("the why page's drawing", () => {301 it("draws the file with @pierre/diffs", () => {302 expect(303 markupOf(<WhyCode project={datekit} text={TEXT} view={view} />)
3 unmodified lines