Files
loki/scripts/test/projects-display.ts
CatoandClaude Fable 5.1 2d539019fb feat(cold-start): a new site merges its own green PRs, and the loop needs no human click (#612)
The last two manual steps on brief → repo → live site → feedback → live
change were the operator merging the agent's PRs on a site repo that had no
CI and no auto-merge. Now:

- scripts/site-template ships auto-merge.yml (the fleet sweep, no PAT
  required) beside ci.yml; ci.yml tolerates a starter without a lint script.
- register-site.sh seeds ci.yml and auto-merge.yml from site-template with
  the deploy shim, through the host's gh login when the caller's token may
  not write workflows, and announces when they are not on the remote.
- The feedback Implement prompt counts a green PR handed to auto-merge as
  shipped: agents were honestly writing status: working because they may
  not merge, so the run never closed and the inbox read "Working now" until
  the reaper stamped it partial an hour later.
- The starter carries app/icon.svg (no favicon 404) and .nvmrc (ci.yml's
  setup-node reads it).
- Add lands on the new project page; the Projects list also sorts a project
  created within a day first. The list folded a just-added project below 25
  rows.
- register-site.sh compares durable and main registers by slug, so plan/price
  edits on main no longer keep the durable checkout from fast-forwarding.
- test-site-template.sh: a here-string was attached to the wrong command and
  the test hung on any open stdin.


Claude-Session: https://claude.ai/code/session_0118cLNxoB3dt2w74vU1PH6w

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-11 00:16:48 -07:00

76 lines
3.1 KiB
TypeScript

import assert from "node:assert/strict";
import { sanitizeActivityPreview, isNoisyProfileActivity } from "../../src/lib/activity-display";
import { mergeDuplicateProjectRows } from "../../src/lib/domain/project-canonical";
import { shortProjectStatus } from "../../src/lib/projects-display";
import { filterProjects, hasProjectAttention, isSiteDown } from "../../src/lib/projects-page-stats";
import type { ProjectGridRow } from "../../src/components/projects/ProjectGridCard";
function row(
partial: Partial<ProjectGridRow> & Pick<ProjectGridRow, "id" | "name">,
): ProjectGridRow {
return {
description: null,
attrs: {},
...partial,
};
}
assert.equal(sanitizeActivityPreview("gh secret set MY_KEY some-value"), "[redacted]");
assert.equal(sanitizeActivityPreview("hello world"), "hello world");
const long = `Status update: ${"still shipping. ".repeat(12)}`;
assert.ok(sanitizeActivityPreview(long).endsWith("…"));
assert.equal(shortProjectStatus("Production"), "Production");
assert.equal(shortProjectStatus("Strategic planning only - no code, nothing else"), null);
assert.equal(shortProjectStatus("Active development — shipping v2"), "Active development");
assert.equal(isNoisyProfileActivity("custom", "AUTOPILOT BATCH — do NOT idle"), true);
assert.equal(isNoisyProfileActivity("dispatch", "Ship the fix"), false);
const merged = mergeDuplicateProjectRows([
row({ id: "1", name: "botsmann", attrs: {} }),
row({ id: "2", name: "Botsmann", description: "Fleet ops", gitUrl: "https://github.com/x/y" }),
]);
assert.equal(merged.length, 1);
assert.equal(merged[0]!.id, "2");
const down = row({ id: "3", name: "site", liveUrl: "https://x.test", siteOk: false });
assert.equal(isSiteDown(down), true);
assert.equal(hasProjectAttention(down), true, "a down site needs attention");
assert.equal(
hasProjectAttention(row({ id: "4", name: "ok", liveUrl: "https://x.test", siteOk: true })),
false,
);
assert.equal(hasProjectAttention(row({ id: "5", name: "none" })), false, "no URL is not an alarm");
console.log("✓ projects-display tests passed");
// A project created moments ago sorts first (for a day), after anything that
// needs attention — an alphabetical fold hid a just-added project below 25
// rows right after Add (kaffeeklappe-sep11, 2026-09-11).
{
const now = Date.now();
const rows = [
row({ id: "a", name: "aardvark", createdAt: new Date(now - 30 * 24 * 3600e3) }),
row({ id: "z", name: "zebra-new", createdAt: new Date(now - 5 * 60e3) }),
row({ id: "m", name: "middle-new", createdAt: new Date(now - 60 * 60e3) }),
row({ id: "o", name: "old-no-date" }),
];
const order = filterProjects(rows, "", null).map((r) => r.id);
assert.deepEqual(
order,
["z", "m", "a", "o"],
`fresh projects first, newest of them first: ${order}`,
);
const stale = filterProjects(
[
row({ id: "y", name: "yesterday", createdAt: new Date(now - 2 * 24 * 3600e3) }),
row({ id: "b", name: "bravo" }),
],
"",
null,
).map((r) => r.id);
assert.deepEqual(stale, ["b", "y"], "after a day the usual alphabetical order applies");
}
console.log("✓ projects-display: fresh projects sort first");