Public: anyone can read this; the crew can change it.
A client list row says in one word where each sent forge got to: sent, opened, saw the crew, claimed #16646
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/16307-a-client-list-row-says-in-one-word-where → main 0 commits fork 2 threads · 2 unresolved
3 files
changed +20
−4
src/spawn/clients.ts +9 −1
| @@ -696,6 +696,11 @@ export interface Stage { | ||
| 696 | 696 | readonly at: string | null; |
| 697 | 697 | /** True when the link has gone unopened for three days: the one action is to resend it. */ |
| 698 | 698 | readonly resend: boolean; |
| 699 | /** | |
| 700 | * The evidence: the forge itself, or its feed where the crew's first run shows; same on every | |
| 701 | * door. | |
| 702 | */ | |
| 703 | readonly href: string; | |
| 699 | 704 | } |
| 700 | 705 | |
| 701 | 706 | export const STAGE_WORDS: Record<StageKey, string> = { |
| @@ -717,11 +722,14 @@ export const STALE_WORDS = "Not opened in 3 days"; | ||
| 717 | 722 | export function stageOf(r: Omit<ClientRow, "attention" | "stage">, now: number): Stage | null { |
| 718 | 723 | if (!r.made || r.claimed === null) return null; |
| 719 | 724 | const at = (...xs: (string | null | undefined)[]): string | null => xs.find((x) => typeof x === "string") ?? null; |
| 725 | const day = (iso: string | null): string => | |
| 726 | iso === null || Number.isNaN(Date.parse(iso)) ? "" : `, sent ${new Date(iso).toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: "UTC" })}`; | |
| 720 | 727 | const make = (key: StageKey, when: string | null, resend = false): Stage => ({ |
| 721 | 728 | key, |
| 722 | words: resend ? STALE_WORDS : STAGE_WORDS[key], | |
| 729 | words: resend ? `${STALE_WORDS}${day(when)}` : STAGE_WORDS[key], | |
| 723 | 730 | at: when, |
| 724 | 731 | resend, |
| 732 | href: key === "crew" || key === "tell" ? `${r.url.replace(/\/+$/, "")}/feed` : r.url, | |
| 725 | 733 | }); |
| 726 | 734 | if (r.claimed) { |
| 727 | 735 | if (r.crew !== undefined && r.crew.runs + r.crew.pulls > 0) return make("crew", r.crew.at); |
src/web/pages/forges.ts +1 −1
| @@ -114,7 +114,7 @@ export function forgeRow(r: ClientRow, now: number, reach?: ForgeReach, bill = f | ||
| 114 | 114 | // only what it does not say (a resend, the last tell) keeps its own words. |
| 115 | 115 | r.stage === null || (seen !== null && r.stage.key !== "tell" && r.stage.key !== "crew" && !r.stage.resend) |
| 116 | 116 | ? null |
| 117 | : html`<span data-stage="${r.stage.key}"${r.stage.resend ? html` data-resend` : null}>${r.stage.words}${r.stage.at === null ? null : html` ${time(r.stage.at)}`}</span>`, | |
| 117 | : html`<span data-stage="${r.stage.key}"${r.stage.resend ? html` data-resend` : null}><a href="${r.stage.href}" data-evidence>${r.stage.words}</a>${r.stage.at === null ? null : html` ${time(r.stage.at)}`}</span>`, | |
| 118 | 118 | // A crew stage replaces the tell stage's place, so the tell keeps its words beside it. |
| 119 | 119 | r.stage?.key === "crew" && r.nextStep.lastTellAt !== null ? html`<span data-stage="tell">Last tell ${time(r.nextStep.lastTellAt)}</span>` : null, |
| 120 | 120 | crewCountWords(r.crew) === null ? null : html`<span data-crew-did>${crewCountWords(r.crew)}</span>`, |
test/client-states.test.ts +10 −2
| @@ -61,10 +61,17 @@ describe("client states", () => { | ||
| 61 | 61 | test("unopened for three days is marked, and only then", () => { |
| 62 | 62 | expect(stageOf(base({ sentAt: ago(2 * DAY) }), NOW)!.resend).toBe(false); |
| 63 | 63 | const s = stageOf(base({ sentAt: ago(4 * DAY) }), NOW)!; |
| 64 | expect([s.key, s.words, s.resend]).toEqual(["sent", STALE_WORDS, true]); | |
| 64 | expect([s.key, s.words, s.resend]).toEqual(["sent", `${STALE_WORDS}, sent Nov 6`, true]); | |
| 65 | 65 | expect(stageOf(base({ sentAt: ago(4 * DAY), claimed: true }), NOW)!.resend).toBe(false); |
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | test("the word links to the forge, and the crew's word to its feed", () => { | |
| 69 | expect(stage().stage!.href).toBe("https://acme.example"); | |
| 70 | const crew = stage({ claimed: true, crew: { runs: 1, pulls: 0, at: ago(60_000) } }).stage!; | |
| 71 | expect([crew.key, crew.href]).toEqual(["crew", "https://acme.example/feed"]); | |
| 72 | expect(String(forgeRow(stage({ sentAt: ago(4 * DAY) }), NOW))).toContain('<a href="https://acme.example" data-evidence>'); | |
| 73 | }); | |
| 74 | ||
| 68 | 75 | test("the page says the same words and offers resend only when stale", () => { |
| 69 | 76 | const fresh = String(forgeRow(stage(), NOW)); |
| 70 | 77 | // The stage's "Sent" is folded into the one seen line (#12694), not said twice. |
| @@ -102,7 +109,8 @@ describe("client states", () => { | ||
| 102 | 109 | const out = (await tool.run({ app } as never, { isAdmin: true } as never, {})) as { ok: true; value: any }; |
| 103 | 110 | const got = (out.value.forges ?? out.value.value?.forges ?? JSON.parse(JSON.stringify(out)).forges ?? [])[0]; |
| 104 | 111 | expect(got.stage).toEqual({ ...row!.stage!, at: got.stage.at }); |
| 105 | expect(got.stage.words).toBe(STALE_WORDS); | |
| 112 | expect(got.stage.words.startsWith(STALE_WORDS)).toBe(true); | |
| 113 | expect(got.stage.href).toBe(row!.url); | |
| 106 | 114 | expect(got.stage.resend).toBe(true); |
| 107 | 115 | expect(String(forgeRow(row!, Date.now()))).toContain(got.stage.words); |
| 108 | 116 | expect(tool.doc).toContain("reachable"); |
new above
offline
Confirm r.url is validated as https at the boundary where clients are recorded, since it lands in an href.