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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/16307-a-client-list-row-says-in-one-word-where → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/16307-a-client-list-row-says-in-one-word-where was merged into main as 8cdc676.

Review

Sign in to review this change.
3 files changed +20 −4
src/spawn/clients.ts +9 −1
@@ -696,6 +696,11 @@ export interface Stage {
696696 readonly at: string | null;
697697 /** True when the link has gone unopened for three days: the one action is to resend it. */
698698 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;
699704 }
700705
701706 export const STAGE_WORDS: Record<StageKey, string> = {
@@ -717,11 +722,14 @@ export const STALE_WORDS = "Not opened in 3 days";
717722 export function stageOf(r: Omit<ClientRow, "attention" | "stage">, now: number): Stage | null {
718723 if (!r.made || r.claimed === null) return null;
719724 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" })}`;
720727 const make = (key: StageKey, when: string | null, resend = false): Stage => ({
721728 key,
722 words: resend ? STALE_WORDS : STAGE_WORDS[key],
729 words: resend ? `${STALE_WORDS}${day(when)}` : STAGE_WORDS[key],
723730 at: when,
724731 resend,
732 href: key === "crew" || key === "tell" ? `${r.url.replace(/\/+$/, "")}/feed` : r.url,

Confirm r.url is validated as https at the boundary where clients are recorded, since it lands in an href.

725733 });
726734 if (r.claimed) {
727735 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
114114 // only what it does not say (a resend, the last tell) keeps its own words.
115115 r.stage === null || (seen !== null && r.stage.key !== "tell" && r.stage.key !== "crew" && !r.stage.resend)
116116 ? 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>`,

Phone: the anchor is inline text in a dense row; give it a 44px tap target (padding, no new colour) and check the stale text 'Not opened in 3 days, sent Nov 6' plus the trailing time does not say the date twice.

118118 // A crew stage replaces the tell stage's place, so the tell keeps its words beside it.
119119 r.stage?.key === "crew" && r.nextStep.lastTellAt !== null ? html`<span data-stage="tell">Last tell ${time(r.nextStep.lastTellAt)}</span>` : null,
120120 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", () => {
6161 test("unopened for three days is marked, and only then", () => {
6262 expect(stageOf(base({ sentAt: ago(2 * DAY) }), NOW)!.resend).toBe(false);
6363 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]);
6565 expect(stageOf(base({ sentAt: ago(4 * DAY), claimed: true }), NOW)!.resend).toBe(false);
6666 });
6767
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
6875 test("the page says the same words and offers resend only when stale", () => {
6976 const fresh = String(forgeRow(stage(), NOW));
7077 // The stage's "Sent" is folded into the one seen line (#12694), not said twice.
@@ -102,7 +109,8 @@ describe("client states", () => {
102109 const out = (await tool.run({ app } as never, { isAdmin: true } as never, {})) as { ok: true; value: any };
103110 const got = (out.value.forges ?? out.value.value?.forges ?? JSON.parse(JSON.stringify(out)).forges ?? [])[0];
104111 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);
106114 expect(got.stage.resend).toBe(true);
107115 expect(String(forgeRow(row!, Date.now()))).toContain(got.stage.words);
108116 expect(tool.doc).toContain("reachable");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs