Skip to content
Myr

Merge build/1412-lists-and-people into main

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

authored by oscabriel · committed by oscabriel · parents 059c75c, 2bb32e1 · Browse files · 9 files+316 added−51 removed
This commit

State

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

Diff stats

9 files+316 added−51 removed

  • tests:+209 added−26 removed
  • other:+107 added−25 removed

9 files+316 added−51 removed

modified:apps/web/src/features/landing/projects.ts+7 added-7 removed
modified:apps/web/src/features/shared/shell/overlays.tsx+24 added-11 removed
135 unmodified lines
136 </Combobox>137 );138};139140/** The Projects sheet's body: the switcher, and the way to import a repo at its foot. */141export const ProjectsSheetBody = ({142 input,143 onChosen,144}: {145 readonly input: RefObject<HTMLInputElement | null>;146 readonly onChosen: () => void;147}) => (148 <>149 <ProjectSwitcher input={input} onChosen={onChosen} />150 <div className="border-rule border-t p-1">151 <AppLink className={RAIL_ROW} to={IMPORT_PATH}>152 <FolderInput153 aria-hidden="true"154 className="text-muted-foreground size-4 shrink-0"155 strokeWidth={1.75}156 />157 Import a repo158 </AppLink>159 </div>160 </>161);162163/** The phone's More: Docs, For agents, the project's sections, the keys, the session. */164const More = () => {165 const project = useCurrentProject();166 const listed = useProjectList();
118 unmodified lines
285 initialFocus={filter}286 side={overlay === "projects" && atLeastTablet() ? "left" : "full"}287 title="Projects"288 >266 <ProjectSwitcher input={filter} onChosen={onClose} />267 <div className="border-rule border-t p-1">268 <AppLink className={RAIL_ROW} to={IMPORT_PATH}>269 <FolderInput270 aria-hidden="true"271 className="text-muted-foreground size-4 shrink-0"272 strokeWidth={1.75}273 />274 Import a repo275 </AppLink>276 </div>289 <ProjectsSheetBody input={filter} onChosen={onClose} />290 </SheetContent>291 </Sheet>292 <KeysDialog onClose={onClose} open={overlay === "keys"} />293 </>
4 unmodified lines
modified:apps/web/src/features/shared/shell/rail.tsx+7 added-7 removed
37 unmodified lines
38import { postureLabel, postureWord } from "../../project/posture-label.ts";39import { AppLink } from "../link.tsx";40import { POSTURE_MARKS } from "../mark-look.ts";41import { ASKS_PATH, docsPath, HOME_PATH } from "../paths.ts";42import { leadingProjects, PROJECTS_SHOWN } from "../project-order.ts";43import {44 useCurrentProject,45 useProjectList,46 useShell,
11 unmodified lines
5859/** A row's mark: 16 px at the marks' stroke, muted until the row is current. */60const MARK = "text-muted-foreground size-4 shrink-0";6161/** At most this many projects in the rail; more open the switcher. */62const SHOWN = 8;6362const SITE = [63 { icon: House, label: "Home", to: HOME_PATH },64 { icon: List, label: "Asks", to: ASKS_PATH },65 { icon: CalendarCheck, label: "Today", to: "/today" },
152 unmodified lines
218);219220/**221 * The projects: the current one first, its sections under it, so the list224 * arriving after the page moves nothing above it; then the others, up to225 * eight in all, and the switcher for the rest.222 * arriving after the page moves nothing above it; then the others that223 * lead (the most open asks first, a tie by name), up to eight in all, and224 * the switcher for the rest.225 */226const Projects = () => {227 const current = useCurrentProject();228 const listed = useProjectList();
2 unmodified lines
231 const listingOf = (project: string) =>232 listed?.find((listing) => listing.project === project);233234 const others = (listed ?? []).filter(({ project }) => project !== current);236 const room = SHOWN - (current === undefined ? 0 : 1);235 const room = PROJECTS_SHOWN - (current === undefined ? 0 : 1);236 const leading = leadingProjects(others, room);237238 return (239 <div className="flex flex-col gap-1">240 <h2 className="text-label text-muted-foreground px-2 pt-4 pb-1">
15 unmodified lines
256 )}257 {listed === undefined ? (258 <PlaceholderRows />259 ) : (260 others.slice(0, room).map((listing) => (260 leading.map((listing) => (261 <li key={listing.project}>262 <ProjectRow263 current={false}264 listing={listing}
154 unmodified lines
added:apps/web/src/features/shared/project-order.ts+26 added
added:apps/web/src/routes/$owner/index.tsx+43 added
modified:apps/web/test/landing.test.tsx+16 added-26 removed
12 unmodified lines
13import { ProjectListing } from "@repo/protocol/domain/front-page";14import { Effect, Schema } from "effect";1516import { LandingView } from "../src/features/landing/landing-page.tsx";17import {18 LandingProjects,19 PROJECTS_SHOWN,20} from "../src/features/landing/projects.ts";17import { LandingProjects } from "../src/features/landing/projects.ts";18import { readLandingProjects } from "../src/features/landing/read.ts";19import { LEDE } from "../src/features/landing/words.ts";20import { landingHead } from "../src/routes/index.tsx";21import { EIGHT_LEADING, TEN_LISTED } from "./listings.ts";22import { textIn } from "./markup.ts";23import { platformWith, unreachablePlatform } from "./platform.ts";24import { renderAt } from "./render.tsx";25
173 unmodified lines
199 Contracts.toLayerHandler("listProjects", () => Effect.succeed({ projects }))200 );201202describe("the landing's projects, read on the server", () => {205 const many = Schema.decodeSync(Schema.Array(ProjectListing))(206 Array.from({ length: PROJECTS_SHOWN + 2 }, (_, at) => ({207 openAsks: 1,208 posture: "open",209 project: `oscabriel/project-${at}`,210 }))211 );203 it.effect(204 "names eight, the most open asks first and a tie by name, each by its full name",205 () =>206 Effect.gen(function* () {207 const read = yield* readLandingProjects.pipe(208 Effect.provide(listing(TEN_LISTED))209 );210213 it.effect("names the first eight projects the platform lists", () =>214 Effect.gen(function* () {215 const read = yield* readLandingProjects.pipe(216 Effect.provide(listing(many))217 );218219 expect(220 LandingProjects.match(read, {221 Listed: ({ projects }) => projects.map(({ project }) => project),222 Unreachable: () => [],223 })224 ).toStrictEqual(225 many.slice(0, PROJECTS_SHOWN).map(({ project }) => project)211 expect(212 LandingProjects.match(read, {213 Listed: ({ projects }) => projects.map(({ project }) => project),214 Unreachable: () => [],215 })216 ).toStrictEqual(EIGHT_LEADING);217 })226 );227 })218 );219220 it.effect("says so, and never fails, when the platform did not answer", () =>221 Effect.gen(function* () {
8 unmodified lines
added:apps/web/test/listings.ts+32 added
added:apps/web/test/owner-route.test.ts+88 added
1/**2 * An owner's address alone: `/<handle>` leads to the person's page,3 * `/people/<handle>` in lowercase (handles compare without case), by a 3024 * (a handle may yet become a page of its own); an owner that is no handle,5 * a source host among them, and a word the web keeps for itself are not6 * found. The app's own router reaches the route for `/<handle>` and still7 * reaches its own pages by their words.8 */9import { describe, expect, it } from "@effect/vitest";10import { reservedProjectNames } from "@repo/protocol/ids";11import { isNotFound, isRedirect } from "@tanstack/react-router";12import { Effect } from "effect";1314import { getRouter } from "../src/router.tsx";15import {16 ownerLoader,17 Route as OwnerRoute,18} from "../src/routes/$owner/index.tsx";19import { Route as ImportRoute } from "../src/routes/import.tsx";2021/** What the loader's load came to for `owner`: a redirect, a 404, or neither. */22interface Outcome {23 readonly location?: string | null;24 readonly notFound: boolean;25 readonly status?: number;26}2728/** What the route's loader rejects with for `owner`, as an outcome. */29const outcomeFor = (owner: string) =>30 Effect.tryPromise({31 catch: (thrown): Outcome =>32 isRedirect(thrown)33 ? {34 location: thrown.headers.get("location"),35 notFound: false,36 status: thrown.status,37 }38 : { notFound: isNotFound(thrown) },39 try: () => ownerLoader({ params: { owner } }),40 }).pipe(Effect.flip);4142/** The route the app's own tree finds for `pathname`. */43const routeAt = (pathname: string) => getRouter().getMatchedRoutes(pathname)[2];4445describe("an owner's address alone", () => {46 it.effect(47 "is a 302 to the person's page, in lowercase, when it names a handle",48 () =>49 Effect.gen(function* () {50 const toPerson = {51 location: "/people/oscabriel",52 notFound: false,53 status: 302,54 };5556 expect(yield* outcomeFor("oscabriel")).toStrictEqual(toPerson);57 expect(yield* outcomeFor("OscaBriel")).toStrictEqual(toPerson);58 })59 );6061 it.effect.each(["github.com", "gitlab.com", "not_a.handle"])(62 "%s is not found",63 (owner) =>64 Effect.gen(function* () {65 expect(yield* outcomeFor(owner)).toStrictEqual({ notFound: true });66 })67 );6869 it.effect(70 "is not found for every word the web keeps, never a person's page",71 () =>72 Effect.gen(function* () {73 const outcomes = yield* Effect.forEach(74 [...reservedProjectNames, "Icons"],75 outcomeFor76 );7778 expect(outcomes.filter(({ notFound }) => !notFound)).toStrictEqual([]);79 })80 );81});8283describe("the app's router", () => {84 it("reaches the owner's route for /<handle>, and its own page for /import", () => {85 expect(routeAt("/oscabriel")).toBe(OwnerRoute);86 expect(routeAt("/import")).toBe(ImportRoute);87 });88});
modified:apps/web/test/shell.test.tsx+73 added
23 unmodified lines
24import { AppLink } from "../src/features/shared/link.tsx";25import { projectPath } from "../src/features/shared/paths.ts";26import { RouteError } from "../src/features/shared/pending.tsx";27import { AppShell } from "../src/features/shared/shell/app-shell.tsx";28import { ShellReadsContext } from "../src/features/shared/shell/context.ts";29import { ProjectsSheetBody } from "../src/features/shared/shell/overlays.tsx";30import { RailSlot } from "../src/features/shared/shell/rail-slot.tsx";31import { Workspace } from "../src/features/shared/shell/workspace.tsx";32import { EIGHT_LEADING, TEN_LISTED } from "./listings.ts";33import { renderAt } from "./render.tsx";3435/** The element `tag` whose opening tag carries `attribute`, whole (no nested `tag`). */36const elementOf = (markup: string, tag: string, attribute: string) =>
337 unmodified lines
374 </p>375 );376};377378/** The projects named in `markup`'s rail rows, in order. */379const railProjectsOf = (markup: string) =>380 [381 ...elementOf(markup, "nav", 'aria-label="Site"').matchAll(382 /<a\b[^>]*data-project="(?<project>[^"]+)"/gu383 ),384 ].map(({ groups }) => groups?.project);385386/** The ledger page at `url`, its rail fed the ten listed projects. */387const listedAt = (url: string) =>388 renderAt(389 url,390 <AppShell projects={TEN_LISTED}>391 <Workspace title="Ledger">392 <p>Entries</p>393 </Workspace>394 </AppShell>395 );396397describe("the rail's projects", () => {398 it.effect(399 "are eight, the most open asks first and a tie by name, each by its full name",400 () =>401 Effect.gen(function* () {402 expect(railProjectsOf(yield* listedAt("/agents"))).toStrictEqual(403 EIGHT_LEADING404 );405 })406 );407408 it.effect(409 "pin the current project first, then the seven that lead among the others",410 () =>411 Effect.gen(function* () {412 expect(413 railProjectsOf(yield* listedAt("/oscabriel/yarrow/ledger"))414 ).toStrictEqual(["oscabriel/yarrow", ...EIGHT_LEADING.slice(0, 7)]);415 expect(416 railProjectsOf(yield* listedAt("/oscabriel/datekit/ledger"))417 ).toStrictEqual([418 "oscabriel/datekit",419 ...EIGHT_LEADING.filter((name) => name !== "oscabriel/datekit"),420 ]);421 })422 );423});424425describe("the project switcher", () => {426 it.effect(427 "lists every project by its full name, and ends with the way to import a repo",428 () =>429 Effect.gen(function* () {430 const markup = yield* renderAt(431 "/agents",432 <ShellReadsContext value={{ projects: TEN_LISTED }}>433 <ProjectsSheetBody input={{ current: null }} onChosen={() => {}} />434 </ShellReadsContext>435 );436437 expect(438 TEN_LISTED.filter(({ project }) => !markup.includes(`>${project}<`))439 ).toStrictEqual([]);440 expect(linksOf(markup).at(-1)).toMatchObject({441 href: "/import",442 text: "Import a repo",443 });444 })445 );446});447448describe("a project at its source path", () => {449 it.effect(450 "reaches the project's pages with its owner in one param, and links back to the same address",451 () =>
159 unmodified lines