Merge build/landing-ceiling 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 9339e2b, 31f42de · Browse files · 10 files·+231 added−115 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+231 added−115 removed
- tests:+104 added−65 removed
- other:+127 added−50 removed
Provenance
- Commit
1b5d02e- Tree
a92aa44- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
9339e2b- Parent 2
31f42de
10 files changed+231 added−115 removed
modified:apps/web/e2e/landing.e2e.ts+21 added-3 removed
1234234567891021 unmodified lines32333435363738394041424344454647484950515253545537 unmodified lines/** * The landing as a first-time reader meets it in a browser: its first action * takes them to the open asks, and on the narrowest phone it scrolls nothing * sideways and axe finds no serious or critical violation, in either scheme. * The landing as a first-time reader meets it in a browser: the page as * sent names its projects, so a reader with no script sees them; its first * action takes them to the open asks; and on the narrowest phone it scrolls * nothing sideways and axe finds no serious or critical violation, in * either scheme. * `a11y.e2e.ts` checks it with every other page at 1440 and 390 px. * * It runs only against `WEB_URL` (a stage's web origin, or a `vite dev` * with the dev fixtures) and is skipped without it. It only reads, signed21 unmodified lines Option.isNone(web), "WEB_URL is not set: point it at a web's origin to run this check" );
// A seeded stage, or the dev world: a platform with no project yet sends // an empty list, which is a page of its own and not this check's. test("names its projects in the page as sent, before any script runs", ({ page, }) => Effect.runPromise( Effect.gen(function* () { const response = yield* Effect.promise(() => page.request.get(at("/"))); const html = yield* Effect.promise(() => response.text());
expect(response.status()).toBe(200); expect(html).toMatch(/data-project="[^"]+"/u); expect(html).toMatch(/data-posture="[^"]+"/u); }) ));
test("leads to the open asks", ({ page }) => Effect.runPromise( Effect.gen(function* () { yield* Effect.promise(() => page.goto(at("/")));37 unmodified linesmodified:apps/web/src/features/landing/landing-page.tsx+22 added-19 removed
20 unmodified lines21 docsPath,22 HOME_PATH,23 projectPath,24 } from "../shared/paths.ts";25-import { ReadingRows, UnreachableNotice } from "../shared/pending.tsx";25+import { UnreachableNotice } from "../shared/pending.tsx";26+import { PostureBadge } from "../shared/posture.tsx";27 import { LandingProjects } from "./projects.ts";28 import { pushTranscript } from "./transcript.ts";29+import { LEDE, WHAT_IT_IS } from "./words.ts";30 29-/** The README's opening line: what the platform is. */30-const WHAT_IT_IS =31- "A Git platform for the boundary between a project and everyone else.";32-31 /** A link in a plain row (the top, the foot): ink, underlined only on hover. */32 const ROW_LINK = "no-underline hover:underline";33 34 /** The primary action: an ink button that is a link. */6 unmodified lines41 const Code = ({ children }: { readonly children: ReactNode }) => (42 <code className={ID}>{children}</code>43 );44 45+/** The branch's name, as git takes it. */46+const MAIN = "main";47+48+/** The lede, its one branch name set as git takes it. */49+const Lede = () => {50+ const [before, after] = LEDE.split(MAIN);51+52+ return (53+ <>54+ {before}55+ <Code>{MAIN}</Code>56+ {after}57+ </>58+ );59+};60+61 /** One part of the page under its name, parted from the last by a hairline. */62 const Part = ({63 children,64 id,202 unmodified lines267 </figure>268 );269 };270 257-/** The projects on the platform, each with its posture word, or why none shows yet. */271+/** The projects on the platform, each with its posture, or that the list did not come. */272 const Projects = ({ projects }: { readonly projects: LandingProjects }) =>273 LandingProjects.match(projects, {274 Listed: ({ projects: listed }) => (275 <ul className="flex flex-col">8 unmodified lines284 to={projectPath(project)}285 >286 {project}287 </AppLink>274- {/* The word alone, not the posture badge: the badge's marks275- would split into chunks every page preloads, past the276- root's byte ceiling (production-bundle.test.ts). */}277- <span278- className="text-ui text-muted-foreground"279- data-posture={posture}280- >281- {postureLabel(posture)}282- </span>288+ <PostureBadge label={postureLabel(posture)} posture={posture} />289 </li>290 ))}291 </ul>292 ),287- Pending: () => <ReadingRows />,293 Unreachable: () => <UnreachableNotice />,294 });295 296 /** The landing, as everyone reads it. */17 unmodified lines314 <div className="flex flex-col gap-8">315 <div className="flex max-w-[60ch] flex-col gap-3">316 <h1 className="text-headline text-balance">{WHAT_IT_IS}</h1>317 <p className="text-body">313- Everything a project ships is public, its contribution process is314- typed code on <Code>main</Code>, and a push lands only by passing a315- typed gate.318+ <Lede />319 </p>320 </div>321 <div className="flex flex-wrap items-center gap-x-4 gap-y-3">322 <AppLink className={PRIMARY} data-action="asks" to={ASKS_PATH}>75 unmodified linesmodified:apps/web/src/features/landing/projects.ts+8 added-20 removed
1234523456978910141112131714151617182324252627281920212230313233343523243625/** * The landing's projects: the platform's list, as the rail reads it in the * browser after the page is up (the same read, so no second request), and * what the page says while it comes or when it does not. The page is the * same for everyone, so the edge may keep it. * The landing's projects block: the first few on the platform, or that the * list did not come. The read that fills it is `read.ts`'s. */import { ProjectListing } from "@repo/protocol/domain/front-page";import { Schema } from "effect";import { AsyncResult } from "effect/reactivity";
/** The projects the page names; the rest are a step away, at `/asks`. */export const PROJECTS_SHOWN = 8;
/** The projects block: the first few on the platform, still coming, or that the list did not come. *//** The projects block: the first few on the platform, or that the list did not come. */export const LandingProjects = Schema.TaggedUnion({ Listed: { projects: Schema.Array(ProjectListing) }, Pending: {}, Unreachable: {},});
export type LandingProjects = typeof LandingProjects.Type;
/** The list's read, as the block says it. */export const landingProjects = ( read: AsyncResult.AsyncResult< { readonly projects: readonly ProjectListing[] }, unknown >/** The block from a list that came. */export const listedProjects = ( projects: readonly ProjectListing[]): LandingProjects => AsyncResult.match(read, { onFailure: () => LandingProjects.cases.Unreachable.make({}), onInitial: () => LandingProjects.cases.Pending.make({}), onSuccess: ({ value }) => LandingProjects.cases.Listed.make({ projects: value.projects.slice(0, PROJECTS_SHOWN), LandingProjects.cases.Listed.make({ projects: projects.slice(0, PROJECTS_SHOWN), }), });added:apps/web/src/features/landing/read.ts+30 added
123456789101112131415161718192021222324252627282930/** * The landing's read on the server, as nobody, by the route's loader: the * platform's project list, so the page arrives with its projects for every * reader (a crawler and a reader with no script included) and the edge may * keep it. The list ignores the caller, so nobody's read is everyone's. */import { Client } from "@repo/protocol/contracts";import { Effect } from "effect";
import { LandingProjects, listedProjects } from "./projects.ts";
/** * The first few projects, or, when the platform did not answer (a refusal, * or a call that died on the way), the block that says so. It never fails: * the page leads to the asks either way. */export const readLandingProjects: Effect.Effect< LandingProjects, never, Client> = Effect.gen(function* () { const client = yield* Client; const { projects } = yield* client.listProjects({});
return listedProjects(projects);}).pipe( Effect.catchCause(() => Effect.succeed(LandingProjects.cases.Unreachable.make({})) ));added:apps/web/src/features/landing/words.ts+13 added
12345678910111213/** * The landing's two opening sentences, the README's, in a module of their * own: the route's `head` unfurls with the lede, and a route's head is * bundled with the route tree every page loads, so it must pull in no view. */
/** The README's opening line: what the platform is. */export const WHAT_IT_IS = "A Git platform for the boundary between a project and everyone else.";
/** The README's lede, the sentence the page unfurls with when its link is shared. */export const LEDE = "Everything a project ships is public, its contribution process is typed code on main, and a push lands only by passing a typed gate.";modified:apps/web/src/routes/index.tsx+33 added-8 removed
1-import { useAtomValue } from "@effect/atom-react";1 import {2 createFileRoute,3 getRouteApi,4 useRouter,5 } from "@tanstack/react-router";6+import { createServerFn } from "@tanstack/react-start";7 import { env } from "cloudflare:workers";8-import { useEffect } from "react";8+import { Effect, Schema } from "effect";9+import { useEffect, useMemo } from "react";10 10-import { projectsAtom } from "../client/front.ts";11 import { useSignedIn } from "../features/auth/session-slot.tsx";12 import {13 markdownAlternateLink,14 markdownLink,15 } from "../features/front/markdown.ts";16 import { LandingView } from "../features/landing/landing-page.tsx";17-import { landingProjects } from "../features/landing/projects.ts";17+import { LandingProjects } from "../features/landing/projects.ts";18+import { readLandingProjects } from "../features/landing/read.ts";19+import { LEDE } from "../features/landing/words.ts";20 import { pageHead } from "../features/shared/head.ts";21 import { HOME_PATH } from "../features/shared/paths.ts";22 import { branchPage } from "../server/cache-headers.ts";23 import { serverClient } from "../server/client.ts";2 unmodified lines26 // `/`, the landing: the one page drawn outside the shell. It is the same27 // page for every reader, so the edge may keep it; its server GET sends a28 // reader who carries a session to `/home` before the page is drawn, and29 // gives an agent `llms.txt`. A signed-in reader who reaches it by a link28-// is moved on once the browser knows who they are. Its projects are the29-// rail's read, in the browser, so every reader is sent the same page.30+// is moved on once the browser knows who they are. Its projects are read31+// on the server as nobody, so every reader, script or not, is sent the32+// same page with its projects in.33 34 const root = getRouteApi("__root__");35 36 /** Where the page's Markdown is. */37 const MARKDOWN = "/llms.txt";38 39+/**40+ * The projects to read, as nobody (the client without the request, so no41+ * cookie reaches the platform), encoded for the loader to carry. The list42+ * ignores the caller, so nobody's read is everyone's, and the page stays43+ * one the edge may keep.44+ */45+const landingData = createServerFn({ method: "GET" }).handler(() =>46+ Effect.runPromise(47+ readLandingProjects.pipe(48+ Effect.flatMap(Schema.encodeEffect(LandingProjects)),49+ Effect.provide(serverClient(env))50+ )51+ )52+);53+54 /** The landing's headers: kept briefly, varied by `Accept`, its Markdown named. */55 export const landingHeaders = () => ({56 ...branchPage,57 link: markdownLink(MARKDOWN),58 vary: "Accept",59 });60 43-/** The landing's head: its title and its Markdown; it unfurls with the site's own sentence. */61+/** The landing's head: its title, its own sentence to unfurl with, and its Markdown. */62 export const landingHead = () => ({63 ...pageHead({64+ description: LEDE,65 title: "A git platform with a typed gate",66 }),67 links: [markdownAlternateLink(MARKDOWN)],68 });13 unmodified lines82 const Landing = () => {83 useHomeOnceSignedIn();84 const { platformUrl } = root.useLoaderData();85 const { origin } = useRouter();67- const projects = landingProjects(useAtomValue(projectsAtom));86+ const loaded = Route.useLoaderData();87 88+ const projects = useMemo(89+ () => Schema.decodeSync(LandingProjects)(loaded),90+ [loaded]91+ );92+93 return (94 <LandingView95 platformUrl={platformUrl}96 projects={projects}3 unmodified lines100 };101 102 export const Route = createFileRoute("/")({103 staticData: { shell: "bare" },104+ loader: () => landingData(),105 head: landingHead,106 headers: landingHeaders,107 component: Landing,108 server: {8 unmodified linesmodified:apps/web/test/landing.test.tsx+49 added-26 removed
2 unmodified lines3 * way to the open asks before anything else, the install line to copy, the4 * screen `git push` prints when the gate refuses (from the one renderer),5 * the four nouns, the loop, and the projects to read, each with its6 * posture. Drawn in the house style: no banned word, and no rounded,7- * shadowed or gradient surface. Its projects are the rail's read, in the8- * browser, so the page is the same for everyone.7+ * shadowed or gradient surface. Its projects are read on the server as8+ * nobody, so the page is the same for everyone, script or not.9 */10 import { describe, expect, it } from "@effect/vitest";11 import { Brand } from "@repo/brand";12+import { Contracts } from "@repo/protocol/contracts";13 import { ProjectListing } from "@repo/protocol/domain/front-page";14 import { Effect, Schema } from "effect";14-import { AsyncResult } from "effect/reactivity";15 16 import { LandingView } from "../src/features/landing/landing-page.tsx";17 import {18 LandingProjects,19- landingProjects,19 PROJECTS_SHOWN,20 } from "../src/features/landing/projects.ts";21+import { readLandingProjects } from "../src/features/landing/read.ts";22+import { LEDE } from "../src/features/landing/words.ts";23+import { landingHead } from "../src/routes/index.tsx";24 import { textIn } from "./markup.ts";25+import { platformWith, unreachablePlatform } from "./platform.ts";26 import { renderAt } from "./render.tsx";27 28 const PLATFORM = "https://platform.example.workers.dev";29 87 unmodified lines117 );118 expect(markup).toMatch(119 /data-project="burrow"[\s\S]*?data-posture="open"/u120 );121+ // The posture badge, with its mark, not the word alone.122+ expect(123+ markup124+ .slice(markup.indexOf('data-project="datekit"'))125+ .split("</li>")[0]126+ ).toContain("<svg");127 })128 );129 130+ it("unfurls with its own sentence, the README's lede", () => {131+ expect(landingHead().meta).toContainEqual({132+ content: LEDE,133+ name: "description",134+ });135+ });136+137 it.effect(138 "says so when the projects did not come, and still leads to the asks",139 () =>140 Effect.gen(function* () {45 unmodified lines186 })187 );188 });189 174-describe(landingProjects, () => {175- const listing = Schema.decodeSync(Schema.Array(ProjectListing))(190+/** A platform that lists `projects`, and answers nothing else. */191+const listing = (projects: readonly ProjectListing[]) =>192+ platformWith(193+ Contracts.toLayerHandler("listProjects", () => Effect.succeed({ projects }))194+ );195+196+describe("the landing's projects, read on the server", () => {197+ const many = Schema.decodeSync(Schema.Array(ProjectListing))(198 Array.from({ length: PROJECTS_SHOWN + 2 }, (_, at) => ({199 openAsks: 1,200 posture: "open",201 project: `project-${at}`,202 }))203 );204 183- it("names the first eight projects, waits while they come, and says when they did not", () => {184- expect(185- LandingProjects.match(186- landingProjects(AsyncResult.success({ projects: listing })),187- {188- Listed: ({ projects }) => projects.length,189- Pending: () => -1,190- Unreachable: () => -2,191- }192- )193- ).toBe(PROJECTS_SHOWN);194- expect(landingProjects(AsyncResult.initial())._tag).toBe("Pending");195- expect(landingProjects(AsyncResult.fail("down"))._tag).toBe("Unreachable");196- });197-});205+ it.effect("names the first eight projects the platform lists", () =>206+ Effect.gen(function* () {207+ const read = yield* readLandingProjects.pipe(208+ Effect.provide(listing(many))209+ );210 199-describe("the landing while its projects come", () => {200- it.effect("keeps their place, busy, and still leads to the asks", () =>211+ expect(212+ LandingProjects.match(read, {213+ Listed: ({ projects }) => projects.map(({ project }) => project),214+ Unreachable: () => [],215+ })216+ ).toStrictEqual(217+ many.slice(0, PROJECTS_SHOWN).map(({ project }) => project)218+ );219+ })220+ );221+222+ it.effect("says so, and never fails, when the platform did not answer", () =>223 Effect.gen(function* () {202- const markup = yield* pageWith(LandingProjects.cases.Pending.make({}));224+ const read = yield* readLandingProjects.pipe(225+ Effect.provide(unreachablePlatform)226+ );227 204- expect(markup).toContain('aria-busy="true"');205- expect(hrefsOf(markup)).toContain("/asks");228+ expect(read._tag).toBe("Unreachable");229 })230 );231 });modified:apps/web/test/llms.test.ts+15 added-31 removed
8 unmodified lines9 import type { CommandDoc } from "@repo/agent-kit/command-doc";10 import { fullLlms } from "@repo/agent-kit/full-llms";11 import { Brand } from "@repo/brand";12 import { claimForkName, workingForkName } from "@repo/project/repo-names";13-import { Client, Contracts } from "@repo/protocol/contracts";13+import { Contracts } from "@repo/protocol/contracts";14 import type { AskListing } from "@repo/protocol/domain/ask";15 import type { ProjectListing } from "@repo/protocol/domain/front-page";16 import { AskId, Handle, KindName, ProjectName } from "@repo/protocol/ids";17-import { asTester, unanswered } from "@repo/protocol/testing";18-import { Effect, Layer, Option } from "effect";17+import { Effect, Option } from "effect";19-import { RpcTest } from "effect/rpc";18 19 import { commands as catalog } from "../src/features/agents/catalog.ts";20 import {21 frontLlms,10 unmodified lines32 import { landingHead, landingHeaders } from "../src/routes/index.tsx";33 import { llmsFullHandler } from "../src/routes/llms-full[.]txt.ts";34 import { frontPageHandler, landingHandler } from "../src/server/front-page.ts";35 import { projectPageHandler } from "../src/server/project-page.ts";36+import { platformWith, unreachablePlatform } from "./platform.ts";37 38 const platformUrl = "https://platform-test.example.workers.dev";39 40 const webUrl = "https://web-test.example.workers.dev";300 unmodified lines341 });342 343 /** A platform that lists `listed` as its projects, and answers nothing else. */344 const listing = (listed: readonly ProjectListing[]) => () =>346- Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(347- Layer.provide([348- Layer.mergeAll(349- unanswered,350- Contracts.toLayerHandler("listProjects", () =>351- Effect.succeed({ projects: listed })352- )345+ platformWith(346+ Contracts.toLayerHandler("listProjects", () =>347+ Effect.succeed({ projects: listed })348+ )353- ),354- asTester,355- ])349 );350 351 /** A platform that cannot be reached: every call dies on the way. */359-const unreachable = () =>360- Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(361- Layer.provide([unanswered, asTester])362- );352+const unreachable = () => unreachablePlatform;353 354 const getFull = () => new Request(`${webUrl}/llms-full.txt`);355 356 const read = (response: Response) =>83 unmodified lines440 /** A platform that lists `listed` as its projects and `listedAsks` as datekit's asks. */441 const listingWithAsks =442 (listed: readonly ProjectListing[], listedAsks: readonly AskListing[]) =>443 () =>454- Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(455- Layer.provide([456- Layer.mergeAll(457- unanswered,458- Contracts.toLayerHandler("listProjects", () =>459- Effect.succeed({ projects: listed })460- ),461- Contracts.toLayerHandler("listAsks", () =>462- Effect.succeed({ asks: listedAsks })463- )444+ platformWith(445+ Contracts.toLayerHandler("listProjects", () =>446+ Effect.succeed({ projects: listed })447+ ),448+ Contracts.toLayerHandler("listAsks", () =>449+ Effect.succeed({ asks: listedAsks })450+ )464- ),465- asTester,466- ])451 );452 453 /** A request for `path` on the web host, accepting `accept`. */454 const getAt = (path: string, accept: string) =>140 unmodified linesadded:apps/web/test/platform.ts+19 added
1+/**2+ * A platform for a test to read from: the contracts it sets up answer, and3+ * every other dies on the way (`unanswered`), as the tester.4+ */5+import { Client, Contracts } from "@repo/protocol/contracts";6+import { asTester, unanswered } from "@repo/protocol/testing";7+import { Layer } from "effect";8+import { RpcTest } from "effect/rpc";9+10+/** A platform that answers only the contracts in `handlers`, each a `Contracts.toLayerHandler` layer. */11+export const platformWith = (12+ ...handlers: readonly Layer.Layer<never>[]13+): Layer.Layer<Client> =>14+ Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(15+ Layer.provide([Layer.mergeAll(unanswered, ...handlers), asTester])16+ );17+18+/** A platform that cannot be reached: every call dies on the way. */19+export const unreachablePlatform: Layer.Layer<Client> = platformWith();modified:apps/web/test/production-bundle.test.ts+21 added-8 removed
59 unmodified lines60 ] as const;61 62 /**63 * The most the chunks every page preloads (the root route's) may weigh,64- * gzipped: about 10% above what they weighed (222,169 bytes in 19 chunks)65- * once the Markdown renderer and the views it came with left them (322,04966- * in 31 before).64+ * gzipped: about 10% above what they weighed (244,172 bytes in 47 chunks)65+ * once the landing read its projects on the server (243,991 before; 222,16966+ * in 19 chunks when the Markdown renderer left them, 322,049 in 31 before67+ * that). Raised on the user's sign-off, 2026-10-10. A route's `head`,68+ * `loader` and server functions ride in the route tree every page loads,69+ * so what they import counts here; its view does not, and the landing's70+ * must not: the next case holds it out.71 */68-const ROOT_PRELOADS_GZIP = 244_000;72+const ROOT_PRELOADS_GZIP = 268_000;73 74 /** A Shiki grammar module, by its name. */75 const GRAMMAR = /node_modules\/@shikijs\/langs\/dist\/(?<name>[\w-]+)\.mjs$/u;76 325 unmodified lines402 ),403 missing: preloads.filter(404 (chunk) => !output.texts.has(`client${chunk}`)405 ),402- underCeiling: total <= ROOT_PRELOADS_GZIP,403- }).toStrictEqual({ markdown: [], missing: [], underCeiling: true });406+ }).toStrictEqual({ markdown: [], missing: [] });407+ // The weight itself, so a failure says how far over it is.408+ expect(409+ total,410+ `${preloads.length} root preloads, gzipped`411+ ).toBeLessThanOrEqual(ROOT_PRELOADS_GZIP);412 })413 );414 415 it.effect(408- "preloads on every page no grammar and nothing of the server's highlighting",416+ "preloads on every page no grammar, nothing of the server's highlighting, and not the landing's view",417 () =>418 Effect.gen(function* () {419 const output = yield* Built;420 421+ // Nor the landing's view: a route's head or loader that imported422+ // it would carry the whole page into every page's preloads.423 expect(424 rootPreloads(output).flatMap((chunk) =>425 (output.holding.get(`client${chunk}`) ?? []).filter(416- (module) => GRAMMAR.test(module) || module.includes("prerender")426+ (module) =>427+ GRAMMAR.test(module) ||428+ module.includes("prerender") ||429+ module.endsWith("features/landing/landing-page.tsx")430 )431 )432 ).toStrictEqual([]);433 60 unmodified lines