Public: anyone can read this; the crew can change it.

/explore marks an app untouched for 90 days as quiet and ranks it below live ones, with the reason in words #15698

Merged opened this

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

Merged

scout/forge:scout/15688-explore-marks-an-app-untouched-for-90-da → main 0 commits fork 2 threads · 2 unresolved

  • Merged. scout/15688-explore-marks-an-app-untouched-for-90-da was merged into main as a3c2412.

Review

Sign in to review this change.
6 files changed +231 −7
docs/features/explore.md +4
@@ -33,6 +33,10 @@ Each row's meta line starts with one phrase for the signal that most explains it
3333
3434 An app's meta line opens with its numbers in full: `3 forks, 5 ships, 2 likes, shipped 2d ago · description`. Forks and ships are always said, even at zero; likes appear when there are some, or when the sort is `likes`; `sort:use` adds `N h in use`. So the figure the active sort ranks by is always on the line. The age is `shipped <time>` on the page (the exact date is the `<time>` element's title), `never shipped` when there is none. The meta stays one ellipsised line at 360 px (`.row-meta`, asserted in `test/explorer-why.test.ts`). `GET /api/v1/explore` and the MCP `explore` tool carry the same line as `figures` on each app row (the age worded by `shippedWords`: `shipped 2 days ago`), `figuresOf` in `actions/explore.ts`; the terminal's explorer rows say it too. People and forges have no `figures`; they keep the `why` phrase. Each app row also carries `forks`, `ships`, `likes` and `updatedAt` (the last ship, null when none) at the top level, copied from the same `numbers` and `shippedAt` the line is made of, by `rowsWithWhy` for both doors (`test/explore-api-numbers.test.ts`).
3535
36 ## Quiet apps (#15688)
37
38 An app whose last change is more than 90 days old (`QUIET_DAYS` in `src/actions/explore.ts`) is quiet. On `/explore` its meta line says `quiet since August` (with the year when it is not this one); hover shows the rule, and when any quiet row is on the page a line under the list says it in words: `Quiet = no change in 90 days; ranked after live apps.` On the `score` sort a quiet app ranks after every live one (`QUIET_DROP` is taken off its score); a named sort keeps its own order. `GET /api/v1/explore` and the MCP `explore` tool carry the same words as `quiet` on a quiet app row (absent otherwise). An app that never shipped is not quiet. The terminal explorer row says `quiet since <month>` the same way (`numbersOf` in `src/tui/screens/dashboard.ts`, `test/tui-explore-quiet.test.ts`).
39

Non-blocking: the last sentence, "The terminal opens /explore on the web, so it needs no screen of its own", is now wrong. The terminal explorer row says quiet since <month> (dashboard.ts numbersOf). Say that instead.

3640 ## How likes count
3741
3842 A like is a `feed_like` row (one per person and post, `src/feed/likes.ts`). An app's count is the likes on posts about its repository, read only for repositories the viewer may read: a private app's likes are never in a public row, and a stranger never sees the private app at all. A person's count is the sum over the apps shown to the viewer.
src/actions/explore.ts +59 −3
@@ -416,6 +416,59 @@ export function shippedAgo(shippedAt: string, now: number): string {
416416 return `${days} days ago`;
417417 }
418418
419 /**
420 * An app whose last change is older than this many days is quiet: a month's window is too short for
421 * a small app, a year too long to tell a visitor what is alive.
422 */
423 export const QUIET_DAYS = 90;
424
425 /**
426 * What quiet takes off the score sort: more than any score reaches, so a quiet app sorts after
427 * every live one.
428 */
429 const QUIET_DROP = 1_000_000;
430
431 const MONTHS = [
432 "January",
433 "February",
434 "March",
435 "April",
436 "May",
437 "June",
438 "July",
439 "August",
440 "September",
441 "October",
442 "November",
443 "December",
444 ];
445
446 /**
447 * True when the last change is older than `QUIET_DAYS`; an app that never shipped has no date to be
448 * quiet since.
449 */
450 export const isQuiet = (shippedAt: string | null, now: number): boolean => {
451 if (shippedAt === null) return false;
452 const at = Date.parse(shippedAt);
453 return Number.isFinite(at) && now - at > QUIET_DAYS * 86_400_000;
454 };
455
456 /** "quiet since August" (with the year when it is not this one), "" when the app is not quiet. */
457 export function quietSince(shippedAt: string | null, now: number): string {
458 if (!isQuiet(shippedAt, now)) return "";
459 const at = new Date(shippedAt!);
460 const year = at.getUTCFullYear() === new Date(now).getUTCFullYear() ? "" : ` ${at.getUTCFullYear()}`;
461 return `quiet since ${MONTHS[at.getUTCMonth()]}${year}`;
462 }
463
464 /** The card's title attribute for a quiet app: the threshold, by name. */
465 export const quietTitle =
466 `Quiet: no change in ${QUIET_DAYS} days (QUIET_DAYS), ` +
467 "so it ranks after every app with a change in that window";
468
469 /** The visible note under the list when a quiet row shows: the same reason, in words. */
470 export const quietNote = `Quiet = no change in ${QUIET_DAYS} days; ranked after live apps.`;
471
419472 /** How long ago a row last shipped, in words; "" when it never did. */
420473 function shippedWords(shippedAt: string | null, now: number): string {
421474 if (shippedAt === null) return "";
@@ -657,7 +710,7 @@ export async function explore(
657710 * The rows as the API and the MCP send them: each with its `why` line when the ranking has one to
658711 * say (omitted otherwise).
659712 */
660 export function rowsWithWhy(app: App, query: ExploreQuery, items: readonly ExploreRow[]): (ExploreRow & { why?: string; figures?: string; forks?: number; ships?: number; likes?: number; updatedAt?: string | null })[] {
713 export function rowsWithWhy(app: App, query: ExploreQuery, items: readonly ExploreRow[]): (ExploreRow & { why?: string; figures?: string; forks?: number; ships?: number; likes?: number; updatedAt?: string | null; quiet?: string })[] {
661714 const weights = frontWeights(app.db);
662715 const now = Date.now();
663716 return items.map((row) => {
@@ -666,7 +719,10 @@ export function rowsWithWhy(app: App, query: ExploreQuery, items: readonly Explo
666719 // An app row says its numbers flat as well, read from the same `numbers` and `shippedAt` the
667720 // page's line is made of.
668721 const out = row.kind !== "app" ? (figures === "" ? row : { ...row, figures }) : { ...row, figures, forks: row.numbers.forks, ships: row.numbers.ships, likes: row.numbers.likes, updatedAt: row.shippedAt };
669 return why === undefined ? out : { ...out, why: why.text };
722 // A quiet app says so in words, so the API and the MCP can say why the order moved.
723 const quiet = row.kind === "app" ? quietSince(row.shippedAt, now) : "";
724 const said = quiet === "" ? out : { ...out, quiet };
725 return why === undefined ? said : { ...said, why: why.text };
670726 });
671727 }
672728
@@ -912,7 +968,7 @@ function rank(
912968 },
913969 shippedAt: s.shippedAt,
914970 ...(dates?.get(repo.id) === undefined ? {} : { createdAt: dates.get(repo.id)!.createdAt }),
915 score: frontScore(s, now, weights) + LIKE_WEIGHT * Math.log1p(liked),
971 score: frontScore(s, now, weights) + LIKE_WEIGHT * Math.log1p(liked) - (isQuiet(s.shippedAt, now) ? QUIET_DROP : 0),
916972 repo: {
917973 owner: repo.ownerName,
918974 name: repo.name,
src/tui/screens/dashboard.ts +5 −2
@@ -16,7 +16,7 @@
1616
1717 import { readyAsk } from "../../spawn/template_record.ts";
1818 import { DEFAULT_WEIGHTS, frontWeights, type FrontWeights } from "../../core/front.ts";
19 import { exploreCount, exploreFiltered, exploreLine, isExploreLine, exploreNote, exploreSuggestion, explorePage, groupForks, parseExploreQuery, readExploreLine, whyOf, figuresOf, type ExploreRow } from "../../actions/explore.ts";
19 import { quietSince, exploreCount, exploreFiltered, exploreLine, isExploreLine, exploreNote, exploreSuggestion, explorePage, groupForks, parseExploreQuery, readExploreLine, whyOf, figuresOf, type ExploreRow } from "../../actions/explore.ts";
2020 import { protectionNotice } from "../../kernel/protection.ts";
2121 import { holdWords, plannerHold } from "../../crew/autonomy.ts";
2222 import { governorLine, governorSeen } from "../../crew/governed.ts";
@@ -1667,7 +1667,9 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
16671667 const said = why?.signal;
16681668 // An app says the page's figures line, as the page does; the rest is for people and forges.
16691669 const figures = figuresOf(row, Date.now(), parseExploreQuery(explored?.line ?? "").sort);
1670 if (figures !== "") return figures;
1670 // A quiet app says so, as the page and the API do.
1671 const quiet = row.kind === "app" ? quietSince(row.shippedAt, Date.now()) : "";
1672 if (figures !== "") return metaOf(figures, quiet);
16711673 return metaOf(
16721674 why?.text ?? "",
16731675 row.kind === "person" ? plural(n.apps, "app") : "",
@@ -1676,6 +1678,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
16761678 n.ships > 0 && said !== "ships" ? `${n.ships} shipped this month` : "",
16771679 n.awakeHours > 0 && said !== "use" ? `${n.awakeHours} h in use` : "",
16781680 row.shippedAt !== null && said !== "fresh" ? `shipped ${ago(row.shippedAt)}` : "",
1681 quiet,
16791682 );
16801683 }
16811684
src/web/studio/explore.ts +6 −2
@@ -22,6 +22,9 @@ import {
2222 MAKE_IT_YOURS,
2323 shippedAgo,
2424 whyOf,
25 quietSince,
26 quietTitle,
27 quietNote,
2528 figureParts,
2629 readExploreLine,
2730 type ExploreQuery,
@@ -86,7 +89,8 @@ function rowHtml(row: ExploreRow, query: ExploreQuery, now: number, weights: Fro
8689 const theirs = href({ kind: "app", sort: "score", text: "", archived: false, updated: "all", owner: row.name });
8790 const apps = row.kind === "person" ? `${row.numbers.apps} app${row.numbers.apps === 1 ? "" : "s"}` : "";
8891 const count = apps === "" ? html`` : row.numbers.apps > 0 ? html`<a href="${theirs}">${apps}</a>` : html`${apps}`;
outdated

Principle 1/8: the reason ('no change in 90 days, ranked after live apps') is only in title, unreachable on touch and weak for keyboard/screen readers. Show it in visible words too (one line under the list when a quiet row is present), keep the title as the named-constant door.

89 const parts = [signal === "" ? html`` : html`${signal}`, row.description === "" ? html`` : html`${row.description}`, count].filter((p) => p.toString() !== "");
92 const quiet = row.kind === "app" ? quietSince(row.shippedAt, now) : "";
93 const parts = [signal === "" ? html`` : html`${signal}`, quiet === "" ? html`` : html`<span class="muted" title="${quietTitle}">${quiet}</span>`, row.description === "" ? html`` : html`${row.description}`, count].filter((p) => p.toString() !== "");
9094 const metaHtml = parts.reduce((all, p, i) => (i === 0 ? p : html`${all} · ${p}`), html``);
9195 const forked = row.forked ?? [];
9296 return rowOf({
@@ -399,7 +403,7 @@ export async function explorePage(ctx: Ctx): Promise<Response> {
399403 : card(html`<ul class="list">${rows.map((r) => rowHtml(r, query, now, weights, pictures))}</ul>`, {
400404 pad: false,
401405 extra: "bare",
402 })}${pager(query, shown.page, shown.pages)}</div>`;
406 })}${rows.some((r) => r.kind === "app" && quietSince(r.shippedAt, now) !== "") ? html`<p class="mb small muted" data-quiet-note>${quietNote}</p>` : html``}${pager(query, shown.page, shown.pages)}</div>`;
403407 const drawn = page({ ctx, title: "Explore", description: "Public apps, forges and people on this forge, ranked by use, forks, deployments and recency.", body: compact(body), feed: { href: "/explore.atom", title: "Explore" }, ...(tag === undefined ? {} : { etag: tag }) });
404408 notePhase(ctx.request, "render", performance.now() - rendering);
405409 return drawn;
test/explore-quiet-rank.test.ts added +85
@@ -0,0 +1,85 @@
1 /**
2 * An app untouched for QUIET_DAYS is quiet: marked with the month and the named threshold, and
3 * ranked after every live app (#15688).
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { createRepo } from "../src/actions/repos.ts";
11 import { QUIET_DAYS, quietSince } from "../src/actions/explore.ts";
12 import { createApp as insertApp } from "../src/core/apps.ts";
13 import { createIssue } from "../src/core/issues.ts";
14 import { createUser } from "../src/core/users.ts";
15 import { serve, type Servers } from "../src/http/server.ts";
16 import { quietLogs } from "./helpers/globals.ts";
17 import { proveAll } from "./helpers/verified.ts";
18 import { promote } from "./helpers/members.ts";
19
20 quietLogs();
21 let dir: string;
22 let app: App;
23 let servers: Servers;
24 const DAY = 86_400_000;
25
26 beforeAll(async () => {
27 dir = await mkdtemp(join(tmpdir(), "forge-explore-quietrank-"));
28 app = createApp({ dataDir: dir, port: 0 });
29 const made = await createUser(app.db, { origin: "seed", username: "pine", email: "[email protected]", password: "a-good-passphrase", adminIfFirst: false });
30 if (!made.ok) throw new Error(made.error);
31 proveAll(app);
32 promote(app.db, made.value);
33 // "loved" is quiet with many likes; "fresh" and "twin" have nothing but a recent change.
34 for (const [name, ago, likes] of [["loved", QUIET_DAYS + 30, 20], ["fresh", 5, 0], ["twin", QUIET_DAYS - 1, 0]] as const) {
35 const repo = await createRepo(app, made.value, { name, visibility: "public" });
36 if (!repo.ok) throw new Error(String(repo.error));
37 const rec = insertApp(app.db, { repoId: repo.value.id, slug: `pine-${name}`, access: "public" });
38 if (!rec.ok) throw new Error(rec.error);
39 const issue = createIssue(app.db, { repoId: repo.value.id, authorId: made.value.id, title: "change", kind: "pull" });
40 if (!issue.ok) throw new Error(issue.error);
41 app.db
42 .query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES (?1, 'main', 'b', '', '', ?2)`)
43 .run(issue.value.id, new Date(Date.now() - ago * DAY).toISOString());
44 for (let i = 0; i < likes; i++)
45 app.db.run("INSERT INTO feed_like (viewer_id, item_id, repo_id) VALUES (?1, ?2, ?3)", [made.value.id, `p-${name}-${i}`, repo.value.id]);
46 }
47 servers = await serve(app);
48 }, 60_000);
49 afterAll(async () => {
50 await servers.stop();
51 app.db.close();
52 await rm(dir, { recursive: true, force: true });
53 });
54
55 test("a quiet app with many likes sorts after apps with a change in the window and says why", async () => {
56 const html = await (await fetch(`${servers.url}/explore?kind=app&owner=pine`)).text();
57 const order = [...html.matchAll(/<a href="\/pine\/(\w+)">/g)].map((m) => m[1]);
58 expect(order.indexOf("loved")).toBeGreaterThan(order.indexOf("fresh"));
59 expect(order.indexOf("loved")).toBeGreaterThan(order.indexOf("twin"));
60 expect(html).toMatch(/title="[^"]*QUIET_DAYS[^"]*"[^>]*>quiet since \w+/);
61 expect(html.match(/quiet since/g)?.length).toBe(1);
62 expect(html).toContain("Quiet = no change in 90 days; ranked after live apps.");
63 });
64
65 test("no note is shown when no row is quiet", async () => {
66 const html = await (await fetch(`${servers.url}/explore?kind=app&owner=pine&sort=new&q=fresh`)).text();
67 expect(html).not.toContain("data-quiet-note");
68 });
69
70 test("two apps equal in every metric but freshness rank the fresh one first", async () => {
71 const api = (await (await fetch(`${servers.url}/api/v1/explore?owner=pine&kind=app`)).json()) as { items: { name: string }[] };
72 const names = api.items.map((i) => i.name);
73 expect(names.indexOf("pine/fresh")).toBeLessThan(names.indexOf("pine/twin"));
74 const rows = (await (await fetch(`${servers.url}/api/v1/explore?owner=pine&kind=app`)).json()) as { items: { name: string; quiet?: string }[] };
75 expect(rows.items.find((i) => i.name === "pine/loved")?.quiet).toMatch(/^quiet since \w+/);
76 expect(rows.items.find((i) => i.name === "pine/fresh")?.quiet).toBeUndefined();
77 });
78
79 test("quietSince names the month, adds the year when it is not this one, and is empty inside the window", () => {
80 const now = Date.parse("2026-11-23T00:00:00Z");
81 expect(quietSince("2026-08-10T00:00:00Z", now)).toBe("quiet since August");
82 expect(quietSince("2025-12-01T00:00:00Z", now)).toBe("quiet since December 2025");
83 expect(quietSince("2026-10-01T00:00:00Z", now)).toBe("");
84 expect(quietSince(null, now)).toBe("");
85 });
test/tui-explore-quiet.test.ts added +72
@@ -0,0 +1,72 @@
1 /**
2 * The terminal's explorer row says `quiet since <month>` for a quiet app, as the page does
3 * (#15688).
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App as Forge } from "../src/app.ts";
10 import { createRepo } from "../src/actions/repos.ts";
11 import { createApp as insertApp } from "../src/core/apps.ts";
12 import { createIssue } from "../src/core/issues.ts";
13 import { createUser, type User } from "../src/core/users.ts";
14 import { createForgeApp } from "../src/tui/forge.ts";
15 import { headlessTerminal } from "../src/tui/term/terminal.ts";
16 import { quietLogs } from "./helpers/globals.ts";
17 import { proveAll } from "./helpers/verified.ts";
18 import { promote } from "./helpers/members.ts";
19 import { settleApp } from "./helpers/tui.ts";
20
21 quietLogs();
22 let dir: string;
23 let forge: Forge;
24 let alice: User;
25 const DAY = 86_400_000;
26
27 beforeAll(async () => {
28 dir = await mkdtemp(join(tmpdir(), "forge-tui-quiet-"));
29 forge = createApp({ dataDir: dir, port: 0 });
30 const u = await createUser(forge.db, { origin: "seed", trusted: true, username: "alice", email: "[email protected]", password: "a-long-passphrase" });
31 if (!u.ok) throw new Error(u.error);
32 proveAll(forge);
33 promote(forge.db, u.value);
34 alice = u.value;
35 for (const [name, ago] of [["olds", 200], ["news", 3]] as const) {
36 const made = await createRepo(forge, alice, { name, visibility: "public" });
37 if (!made.ok) throw new Error(String(made.error));
38 const rec = insertApp(forge.db, { repoId: made.value.id, slug: `alice-${name}`, access: "public" });
39 if (!rec.ok) throw new Error(rec.error);
40 const issue = createIssue(forge.db, { repoId: made.value.id, authorId: alice.id, title: "change", kind: "pull" });
41 if (!issue.ok) throw new Error(issue.error);
42 forge.db
43 .query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, merged_at) VALUES (?1, 'main', 'b', '', '', ?2)`)
44 .run(issue.value.id, new Date(Date.now() - ago * DAY).toISOString());
45 }
46 });
47 afterAll(async () => {
48 forge.close();
49 await rm(dir, { recursive: true, force: true });
50 });
51
52 test("the quiet app's terminal row says quiet since; the live one does not", async () => {
53 const terminal = headlessTerminal(160, 40);
54 const { app } = createForgeApp(
55 forge,
56 { sshUsername: "alice", remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: alice },
57 { terminal, exitHooks: false },
58 );
59 app.start();
60 await settleApp(app);
61 const press = (key: string): void => app.dispatch({ type: "key", key, ctrl: false, alt: false, shift: false });
62 press("/");
63 for (const ch of "kind:app owner:alice") press(ch);
64 await settleApp(app);
65 press("enter");
66 await settleApp(app);
67 const text = app.screen.toText();
68 app.stop();
69 expect(text).toContain("alice/olds");
70 expect(text).toContain("alice/news");
71 expect(text.match(/quiet since/g)?.length).toBe(1);
72 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs