Skip to content
Myr

Lead the rail and the landing with the projects that have the most open asks, by full name, and send /<handle> to the person's page

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

authored by oscabriel · committed by oscabriel · parent 059c75c · Browse files · 9 files+280 added−46 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+280 added−46 removed

  • tests:+185 added−26 removed
  • other:+95 added−20 removed

9 files+280 added−46 removed

modified:apps/web/src/features/landing/projects.ts+8 added-5 removed
modified:apps/web/src/features/shared/shell/overlays.tsx+25 added-12 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);162140/** The phone's More: Docs, For agents, the project's sections, the keys, the session. */163/** 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();167 const { open } = useShell();
117 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+6 added-3 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 } from "../project-order.ts";43import {44 useCurrentProject,45 useProjectList,46 useShell,
174 unmodified lines
221);222223/**224 * 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.225 * arriving after the page moves nothing above it; then the others that226 * lead (the most open asks first, a tie by name), up to eight in all, and227 * the switcher for the rest.228 */229const Projects = () => {230 const current = useCurrentProject();231 const listed = useProjectList();
3 unmodified lines
235 listed?.find((listing) => listing.project === project);236237 const others = (listed ?? []).filter(({ project }) => project !== current);238 const room = SHOWN - (current === undefined ? 0 : 1);239 const leading = leadingProjects(others, room);240241 return (242 <div className="flex flex-col gap-1">243 <h2 className="text-label text-muted-foreground px-2 pt-4 pb-1">
15 unmodified lines
259 )}260 {listed === undefined ? (261 <PlaceholderRows />262 ) : (260 others.slice(0, room).map((listing) => (263 leading.map((listing) => (264 <li key={listing.project}>265 <ProjectRow266 current={false}267 listing={listing}
154 unmodified lines
added:apps/web/src/features/shared/project-order.ts+23 added
added:apps/web/src/routes/$owner/index.tsx+33 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+64 added
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