Skip to content
Myr

Say a project's posture only from its own ledger, and show that the front toolbar scrolls

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

- The project home passed `ledger?.posture ?? "open"`, so a project whose ledger read failed or had not arrived read "Open" in its project line and Posture block, a sealed one included. `homeListing` gives the posture only from the project's own ledger; until then the line shows no badge and the inspector a sized Posture skeleton. The route and the test harness both build the listing through it. - Below the shell width the front page's filter strip cut "Any" mid-word under a hidden scrollbar; it now fades its last 2 rem and pads its end, so the filters past the edge read as more and the last one scrolls clear of the fade. - The filter's `Option` component, which shadowed effect's `Option` by name, is `FilterOption`; one `plural` replaces three copies. - Test added: "says no posture while its own ledger is unread, never one it was not told" (red by assertion before the fix).

authored by oscabriel · committed by oscabriel · parent 99bce97 · Browse files · 5 files+120 added−50 removed
This commit

State

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

Diff stats

5 files+120 added−50 removed

  • tests:+24 added−4 removed
  • other:+96 added−46 removed

5 files+120 added−50 removed

modified:apps/web/src/features/front/facts.tsx+2 added-1 removed
89 unmodified lines
90 <ForAgents href="/llms.txt" />91 </FactBlock>92);9394/** A count and its noun: "1 open ask", "7 open asks". */94const plural = (count: number, one: string, many: string) =>95export const plural = (count: number, one: string, many: string) =>96 `${count} ${count === 1 ? one : many}`;9798/** Every project the platform lists, its posture and its open asks; bars until the list arrives. */99export const ProjectsFacts = ({
162 unmodified lines
modified:apps/web/src/features/front/front-page.tsx+13 added-11 removed
34 unmodified lines
35import { projectPath } from "../shared/paths.ts";36import { PostureBadge } from "../shared/posture.tsx";37import { AskRow, RowGroup, useRowSelection } from "../shared/row.tsx";38import { Workspace } from "../shared/shell/workspace.tsx";39import { ProjectsFacts, SelectedAskFacts, StartHere } from "./facts.tsx";39import {40 ProjectsFacts,41 SelectedAskFacts,42 StartHere,43 plural,44} from "./facts.tsx";45import { arrange, finaleOf } from "./families.ts";46import type { Arranged } from "./families.ts";47import { countWith, filterEntries, frontPath } from "./filter.ts";48import type { FrontFilter, FrontFilterInput } from "./filter.ts";49import { EXPLAINER } from "./head.ts";5046const plural = (count: number, one: string, many: string) =>47 `${count} ${count === 1 ? one : many}`;4851/** The list's count, as the context bar says it: "10 open asks, 8 open to take". */52export const frontCount = (shown: readonly FrontPageEntry[]) =>53 `${plural(shown.length, "open ask", "open asks")}, ${54 shown.filter(({ takeable }) => takeable).length
28 unmodified lines
83 return [...groups];84};8586/** One option of a filter: its words and its count, the current one marked. */85const Option = ({87const FilterOption = ({88 count,89 current,90 label,91 search,
116 unmodified lines
208 return (209 <>210 <nav211 aria-label="Filter the asks"210 className="flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-6 overflow-x-auto overscroll-x-contain"212 className="max-shell:pr-8 max-shell:[mask-image:linear-gradient(to_right,#000_calc(100%-2rem),transparent)] flex min-w-0 flex-1 [scrollbar-width:none] items-center gap-6 overflow-x-auto overscroll-x-contain"213 >214 <Segment label="Kind">213 <Option215 <FilterOption216 count={countWith(entries, filter, { kind: undefined })}217 current={filter.kind === undefined}218 label="All"219 search={{ ...filter, kind: undefined }}220 />221 {kindsOf(entries, filter).map((kind: KindName) => (220 <Option222 <FilterOption223 count={countWith(entries, filter, { kind })}224 current={filter.kind === kind}225 key={kind}226 label={kind}
2 unmodified lines
229 ))}230 </Segment>231 <span aria-hidden="true" className="bg-rule h-4 w-px shrink-0" />232 <Segment label="Who may take it">231 <Option233 <FilterOption234 count={countWith(entries, filter, {235 reserved: undefined,236 take: undefined,237 })}238 current={filter.take === undefined && filter.reserved === undefined}239 label="Any"240 search={{ ...filter, reserved: undefined, take: undefined }}241 />240 <Option242 <FilterOption243 count={countWith(entries, filter, {244 reserved: undefined,245 take: "open",246 })}
1 unmodified line
248 label="Open to take"249 search={{ ...filter, reserved: undefined, take: "open" }}250 />251 {held.map((reserved) => (250 <Option252 <FilterOption253 count={countWith(entries, filter, { reserved, take: undefined })}254 current={filter.reserved === reserved}255 key={reserved}256 label={reserveWords[reserved]}
295 unmodified lines
modified:apps/web/src/features/project/project-page.tsx+79 added-29 removed
15 unmodified lines
16import type { LandingView } from "@repo/protocol/domain/landing";17import { LedgerEntry } from "@repo/protocol/domain/visibility";18import type { Ledger } from "@repo/protocol/domain/visibility";19import type { AreaName, AskId, Handle, ProjectName } from "@repo/protocol/ids";20import type { Posture } from "@repo/protocol/posture";21import { useRouter } from "@tanstack/react-router";22import { Option, Predicate } from "effect";23import type { DateTime } from "effect";24import type { ReactNode } from "react";2525import { SelectedAskFacts, Onward, ForAgents, Step } from "../front/facts.tsx";26import {27 ForAgents,28 Onward,29 SelectedAskFacts,30 Step,31 plural,32} from "../front/facts.tsx";33import { finaleOf } from "../front/families.ts";34import { ledeOf } from "../front/head.ts";35import { ProposeLink } from "../propose/propose-link.tsx";36import type { AskProgress } from "../shared/ask-progress.ts";
8 unmodified lines
45import { ReadingRows, UnreachableNotice } from "../shared/pending.tsx";46import { PostureBadge } from "../shared/posture.tsx";47import { MetaCode, useRowSelection } from "../shared/row.tsx";48import { Workspace } from "../shared/shell/workspace.tsx";49import { FactsSkeleton } from "../shared/skeleton.tsx";50import { When } from "../shared/time.tsx";51import { AskList, askListIds, openAsks, openToTake } from "./asks.tsx";52import { LandingList, recentShown } from "./landings.tsx";53import { postureLabel } from "./posture-label.ts";
51 unmodified lines
105 detail: `${count} sealed ${count === 1 ? "check" : "checks"}`,106 }));107};108109/**110 * The project as its home knows it: its name, its open asks, when it last111 * landed, and its posture once its own ledger has said it. Until then the112 * page says no posture, never one it was not told.113 */114export type HomeListing = Omit<ProjectListing, "posture"> & {115 readonly posture?: Posture | undefined;116};117118/** The project for its home, from what was read: the posture only from its own ledger. */119export const homeListing = ({120 asks,121 ledger,122 project,123}: {124 readonly asks: readonly AskListing[] | undefined;125 readonly ledger: Ledger | undefined;126 readonly project: ProjectName;127}): HomeListing => ({128 openAsks: asks?.length ?? 0,129 posture: ledger?.posture,130 project,131});132133/** A posture known, in the platform's words. */134interface KnownPosture {135 readonly label: string;136 readonly posture: Posture;137}138139export interface ProjectViewProps {140 /** The open asks; none while they are read, and none when they could not be. */141 readonly asks: readonly AskListing[] | undefined;142 /** Whether the asks could not be read: the platform did not answer. */143 readonly unreachable?: boolean;144 /** The project's landings, newest first. */145 readonly landings: readonly LandingView[];108 /** The project: its posture, when it last landed, its open asks. */109 readonly listing: ProjectListing;146 /** The project: its posture (once its ledger is read), when it last landed, its open asks. */147 readonly listing: HomeListing;148 /** When it last landed, as its events say, over what the listing says. */149 readonly lastLanded?: DateTime.Utc | undefined;150 /** Its posture in the platform's words, from its own ledger. */151 readonly postureLabel?: string | undefined;
16 unmodified lines
168 /** Whether someone is signed in, who may propose an ask. */169 readonly signedIn?: boolean;170}171134const plural = (count: number, one: string, many: string) =>135 `${count} ${count === 1 ? one : many}`;136172/** Who decides, one line per set of paths, at most three, then the policy. */173const WhoDecides = ({174 deciders,175 project,
73 unmodified lines
249 platformUrl,250}: {251 readonly landedAt: DateTime.Utc | undefined;252 readonly landings: readonly LandingView[];218 readonly listing: ProjectListing;253 readonly listing: HomeListing;254 readonly now: DateTime.Utc;255 readonly platformUrl: string;256}) => {257 let shown: ReactNode;
26 unmodified lines
284/** How a change lands here: the facts with nothing selected. */285const HowItLands = ({286 deciders,287 heldBack,253 label,288 landedAt,289 landings,290 listing,291 now,292 platformUrl,293 posture,294}: Pick<295 ProjectViewProps,296 "deciders" | "heldBack" | "landings" | "listing" | "now" | "platformUrl"297> & {263 readonly label: string;298 readonly posture: KnownPosture | undefined;299 readonly landedAt: DateTime.Utc | undefined;300}) => (301 <>302 {posture === undefined ? (303 <FactsSkeleton labels={["Posture"]} />304 ) : (267 <PostureFacts268 label={label}269 posture={listing.posture}270 project={listing.project}271 />305 <PostureFacts306 label={posture.label}307 posture={posture.posture}308 project={listing.project}309 />310 )}311 <GateFacts />312 <WhoDecides deciders={deciders} project={listing.project} />313 {heldBack === undefined ? null : <HeldBackFacts areas={heldBack} />}314 <TakePart platformUrl={platformUrl} project={listing.project} />
10 unmodified lines
325326/** The project line: its posture, its open asks, when it last landed; then its README's first sentence. */327const ProjectLine = ({328 count,290 label,329 landedAt,330 lede,293 listing,331 now,332 posture,333}: {334 readonly count: number;297 readonly label: string;335 readonly posture: KnownPosture | undefined;336 readonly landedAt: DateTime.Utc | undefined;337 readonly lede: string | undefined;300 readonly listing: ProjectListing;338 readonly now: DateTime.Utc;339}) => (340 <div className="flex flex-col gap-3">341 <p className="text-ui text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-1">342 {posture === undefined ? null : (343 <>305 <PostureBadge label={label} posture={listing.posture} />306 <span aria-hidden="true">·</span>344 <PostureBadge label={posture.label} posture={posture.posture} />345 <span aria-hidden="true">·</span>346 </>347 )}348 <span className="tabular-nums">349 {plural(count, "open ask", "open asks")}350 </span>351 <span aria-hidden="true">·</span>
77 unmodified lines
429};430431/** Whichever facts the inspector shows: how a change lands here, or the selected ask's. */432const PageFacts = ({392 label,433 landedAt,434 picked,435 posture,436 props,437 states,438}: {439 readonly props: ProjectViewProps;440 readonly picked: AskListing | undefined;400 readonly label: string;441 readonly posture: KnownPosture | undefined;442 readonly landedAt: DateTime.Utc | undefined;443 readonly states: ReadonlyMap<AskId, AskProgress>;444}) => {445 const { listing, parents = [], platformUrl, selectedAsk } = props;
2 unmodified lines
448 return (449 <HowItLands450 deciders={props.deciders}451 heldBack={props.heldBack}411 label={label}452 landedAt={landedAt}453 landings={props.landings}454 listing={listing}455 now={props.now}456 platformUrl={platformUrl}457 posture={posture}458 />459 );460 }461
10 unmodified lines
472 }473 full={selectedAsk?.id === picked.ask ? selectedAsk : undefined}474 listing={picked}475 platformUrl={platformUrl}435 posture={{ label, posture: listing.posture }}476 posture={posture}477 progress={states.get(picked.ask)}478 project={listing.project}479 takeable={openToTake(picked)}480 />
18 unmodified lines
499}) => {500 const { asks, code, listing } = props;501 const states = props.states ?? new Map<AskId, AskProgress>();502 const { project } = listing;462 const label = props.postureLabel ?? postureLabel(listing.posture);503504 const posture = Option.getOrUndefined(505 Option.map(506 Option.fromUndefinedOr(listing.posture),507 (known): KnownPosture => ({508 label: props.postureLabel ?? postureLabel(known),509 posture: known,510 })511 )512 );513514 const landedAt = props.lastLanded ?? listing.landedAt;515 const open = Option.map(Option.fromUndefinedOr(asks), openAsks);516 const text = code?.readme?.text;517
5 unmodified lines
523 })}524 crumbs={[{ label: project, to: `/${project}` }, { label: "Asks" }]}525 facts={526 <PageFacts476 label={label}527 landedAt={landedAt}528 picked={asks?.find(({ ask }) => ask === selected)}529 posture={posture}530 props={props}531 states={states}532 />533 }
5 unmodified lines
539 {...Option.match(Option.fromUndefinedOr(selected), {540 onNone: () => ({}),541 onSome: (factsKey) => ({ factsKey }),542 })}492 factsSummary={label}543 factsSummary={posture?.label ?? "Posture, gate, who decides, take part"}544 status={545 <ProjectLine546 count={Option.match(open, {547 onNone: () => listing.openAsks,548 onSome: (each) => each.length,549 })}499 label={label}550 landedAt={landedAt}551 lede={Predicate.isString(text) ? ledeOf(text) : undefined}502 listing={listing}552 now={props.now}553 posture={posture}554 />555 }556 title={project}557 variant="list"
40 unmodified lines
modified:apps/web/src/routes/$project/index.tsx+2 added-5 removed
33 unmodified lines
34import { useStamps } from "../../features/front/stamps.ts";35import {36 ProjectView,37 heldBackOf,38 homeListing,39} from "../../features/project/project-page.tsx";40import { UnknownProjectView } from "../../features/project/unknown-project.tsx";41import { askStates } from "../../features/shared/ask-progress.ts";42import { pageHead } from "../../features/shared/head.ts";
164 unmodified lines
207 deciders={deciders}208 heldBack={ledger === undefined ? undefined : heldBackOf(ledger)}209 landings={landings}210 lastLanded={latest?.landedAt}210 listing={{211 openAsks: asks?.length ?? 0,212 posture: ledger?.posture ?? "open",213 project,214 }}211 listing={homeListing({ asks, ledger, project })}212 now={data.now}213 parents={data.parents}214 platformUrl={platformUrl}215 postureLabel={ledger?.postureLabel}
89 unmodified lines
modified:apps/web/test/project.test.tsx+24 added-4 removed
41 unmodified lines
42import { recentShown } from "../src/features/project/landings.tsx";43import {44 ProjectView,45 heldBackOf,46 homeListing,47} from "../src/features/project/project-page.tsx";48import type { ProjectViewProps } from "../src/features/project/project-page.tsx";49import { UnknownProjectView } from "../src/features/project/unknown-project.tsx";50import { askStates } from "../src/features/shared/ask-progress.ts";
549 unmodified lines
600 deciders={data.policy?.policy?.deciders}601 heldBack={data.ledger === undefined ? undefined : heldBackOf(data.ledger)}602 landings={recentLandings(events)}603 lastLanded={latest?.landedAt}603 listing={{604 openAsks: data.asks?.length ?? 0,605 posture: data.ledger?.posture ?? "open",604 listing={homeListing({605 asks: data.asks,606 ledger: data.ledger,607 project: data.project,607 }}608 })}609 now={data.now}610 parents={data.parents}611 platformUrl={platformUrl}612 postureLabel={data.ledger?.postureLabel}
80 unmodified lines
693 seededWorld694 );695696 it.effect(697 "says no posture while its own ledger is unread, never one it was not told",698 () =>699 Effect.gen(function* () {700 const { ledger: _unread, ...data } = yield* readFrom(701 "vellum",702 devWorldWith({ fixtures: "on" })703 );704705 const markup = yield* sentFrom(data);706707 expect({708 badges: markup.match(/data-posture="/gu)?.length ?? 0,709 open: textIn(inspectorOf(markup)).includes("Everything it ships"),710 }).toStrictEqual({ badges: 0, open: false });711 }),712 seededWorld713 );714715 it.effect(716 "is sent without its asks and code, not as a not-found, when the platform does not answer",717 () =>718 Effect.gen(function* () {719 const { asks: read, code } = yield* readFrom("datekit", unanswering);
136 unmodified lines