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

Repo header: descriptions clamp to 2 lines with expand (apps API separates description from brief), and a clear crew status line: "paused at its ceiling" with a Raise button #16936

Merged opened this

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

Merged

scout/forge:scout/6008-repo-header-descriptions-clamp-to-2-line → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/6008-repo-header-descriptions-clamp-to-2-line was merged into main as 81d5354.

Review

Sign in to review this change.
52 files changed +588 −93
docs/design/areas/clamp.md added +13
@@ -0,0 +1,13 @@
1 # Clamp (descriptions)

Principle 1: the sentence says what the clamp is for. The list of classes is fine. But no docs/features/ how-to covers the new brief field.

2
3 A repository's or app's description, at most two lines tall, with a quiet "more" that opens it in place and "less"
4 that closes it. No script: a visually hidden checkbox inside a label does the toggling. Written by `src/web/clamp.ts`
5 (used by `chrome.ts`'s repo header, `pages/repo.ts` and `pages/browse.ts`'s About card, `studio/home.ts`); styled in
6 `style/content.ts`. A description of 40 characters or fewer gets no expander; one of up to 200 keeps it on phones only (two lines hold it from 760px).
7
8 - `.clamp` — the paragraph around a description.
9 - `.clamp-l` — the label that wraps the text and the word, so a click on either toggles.
10 - `.clamp-x` — the hidden checkbox holding the open state.
11 - `.clamp-t` — the text, cut to two lines (`-webkit-line-clamp: 2`) until the checkbox is checked.
12 - `.clamp-open` — the quiet "more"/"less" word, drawn by CSS.
13 - `.clamp-mid` — a description of up to 200 characters: its "more" word is hidden from 760px wide.
docs/design/attention-budget.json +22 −21
@@ -63,41 +63,42 @@
6363 },
6464 "issues list": {
6565 "390": {
66 "words": 32,
67 "blocks": 7,
66 "words": 43,
67 "blocks": 8,
6868 "colours": 2
6969 },
7070 "1280": {
71 "words": 32,
72 "blocks": 7,
71 "words": 43,
72 "blocks": 8,
7373 "colours": 2
7474 },
75 "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
75 "note": "Raised by 11 words and one block for the crew line an admin sees in the repository head (#6008); the line is the one place the crew's state and its one fix are said. Before: Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
7676 },
7777 "pulls list": {
7878 "390": {
79 "words": 26,
80 "blocks": 6,
79 "words": 37,
80 "blocks": 7,
8181 "colours": 1
8282 },
8383 "1280": {
84 "words": 26,
85 "blocks": 6,
84 "words": 37,
85 "blocks": 7,
8686 "colours": 1
8787 },
88 "note": "Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
88 "note": "Raised by 11 words and one block for the crew line an admin sees in the repository head (#6008); the line is the one place the crew's state and its one fix are said. Before: Raised by 2 words for the #N that leads each row's meta line, so a person on a phone can say which one they mean (#16418)."
8989 },
9090 "runs": {
9191 "390": {
92 "words": 38,
93 "blocks": 8,
92 "words": 49,
93 "blocks": 9,
9494 "colours": 1
9595 },
9696 "1280": {
97 "words": 38,
98 "blocks": 8,
97 "words": 49,
98 "blocks": 9,
9999 "colours": 1
100 }
100 },
101 "note": "Raised by 11 words and one block for the crew line an admin sees in the repository head (#6008); the line is the one place the crew's state and its one fix are said."
101102 },
102103 "run": {
103104 "390": {
@@ -225,7 +226,7 @@
225226 "blocks": 99,
226227 "colours": 2
227228 },
228 "note": "Raised by 6 words and 3 blocks for the slots above the pipeline, at their least: a line each for checks and the crew (\"Checks 0 of 1 slots busy\", nothing more while nothing waits) and the Change capacity button that replaced the header's Capacity link; no legend (#16830). Plus 3 words and 1 block for the live line, \"live · Pause\", the one mechanism that replaced the page's old refresh (#3715)."
229 "note": "Raised by 6 words and 3 blocks for the slots above the pipeline, at their least: a line each for checks and the crew (\"Checks 0 of 1 slots busy\", nothing more while nothing waits) and the Change capacity button that replaced the header's Capacity link; no legend (#16830). Plus 3 words and 1 block for the live line, \"live \u00b7 Pause\", the one mechanism that replaced the page's old refresh (#3715)."
229230 },
230231 "forges": {
231232 "390": {
@@ -254,15 +255,15 @@
254255 },
255256 "milestone": {
256257 "390": {
257 "words": 90,
258 "blocks": 20,
258 "words": 101,
259 "blocks": 21,
259260 "colours": 2
260261 },
261262 "1280": {
262 "words": 90,
263 "blocks": 20,
263 "words": 101,
264 "blocks": 21,
264265 "colours": 2
265266 },
266 "note": "Added with #14795: the first view of a milestone, open work first and done folded behind one \"Show done issues (N)\" link. Raised for #15839: ` \u00b7 landed <date>` on the muted weight line, 3 words, no block."
267 "note": "Raised by 11 words and one block for the crew line an admin sees in the repository head (#6008); the line is the one place the crew's state and its one fix are said. Before: Added with #14795: the first view of a milestone, open work first and done folded behind one \"Show done issues (N)\" link. Raised for #15839: ` \u00b7 landed <date>` on the muted weight line, 3 words, no block."
267268 }
268269 }
docs/design/size-budget/board.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/board",
3 "js": 29184,
4 "css": 51712
3 "js": 29440,
4 "css": 52736
55 }
docs/design/size-budget/changelog.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/changelog",
3 "js": 29696,
4 "css": 51712
3 "js": 30208,
4 "css": 52736
55 }
docs/design/size-budget/claim.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/claim",
3 "js": 27136,
4 "css": 51712
3 "js": 27648,
4 "css": 52736
55 }
docs/design/size-budget/explore.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/explore",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/design/size-budget/feed.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/feed",
3 "js": 39168,
4 "css": 51712
3 "js": 39680,
4 "css": 52736
55 }
docs/design/size-budget/fleet.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/fleet",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/design/size-budget/forges-new.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/forges/new",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/design/size-budget/home.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/",
3 "js": 24576,
4 "css": 51712
3 "js": 24832,
4 "css": 52736
55 }
docs/design/size-budget/maintenance.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/maintenance",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/design/size-budget/map.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/map",
3 "js": 31744,
4 "css": 53248
3 "js": 32256,
4 "css": 54528
55 }
docs/design/size-budget/owner-name-next.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/:owner/:name/next",
3 "js": 26112,
4 "css": 51968
3 "js": 26368,
4 "css": 52992
55 }
docs/design/size-budget/owner-name-pulls-number.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/:owner/:name/pulls/:number",
3 "js": 34560,
4 "css": 51712
3 "js": 35072,
4 "css": 52736
55 }
docs/design/size-budget/owner-name-space.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/:owner/:name/space",
3 "js": 33024,
4 "css": 52736
3 "js": 33536,
4 "css": 54016
55 }
docs/design/size-budget/owner-name.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/:owner/:name",
3 "js": 41216,
4 "css": 51712
3 "js": 41728,
4 "css": 52736
55 }
docs/design/size-budget/pricing.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/pricing",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/design/size-budget/system.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/system",
3 "js": 26112,
4 "css": 51712
3 "js": 26368,
4 "css": 52736
55 }
docs/design/size-budget/talk.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/talk",
3 "js": 42496,
4 "css": 58112
3 "js": 43008,
4 "css": 59392
55 }
docs/design/size-budget/templates.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "page": "/templates",
3 "js": 24320,
4 "css": 51712
3 "js": 24576,
4 "css": 52736
55 }
docs/features/app-description-brief.md added +16
@@ -0,0 +1,16 @@
1 ---
2 topic: Your first app in five minutes
3 row: A description and a brief, kept apart
4 ---
5 # A description and a brief, kept apart (#6008)
6
7 An app has a **description**, one line every card and the repository header show, and a **brief**, the longer ask that is the body of its first issue. The header clamps a description to two lines; "more" opens it in place and "less" closes it (no script).
8
9 - **API** (`POST /api/v1/apps`): send `description` (at most 160 characters when a `brief` comes with it) and `brief` (at most 4000). Send only a long `description` and it is the brief, its first sentence the description; a short one serves as both, as it always did. Refused in words: `description_too_long` (422) when the description is over 160 and a brief came too, `brief_too_long` (422) over 4000.
10 - **Terminal** (`forge new NAME "a line" --brief "the longer ask"`, `src/cli/commands/new.ts`; the forge's own terminal shows the same refusals from `src/tui/screens/common.ts`): the same two fields, the same refusals.
11 - **MCP** (`new_app`, `src/http/mcp/tools/new_app.ts`): `description` and `brief` as above.
12 - **Web** (`/apps/new`, `src/web/pages/apps.ts`): one box; a long text is split as above.
13
14 The limits live in one place, `newApp` in `src/actions/apps.ts` (`src/actions/app_brief.ts` does the split); every door reaches it. The clamp is `src/web/clamp.ts` (a description of 40 characters or fewer gets no expander; up to 200 the word shows on phones only).
15
16 Tests: `test/description-clamp.test.ts`, `test/description-clamp-browse.test.ts`.
docs/features/crew-stop-line.md added +15
@@ -0,0 +1,15 @@
1 ---
2 topic: Tell the crew
3 row: The crew line at the top of a repository
4 ---
5 # The crew line at the top of a repository
6
7 A repository's admins see one line under its description saying what the crew is doing here (#6008). The web header and the terminal's Autonomy screen (`Crew` row) print the same words from `stopWords` (`src/crew/stop_words.ts`), read from `autonomyStatus`, the status the loop itself gates on.
8
9 - **Running**: `Crew: 2 of 3 slots building.` in quiet text.
10 - **Stopped**, each with its one fix: *off* (Turn autonomy on), *waiting on a decision* (Set the mode), *no crew* (Add an agent). The fix links to Settings › Autonomy; in the terminal it is `m` on that screen.
11 - **Paused** by the week's share or the forge's ceiling: says until when, UTC. These end by themselves, so no fix.
12
13 With the forge's daily ceiling set (`FORGE_CREW_CEILING_USD`) the line names it: `Crew: 2 of 3 slots building · $19 of $300 today.`, a notice from 80% (`Nearing today's $40 ceiling ($32 spent).`) and, at the cap, `Crew paused: at today's $40 ceiling ($43.07 spent). Resumes 2026-12-02 00:00 UTC.`
14
15 Not here: a Raise ceiling button (the ceiling is read from the forge's environment at boot, so neither a repository's admin nor a fleet op can change it) and the one-off owner notification.
scripts/doorless-allow.json −1
@@ -4,7 +4,6 @@
44 "src/web/pages/app_flag_edit.ts",
55 "src/web/pages/app_variants.ts",
66 "src/web/pages/apps-starters.ts",
7 "src/web/pages/apps.ts",
87 "src/web/pages/asking.ts",
98 "src/web/pages/backups.ts",
109 "src/web/pages/board-notes.ts",
src/actions/app_brief.ts added +33
@@ -0,0 +1,33 @@
1 /**
2 * An app's one-line description and its brief, kept apart: the description
3 * is what the repository header and every card show (at most `MAX_DESCRIPTION`
4 * characters); the brief (at most `BRIEF_MAX`) is the longer ask that opens issue #1.
5 */
6
7 import { cutWords, sentenceOf } from "../core/client-apps.ts";
8
9 export const MAX_DESCRIPTION = 160;
10
11 export interface Split {
12 readonly description: string;
13 readonly brief: string;
outdated

Duplicates cutTitle in core/client-apps.ts: one way to cut a sentence, please. Reuse it, or say why not.

14 }
15
16 /**
17 * The first sentence of `text`, cut at a word to fit `MAX_DESCRIPTION` (the cut `cutTitle` makes).
18 */
19 export function firstSentence(text: string): string {
20 return cutWords(sentenceOf(text), MAX_DESCRIPTION);
21 }
22
23 /**
24 * With only a description, a long one is the brief and the description
25 * becomes its first sentence; a short one serves as both, as it always did.
26 */
27 export function splitDescription(description: string, brief?: string): Split {
28 const d = description.trim();
29 const b = (brief ?? "").trim();
30 if (b !== "") return { description: d, brief: b };
31 if (d.length <= MAX_DESCRIPTION) return { description: d, brief: d };
32 return { description: firstSentence(d), brief: d };
33 }
src/actions/apps.ts +24 −7
@@ -8,7 +8,9 @@
88
99 import { runnerSettings } from "../crew/runner_env.ts";
1010 import { getVariant } from "../core/variants.ts";
11 import { pullDir } from "../core/pulls.ts";
11 import { MAX_DESCRIPTION, splitDescription } from "./app_brief.ts";
12 import { BRIEF_MAX } from "../core/agents.ts";
13 import { getPull, pullDir } from "../core/pulls.ts";
1214 import { mayView, sealedPreviewPull } from "../core/sealed.ts";
1315 import { deriveAppName } from "../web/pages/apps-name.ts";
1416 import { REPO_DIR_IN_THE_WAY, REPO_INIT_FAILED, REPO_NAME_RULES } from "./repo_words.ts";
@@ -67,7 +69,6 @@ import { addCrew, getAgentByName } from "../core/agents.ts";
6769 import { listAllAgents } from "./crew.ts";
6870 import { plan, planIssueBody, planningAvailable } from "../crew/plan.ts";
6971 import type { Issue } from "../core/issues.ts";
70 import { getPull } from "../core/pulls.ts";
7172 import { canAdmin, canEnterApp, canWrite, getRepo, type Repo } from "../core/repos.ts";
7273 import type { Run } from "../core/runs.ts";
7374 import { type User } from "../core/users.ts";
@@ -275,6 +276,8 @@ export interface NewAppInput {
275276 owner?: string;
276277 /** What the app should become; becomes the first issue when given. */
277278 description?: string;
279 /** The longer ask that opens issue #1; the description when left out. */
280 brief?: string;
278281 /** @default "private" */
279282 visibility?: "public" | "private";
280283 /** An agent to put on the crew and hand the first issue to. */
@@ -316,7 +319,9 @@ export type NewAppError =
316319 | "no_such_agent"
317320 | "not_a_builder"
318321 | "app_limit"
319 | "invalid_secret";
322 | "invalid_secret"
323 | "description_too_long"
324 | "brief_too_long";
320325
321326 /**
322327 * The golden path's first step, as one call: a repository with a working
@@ -341,6 +346,12 @@ export async function newApp(
341346 if (input.agent && !agent) return err("no_such_agent");
342347 if (agent && !agent.roles.includes("builder")) return err("not_a_builder");
343348
349 // The one place the description and brief limits are held: the page, the API, MCP and the
350 // terminal all come here.
351 if ((input.brief ?? "").trim() !== "" && (input.description ?? "").trim().length > MAX_DESCRIPTION)
352 return err("description_too_long");
353 if (splitDescription(input.description ?? "", input.brief).brief.length > BRIEF_MAX) return err("brief_too_long");
354
344355 // A secret that cannot be sealed is refused before anything exists to take back.
345356 const secrets = (input.secrets ?? []).filter((x) => x.name !== "" || x.value !== "");
346357 for (const x of secrets)
@@ -363,12 +374,16 @@ export async function newApp(
363374 )
364375 return err("slug_taken");
365376
377 const { description: shortDescription, brief } = splitDescription(
378 input.description ?? "",
379 input.brief,
380 );
366381 // Read the template before a repository exists to take back.
367382 let starter: FileWrite[] | undefined;
368383 if (input.template !== undefined && input.template !== "") {
369384 const copied = await templateFiles(app, user.value, input.template, {
370385 name: input.name,
371 description: input.description ?? "",
386 description: shortDescription,
372387 });
373388 if (!copied.ok) return copied;
374389 starter = copied.value;
@@ -383,7 +398,7 @@ export async function newApp(
383398 const repo = await createRepo(app, user.value, {
384399 name: input.name,
385400 visibility: input.visibility ?? "private",
386 description: input.description ?? "",
401 description: shortDescription,
387402 ...(input.owner === undefined ? {} : { owner: input.owner }),
388403 });
389404 lap("repo");
@@ -394,7 +409,7 @@ export async function newApp(
394409 starter ??
395410 (await scaffoldFiles(app, {
396411 name: input.name,
397 description: input.description ?? "",
412 description: shortDescription,
398413 })),
399414 });
400415 lap("scaffold");
@@ -421,7 +436,7 @@ export async function newApp(
421436 payload: { names: secrets.map((x) => x.name), scope: "all" },
422437 });
423438
424 const description = (input.description ?? "").trim();
439 const description = brief;
425440 let chosen = agent;
426441 let body = description;
427442 let picked: NewAppResult["plan"];
@@ -533,6 +548,8 @@ export const NEW_APP_ERRORS: Record<string, string> = {
533548 slug_taken:
534549 "Another app already answers to that hostname. Pick another name.",
535550 already_app: "That repository is already an app.",
551 description_too_long: `The description is at most ${MAX_DESCRIPTION} characters; put the longer ask in the brief.`,
552 brief_too_long: `The brief is at most ${BRIEF_MAX} characters.`,
536553 scaffold_failed: "The starter app could not be committed.",
537554 ...TEMPLATE_ERRORS,
538555 no_such_agent: NO_SUCH_AGENT,
src/cli/api.ts +2
@@ -325,6 +325,8 @@ export class ForgeApi {
325325 async newApp(input: {
326326 name: string;
327327 description?: string;
328 /** The longer ask; the first issue's body. */
329 brief?: string;
328330 visibility: "public" | "private";
329331 owner?: string;
330332 }): Promise<ApiResult<NewApp>> {
src/cli/commands/new.ts +3 −1
@@ -30,11 +30,13 @@ async function newApp(out: Out, args: Args): Promise<number> {
3030 const api = new ForgeApi(loaded.url, loaded.token);
3131 const description = words.join(" ").trim();
3232 const owner = args.value("owner");
33 const brief = args.value("brief")?.trim();
3334 const made = await api.newApp({
3435 name,
3536 ...(description === "" ? {} : { description }),
3637 visibility: args.flag("private") ? "private" : "public",
3738 ...(owner === undefined ? {} : { owner }),
39 ...(brief === undefined || brief === "" ? {} : { brief }),
3840 });
3941 if (!made.ok) return refusal(out, made.error);
4042
@@ -75,7 +77,7 @@ export const command: Command = {
7577 name: "new",
7678 usage: {
7779 synopsis: "forge new <name> [words…]",
78 flags: "[--template [NAME]] [--private] [--owner org] [--root DIR]",
80 flags: "[--template [NAME]] [--private] [--owner org] [--brief TEXT] [--root DIR]",
7981 },
8082 run: (out, args) => newApp(out, args),
8183 };
src/contract/openapi/routes/postApiV1Apps.ts +2 −1
@@ -1,8 +1,9 @@
11 import type { Route } from "../shared.ts";
22
33 /** What `POST /api/v1/apps` reads from its body, and the refusals it answers. */
4 const APP_BODY = { name: "string", owner: "string", description: "string", sentence: "string", visibility: "string", agent: "string", pick: "boolean", template: "string" };
4 const APP_BODY = { name: "string", owner: "string", description: "string (at most 160 characters)", brief: "string", sentence: "string", visibility: "string", agent: "string", pick: "boolean", template: "string" };
55 const APP_REFUSALS = {
6 description_too_long: "description is over 160 characters and a brief was sent too (422)",
67 unverified: "the account has not verified its email",
78 no_name: "no `name`, and the `sentence` leaves nothing to make one from",
89 app_limit: "the owner is at the app limit",
src/core/client-apps.ts +20 −5
@@ -142,11 +142,26 @@ export function clientFinished(
142142
143143 const TITLE_MAX = 80;
144144
145 /** `title` cut to 80 characters at a word boundary, with "…" when anything was dropped. */
146 export function cutTitle(title: string): string {
147 const text = title.replace(/\s+/g, " ").trim();
148 if (text.length <= TITLE_MAX) return text;
149 const head = text.slice(0, TITLE_MAX - 1);
145 /** `text` cut to `max` characters at a word boundary, with "…" when anything was dropped. */
146 export function cutWords(text: string, max: number): string {
147 const flat = text.replace(/\s+/g, " ").trim();
148 if (flat.length <= max) return flat;
149 const head = flat.slice(0, max - 1);
150150 const space = head.lastIndexOf(" ");
151151 return `${(space > 0 ? head.slice(0, space) : head).trimEnd()}…`;
152152 }
153
154 /**
155 * The first sentence of `text` (to its ". ", "! " or "? "), whitespace flattened; all of it when it
156 * has none.
157 */
158 export function sentenceOf(text: string): string {
159 const flat = text.replace(/\s+/g, " ").trim();
160 const end = flat.search(/[.!?](\s|$)/);
161 return end === -1 ? flat : flat.slice(0, end + 1);
162 }
163
164 /** `title` cut to 80 characters (`TITLE_MAX`) at a word boundary. */
165 export function cutTitle(title: string): string {
166 return cutWords(title, TITLE_MAX);
167 }
src/crew/autonomy_status.ts +5 −1
@@ -25,6 +25,8 @@ export interface AutonomyStatus {
2525 readonly pace: "ahead" | "on" | "behind";
2626 readonly resetsAt: string;
2727 } | null;
28 /** The forge's daily ceiling and what the whole crew spent today against it; null with no cap. */
29 readonly forge: { readonly capUsd: number; readonly spentUsd: number } | null;
2830 readonly slots: number;
2931 /**
3032 * Agent runs in flight here that spend a slot — what `slottedRuns` counts,
@@ -91,6 +93,7 @@ export function autonomyStatus(
9193 const crew = listCrewRoles(app.db, repo.id);
9294 const forgeCap = forgeCeiling(app.config);
9395 const decision = crewWeekFor(app, repo, now);
96 const forgeSpent = spentTodayEverywhere(app.db, now);
9497 const paused: Paused | null =
9598 repo.autonomy === "off"
9699 ? null
@@ -100,7 +103,7 @@ export function autonomyStatus(
100103 ? "no crew"
101104 : decision !== null && decision.slots === 0
102105 ? "week"
103 : ceilingReached(spentTodayEverywhere(app.db, now), forgeCap)
106 : ceilingReached(forgeSpent, forgeCap)
104107 ? "forge ceiling"
105108 : null;
106109 const tomorrow = startOfTodayUtc(now);
@@ -112,6 +115,7 @@ export function autonomyStatus(
112115 decision === null
113116 ? null
114117 : { usedPct: decision.usedPct, mayUsePct: decision.mayUsePct, elapsedPct: decision.elapsedPct, pace: decision.pace, resetsAt: decision.resetsAt },
118 forge: forgeCap === null ? null : { capUsd: forgeCap, spentUsd: forgeSpent },
115119 slots: repo.autonomySlots,
116120 active: slottedRuns(activeRuns(app, repo.id), crew).length,
117121 paused,
src/crew/stop_words.ts added +53
@@ -0,0 +1,53 @@
1 /**
2 * What the crew is doing here, in one line: the header of a repository on the
3 * web and the Autonomy screen in the terminal both print it, so they cannot
4 * disagree (#6008). Pure: an `AutonomyStatus` in, words out. The forge's ceiling
5 * and what the crew spent against it are named, since the stop is that figure.
6 */
7
8 import type { AutonomyStatus } from "./autonomy_status.ts";
9
10 /** Where a soft notice begins: this share of the forge's daily ceiling. */
11 export const EARLY_WARNING = 0.8;
12
13 const usd = (n: number): string => `$${Number.isInteger(n) ? n : n.toFixed(2)}`;
14
15 export interface StopWords {
16 /** True when the crew is not running freely: the line is a notice, not a quiet note. */
17 readonly stopped: boolean;
18 readonly words: string;
19 /** The one thing that ends the stop, or null when it ends by itself. */
20 readonly fix: string | null;
21 }
22
23 /** "00:00 UTC" style time of day for a resume, in UTC, or "later". */
24 function resumes(iso: string | null): string {
25 const at = iso === null ? NaN : Date.parse(iso);
26 if (Number.isNaN(at)) return "Resumes later.";
27 return `Resumes ${new Date(at).toISOString().slice(0, 16).replace("T", " ")} UTC.`;
28 }
29
30 export function stopWords(s: AutonomyStatus): StopWords {
31 if (s.autonomy === "off")
32 return { stopped: true, words: "Crew off: nothing runs here on its own.", fix: "Turn autonomy on" };
33 if (s.paused === "nobody")
34 return { stopped: true, words: "Crew waiting on a decision: no one has switched autonomy on here.", fix: "Set the mode" };
35 if (s.paused === "no crew")
36 return { stopped: true, words: "No crew: no agent is on this repository's crew.", fix: "Add an agent" };
37 if (s.paused === "week")
38 return { stopped: true, words: `Crew paused: the week's share is spent. ${resumes(s.resumesAt)}`, fix: null };
39 if (s.paused === "forge ceiling")
40 return {
41 stopped: true,
42 words:
43 s.forge === null
44 ? `Crew paused at the forge's ceiling. ${resumes(s.resumesAt)}`
45 : `Crew paused: at today's ${usd(s.forge.capUsd)} ceiling (${usd(s.forge.spentUsd)} spent). ${resumes(s.resumesAt)}`,
46 fix: null,
47 };
48 const building = `Crew: ${s.active} of ${s.slots} ${s.slots === 1 ? "slot" : "slots"} building`;
49 if (s.forge === null) return { stopped: false, words: `${building}.`, fix: null };
50 if (s.forge.spentUsd >= EARLY_WARNING * s.forge.capUsd)
51 return { stopped: true, words: `${building}. Nearing today's ${usd(s.forge.capUsd)} ceiling (${usd(s.forge.spentUsd)} spent).`, fix: null };
52 return { stopped: false, words: `${building} · ${usd(s.forge.spentUsd)} of ${usd(s.forge.capUsd)} today.`, fix: null };
53 }
src/feed/items.ts +2 −3
@@ -7,6 +7,7 @@
77 */
88
99 import type { Database } from "bun:sqlite";
10 import { sentenceOf } from "../core/client-apps.ts";
1011 import { isEnvName, type EnvName } from "../apps/data.ts";
1112 import type { Chips } from "../core/feed_chips.ts";
1213 import { listDecidedIn } from "../core/decisions.ts";
@@ -683,9 +684,7 @@ function sourceWords(source: unknown, pull: Pull | undefined): string {
683684
684685 /** Up to the first sentence's end, at most 100 characters. */
685686 function firstSentence(body: string): string {
686 const text = body.trim().replace(/\s+/g, " ");
687 const end = text.search(/[.!?](\s|$)/);
688 return clip(end === -1 ? text : text.slice(0, end + 1), 100);
687 return clip(sentenceOf(body), 100);
689688 }
690689
691690 function fromEvent(
src/http/api.ts +8 −2
@@ -21,6 +21,8 @@ import { liveOf } from "../perf/live.ts";
2121 import { inviteWelcome } from "../actions/invite_welcome.ts";
2222 import { growth, MAX_DAYS as MAX_GROWTH_DAYS } from "../core/growth.ts";
2323 import { CEILING_REFUSAL, PAUSE_REFUSAL, pausedUntil } from "../core/planner_pause.ts";
24 import { BRIEF_MAX } from "../core/agents.ts";
25 import { MAX_DESCRIPTION } from "../actions/app_brief.ts";
2426 import { homeTruth } from "../system/home_truth.ts";
2527 import { upstreamFacts } from "../actions/upstream_follow.ts";
2628 import { FAMILY_WORDS } from "../actions/family_words.ts";
@@ -373,8 +375,7 @@ import { deepsecRoutes } from "./api/deepsec.ts";
373375 import { appNoteRoutes } from "./api/app_notes.ts";
374376 import { appChangesRoutes } from "./api/app_changes.ts";
375377 import { reportRoutes } from "./api/reports.ts";
376 import { offerHandler, offerStatusHandler } from "./offer_routes.ts";
377 import { outsiderStatusJson } from "./offer_routes.ts";
378 import { offerHandler, offerStatusHandler, outsiderStatusJson } from "./offer_routes.ts";
378379 import { startRoutes } from "./api/start.ts";
379380 import { rollbackRoutes } from "./api/rollback.ts";
380381 import { takeBackRoutes } from "./api/take_back.ts";
@@ -3037,6 +3038,7 @@ export function apiRoutes(router: Router<Handler>, isPage: (path: string) => boo
30373038 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
30383039 const input = await body(ctx.request);
30393040 const options: Omit<NewAppInput, "name" | "description"> = {
3041 ...(typeof input.brief === "string" ? { brief: input.brief } : {}),
30403042 ...(typeof input.owner === "string" ? { owner: input.owner } : {}),
30413043 ...(input.visibility === "public" || input.visibility === "private"
30423044 ? { visibility: input.visibility }
@@ -3074,6 +3076,10 @@ export function apiRoutes(router: Router<Handler>, isPage: (path: string) => boo
30743076 }
30753077 if (!made.ok && made.error === "no_name")
30763078 return apiError("no_name", 422, NO_NAME_ERROR);
3079 if (!made.ok && made.error === "description_too_long")
3080 return apiError("description_too_long", 422, `description is at most ${MAX_DESCRIPTION} characters; put the longer ask in brief`);
3081 if (!made.ok && made.error === "brief_too_long")
3082 return apiError("brief_too_long", 422, `brief is at most ${BRIEF_MAX} characters`);
30773083 if (!made.ok) {
30783084 if (made.error === "repository_limit")
30793085 return apiError("repository_limit", 403, repositoryLimitMessage(ctx.app, ctx.auth.user!));
src/http/mcp/tools/new_app.ts +5 −2
@@ -20,7 +20,7 @@ async function fromSentence(app: App, user: User, sentence: string, input: Omit<
2020
2121 export const tool: Tool = {
2222 name: "new_app",
23 doc: "`{ name?, sentence?, description?, owner?, visibility?, agent?, pick?, template? }`: make an app from a sentence: with `sentence` and no `name` the name is derived from it (`-2`, `-3` when taken), as the web and terminal do; `name` and `sentence` together keep the name; the first issue is `description`, else `sentence`; answers `{ repo, url, issue, agent, run, visibility, says? }` (`run` is the first run's state, or `none`) and draws the `ui://forge/app` card: name, production URL, first issue, agent; refused as `POST /api/v1/apps` is (unverified, app_limit, no_such_agent, name_taken)",
23 doc: "`{ name?, sentence?, description?, brief?, owner?, visibility?, agent?, pick?, template? }`: make an app from a sentence: with `sentence` and no `name` the name is derived from it (`-2`, `-3` when taken), `name` and `sentence` together keep the name; the card line is `description` (≤160 with `brief`), the first issue `brief`, else `description`, else `sentence`; answers `{ repo, url, issue, agent, run, visibility, says? }` (`run`: state or `none`) and draws the `ui://forge/app` card; refused as `POST /api/v1/apps` is (unverified, app_limit, no_such_agent, name_taken)",
2424 description:
2525 "An app from a sentence: repo, production; `description` files a first issue.",
2626 inputSchema: {
@@ -28,7 +28,8 @@ export const tool: Tool = {
2828 properties: {
2929 name: { type: "string", maxLength: 100 },
3030 sentence: { type: "string", maxLength: 4000 },
31 description: { type: "string", maxLength: 4000, description: "The first issue." },
31 description: { type: "string", maxLength: 4000 },
32 brief: { type: "string", maxLength: 4000 },
3233 owner: { type: "string", maxLength: 39 },
3334 visibility: { type: "string", enum: ["public", "private"] },
3435 agent: { type: "string", maxLength: 39 },
@@ -45,10 +46,12 @@ export const tool: Tool = {
4546 const agent = text("agent");
4647 const sentence = text("sentence");
4748 const template = text("template");
49 const brief = text("brief");
4850 const rest: Omit<NewAppInput, "name" | "description"> = {
4951 ...(owner === undefined ? {} : { owner }),
5052 ...(visibility === "public" || visibility === "private" ? { visibility } : {}),
5153 ...(agent === undefined ? {} : { agent }),
54 ...(brief === undefined ? {} : { brief }),
5255 ...(template === undefined || template === "" ? {} : { template }),
5356 ...(args["pick"] === true ? { pickAgent: true } : {}),
5457 };
src/perf/page_budgets/app.ts +5 −4
@@ -1,6 +1,7 @@
11 import type { PageBudget } from "../page_budget.ts";
22
3 // 51 warm. The earlier 50 grew by one when the growth panel began reading the owner's
4 // open-pull ceiling and the open-pull count fresh on every request (#15808: the count moves with
5 // no setter to clear a kept panel); the two are now one statement.
6 export const budget: PageBudget = { page: "an app page", pattern: "/:owner/:name", medianMs: 50, statements: 51 };
3 // 58 warm: +7 for the crew line an admin sees in the head (#6008: the autonomy status, read once).
4 // 51 before. The earlier 50 grew by one when the growth panel began reading the owner's open-pull
5 // ceiling and the open-pull count fresh on every request (#15808: the count moves with no setter to
6 // clear a kept panel); the two are now one statement.
7 export const budget: PageBudget = { page: "an app page", pattern: "/:owner/:name", medianMs: 50, statements: 58 };
src/perf/page_budgets/next.ts +1 −1
@@ -1,3 +1,3 @@
11 import type { PageBudget } from "../page_budget.ts";
22
3 export const budget: PageBudget = { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 63 };
3 export const budget: PageBudget = { page: "next up", pattern: "/:owner/:name/next", medianMs: 50, statements: 69 };
src/tui/screens/autonomy.ts +9
@@ -18,6 +18,8 @@ import { checkPool, setCheckSlots } from "../../actions/check_slots.ts";
1818 import { pullChecksOf } from "../../checks/check_slots.ts";
1919 import { updateRepoSettings } from "../../actions/repos.ts";
2020 import { POLISH_SHARE_MAX, validPolishShare } from "../../crew/polish_share.ts";
21 import { autonomyStatus } from "../../crew/autonomy_status.ts";
22 import { stopWords } from "../../crew/stop_words.ts";
2123 import { weekCardRows } from "../../crew/week.ts";
2224 import { crewWeekFor } from "../../crew/week_read.ts";
2325 import { seatSlotsSaid, setSeatSlots } from "../../actions/seat_slots.ts";
@@ -73,6 +75,12 @@ export function autonomyCommands(f: Session, ctx: Ctx, repo: Repo | undefined):
7375 ];
7476 }
7577
78 /** The header's crew line, as the web prints it, with its fix. */
79 function stopLineOf(f: Session, r: Repo): string {
80 const w = stopWords(autonomyStatus(f.app, r));
81 return w.fix === null ? w.words : `${w.words} ${w.fix} (m).`;
82 }
83
7684 export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
7785 const current = (): Repo => getRepoById(f.db, repo.id) ?? repo;
7886 // Whoever administers the repository; the action decides again on save.
@@ -131,6 +139,7 @@ export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
131139 "",
132140 `Mode ${r.autonomy}`,
133141 ` ${AUTONOMY_SAID[r.autonomy]}`,
142 `Crew ${stopLineOf(f, r)}`,
134143 ...weekLines(crewWeekFor(f.app, r, new Date())),
135144 `Polish ${r.polishShare}% of the week's spend`,
136145 checksLine(f.app, r),
src/tui/screens/common.ts +1
@@ -1088,6 +1088,7 @@ const MESSAGES: Record<string, string> = {
10881088 agent_not_on_crew: AGENT_NOT_ON_CREW,
10891089 invalid_model: "that model name is not valid",
10901090 brief_too_long: "that brief is too long (4000 characters at most)",
1091 description_too_long: "the description is at most 160 characters; put the longer ask in the brief",
10911092 invalid_budget: "the budget must be between 0 and 100 dollars",
10921093 };
10931094
src/web/chrome.ts +14 −2
@@ -31,6 +31,9 @@ import { followLineWords } from "../actions/follow_words.ts";
3131 import { forkFollowMode } from "../core/fork_follow.ts";
3232 import { keptBehind, MINE_ANCHOR, ownsInTree } from "../core/following.ts";
3333 import { html, raw, when, type Html } from "./html.ts";
34 import { clamp } from "./clamp.ts";
35 import { autonomyStatus } from "../crew/autonomy_status.ts";
36 import { stopWords } from "../crew/stop_words.ts";
3437 import { icon } from "./icons.ts";
3538 import { nearPages } from "./near_pages.ts";
3639 import { page, redirect } from "./layout.ts";
@@ -367,7 +370,7 @@ export function scopeHeader(
367370 ${repo === undefined ? null : audienceLine(ctx, repo, admin, base)}
368371 ${when(
369372 !options.compact && facts.description !== "",
370 () => html`<p class="muted small">${facts.description}</p>`,
373 () => clamp(facts.description, "muted small"),
371374 )}
372375 ${repo === undefined ? null : ancestryCrumb(ctx, repo)}
373376 ${repo === undefined ? null : lineageLine(ctx.app, repo, parent, family, parent !== undefined && canAdmin(ctx.app.db, repo, ctx.auth.user) ? `${base}/settings#follow-choice` : undefined)}
@@ -386,7 +389,16 @@ export function scopeHeader(
386389 )}
387390 ${studio ? studioOriginNote(repo) : options.quiet ? null : whereRow(ctx, scope)}
388391 ${repoNav(items)}
389 </header>${repo === undefined || scope.kind !== "local" || ctx.auth.user === undefined ? null : togetherHtml(ctx.app.db, repo, ctx.auth.user, options.together === "full" ? "full" : "here")}`;
392 </header>${repo === undefined || !admin || scope.kind !== "local" || options.compact ? null : crewStopLine(ctx, repo, base)}${repo === undefined || scope.kind !== "local" || ctx.auth.user === undefined ? null : togetherHtml(ctx.app.db, repo, ctx.auth.user, options.together === "full" ? "full" : "here")}`;
393 }
394
395 /**
396 * What the crew is doing here, for a repository's admins: the notice when it is stopped, the one
397 * fix beside it.
398 */
399 function crewStopLine(ctx: Ctx, repo: Repo, base: string): Html {
400 const w = stopWords(autonomyStatus(ctx.app, repo));
401 return html`<p class="${w.stopped ? "small" : "muted small"}" data-crew-line role="status">${w.words}${w.fix === null ? null : html` <a href="${base}/settings/autonomy">${w.fix}</a>`}</p>`;
390402 }
391403
392404 /** The siblings the viewer may read, and whether they own a node in `parent`'s tree to land on. */
src/web/clamp.ts added +24
@@ -0,0 +1,24 @@
1 /**
2 * A description at most two lines tall, with a quiet "more" that opens it in
3 * place. No script: the label wraps a visually hidden checkbox, so a click on
4 * the text or the word toggles it. Always plain text (`html` escapes it); a
5 * short one gets no expander.
6 */
7
8 import { html, type Html } from "./html.ts";
9
10 /** One line holds this on the narrowest phone (about 50 characters a line at 13px): no expander. */
11 const ONE_LINE = 40;
12 /**
13 * Two lines hold this from a wide screen up (about 100 characters a line): there the word is
14 * hidden.
outdated

A fixed 80-character threshold is a guess. It adds a dead "more" on wide screens and may not hold two lines on a phone. Either always render the expander and let CSS hide it, or justify the number.

15 */
16 const TWO_WIDE = 200;
17
18 export function clamp(text: string, cls = ""): Html {
19 const flat = text.replace(/\s+/g, " ").trim();
20 const c = `clamp ${cls}`.trim();
21 if (flat.length <= ONE_LINE) return html`<p class="${c}"><span class="clamp-t">${flat}</span></p>`;
22 const k = flat.length <= TWO_WIDE ? `${c} clamp-mid` : c;
23 return html`<p class="${k}"><label class="clamp-l"><input type="checkbox" class="sr-only clamp-x" aria-label="Show the whole description"><span class="clamp-t">${flat}</span> <span class="clamp-open" aria-hidden="true"></span></label></p>`;
24 }
src/web/pages/browse.ts +2 −1
@@ -27,6 +27,7 @@
2727
2828 import { emptyList } from "../empty_words.ts";
2929 import { binaryRefusal } from "../render/opens_with.ts";
30 import { clamp } from "../clamp.ts";
3031 import { mirrorJobFor, startMirrorJob } from "../../actions/origins.ts";
3132 import { forkOrigin } from "../../actions/contribute.ts";
3233 import { getOriginFor } from "../../core/origins.ts";
@@ -568,7 +569,7 @@ function aboutRail(scope: RepoScope): Html {
568569 return html`${card(
569570 html`${when(
570571 facts.description !== "",
571 () => html`<p class="mb">${facts.description}</p>`,
572 () => clamp(facts.description, "mb"),
572573 )}
573574 <div class="where-block">
574575 <h3>Where it lives</h3>
src/web/pages/repo.ts +2 −1
@@ -8,6 +8,7 @@
88 * path segment and can never smuggle a path of its own.
99 */
1010
11 import { clamp } from "../clamp.ts";
1112 import { reviewCard } from "./review.ts";
1213 import { keyOf } from "../keymap.ts";
1314 import { DELETING_SAYS } from "../../core/repo_deleting.ts";
@@ -1030,7 +1031,7 @@ function aboutCard(
10301031 <h2>About</h2>
10311032 ${when(
10321033 repo.description !== "",
1033 () => html`<p class="mb">${repo.description}</p>`,
1034 () => clamp(repo.description, "mb"),
10341035 )}
10351036 <dl class="rail-facts">
10361037 ${fact("Visibility", html`${repo.visibility}`)}
src/web/style/content.ts +10
@@ -24,6 +24,16 @@ export const content = /* css */ `
2424 /* The by-wave link under the changelog filters: a thumb-sized target, no new class. */
2525 a[data-waves-link] { display: inline-flex; align-items: center; min-height: 44px; }
2626 .repo-head p.muted.small { margin-top: 4px; text-wrap: pretty; }
27 /* A description: two lines, then "more" opens it in place. */
28 .clamp { margin: 0; }
29 .clamp-l { display: block; cursor: pointer; }
30 .clamp-t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
31 .clamp-x:checked ~ .clamp-t { display: block; }
32 .clamp-open { color: var(--faint); font-size: 12.5px; }
33 .clamp-open::before { content: "more"; }
34 .clamp-x:checked ~ .clamp-open::before { content: "less"; }
35 .clamp-x:focus-visible ~ .clamp-open { text-decoration: underline; }
36 @media (min-width: 760px) { .clamp-mid .clamp-open { display: none; } }
2737 .repo-head .tabs, .repo-head .repo-nav { margin-top: 12px; }
2838 .repo-nav { display: flex; align-items: flex-start; gap: 4px; border-bottom: 1px solid var(--border); }
2939 .repo-nav .tabs { margin-top: 0; border-bottom: 0; flex: 1 1 auto; }
test/budgets/pages/owner-name-map.json added +5
@@ -0,0 +1,5 @@
1 {
2 "pattern": "/:owner/:name/map",
3 "statements": 61,
4 "why": "+1: the header's crew line for an admin (#6008)"
5 }
test/budgets/pages/owner-name-next.json +2 −2
@@ -1,5 +1,5 @@
11 {
22 "pattern": "/:owner/:name/next",
3 "statements": 63,
4 "why": "-3 (#15913): the waiting offers and outsider reports ride the page's own writer check, the open-pull ceiling and count are one statement; -6 (#15940): the page's repository read once per request, the palette lists skip counts, the runs tab reuses the app read; +2: the waiting offers and the decision check beside the reports (#15887); +1: the size limits of held issues, one read of both (#15845); +2: the waiting outsider reports, the decider check and the list (#15840); +1: whether the repository is archived (#14305); +1: the wallet row, one read of the monthly cap (#13529); +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867)"
3 "statements": 69,
4 "why": "+6: the header's crew line for an admin (#6008); -3 (#15913): the waiting offers and outsider reports ride the page's own writer check, the open-pull ceiling and count are one statement; -6 (#15940): the page's repository read once per request, the palette lists skip counts, the runs tab reuses the app read; +2: the waiting offers and the decision check beside the reports (#15887); +1: the size limits of held issues, one read of both (#15845); +2: the waiting outsider reports, the decider check and the list (#15840); +1: whether the repository is archived (#14305); +1: the wallet row, one read of the monthly cap (#13529); +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867)"
55 }
test/budgets/pages/owner-name-queue.json added +5
@@ -0,0 +1,5 @@
1 {
2 "pattern": "/:owner/:name/queue",
3 "statements": 64,
4 "why": "+4: the header's crew line for an admin (#6008)"
5 }
test/description-clamp-browse.test.ts added +64
@@ -0,0 +1,64 @@
1 /** The About card of an origin's repository clamps a long description too (#6008). */
2 import { afterAll, beforeAll, expect, test } from "bun:test";
3 import { mkdtemp, rm } from "node:fs/promises";
4 import { tmpdir } from "node:os";
5 import { join } from "node:path";
6 import { createApp, type App } from "../src/app.ts";
7 import { serve, type Servers } from "../src/http/server.ts";
8 import { forgetProviders } from "../src/origins/providers/index.ts";
9 import { clearViewCache } from "../src/view/cache.ts";
10 import { newFakeState, serveFakeForge, type FakeForge } from "./fake-origin.ts";
11 import { fastFirstFetch } from "./helpers/globals.ts";
12 import { seedAdmin } from "./helpers/admin.ts";
13
14 const TOKEN = "octo-origin-secret-4b81";
15 const PASSWORD = "alice-login-secret";
16 const auth = `Basic ${Buffer.from(`alice:${PASSWORD}`).toString("base64")}`;
17
18 fastFirstFetch();
19
20 let dataDir: string;
21 let app: App;
22 let servers: Servers;
23 let fake: FakeForge;
24 let id = "";
25
26 beforeAll(async () => {
27 dataDir = await mkdtemp(join(tmpdir(), "forge-clamp-browse-"));
28 const state = newFakeState("forgejo", "octo", TOKEN);
29 state.repos.push({
30 id: 41,
31 fullName: "octo/widgets",
32 cloneUrl: "http://127.0.0.1:1/octo/widgets.git",
33 defaultBranch: "main",
34 description: "gear ".repeat(120),
35 });
36 state.files.set("octo/widgets", new Map([["README.md", "# widgets\n"]]));
37 state.branches.set("octo/widgets", [{ name: "main", sha: "a".repeat(40), protected: false }]);
38 fake = serveFakeForge(state);
39 app = createApp({ dataDir, port: 0 });
40 servers = await serve(app);
41 await seedAdmin(app, { username: "alice", email: "[email protected]", password: PASSWORD });
42 const connected = await fetch(`${servers.url}/api/v1/user/origins`, {
43 method: "POST",
44 headers: { "content-type": "application/json", authorization: auth },
45 body: JSON.stringify({ host: fake.url, token: TOKEN }),
46 });
47 id = ((await connected.json()) as { id: string }).id;
48 clearViewCache();
49 });
50
51 afterAll(async () => {
52 fake.stop();
53 servers.stop();
54 app.close();
55 forgetProviders(dataDir);
56 await rm(dataDir, { recursive: true, force: true });
57 });
58
59 test("the browse About card carries the expander", async () => {
60 const res = await fetch(`${servers.url}/origins/${id}/r/octo/widgets`, { headers: { authorization: auth } });
61 const page = await res.text();
62 expect(res.status).toBe(200);
63 expect(page).toMatch(/<p class="clamp mb[^"]*"><label class="clamp-l"><input type="checkbox"/);
64 });
test/description-clamp.test.ts added +141
@@ -0,0 +1,141 @@
1 /**
2 * A description stays small: the API splits it from the brief, and the header clamps it to two
3 * lines with an expander (#6008).
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 { MAX_DESCRIPTION, firstSentence, splitDescription } from "../src/actions/app_brief.ts";
11 import { newApp } from "../src/actions/apps.ts";
12 import { createUser, getUserByName } from "../src/core/users.ts";
13 import { serve, type Servers } from "../src/http/server.ts";
14 import { clamp } from "../src/web/clamp.ts";
15 import { content as contentCss } from "../src/web/style/content.ts";
16 import { quietLogs } from "./helpers/globals.ts";
17 import { tokenFor } from "./helpers/tokens.ts";
18
19 quietLogs();
20
21 let dataDir: string;
22 let app: App;
23 let servers: Servers;
24 let token = "";
25 const cells = process.env["FORGE_CELLS"];
26
27 beforeAll(async () => {
28 process.env["FORGE_CELLS"] = "off";
29 dataDir = await mkdtemp(join(tmpdir(), "forge-clamp-"));
30 app = createApp({ dataDir, port: 0 });
31 servers = await serve(app);
32 const made = await createUser(app.db, {
33 origin: "seed",
34 trusted: true,
35 username: "alice",
36 email: "[email protected]",
37 password: "a-good-passphrase",
38 adminIfFirst: true,
39 });
40 if (!made.ok) throw new Error(String(made.error));
41 token = tokenFor(app, "alice", "rw");
42 });
43 afterAll(async () => {
44 await servers.stop();
45 app.close();
46 if (cells === undefined) delete process.env["FORGE_CELLS"];
47 else process.env["FORGE_CELLS"] = cells;
48 await rm(dataDir, { recursive: true, force: true });
49 });
50
51 const post = (body: unknown) =>
52 fetch(`${servers.url}/api/v1/apps`, {
53 method: "POST",
54 headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
55 body: JSON.stringify(body),
56 });
57
58 test("only a long description: it becomes the brief, the description its first sentence", () => {
59 const long = `Track my reading list. ${"More detail. ".repeat(40)}`;
60 const s = splitDescription(long);
61 expect(s.description).toBe("Track my reading list.");
62 expect(s.brief).toBe(long.trim());
63 expect(firstSentence("x".repeat(500)).length).toBeLessThanOrEqual(MAX_DESCRIPTION);
64 expect(splitDescription("Keep notes")).toEqual({ description: "Keep notes", brief: "Keep notes" });
65 });
66
67 test("POST /apps: a long description alone splits; with a brief it is refused in words", async () => {
68 const long = `Track my reading list. ${"More detail. ".repeat(40)}`;
69 const made = await post({ name: "reads", description: long });
70 expect(made.status).toBe(201);
71 const body = (await made.json()) as { repo: { description: string }; issue: { body: string } };
72 expect(body.repo.description).toBe("Track my reading list.");
73 expect(body.issue.body).toBe(long.trim());
74
75 const split = await post({ name: "notes", description: "Keep notes", brief: "A long ask.\n\n- one\n- two" });
76 expect(split.status).toBe(201);
77 const s = (await split.json()) as { repo: { description: string }; issue: { body: string } };
78 expect(s.repo.description).toBe("Keep notes");
79 expect(s.issue.body).toBe("A long ask.\n\n- one\n- two");
80
81 const refused = await post({ name: "wall", description: "x".repeat(161), brief: "ask" });
82 expect(refused.status).toBe(422);
83 const r = (await refused.json()) as { error: string; message: string };
84 expect(r.error).toBe("description_too_long");
85 expect(r.message).toContain("160");
86 });
87
88 test("a 5,000-character description renders as clamped text with an expander, as plain text", () => {
89 const text = `<b>wall</b> ${"word ".repeat(1000)}`;
90 const out = clamp(text, "repo-desc").toString();
91 expect(out).toContain('class="clamp repo-desc"');
92 expect(out).toContain('type="checkbox"');
93 expect(out).toContain("clamp-open");
94 expect(out).not.toContain("<b>");
95 expect(out).toContain("&lt;b&gt;");
96 });
97
98 test("the expander follows the length: none on a line, phones only up to 200, always past it", () => {
99 expect(clamp("Short.").toString()).not.toContain("checkbox");
100 const mid = clamp("w".repeat(120)).toString();
101 expect(mid).toContain("checkbox");
102 expect(mid).toContain("clamp-mid");
103 const long = clamp("w ".repeat(300)).toString();
104 expect(long).toContain("checkbox");
105 expect(long).not.toContain("clamp-mid");
106 // Two lines by count, not by width, and the word of a middling one is hidden on wide screens.
107 expect(contentCss).toContain("-webkit-line-clamp: 2");
108 expect(contentCss).toContain(".clamp-mid .clamp-open { display: none; }");
109 });
110
111 test("the repo header and the About card carry the expander on a long description", async () => {
112 const made = await post({ name: "page", description: "y ".repeat(300), visibility: "public" });
113 expect(made.status).toBe(201);
114 const get = async (path: string) =>
115 (await fetch(`${servers.url}${path}`, { headers: { authorization: `Bearer ${token}` } })).text();
116 const head = await get("/alice/page/issues");
117 expect(head).toMatch(/<header class="repo-head">[\s\S]*<p class="clamp muted small[^"]*"><label class="clamp-l"><input type="checkbox"/);
118 const about = await get("/alice/page/files");
119 expect(about).toContain("<h2>About</h2>");
120 expect(about).toMatch(/<h2>About<\/h2>\s*<p class="clamp mb[^"]*"><label class="clamp-l"><input type="checkbox"/);
121 });
122
123 test("an admin sees the crew line just under the repo head, with its one fix; it says off on a new repo", async () => {
124 const head = await (await fetch(`${servers.url}/alice/page/issues`, { headers: { authorization: `Bearer ${token}` } })).text();
125 expect(head).toMatch(/<p class="small" data-crew-line role="status">Crew off: nothing runs here on its own\. <a href="\/alice\/page\/settings\/autonomy">Turn autonomy on<\/a><\/p>/);
126 const anon = await (await fetch(`${servers.url}/alice/page/issues`)).text();
127 expect(anon).not.toContain("data-crew-line");
128 });
129
130 test("newApp holds the limits for every door: a long description with a brief, a brief over 4000", async () => {
131 const user = getUserByName(app.db, "alice")!;
132 const long = await newApp(app, user, { name: "w1", description: "x".repeat(161), brief: "ask" });
133 expect(long).toEqual({ ok: false, error: "description_too_long" });
134 const big = await newApp(app, user, { name: "w2", description: "ok", brief: "b".repeat(4001) });
135 expect(big).toEqual({ ok: false, error: "brief_too_long" });
136 const alone = await newApp(app, user, { name: "w3", description: "z ".repeat(2500) });
137 expect(alone).toEqual({ ok: false, error: "brief_too_long" });
138 const over = await post({ name: "w4", description: "ok", brief: "b".repeat(4001) });
139 expect(over.status).toBe(422);
140 expect(((await over.json()) as { error: string }).error).toBe("brief_too_long");
141 });
test/repo-audience.test.ts +1 −1
@@ -104,7 +104,7 @@ test("the head draws the owner, separator and description with shared classes",
104104 const h = await head("/olive/yard");
105105 expect(h).toContain('<a class="muted" href="/olive">olive</a>');
106106 expect(h).toContain('<span class="sep">/</span');
107 expect(h).toContain('<p class="muted small">Where the mowers sleep</p>');
107 expect(h).toContain(`<p class="clamp muted small"><span class="clamp-t">Where the mowers sleep</span></p>`);
108108 expect(h).not.toContain('class="owner"');
109109 expect(h).not.toContain('class="slash"');
110110 });
test/stop-words.test.ts added +41
@@ -0,0 +1,41 @@
1 /**
2 * The crew line says why the crew is stopped, and the one fix, from the status the loop gates on
3 * (#6008).
4 */
5 import { expect, test } from "bun:test";
6 import type { AutonomyStatus } from "../src/crew/autonomy_status.ts";
7 import { stopWords } from "../src/crew/stop_words.ts";
8
9 const base: AutonomyStatus = {
10 autonomy: "autonomous",
11 spentTodayUsd: 43.07,
12 week: null,
13 forge: null,
14 slots: 3,
15 active: 2,
16 paused: null,
17 resumesAt: null,
18 };
19
20 test("running quietly: slots in use, no notice, no fix", () => {
21 expect(stopWords(base)).toEqual({ stopped: false, words: "Crew: 2 of 3 slots building.", fix: null });
22 });
23
24 test("each stop the autonomy tick knows has its words and fix, and no dollars", () => {
25 expect(stopWords({ ...base, autonomy: "off" }).fix).toBe("Turn autonomy on");
26 expect(stopWords({ ...base, paused: "nobody" }).words).toContain("waiting on a decision");
27 expect(stopWords({ ...base, paused: "no crew" }).fix).toBe("Add an agent");
28 const ceiling = stopWords({ ...base, paused: "forge ceiling", resumesAt: "2026-12-02T00:00:00.000Z" });
29 expect(ceiling).toEqual({ stopped: true, words: "Crew paused at the forge's ceiling. Resumes 2026-12-02 00:00 UTC.", fix: null });
30 expect(stopWords({ ...base, paused: "week", resumesAt: null }).words).toBe("Crew paused: the week's share is spent. Resumes later.");
31 const dollars = stopWords({ ...base, paused: "forge ceiling", resumesAt: "2026-12-02T00:00:00.000Z", forge: { capUsd: 40, spentUsd: 43.07 } });
32 expect(dollars.words).toBe("Crew paused: at today's $40 ceiling ($43.07 spent). Resumes 2026-12-02 00:00 UTC.");
33 });
34
35 test("with a ceiling, running says the spend quietly; from 80% it is a notice", () => {
36 expect(stopWords({ ...base, forge: { capUsd: 300, spentUsd: 19 } })).toEqual({ stopped: false, words: "Crew: 2 of 3 slots building · $19 of $300 today.", fix: null });
37 const soft = stopWords({ ...base, forge: { capUsd: 40, spentUsd: 32 } });
38 expect(soft.stopped).toBe(true);
39 expect(soft.words).toContain("Nearing today's $40 ceiling ($32 spent)");
40 expect(stopWords({ ...base, forge: { capUsd: 40, spentUsd: 31.99 } }).stopped).toBe(false);
41 });
test/studio-changes.test.ts +1 −1
@@ -176,7 +176,7 @@ describe("the studio, continued", () => {
176176 const runs = await (await get("/alice/notes/runs")).text();
177177 // The same header on all three: the description, not the compact one.
178178 for (const page of [issues, pulls, runs])
179 expect(page).toContain('<p class="muted small">a place for notes</p>');
179 expect(page).toContain('<p class="clamp muted small"><span class="clamp-t">a place for notes</span></p>');
180180 // No pull and no run is ever told, so only the issue list links to it.
181181 expect(issues).toContain('href="/alice/notes/issues?word=told"');
182182 expect(pulls).not.toContain("word=told");
test/tui-autonomy.test.ts +1
@@ -116,6 +116,7 @@ describe("autonomy in the terminal", () => {
116116 const h = boot(erin);
117117 await h.open();
118118 expect(h.text()).toContain("Autonomy is off.");
119 expect(h.text()).toContain("Crew Crew off: nothing runs here on its own. Turn autonomy on (m).");
119120 await h.press("m");
120121 expect(h.text()).toContain("Set autonomy (now off)");
121122 expect(h.text()).toContain(AUTONOMY_SAID.autonomous);

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

Keyboard shortcuts

Docs