Skip to content
Merged
1 change: 1 addition & 0 deletions desktop/src/features/bench/lib/benchScreen.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ test("sections: each item lands in exactly one section, like the board", () => {
card("w/status", { kind: "status", options: [], state: "done" }),
card("w/stale", { validity: "suspected-stale" }),
card("w/gone", { kind: "status", validity: "superseded" }),
card("steward/ship-all-check", { kind: "status", options: [] }),
]),
);
assert.deepEqual(ids(sections.needsYou), ["w/open"]);
Expand Down
3 changes: 3 additions & 0 deletions desktop/src/features/bench/lib/benchScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
benchCreatedSeconds,
enabledBenchSnapshot,
} from "@/features/bench/lib/benchCards";
import { SHIP_ALL_CHECK_ID } from "@/features/bench/lib/benchShipAll";
import { normalizePubkey } from "@/shared/lib/pubkey";

export type BenchSections = {
Expand Down Expand Up @@ -127,6 +128,8 @@ export function benchSections(
viewer === undefined ||
(owner !== null && normalizePubkey(viewer) === normalizePubkey(owner));
for (const card of snapshot.items) {
// Machine lines for Ship all: the digest's bar speaks for it.
if (card.id === SHIP_ALL_CHECK_ID) continue;
if (card.validity !== "current") {
sections.retiring += 1;
} else if (card.kind === "pending") {
Expand Down
117 changes: 117 additions & 0 deletions desktop/src/features/bench/lib/benchShipAll.test-support.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/** Steward cards and the kit's Ship all check as a Bench snapshot shows them. */

export const RESET = "QuicksilverSlick/Metabolic-reset";
export const ANSWER = {
option: 0,
answeredAt: 1,
by: "",
byName: null,
byOwner: true,
source: "tap",
};
export const REPLY = {
eventId: "r",
by: "",
byName: null,
role: null,
at: 1,
hhmm: "",
};
const OPTIONS = ["Ship it", "Send it back", "Keep holding"];
const BASE = "b".repeat(40);

export function stewardItem(id, overrides = {}) {
return {
id,
writer: "steward",
kind: "pending",
title: id,
body: "",
area: "28-day-reset",
severity: "attention",
options: OPTIONS,
state: null,
decidedBy: null,
deadline: null,
links: [],
order: 0,
validity: "current",
cardEventId: "e".repeat(64),
answer: null,
recorded: null,
updatedAt: "2026-11-15T18:00:00Z",
channelId: null,
project: null,
scoped: false,
needs: "you",
answerers: [],
ownerName: null,
recommend: 1,
recommender: null,
reply: null,
request: null,
plain: { risk: "medium", undo: "easy" },
...overrides,
};
}

/** A reset hold card as the kit raises it; `sha` seeds its head commit. */
export function hold(pr, { sha = "a", readFirst = false, ...overrides } = {}) {
const head = sha.repeat(40);
const wait = readFirst ? "waits for you, read first" : "waits for your tap";
return stewardItem(
`steward/hold-reset-${pr}-${head.slice(0, 12)}-${BASE.slice(0, 12)}`,
{
title: `reset PR ${pr} ${wait}: Change ${pr}`,
action: `Ship pull request ${pr} of ${RESET} at commit ${head} on top of main at commit ${BASE}`,
cardEventId: String(pr).padStart(64, "e"),
...overrides,
},
);
}

export function stack(prs, { digest = "c".repeat(64), ...overrides } = {}) {
const span = `${prs[0]}-${prs.at(-1)}`;
return stewardItem(`steward/stack-reset-${span}-${digest.slice(0, 12)}`, {
title: `reset stack ${span} waits for your tap: ${prs.length} pull requests`,
action: `Ship as one stack the pull requests ${prs.join(", ")} of ${RESET}, list ${digest}`,
...overrides,
});
}

/**
* The kit's check item; `listed` as [card, on the digest button too?], the
* clear ones; `held` as [card, why].
*/
export function shipAllCheck(
listed,
{
at = Date.now(),
digest = "clear",
details = "clear",
held = [],
whys = [],
} = {},
) {
const iso = (ms) => new Date(ms).toISOString();
return stewardItem("steward/ship-all-check", {
kind: "status",
state: "active",
options: [],
recommend: null,
cardEventId: null,
title: "Ship all check",
body: [
"Ship all check v1: the steward's check for the desktop's Ship all buttons. It ships nothing.",
`checked: ${iso(at)}`,
`next: ${iso(at + 15 * 60_000)}`,
`digest: ${digest}`,
`details: ${details}`,
...listed.map(
([c, both]) => `card: ${c.id} ${both ? "digest " : ""}details`,
),
...held.map(([c, why]) => `held: ${c.id} ${why}`),
...whys,
].join("\n"),
});
}
Loading
Loading