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

The explorer ranks forks of the same app under their parent instead of beside it #14113

Merged opened this

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

Merged

scout/forge:scout/14082-the-explorer-ranks-forks-of-the-same-app → main 3 commits fork 4 threads · 4 unresolved

  • Merged. scout/14082-the-explorer-ranks-forks-of-the-same-app was merged into main as 6c288bf.

Review

Sign in to review this change.
9 files changed +277 −14
docs/design/areas/explore.md +6
@@ -8,3 +8,9 @@ The how-to is in docs/features/explore.md.
88
99 ## First view
1010 A row is its name, what it does, and one signal (the phrase `whyOf` gives), with "Make it yours" as its one tap. The filter line (`[data-filter-line]`) is the search box and the kind tabs; sort, time and archived sit in one `<details data-more-filters>`, closed on the bare view and open when any of them is set. The explore part of the page is compacted by `web/compact.ts` (indentation between and inside tags only; text and attribute values are untouched) and is under 10 KB raw; "Sort and time" (`.sort-toggle`) is a 44px target (`test/explore-first-view.test.ts`).
11
12 ## Forks under their parent (#14082)
13
14 A fork whose parent is listed folds under the parent's row: `.row-forks` is a `<details>` in the row's
15 `after` slot, its summary the count ("2 forks"), its body the same `list` of rows, ranked as the page is.
16 It needs no script, and the summary keeps the 44px tap height and has the same focus-visible outline as `.sort-toggle`. The nested list is indented 8px, so a row keeps its width at 360px; each nested row keeps its own "Make it yours". It is a part of the row (`rowOf`'s `after` slot), not a new component. The how-to is in docs/features/explore.md.
outdated

The how-to for the fold must be in docs/features/explore.md; this file is for the design area only.

docs/features/explore.md +4
@@ -17,6 +17,10 @@
1717
1818 The page's tabs are Best, Forks, Shipped, Liked, Use, Fresh and Newest; a row shows `N likes` when N > 0, on the web and in the terminal.
1919
20 ## Forks fold under their parent (#14082)
21
22 When an app and forks of it are both in the list, the page lists the app once and its forks under it: the row says `2 forks`, and a tap opens them, in the same order as the list. A fork whose parent is not listed (private to you, or filtered out) stays a row of its own, so nothing is hidden. The terminal does the same: the parent's line ends `▸ 2 forks under it (f)`, and `f` opens them in place, indented. `GET /api/v1/explore` and the MCP tool stay flat, one row per app in rank order; each app row's `repo.parentId` names the app it was forked from, only when that app is one the caller may read, so a fork can be grouped by the caller (`groupForks`).
23
2024 ## Why a row ranks where it does (#11296)
2125
2226 Each row's meta line starts with one phrase for the signal that most explains its place: `12 forks`, `3 shipped this month`, `2 likes`, `shipped today`, `in use`. On a named sort it is that sort's signal; on `score` it is the largest term of the score, weighed as the ranking weighs them (`frontScore` at the forge's front weights, and `LIKE_WEIGHT` for likes; a tie goes to forks, ships, likes, freshness, use). `whyOf` in `actions/explore.ts` reads it from the row's numbers, with no query. The number the phrase says is left out of the rest of the line, so nothing is said twice. The terminal's explorer lines (`/` then `kind:` or `sort:`) show the same phrase first and drop the same duplicate. A row with nothing to say has no phrase; `sort:name` and `sort:new` have none.
src/actions/explore.ts +61 −3
@@ -451,6 +451,19 @@ export function whyOf(
451451 */
452452 export const MAKE_IT_YOURS = { do: "make_it_yours", label: "Make it yours" } as const;
453453
454 export interface ExploreRepo {
455 readonly owner: string;
456 readonly name: string;
457 readonly id: string;
458 readonly branch: string;
459 readonly public: boolean;
460 /**
461 * The app this one was forked from, only when that parent is itself one of the apps this viewer
462 * may read (so it never names a repository the viewer cannot see).
463 */
464 readonly parentId?: string;
465 }
466
454467 export interface ExploreRow {
455468 readonly kind: ExploreKind;
456469 readonly name: string;
@@ -471,7 +484,7 @@ export interface ExploreRow {
471484 readonly createdAt?: string;
472485 readonly score: number;
473486 /** An app's repository, for "Make it yours". */
474 readonly repo?: { readonly owner: string; readonly name: string; readonly id: string; readonly branch: string; readonly public: boolean };
487 readonly repo?: ExploreRepo;
475488 /** A person's mark, from their account (`core/marks.ts`): the owner's, never a typed one. */
476489 readonly mark?: Mark;
477490 /**
@@ -482,6 +495,37 @@ export interface ExploreRow {
482495 readonly copyable?: boolean;
483496 /** Present exactly when `copyable`: the action name (an MCP tool) and label the page shows. */
484497 readonly action?: typeof MAKE_IT_YOURS;
498 /**
499 * Only on the page's grouped view: the forks of this app that are listed beside it, in rank
500 * order.
501 */
502 readonly forked?: readonly ExploreRow[];
503 }
504
505 /**
506 * Forks of an app that is itself in the list fold under it, in the list's own order (the existing
507 * score, or whatever sort was asked). A fork whose parent is not listed (private, filtered out)
508 * stays a row of its own, so nothing is hidden. Plain data in, plain data out.
509 */
510 export function groupForks(rows: readonly ExploreRow[]): ExploreRow[] {
511 const ids = new Set(rows.filter((r) => r.kind === "app" && r.repo !== undefined).map((r) => r.repo!.id));
512 const under = new Map<string, ExploreRow[]>();
513 const top: ExploreRow[] = [];
514 for (const r of rows) {
515 const parent = r.kind === "app" ? r.repo?.parentId : undefined;
516 if (parent !== undefined && parent !== r.repo!.id && ids.has(parent)) {
517 const list = under.get(parent) ?? [];
518 list.push(r);
519 under.set(parent, list);
520 } else top.push(r);
521 }
522 // A fork of a fork folds under the nearest listed ancestor that is on top.
523 const collect = (id: string): ExploreRow[] => (under.get(id) ?? []).flatMap((c) => [c, ...collect(c.repo!.id)]);
524 const rank = new Map(rows.map((r, i) => [r, i]));
525 return top.map((r) => {
526 const mine = r.repo === undefined || r.kind !== "app" ? [] : collect(r.repo.id).sort((a, b) => rank.get(a)! - rank.get(b)!);
527 return mine.length === 0 ? r : { ...r, forked: mine };
528 });
485529 }
486530
487531 const NOUNS = {
@@ -616,12 +660,24 @@ export async function explorePageAt(
616660 query: ExploreQuery,
617661 n: number,
618662 limit: number = ROWS,
663 group = false,
619664 ): Promise<ExplorePageAt> {
620 const { rows, stamp } = await everything(app, viewer, query);
665 const { rows: ranked, stamp } = await everything(app, viewer, query);
666 const rows = group ? groupForks(ranked) : ranked;
621667 const pages = Math.max(1, Math.ceil(rows.length / limit));
622668 const page = Math.min(Math.max(1, Math.trunc(n) || 1), pages);
623669 const items = rows.slice((page - 1) * limit, page * limit);
624 return { items: await described(app, items, stamp), page, pages, total: rows.length };
670 if (!group) return { items: await described(app, items, stamp), page, pages, total: rows.length };
671 // The folded forks are described too, in the same pass, then put back under their parents.
672 const flat = items.flatMap((r) => [r, ...(r.forked ?? [])]);
673 const done = await described(app, flat, stamp);
674 let at = 0;
675 const out = items.map((r) => {
676 const head = done[at++]!;
677 const kids = (r.forked ?? []).map(() => done[at++]!);
678 return kids.length === 0 ? head : { ...head, forked: kids };
679 });
680 return { items: out, page, pages, total: rows.length };
625681 }
626682
627683 interface Place {
@@ -771,6 +827,7 @@ function rank(
771827 canEnterApp(db, repo, record, viewer, { named: false })
772828 );
773829 };
830 const listed = new Set(appRepos.map((r) => r.id));
774831 const appRows: ExploreRow[] = appRepos.map((repo) => {
775832 const s = told(repo);
776833 const liked = likes.get(repo.id) ?? 0;
@@ -796,6 +853,7 @@ function rank(
796853 id: repo.id,
797854 branch: repo.defaultBranch,
798855 public: repo.visibility === "public",
856 ...(repo.forkParentId !== null && listed.has(repo.forkParentId) ? { parentId: repo.forkParentId } : {}),
799857 },
800858 copyable: canCopy,
801859 ...(canCopy ? { action: MAKE_IT_YOURS } : {}),
src/tui/screens/dashboard.ts +29 −3
@@ -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, parseExploreQuery, readExploreLine, whyOf, figuresOf, type ExploreRow } from "../../actions/explore.ts";
19 import { 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";
@@ -297,7 +297,21 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
297297 /** The forge's front weights, read once per ranked line so the reasons agree with the order. */
298298 let exploredWeights: FrontWeights = DEFAULT_WEIGHTS;
299299 const exploring = (): boolean => isExploreLine(filter.query);
300 const exploredRows = (): readonly ExploreRow[] => (exploring() ? (explored?.rows ?? []) : []);
300 /**
301 * Forks of a listed app fold under it, as on the page (#14082): the parent says how many, `f`
302 * opens them in place, indented, in the list's order.
303 */
304 const foldOpen = new Set<string>();
305 const underParent = new WeakSet<ExploreRow>();
306 const exploredRows = (): readonly ExploreRow[] =>
307 exploring()
308 ? groupForks(explored?.rows ?? []).flatMap((r) => {
309 const kids = foldOpen.has(r.name) ? (r.forked ?? []) : [];
310 for (const k of kids) underParent.add(k);
311 return [r, ...kids];
312 })
313 : [];
314 const foldedOf = (row: ExploreRow | undefined): number => groupForks(explored?.rows ?? []).find((r) => r.name === row?.name)?.forked?.length ?? 0;
301315 const syncExplore = (): void => {
302316 if (!exploring()) {
303317 explored = undefined;
@@ -1458,6 +1472,14 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
14581472 return true;
14591473 }
14601474 if (e.key === "n" && exploring() && explored?.next != null) return morePage(), true;
1475 if (e.key === "f" && exploring()) {
1476 const row = exploredRows()[at("repos").index];
1477 if (row !== undefined && foldedOf(row) > 0) {
1478 if (!foldOpen.delete(row.name)) foldOpen.add(row.name);
1479 ctx.invalidate();
1480 }
1481 return true;
1482 }
14611483 if (e.key === "n" && f.signedIn) {
14621484 ctx.push(newRepoScreen(f, ctx));
14631485 return true;
@@ -1631,7 +1653,11 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
16311653 r,
16321654 c,
16331655 at("repos"),
1634 rows.map((row): ListRow => ({ title: row.name, secondary: row.description, meta: numbersOf(row) })),
1656 rows.map((row): ListRow => {
1657 const n = row.forked?.length ?? 0;
1658 const fold = n === 0 ? "" : `${foldOpen.has(row.name) ? "▾" : "▸"} ${n} fork${n === 1 ? "" : "s"} under it (f)`;
1659 return { title: `${underParent.has(row) ? " ↳ " : ""}${row.name}`, secondary: row.description, meta: metaOf(numbersOf(row), fold) };
1660 }),
16351661 on,
16361662 );
16371663 hitList(ctx, r, at("repos"), rows.length, {
src/web/studio/explore.ts +11 −1
@@ -54,7 +54,17 @@ function rowHtml(row: ExploreRow, signedIn: boolean, query: ExploreQuery, now: n
5454 const count = apps === "" ? html`` : row.numbers.apps > 0 ? html`<a href="${theirs}">${apps}</a>` : html`${apps}`;
5555 const parts = [signal === "" ? html`` : html`${signal}`, row.description === "" ? html`` : html`${row.description}`, count].filter((p) => p.toString() !== "");
5656 const metaHtml = parts.reduce((all, p, i) => (i === 0 ? p : html`${all} · ${p}`), html``);
57 const forked = row.forked ?? [];
5758 return rowOf({
59 // Forks of this app, folded under it: a tap opens them, ranked as the list is.
60 ...(forked.length === 0
61 ? {}
62 : {
63 after: html`<details class="row-forks" data-forks>
64 <summary class="muted small">${forked.length} fork${forked.length === 1 ? "" : "s"}</summary>

Hand-rolled <details>/<summary> inside a row, not a named component. Principle 7 (rows over boxes) is fine, but a keyboard user needs a visible focus style on this summary, and nested rows each carry their own 'Make it yours' button: say how that reads on a 360px phone.

65 <ul class="list">${forked.map((f) => rowHtml(f, signedIn, query, now, weights))}</ul>
66 </details>`,
67 }),
5868 title: html`<a href="${row.url}">${row.name}</a>${nameMark(row.mark)}`,
5969 ...(parts.length === 0 ? {} : { meta: metaHtml }),
6070 ...(row.copyable === true && row.repo !== undefined
@@ -186,7 +196,7 @@ export async function explorePage(ctx: Ctx): Promise<Response> {
186196 const note = exploreNote(unknown);
187197 const suggestion = exploreSuggestion(line);
188198 const ranking = performance.now();
189 const shown = await explorePageAt(ctx.app, ctx.auth.user, query, explorePageFrom((name) => ctx.url.searchParams.get(name)));
199 const shown = await explorePageAt(ctx.app, ctx.auth.user, query, explorePageFrom((name) => ctx.url.searchParams.get(name)), undefined, true);
190200 // The address names the page shown: a `page` that is not it (past the last, zero, junk, or a
191201 // redundant 1) answers 303 to the same address with the real page, none for page 1.
192202 const asked = ctx.url.searchParams.get("page");
src/web/style/content.ts +3
@@ -302,6 +302,9 @@ form.inline { display: inline; margin-left: auto; }
302302 what is below. */
303303 .sort-toggle { display: flex; align-items: center; min-height: 44px; padding: 0 4px; cursor: pointer; }
304304 .sort-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
305 .row-forks > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; padding: 0 12px; }

Add .row-forks > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; } as .sort-toggle has. Keep the nested indent small so rows on a 360px phone do not squeeze.

306 .row-forks > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
307 .row-forks > .list { margin-left: 8px; }
305308 .explore-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
306309 .explore-pager .btn { min-height: 44px; }
307310 .door-says { min-height: 1lh; margin: 6px 0 0; }
test/explore-fork-group.test.ts added +116
@@ -0,0 +1,116 @@
1 /**
2 * #14082: forks of an app fold under it on /explore with a count, in rank order; a tap opens them.
3 */
4 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
5 import { mkdtemp, rm } from "node:fs/promises";
6 import { tmpdir } from "node:os";
7 import { join } from "node:path";
8 import { createApp, type App } from "../src/app.ts";
9 import { newApp } from "../src/actions/apps.ts";
10 import { groupForks, type ExploreRow } from "../src/actions/explore.ts";
11 import { createSession } from "../src/core/sessions.ts";
12 import { createUser } from "../src/core/users.ts";
13 import { serve, type Servers } from "../src/http/server.ts";
14 import { quietLogs } from "./helpers/globals.ts";
15 import { promote } from "./helpers/members.ts";
16
17 quietLogs();
18
19 const row = (name: string, score: number, parentId?: string): ExploreRow => ({
20 kind: "app",
21 name,
22 url: `/${name}`,
23 description: "",
24 numbers: { forks: 0, ships: 0, likes: 0, awakeHours: 0, apps: 1 },
25 shippedAt: null,
26 score,
27 repo: { owner: name.split("/")[0]!, name: name.split("/")[1]!, id: name, branch: "main", public: true, ...(parentId === undefined ? {} : { parentId }) },
28 });
29
30 describe("groupForks", () => {
31 test("a parent with two forks: the forks leave the list and sit under it in list order", () => {
32 const out = groupForks([row("a/x", 9), row("c/x", 8, "a/x"), row("d/y", 5), row("b/x", 3, "a/x")]);
33 expect(out.map((r) => r.name)).toEqual(["a/x", "d/y"]);
34 expect(out[0]!.forked!.map((r) => r.name)).toEqual(["c/x", "b/x"]);
35 expect(out[1]!.forked).toBeUndefined();
36 });
37
38 test("a fork whose parent is not listed stays a row of its own", () => {
39 expect(groupForks([row("c/x", 8, "gone")]).map((r) => r.name)).toEqual(["c/x"]);
40 });
41 });
42
43 describe("explore: forks under their parent", () => {
44 let dataDir: string;
45 let app: App;
46 let servers: Servers;
47
48 beforeAll(async () => {
49 dataDir = await mkdtemp(join(tmpdir(), "forge-explore-group-"));
50 app = createApp({ dataDir, port: 0 });
51 servers = await serve(app);
52 const users = [];
53 for (const [i, username] of ["alice", "bob", "carol"].entries()) {
54 const r = await createUser(app.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst: i === 0 });
55 if (!r.ok) throw new Error(r.error);
56 promote(app.db, r.value);
57 users.push(r.value);
58 }
59 const made = await newApp(app, users[0]!, { name: "garden", description: "a garden", visibility: "public" });
60 if (!made.ok) throw new Error(String(made.error));
61 for (const u of users.slice(1)) {
62 const cookie = `forge_session=${createSession(app.db, u.id).token}`;
63 const res = await fetch(`${servers.url}/alice/garden/make-it-yours`, { method: "POST", headers: { cookie, origin: servers.url }, redirect: "manual" });
64 if (res.status >= 400) throw new Error(`fork ${res.status}`);
65 }
66 // Forks start private; these two are shared.
67 app.db.run("UPDATE repo SET visibility = 'public'");
68 }, 60_000);
69
70 afterAll(async () => {
71 servers.stop();
72 app.close();
73 await rm(dataDir, { recursive: true, force: true });
74 });
75
76 test("the page lists the parent once with '2 forks' and the forks inside the fold", async () => {
77 const page = await fetch(`${servers.url}/explore?q=kind:app`).then((r) => r.text());
78 expect(page).toContain("2 forks</summary>");
79 const fold = page.match(/<details class="row-forks" data-forks>([\s\S]*?)<\/details>/)![1]!;
80 expect(fold).toContain('href="/bob/garden"');
81 expect(fold).toContain('href="/carol/garden"');
82 // Beside the parent, not in the top-level list: each fork link appears once.
83 expect(page.split('href="/bob/garden"').length).toBe(2);
84 expect(page.indexOf('href="/alice/garden"')).toBeLessThan(page.indexOf("data-forks"));
85 });
86 });
87
88 describe("parentId in the public API", () => {
89 test("a fork of a private parent does not name it, and stands as a row of its own", async () => {
90 const dir = await mkdtemp(join(tmpdir(), "forge-explore-parent-"));
91 const a = createApp({ dataDir: dir, port: 0 });
92 const s = await serve(a);
93 try {
94 const users = [];
95 for (const [i, username] of ["alice", "bob"].entries()) {
96 const r = await createUser(a.db, { origin: "seed", trusted: true, username, email: `${username}@forge.local`, password: "a-good-passphrase", adminIfFirst: i === 0 });
97 if (!r.ok) throw new Error(r.error);
98 promote(a.db, r.value);
99 users.push(r.value);
100 }
101 const made = await newApp(a, users[0]!, { name: "garden", description: "a garden", visibility: "public" });
102 if (!made.ok) throw new Error(String(made.error));
103 const cookie = `forge_session=${createSession(a.db, users[1]!.id).token}`;
104 await fetch(`${s.url}/alice/garden/make-it-yours`, { method: "POST", headers: { cookie, origin: s.url }, redirect: "manual" });
105 a.db.run("UPDATE repo SET visibility = 'public' WHERE owner_id != (SELECT id FROM user WHERE username = 'alice')");
106 a.db.run("UPDATE repo SET visibility = 'private' WHERE id IN (SELECT fork_parent_id FROM repo WHERE fork_parent_id IS NOT NULL)");
107 const api = (await fetch(`${s.url}/api/v1/explore?kind=app`).then((r) => r.json())) as { items: { name: string; repo?: { parentId?: string } }[] };
108 expect(api.items.map((i) => i.name)).toEqual(["bob/garden"]);
109 expect(api.items[0]!.repo!.parentId).toBeUndefined();
110 } finally {
111 s.stop();
112 a.close();
113 await rm(dir, { recursive: true, force: true });
114 }
115 }, 60_000);
116 });
test/explore-parity.test.ts +27 −7
@@ -16,7 +16,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
1717 import { proveAll } from "./helpers/verified.ts";
1818 import { promote } from "./helpers/members.ts";
19 import { exploreParams, readExploreLine } from "../src/actions/explore.ts";
19 import { exploreParams, groupForks, readExploreLine, type ExploreRow } from "../src/actions/explore.ts";
2020 /** The href the page gives a line: separate parameters, `&` escaped as in markup. */
2121 const linkOf = (line: string): string => `/explore?${exploreParams(readExploreLine(line).query)}`.replace(/&/g, "&amp;");
2222
@@ -139,11 +139,31 @@ const LINES = [
139139 * to its own url.
140140 */
141141 function pageOrder(html: string): string[] {
142 const list = /<ul class="list">([\s\S]*?)<\/ul>/.exec(html);
143 if (list === null) return [];
142 // The top-level list: from its `<ul class="list">` to the `</ul>` that closes it, counting the
outdated

Loosening the terminator to </main> makes this helper match more than the list. Keep the assertion strict.

143 // lists folded inside rows (forks) so the first of those does not end it.
144 const open = html.indexOf('<ul class="list">');
145 if (open < 0) return [];
146 let depth = 0;
147 let end = -1;
148 for (const m of html.slice(open).matchAll(/<ul[\s>]|<\/ul>/g)) {
149 depth += m[0] === "</ul>" ? -1 : 1;
150 if (depth === 0) {
151 end = open + m.index!;
152 break;
153 }
154 }
155 if (end < 0) return [];
156 const list = [null, html.slice(open + '<ul class="list">'.length, end)] as const;
144157 return [...list[1]!.matchAll(/<li[^>]*>[\s\S]*?<a href="(\/[^"?]*)">[^<]*<\/a>/g)].map((m) => m[1]!);
145158 }
146159
160 /**
161 * The page folds forks under their parent (#14082): its order is the API's order grouped the same
162 * way, each fork right after the app it came from.
163 */
164 const grouped = (items: readonly { url: string }[]): string[] =>
165 groupForks(items as unknown as ExploreRow[]).flatMap((r) => [r.url, ...(r.forked ?? []).map((f) => f.url)]);
166
147167 const ids = (items: { kind: string; name: string }[]) => items.map((i) => `${i.kind}:${i.name}`);
148168
149169 async function mcp(line: string): Promise<{ ok: boolean; text: string }> {
@@ -181,7 +201,7 @@ describe("one filter, three surfaces", () => {
181201 expect(tool.ok).toBe(true);
182202 expect((JSON.parse(tool.text) as typeof api).items.map((i) => i.name)).toEqual(api.items.map((i) => i.name));
183203 const html = await (await fetch(`${servers.url}/explore?q=${encodeURIComponent(line)}`)).text();
184 expect(pageOrder(html)).toEqual(api.items.map((i) => i.url));
204 expect(pageOrder(html)).toEqual(grouped(api.items));
185205 });
186206 }
187207
@@ -200,7 +220,7 @@ describe("one filter, three surfaces", () => {
200220 const tool = await mcp(line);
201221 expect(ids((JSON.parse(tool.text) as typeof api).items)).toEqual(ids(api.items));
202222 const html = await (await fetch(`${servers.url}/explore?q=${encodeURIComponent(line)}`)).text();
203 expect(pageOrder(html)).toEqual(api.items.map((i) => i.url));
223 expect(pageOrder(html)).toEqual(grouped(api.items));
204224 });
205225 }
206226
@@ -250,7 +270,7 @@ describe("one filter, three surfaces", () => {
250270 // The page, anonymous, sees the same public rows; its order is the API's order.
251271 const anon = (await (await fetch(`${servers.url}/api/v1/explore?q=${encodeURIComponent(line)}`)).json()) as { items: { kind: string; name: string; url: string }[] };
252272 const html = await (await fetch(`${servers.url}/explore?q=${encodeURIComponent(line)}`)).text();
253 expect(pageOrder(html)).toEqual(anon.items.map((i) => i.url));
273 expect(pageOrder(html)).toEqual(grouped(anon.items));
254274 });
255275 }
256276
@@ -313,7 +333,7 @@ describe("separate parameters", () => {
313333 expect(ids(await names(`q=${encodeURIComponent(line)}`))).toEqual(ids(api));
314334 const html = await (await fetch(`${servers.url}/explore?${qs}`)).text();
315335 expect(pageOrder(html)).toEqual(
316 ((await (await fetch(`${servers.url}/api/v1/explore?${qs}`)).json()) as { items: { url: string }[] }).items.map((i) => i.url),
336 grouped(((await (await fetch(`${servers.url}/api/v1/explore?${qs}`)).json()) as { items: { url: string }[] }).items),
317337 );
318338 });
319339 }
test/tui-dashboard-explore.test.ts +20
@@ -301,3 +301,23 @@ test("the palette's repo prompt offers /system to an admin and never to a guest"
301301 expect(guest).toContain("not found");
302302 expect(guest).not.toContain("/system");
303303 });
304
305 test("forks of a listed app fold under it with a count; f opens them in place (#14082)", async () => {
306 const mk = async (owner: User, name: string, parent?: Repo): Promise<Repo> => {
307 const r = await appOf(owner, name);
308 if (parent !== undefined) forge.db.query(`UPDATE repo SET fork_parent_id = ?1 WHERE id = ?2`).run(parent.id, r.id);
309 return r;
310 };
311 const root = await mk(alice, "root");
312 await mk(bob, "root-a", root);
313 await mk(bob, "root-b", root);
314 const closed = await typed("kind:app sort:name");
315 expect(closed).toContain("alice/root");
316 expect(closed).toContain("▸ 2 forks under it (f)");
317 expect(closed).not.toContain("bob/root-a");
318 // enter leaves the line for the list; ant, mid, root: two down, then f.
319 const open = await typed("kind:app sort:name", ["enter", "down", "down", "f"]);
320 expect(open).toContain("▾ 2 forks under it (f)");
321 expect(open).toContain("↳ bob/root-a");
322 expect(open).toContain("↳ bob/root-b");
323 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs