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

A list is one line a row and detail opens on demand: crew member descriptions first #18481

opened this

Merged 4h 55m ago, live in production

scout/forge:scout/18478-a-list-is-one-line-a-row-and-detail-open → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/18478-a-list-is-one-line-a-row-and-detail-open was merged into main as 324c098.

Review

Sign in to review this change.
7 files changed +191 −29
docs/features/crew-roles.md +2
@@ -12,3 +12,5 @@ An agent declares its **roles** in its own config: any of planner, builder, revi
1212 - **A dispatch keeps to the seat.** An assigned issue, feedback, a red check, a conflict, a converge and a resolve run only for a builder (the direction issue only for a planner); a review only for a reviewer. An issue assigned to a planner or reviewer gets one comment saying so.
1313 - **`/migrate`** offers builders only; `crew=<name>` naming anyone else is refused in a sentence and the first builder stays the default.
1414 - **No reviewer says so (#3512).** A crew with a builder and no reviewer shows "Nobody reviews this crew's pulls: agent pulls wait for you" on Settings → Crew and in the terminal's About card (a Warning row with the same count), with a *Make <name> the reviewer* button for each member who declares the role (admins only; the terminal's `r` does the same for the first). The autonomy tick line adds `review="no reviewer"` and `waits for a reviewer=N` (open agent pulls). Code: `reviewerGap` in `src/crew/seats.ts`.
15
16 A seated member is one line on a repository's settings page: its name, the seat it holds and its state (working or paused). Its model and brief open in place, under the line, from the chevron: no reload, and only what is below moves (`memberRow` in `src/web/studio/crew.ts`, `test/multiline-rows.test.ts`). The terminal's seat list (`src/tui/screens/about.ts`) already gives one member a line. `scripts/multiline-rows.json` lists the modules whose rows still run past one line; it only shrinks, and this page is not on it.
scripts/multiline-rows.json added +32
@@ -0,0 +1,32 @@
1 {
2 "/": ["src/web/first_wrong.ts"],
3 "/:owner": ["src/web/describe.ts", "src/web/pages/org.ts"],
4 "/:owner/:name": ["src/web/studio/adapter.ts", "src/web/studio/app.ts", "src/web/studio/crash_card.ts"],
5 "/:owner/:name/map": ["src/web/node_facts.ts", "src/web/space_view.ts"],
6 "/:owner/:name/releases": ["src/web/pages/app_releases.ts"],
7 "/:owner/:name/variants": ["src/web/pages/app_variants.ts"],
8 "/:owner/:name/waves": ["src/web/pages/waves.ts"],
9 "/admin/abstractions": ["src/web/pages/abstractions.ts"],
10 "/admin/limits": ["src/web/pages/system.ts"],
11 "/admin/plans": ["src/web/settings/plans.ts"],
12 "/advisories": ["src/web/pages/advisories.ts"],
13 "/archive": ["src/web/pages/archive.ts"],
14 "/boards": ["src/web/pages/boards.ts"],
15 "/changelog": ["src/web/pages/changelog.ts"],
16 "/cloud": ["src/web/pages/cloud.ts"],
17 "/design/registry": ["src/web/pages/registry_gallery.ts"],
18 "/flow": ["src/web/pages/boards-doctor.ts", "src/web/pages/flow-waiting.ts"],
19 "/games": ["src/web/pages/games.ts", "src/web/pages/games_spark_view.ts"],
20 "/infra": ["src/web/pages/infra.ts"],
21 "/migrate": ["src/web/pages/inventory.ts"],
22 "/pinned": ["src/web/pages/pinned.ts"],
23 "/runs/:id": ["src/web/pages/runs.ts"],
24 "/settings/account": ["src/web/pages/account.ts"],
25 "/settings/devices": ["src/web/settings/devices.ts"],
26 "/settings/features": ["src/web/pages/features.ts"],
27 "/settings/model": ["src/web/pages/connections.ts"],
28 "/settings/origins": ["src/web/scope.ts"],
29 "/settings/runners": ["src/web/pages/runners.ts"],
30 "/settings/traffic": ["src/web/pages/visitors.ts"],
31 "/templates": ["src/web/template_card.ts"]
32 }
scripts/multiline-rows.ts added +32
@@ -0,0 +1,32 @@
1 /**
2 * Pages whose rows exceed one line (#18478, P18 line 2 of #334). A list is one line a row and
3 * detail opens on demand; a row that carries `facts` draws a `dl` under its meta, so it is more
4 * than one line by construction. This reads the web tree for the modules that draw one and
5 * `scripts/multiline-rows.json` names them by the route they draw, `{ route: [module] }`: the list only shrinks (`--write` prunes). The crew
6 * page (`src/web/studio/crew.ts`, the repository's `/settings` Your team) is not on it: a member
7 * is one line and its words open in place (`memberRow`).
8 */
9
10 import { readFileSync, writeFileSync } from "node:fs";
11 import { join } from "node:path";
12

The issue says the list is by route; this returns modules. Map them to the routes that mount them, or the box is not met.

13 /** `src/web/**` modules that pass `facts:` to a row, sorted. */
14 export function multilineRows(root: string): string[] {
15 return [...new Bun.Glob("src/web/**/*.ts").scanSync({ cwd: root })]
16 .filter((f) => !f.includes("/style/") && !f.includes("/render/") && f !== "src/web/ui.ts")
17 .filter((f) => /\bfacts\s*[:,]/.test(readFileSync(join(root, f), "utf8")))
18 .sort();
19 }
20
21 if (import.meta.main) {
22 const root = join(import.meta.dir, "..");
23 const path = join(root, "scripts/multiline-rows.json");
24 const found = multilineRows(root);
25 if (process.argv.includes("--write")) {
26 const listed: Record<string, string[]> = JSON.parse(readFileSync(path, "utf8"));
27 const kept = Object.entries(listed)
28 .map(([route, mods]) => [route, mods.filter((f) => found.includes(f))] as const)
29 .filter(([, mods]) => mods.length > 0);
30 writeFileSync(path, JSON.stringify(Object.fromEntries(kept), null, 2) + "\n");
31 } else console.log(found.join("\n"));
32 }
src/web/studio/crew.ts +45 −28
@@ -129,6 +129,48 @@ export const teamJs = /* js */ `
129129 })();
130130 `;
131131
132 /**
133 * One crew member as one line: name, the seat it holds, its state. What the agent's own words say
134 * (its model and brief) opens in place, a native `<details>`, closed on first paint, so a row
135 * opening moves only what is below it and needs no script and no reload; a member with nothing
136 * to say is a plain line. Every word of it is escaped by `html`. The remove button sits beside the
137 * row (`after`), not in the summary, so pressing it never toggles the row.
138 */
139 export function memberRow(
140 user: string,
141 agent: Agent | undefined,
142 role: CrewRole,
143 paused: boolean,
144 base: string,
145 admin: boolean,
146 ): Html {
147 const said = [agent?.model ?? "", agent?.brief ?? ""].filter((w) => w !== "");
148 const state = role === "maintainer" ? null : paused ? badge("paused", { tone: "attn" }) : badge("working", { tone: "success" });
149 return row({
150 lead: said.length === 0 ? icon("bot") : icon("chevronRight"),
151 title: agent ? userLink(user, { mark: markOf(agent.user) }) : userLink(user),
152 meta: html`${role}`,
153 ...(state === null ? {} : { trail: state }),
154 ...(said.length === 0
155 ? {}
156 : {
157 fold: {
158 id: `member-${role}-${user.replace(/[^a-z0-9]+/gi, "-")}`,
159 open: false,
160 body: html`<div class="card-body" data-said>${said.map((w, i) => html`<p class="${i === 0 ? "muted small" : "small"}">${w}</p>`)}</div>`,
161 },
162 }),
163 ...(admin
164 ? {
165 after: html`<form class="row-actions" method="post" action="${base}/settings/crew/${encodeURIComponent(user)}/remove">
166 ${btn("Remove", { size: "sm", icon: "x" })}
167 </form>`,
168 }
169 : {}),
170 data: { member: user, seat: role },
171 });
172 }
173
132174 const SEAT_TITLE: Record<CrewRole, string> = {
133175 planner: "Planners",
134176 builder: "Builders",
@@ -186,20 +228,7 @@ function teamCard(
186228 </form>`;
187229 const members = p.by.map((u) => {
188230 const agent = byName.get(u);
189 const said = [agent?.model ?? "", agent?.brief ?? ""].filter((w) => w !== "").join(" · ");
190 return row({
191 lead: icon("bot"),
192 title: agent ? userLink(u, { mark: markOf(agent.user) }) : userLink(u),
193 ...(said === "" ? {} : { meta: html`<span title="${said}">${said}</span>` }),
194 ...(admin
195 ? {
196 trail: html`<form class="row-actions" method="post" action="${base}/settings/crew/${encodeURIComponent(u)}/remove">
197 ${btn("Remove", { size: "sm", icon: "x" })}
198 </form>`,
199 }
200 : {}),
201 data: { member: u, seat: p.role },
202 });
231 return memberRow(u, agent, p.role, paused, base, admin);
203232 });
204233 return row({
205234 lead: icon(SEAT_LEAD[p.state]),
@@ -284,20 +313,8 @@ function maintainerRow(
284313 </form>`;
285314 const members = crew
286315 .filter((c) => c.role === "maintainer")
287 .map((c) =>
288 row({
289 lead: icon("bot"),
290 title: userLink(c.agent.user.username, { mark: markOf(c.agent.user) }),
291 ...(admin
292 ? {
293 trail: html`<form class="row-actions" method="post" action="${base}/settings/crew/${encodeURIComponent(c.agent.user.username)}/remove">
294 ${btn("Remove", { size: "sm", icon: "x" })}
295 </form>`,
296 }
297 : {}),
298 data: { member: c.agent.user.username, seat: "maintainer" },
299 }),
300 );
316 .map((c) => memberRow(c.agent.user.username, c.agent, "maintainer", false, base, admin));
317
301318 // No maintainer seated and none to add: the row would say nothing, so it is not drawn.
302319 if (members.length === 0 && add === null) return null;
303320 return row({
src/web/style/components.ts +3
@@ -654,6 +654,9 @@ details[open] > summary.row > .row-lead { transform: rotate(90deg); }
654654 .setting-list .row { flex-wrap: wrap; align-items: flex-start; }
655655 .setting-list .row-main { flex: 1 1 18rem; }
656656 .setting-list .row-title, .setting-list .row-meta { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
657 /* A crew member is one line (#18478): its words open in place, they never wrap the row. A name
658 too long for a phone still wraps anywhere (the .setting-list rule above), never sideways. */
659 .setting-list li[data-member] .row-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
657660 .setting-list .record-value { user-select: all; }
658661 .setting-list .row-trail { flex: 0 1 auto; max-width: 100%; }
659662 @media (max-width: 640px) { .setting-list .row-trail { flex-basis: 100%; } }
test/multiline-rows.test.ts added +75
@@ -0,0 +1,75 @@
1 /**
2 * A list is one line a row and detail opens on demand (#18478, P18 line 2 of #334): the modules
3 * that still draw rows of more than one line are listed in `scripts/multiline-rows.json`, and the
4 * list only shrinks. The crew page opens a member's words in place.
5 */
6
7 import { expect, test } from "bun:test";
8 import { readFileSync } from "node:fs";
9 import { join } from "node:path";
10 import { multilineRows } from "../scripts/multiline-rows.ts";
11 import listed from "../scripts/multiline-rows.json";
12 import { memberRow } from "../src/web/studio/crew.ts";
13 import type { Agent } from "../src/core/agents.ts";
14
15 const root = new URL("..", import.meta.url).pathname;
16 const found = multilineRows(root);
17 const routes = listed as Record<string, string[]>;
18 const modules = Object.values(routes).flat();
19
20 test("a module drawing rows of more than one line is on the list, or the row folds its detail", () => {
21 const fresh = found.filter((f) => !modules.includes(f));
22 expect(fresh, `these modules draw rows with facts, more than one line: open the detail on demand (see memberRow), or list them under the route they draw in scripts/multiline-rows.json: ${fresh.join(", ")}`).toEqual([]);
outdated

CEILING repeats what the two tests above already enforce; it is a second rule for one thing. Remove it.

23 });
24
25 test("a listed module that stopped drawing such rows is pruned", () => {
26 const stale = modules.filter((f) => !found.includes(f));
27 expect(stale, `run \`bun scripts/multiline-rows.ts --write\`: ${stale.join(", ")}`).toEqual([]);
28 });
29
30 test("each listed route is one the forge serves, and names a module once", () => {
31 const served = ["src/http", "src/web"].flatMap((d) => [...new Bun.Glob(`${d}/**/*.ts`).scanSync({ cwd: root })]).map((f) => readFileSync(join(root, f), "utf8")).join("\n");
32 const unserved = Object.keys(routes).filter((r) => r !== "/" && !served.includes(r));
33 expect(unserved, "a route no source names").toEqual([]);
34 expect(new Set(modules).size).toBe(modules.length);
35 });
36
37 test("the crew page is not on the list", () => {
38 expect(modules.filter((f) => f.endsWith("studio/crew.ts"))).toEqual([]);
outdated

Box 3 asks for tests of open and close. Add: the details id is the anchor that opens the row, the form is outside the details element, and a member with words is closed by default. At present only first paint is covered.

39 expect(Object.keys(routes)).not.toContain("/:owner/:name/settings");
40 });
41
42 const agent = { user: { username: "bob", id: "u1" }, model: "sonnet", brief: '<script>alert(1)</script> builds "things"', roles: ["builder"] } as unknown as Agent;
43
44 test("a member is one closed line; its words wait inside, escaped, and a click or its link opens them", () => {
45 const out = memberRow("bob", agent, "builder", false, "/a/b", true).text;
46 expect(out).toContain('data-member="bob"');
47 expect(out).toMatch(/<details id="member-builder-bob"\s*>/);
48 expect(out).not.toMatch(/<details[^>]* open/);
49 expect(out).toContain("<summary");
50 expect(out).not.toContain("<script>");
51 expect(out).toContain("&lt;script&gt;");
52 expect(out).toContain("working");
53 // the button is beside the row, not inside the summary it would toggle
54 expect(out.indexOf("</summary>")).toBeLessThan(out.indexOf("/remove"));
55 });
56
57 test("a member with nothing to say is a plain line, with no fold; a paused seat says so", () => {
58 const bare = { user: { username: "amy", id: "u2" }, model: "", brief: "", roles: ["builder"] } as unknown as Agent;
59 const out = memberRow("amy", bare, "builder", true, "/a/b", false).text;
60 expect(out).not.toContain("<details");
61 expect(out).toContain("paused");
62 expect(out).not.toContain("/remove");
63 });
64
65 test("the details id is the anchor that opens the row, and the form sits beside the details, not in it", () => {
66 const out = memberRow("bob", agent, "builder", false, "/a/b", true).text;
67 const d = out.indexOf("<details");
68 const end = out.indexOf("</details>");
69 expect(out.slice(d, out.indexOf(">", d))).toContain('id="member-builder-bob"');
70 expect(out.slice(d, end)).not.toContain("<form");
71 expect(out.indexOf("<form")).toBeGreaterThan(end);
72 // one summary, the only toggle
73 expect(out.match(/<summary/g)?.length).toBe(1);
74 expect(out.slice(d, end)).toContain("sonnet");
75 });
test/studio-stranger.test.ts +2 −1
@@ -461,7 +461,8 @@ describe("a stranger sees the app, not the owner's books", () => {
461461 // reviewer: it is drawn once, under the seat it holds — the team lists
462462 // are the crew, there is no second Crew card listing it again.
463463 const keeperRows = after.match(/<li[^>]*data-member="keeper"[^>]*>/g) ?? [];
464 expect(keeperRows).toEqual(['<li data-member="keeper" data-seat="builder">']);
464 expect(keeperRows.length).toBe(1);
465 expect(keeperRows[0]).toBe('<li class="has-after" data-member="keeper" data-seat="builder">');
465466 expect(after).not.toContain("<h2>Crew</h2>");
466467 });
467468

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs