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
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/6008-repo-header-descriptions-clamp-to-2-line → main 0 commits fork 3 threads · 3 unresolved
52 files
changed +588
−93
- docs/design/areas/clamp.md
- docs/design/attention-budget.json
- docs/design/size-budget/board.json
- docs/design/size-budget/changelog.json
- docs/design/size-budget/claim.json
- docs/design/size-budget/explore.json
- docs/design/size-budget/feed.json
- docs/design/size-budget/fleet.json
- docs/design/size-budget/forges-new.json
- docs/design/size-budget/home.json
- docs/design/size-budget/maintenance.json
- docs/design/size-budget/map.json
- docs/design/size-budget/owner-name-next.json
- docs/design/size-budget/owner-name-pulls-number.json
- docs/design/size-budget/owner-name-space.json
- docs/design/size-budget/owner-name.json
- docs/design/size-budget/pricing.json
- docs/design/size-budget/system.json
- docs/design/size-budget/talk.json
- docs/design/size-budget/templates.json
- docs/features/app-description-brief.md
- docs/features/crew-stop-line.md
- scripts/doorless-allow.json
- src/actions/app_brief.ts
- src/actions/apps.ts
- src/cli/api.ts
- src/cli/commands/new.ts
- src/contract/openapi/routes/postApiV1Apps.ts
- src/core/client-apps.ts
- src/crew/autonomy_status.ts
- src/crew/stop_words.ts
- src/feed/items.ts
- src/http/api.ts
- src/http/mcp/tools/new_app.ts
- src/perf/page_budgets/app.ts
- src/perf/page_budgets/next.ts
- src/tui/screens/autonomy.ts
- src/tui/screens/common.ts
- src/web/chrome.ts
- src/web/clamp.ts
- src/web/pages/browse.ts
- src/web/pages/repo.ts
- src/web/style/content.ts
- test/budgets/pages/owner-name-map.json
- test/budgets/pages/owner-name-next.json
- test/budgets/pages/owner-name-queue.json
- test/description-clamp-browse.test.ts
- test/description-clamp.test.ts
- test/repo-audience.test.ts
- test/stop-words.test.ts
- test/studio-changes.test.ts
- test/tui-autonomy.test.ts
docs/design/areas/clamp.md added +13
| @@ -0,0 +1,13 @@ | ||
| 1 | # Clamp (descriptions) | |
| 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 @@ | ||
| 63 | 63 | }, |
| 64 | 64 | "issues list": { |
| 65 | 65 | "390": { |
| 66 | "words": 32, | |
| 67 | "blocks": 7, | |
| 66 | "words": 43, | |
| 67 | "blocks": 8, | |
| 68 | 68 | "colours": 2 |
| 69 | 69 | }, |
| 70 | 70 | "1280": { |
| 71 | "words": 32, | |
| 72 | "blocks": 7, | |
| 71 | "words": 43, | |
| 72 | "blocks": 8, | |
| 73 | 73 | "colours": 2 |
| 74 | 74 | }, |
| 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)." | |
| 76 | 76 | }, |
| 77 | 77 | "pulls list": { |
| 78 | 78 | "390": { |
| 79 | "words": 26, | |
| 80 | "blocks": 6, | |
| 79 | "words": 37, | |
| 80 | "blocks": 7, | |
| 81 | 81 | "colours": 1 |
| 82 | 82 | }, |
| 83 | 83 | "1280": { |
| 84 | "words": 26, | |
| 85 | "blocks": 6, | |
| 84 | "words": 37, | |
| 85 | "blocks": 7, | |
| 86 | 86 | "colours": 1 |
| 87 | 87 | }, |
| 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)." | |
| 89 | 89 | }, |
| 90 | 90 | "runs": { |
| 91 | 91 | "390": { |
| 92 | "words": 38, | |
| 93 | "blocks": 8, | |
| 92 | "words": 49, | |
| 93 | "blocks": 9, | |
| 94 | 94 | "colours": 1 |
| 95 | 95 | }, |
| 96 | 96 | "1280": { |
| 97 | "words": 38, | |
| 98 | "blocks": 8, | |
| 97 | "words": 49, | |
| 98 | "blocks": 9, | |
| 99 | 99 | "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." | |
| 101 | 102 | }, |
| 102 | 103 | "run": { |
| 103 | 104 | "390": { |
| @@ -225,7 +226,7 @@ | ||
| 225 | 226 | "blocks": 99, |
| 226 | 227 | "colours": 2 |
| 227 | 228 | }, |
| 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)." | |
| 229 | 230 | }, |
| 230 | 231 | "forges": { |
| 231 | 232 | "390": { |
| @@ -254,15 +255,15 @@ | ||
| 254 | 255 | }, |
| 255 | 256 | "milestone": { |
| 256 | 257 | "390": { |
| 257 | "words": 90, | |
| 258 | "blocks": 20, | |
| 258 | "words": 101, | |
| 259 | "blocks": 21, | |
| 259 | 260 | "colours": 2 |
| 260 | 261 | }, |
| 261 | 262 | "1280": { |
| 262 | "words": 90, | |
| 263 | "blocks": 20, | |
| 263 | "words": 101, | |
| 264 | "blocks": 21, | |
| 264 | 265 | "colours": 2 |
| 265 | 266 | }, |
| 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." | |
| 267 | 268 | } |
| 268 | 269 | } |
docs/design/size-budget/board.json +2 −2
docs/design/size-budget/changelog.json +2 −2
docs/design/size-budget/claim.json +2 −2
docs/design/size-budget/explore.json +2 −2
docs/design/size-budget/feed.json +2 −2
docs/design/size-budget/fleet.json +2 −2
docs/design/size-budget/forges-new.json +2 −2
docs/design/size-budget/home.json +2 −2
docs/design/size-budget/maintenance.json +2 −2
docs/design/size-budget/map.json +2 −2
docs/design/size-budget/owner-name-next.json +2 −2
docs/design/size-budget/owner-name-pulls-number.json +2 −2
docs/design/size-budget/owner-name-space.json +2 −2
docs/design/size-budget/owner-name.json +2 −2
docs/design/size-budget/pricing.json +2 −2
docs/design/size-budget/system.json +2 −2
docs/design/size-budget/talk.json +2 −2
docs/design/size-budget/templates.json +2 −2
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
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; | |
| 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 @@ | ||
| 8 | 8 | |
| 9 | 9 | import { runnerSettings } from "../crew/runner_env.ts"; |
| 10 | 10 | 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"; | |
| 12 | 14 | import { mayView, sealedPreviewPull } from "../core/sealed.ts"; |
| 13 | 15 | import { deriveAppName } from "../web/pages/apps-name.ts"; |
| 14 | 16 | 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"; | ||
| 67 | 69 | import { listAllAgents } from "./crew.ts"; |
| 68 | 70 | import { plan, planIssueBody, planningAvailable } from "../crew/plan.ts"; |
| 69 | 71 | import type { Issue } from "../core/issues.ts"; |
| 70 | import { getPull } from "../core/pulls.ts"; | |
| 71 | 72 | import { canAdmin, canEnterApp, canWrite, getRepo, type Repo } from "../core/repos.ts"; |
| 72 | 73 | import type { Run } from "../core/runs.ts"; |
| 73 | 74 | import { type User } from "../core/users.ts"; |
| @@ -275,6 +276,8 @@ export interface NewAppInput { | ||
| 275 | 276 | owner?: string; |
| 276 | 277 | /** What the app should become; becomes the first issue when given. */ |
| 277 | 278 | description?: string; |
| 279 | /** The longer ask that opens issue #1; the description when left out. */ | |
| 280 | brief?: string; | |
| 278 | 281 | /** @default "private" */ |
| 279 | 282 | visibility?: "public" | "private"; |
| 280 | 283 | /** An agent to put on the crew and hand the first issue to. */ |
| @@ -316,7 +319,9 @@ export type NewAppError = | ||
| 316 | 319 | | "no_such_agent" |
| 317 | 320 | | "not_a_builder" |
| 318 | 321 | | "app_limit" |
| 319 | | "invalid_secret"; | |
| 322 | | "invalid_secret" | |
| 323 | | "description_too_long" | |
| 324 | | "brief_too_long"; | |
| 320 | 325 | |
| 321 | 326 | /** |
| 322 | 327 | * The golden path's first step, as one call: a repository with a working |
| @@ -341,6 +346,12 @@ export async function newApp( | ||
| 341 | 346 | if (input.agent && !agent) return err("no_such_agent"); |
| 342 | 347 | if (agent && !agent.roles.includes("builder")) return err("not_a_builder"); |
| 343 | 348 | |
| 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 | ||
| 344 | 355 | // A secret that cannot be sealed is refused before anything exists to take back. |
| 345 | 356 | const secrets = (input.secrets ?? []).filter((x) => x.name !== "" || x.value !== ""); |
| 346 | 357 | for (const x of secrets) |
| @@ -363,12 +374,16 @@ export async function newApp( | ||
| 363 | 374 | ) |
| 364 | 375 | return err("slug_taken"); |
| 365 | 376 | |
| 377 | const { description: shortDescription, brief } = splitDescription( | |
| 378 | input.description ?? "", | |
| 379 | input.brief, | |
| 380 | ); | |
| 366 | 381 | // Read the template before a repository exists to take back. |
| 367 | 382 | let starter: FileWrite[] | undefined; |
| 368 | 383 | if (input.template !== undefined && input.template !== "") { |
| 369 | 384 | const copied = await templateFiles(app, user.value, input.template, { |
| 370 | 385 | name: input.name, |
| 371 | description: input.description ?? "", | |
| 386 | description: shortDescription, | |
| 372 | 387 | }); |
| 373 | 388 | if (!copied.ok) return copied; |
| 374 | 389 | starter = copied.value; |
| @@ -383,7 +398,7 @@ export async function newApp( | ||
| 383 | 398 | const repo = await createRepo(app, user.value, { |
| 384 | 399 | name: input.name, |
| 385 | 400 | visibility: input.visibility ?? "private", |
| 386 | description: input.description ?? "", | |
| 401 | description: shortDescription, | |
| 387 | 402 | ...(input.owner === undefined ? {} : { owner: input.owner }), |
| 388 | 403 | }); |
| 389 | 404 | lap("repo"); |
| @@ -394,7 +409,7 @@ export async function newApp( | ||
| 394 | 409 | starter ?? |
| 395 | 410 | (await scaffoldFiles(app, { |
| 396 | 411 | name: input.name, |
| 397 | description: input.description ?? "", | |
| 412 | description: shortDescription, | |
| 398 | 413 | })), |
| 399 | 414 | }); |
| 400 | 415 | lap("scaffold"); |
| @@ -421,7 +436,7 @@ export async function newApp( | ||
| 421 | 436 | payload: { names: secrets.map((x) => x.name), scope: "all" }, |
| 422 | 437 | }); |
| 423 | 438 | |
| 424 | const description = (input.description ?? "").trim(); | |
| 439 | const description = brief; | |
| 425 | 440 | let chosen = agent; |
| 426 | 441 | let body = description; |
| 427 | 442 | let picked: NewAppResult["plan"]; |
| @@ -533,6 +548,8 @@ export const NEW_APP_ERRORS: Record<string, string> = { | ||
| 533 | 548 | slug_taken: |
| 534 | 549 | "Another app already answers to that hostname. Pick another name.", |
| 535 | 550 | 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.`, | |
| 536 | 553 | scaffold_failed: "The starter app could not be committed.", |
| 537 | 554 | ...TEMPLATE_ERRORS, |
| 538 | 555 | no_such_agent: NO_SUCH_AGENT, |
src/cli/api.ts +2
src/cli/commands/new.ts +3 −1
| @@ -30,11 +30,13 @@ async function newApp(out: Out, args: Args): Promise<number> { | ||
| 30 | 30 | const api = new ForgeApi(loaded.url, loaded.token); |
| 31 | 31 | const description = words.join(" ").trim(); |
| 32 | 32 | const owner = args.value("owner"); |
| 33 | const brief = args.value("brief")?.trim(); | |
| 33 | 34 | const made = await api.newApp({ |
| 34 | 35 | name, |
| 35 | 36 | ...(description === "" ? {} : { description }), |
| 36 | 37 | visibility: args.flag("private") ? "private" : "public", |
| 37 | 38 | ...(owner === undefined ? {} : { owner }), |
| 39 | ...(brief === undefined || brief === "" ? {} : { brief }), | |
| 38 | 40 | }); |
| 39 | 41 | if (!made.ok) return refusal(out, made.error); |
| 40 | 42 | |
| @@ -75,7 +77,7 @@ export const command: Command = { | ||
| 75 | 77 | name: "new", |
| 76 | 78 | usage: { |
| 77 | 79 | 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]", | |
| 79 | 81 | }, |
| 80 | 82 | run: (out, args) => newApp(out, args), |
| 81 | 83 | }; |
src/contract/openapi/routes/postApiV1Apps.ts +2 −1
| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | import type { Route } from "../shared.ts"; |
| 2 | 2 | |
| 3 | 3 | /** 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" }; | |
| 5 | 5 | const APP_REFUSALS = { |
| 6 | description_too_long: "description is over 160 characters and a brief was sent too (422)", | |
| 6 | 7 | unverified: "the account has not verified its email", |
| 7 | 8 | no_name: "no `name`, and the `sentence` leaves nothing to make one from", |
| 8 | 9 | app_limit: "the owner is at the app limit", |
src/core/client-apps.ts +20 −5
| @@ -142,11 +142,26 @@ export function clientFinished( | ||
| 142 | 142 | |
| 143 | 143 | const TITLE_MAX = 80; |
| 144 | 144 | |
| 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); | |
| 150 | 150 | const space = head.lastIndexOf(" "); |
| 151 | 151 | return `${(space > 0 ? head.slice(0, space) : head).trimEnd()}…`; |
| 152 | 152 | } |
| 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 { | ||
| 25 | 25 | readonly pace: "ahead" | "on" | "behind"; |
| 26 | 26 | readonly resetsAt: string; |
| 27 | 27 | } | 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; | |
| 28 | 30 | readonly slots: number; |
| 29 | 31 | /** |
| 30 | 32 | * Agent runs in flight here that spend a slot — what `slottedRuns` counts, |
| @@ -91,6 +93,7 @@ export function autonomyStatus( | ||
| 91 | 93 | const crew = listCrewRoles(app.db, repo.id); |
| 92 | 94 | const forgeCap = forgeCeiling(app.config); |
| 93 | 95 | const decision = crewWeekFor(app, repo, now); |
| 96 | const forgeSpent = spentTodayEverywhere(app.db, now); | |
| 94 | 97 | const paused: Paused | null = |
| 95 | 98 | repo.autonomy === "off" |
| 96 | 99 | ? null |
| @@ -100,7 +103,7 @@ export function autonomyStatus( | ||
| 100 | 103 | ? "no crew" |
| 101 | 104 | : decision !== null && decision.slots === 0 |
| 102 | 105 | ? "week" |
| 103 | : ceilingReached(spentTodayEverywhere(app.db, now), forgeCap) | |
| 106 | : ceilingReached(forgeSpent, forgeCap) | |
| 104 | 107 | ? "forge ceiling" |
| 105 | 108 | : null; |
| 106 | 109 | const tomorrow = startOfTodayUtc(now); |
| @@ -112,6 +115,7 @@ export function autonomyStatus( | ||
| 112 | 115 | decision === null |
| 113 | 116 | ? null |
| 114 | 117 | : { usedPct: decision.usedPct, mayUsePct: decision.mayUsePct, elapsedPct: decision.elapsedPct, pace: decision.pace, resetsAt: decision.resetsAt }, |
| 118 | forge: forgeCap === null ? null : { capUsd: forgeCap, spentUsd: forgeSpent }, | |
| 115 | 119 | slots: repo.autonomySlots, |
| 116 | 120 | active: slottedRuns(activeRuns(app, repo.id), crew).length, |
| 117 | 121 | 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 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | import type { Database } from "bun:sqlite"; |
| 10 | import { sentenceOf } from "../core/client-apps.ts"; | |
| 10 | 11 | import { isEnvName, type EnvName } from "../apps/data.ts"; |
| 11 | 12 | import type { Chips } from "../core/feed_chips.ts"; |
| 12 | 13 | import { listDecidedIn } from "../core/decisions.ts"; |
| @@ -683,9 +684,7 @@ function sourceWords(source: unknown, pull: Pull | undefined): string { | ||
| 683 | 684 | |
| 684 | 685 | /** Up to the first sentence's end, at most 100 characters. */ |
| 685 | 686 | 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); | |
| 689 | 688 | } |
| 690 | 689 | |
| 691 | 690 | function fromEvent( |
src/http/api.ts +8 −2
| @@ -21,6 +21,8 @@ import { liveOf } from "../perf/live.ts"; | ||
| 21 | 21 | import { inviteWelcome } from "../actions/invite_welcome.ts"; |
| 22 | 22 | import { growth, MAX_DAYS as MAX_GROWTH_DAYS } from "../core/growth.ts"; |
| 23 | 23 | 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"; | |
| 24 | 26 | import { homeTruth } from "../system/home_truth.ts"; |
| 25 | 27 | import { upstreamFacts } from "../actions/upstream_follow.ts"; |
| 26 | 28 | import { FAMILY_WORDS } from "../actions/family_words.ts"; |
| @@ -373,8 +375,7 @@ import { deepsecRoutes } from "./api/deepsec.ts"; | ||
| 373 | 375 | import { appNoteRoutes } from "./api/app_notes.ts"; |
| 374 | 376 | import { appChangesRoutes } from "./api/app_changes.ts"; |
| 375 | 377 | 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"; | |
| 378 | 379 | import { startRoutes } from "./api/start.ts"; |
| 379 | 380 | import { rollbackRoutes } from "./api/rollback.ts"; |
| 380 | 381 | import { takeBackRoutes } from "./api/take_back.ts"; |
| @@ -3037,6 +3038,7 @@ export function apiRoutes(router: Router<Handler>, isPage: (path: string) => boo | ||
| 3037 | 3038 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 3038 | 3039 | const input = await body(ctx.request); |
| 3039 | 3040 | const options: Omit<NewAppInput, "name" | "description"> = { |
| 3041 | ...(typeof input.brief === "string" ? { brief: input.brief } : {}), | |
| 3040 | 3042 | ...(typeof input.owner === "string" ? { owner: input.owner } : {}), |
| 3041 | 3043 | ...(input.visibility === "public" || input.visibility === "private" |
| 3042 | 3044 | ? { visibility: input.visibility } |
| @@ -3074,6 +3076,10 @@ export function apiRoutes(router: Router<Handler>, isPage: (path: string) => boo | ||
| 3074 | 3076 | } |
| 3075 | 3077 | if (!made.ok && made.error === "no_name") |
| 3076 | 3078 | 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`); | |
| 3077 | 3083 | if (!made.ok) { |
| 3078 | 3084 | if (made.error === "repository_limit") |
| 3079 | 3085 | 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< | ||
| 20 | 20 | |
| 21 | 21 | export const tool: Tool = { |
| 22 | 22 | 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)", | |
| 24 | 24 | description: |
| 25 | 25 | "An app from a sentence: repo, production; `description` files a first issue.", |
| 26 | 26 | inputSchema: { |
| @@ -28,7 +28,8 @@ export const tool: Tool = { | ||
| 28 | 28 | properties: { |
| 29 | 29 | name: { type: "string", maxLength: 100 }, |
| 30 | 30 | 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 }, | |
| 32 | 33 | owner: { type: "string", maxLength: 39 }, |
| 33 | 34 | visibility: { type: "string", enum: ["public", "private"] }, |
| 34 | 35 | agent: { type: "string", maxLength: 39 }, |
| @@ -45,10 +46,12 @@ export const tool: Tool = { | ||
| 45 | 46 | const agent = text("agent"); |
| 46 | 47 | const sentence = text("sentence"); |
| 47 | 48 | const template = text("template"); |
| 49 | const brief = text("brief"); | |
| 48 | 50 | const rest: Omit<NewAppInput, "name" | "description"> = { |
| 49 | 51 | ...(owner === undefined ? {} : { owner }), |
| 50 | 52 | ...(visibility === "public" || visibility === "private" ? { visibility } : {}), |
| 51 | 53 | ...(agent === undefined ? {} : { agent }), |
| 54 | ...(brief === undefined ? {} : { brief }), | |
| 52 | 55 | ...(template === undefined || template === "" ? {} : { template }), |
| 53 | 56 | ...(args["pick"] === true ? { pickAgent: true } : {}), |
| 54 | 57 | }; |
src/perf/page_budgets/app.ts +5 −4
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import type { PageBudget } from "../page_budget.ts"; |
| 2 | 2 | |
| 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 @@ | ||
| 1 | 1 | import type { PageBudget } from "../page_budget.ts"; |
| 2 | 2 | |
| 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"; | ||
| 18 | 18 | import { pullChecksOf } from "../../checks/check_slots.ts"; |
| 19 | 19 | import { updateRepoSettings } from "../../actions/repos.ts"; |
| 20 | 20 | 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"; | |
| 21 | 23 | import { weekCardRows } from "../../crew/week.ts"; |
| 22 | 24 | import { crewWeekFor } from "../../crew/week_read.ts"; |
| 23 | 25 | import { seatSlotsSaid, setSeatSlots } from "../../actions/seat_slots.ts"; |
| @@ -73,6 +75,12 @@ export function autonomyCommands(f: Session, ctx: Ctx, repo: Repo | undefined): | ||
| 73 | 75 | ]; |
| 74 | 76 | } |
| 75 | 77 | |
| 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 | ||
| 76 | 84 | export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen { |
| 77 | 85 | const current = (): Repo => getRepoById(f.db, repo.id) ?? repo; |
| 78 | 86 | // Whoever administers the repository; the action decides again on save. |
| @@ -131,6 +139,7 @@ export function autonomyScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 131 | 139 | "", |
| 132 | 140 | `Mode ${r.autonomy}`, |
| 133 | 141 | ` ${AUTONOMY_SAID[r.autonomy]}`, |
| 142 | `Crew ${stopLineOf(f, r)}`, | |
| 134 | 143 | ...weekLines(crewWeekFor(f.app, r, new Date())), |
| 135 | 144 | `Polish ${r.polishShare}% of the week's spend`, |
| 136 | 145 | checksLine(f.app, r), |
src/tui/screens/common.ts +1
| @@ -1088,6 +1088,7 @@ const MESSAGES: Record<string, string> = { | ||
| 1088 | 1088 | agent_not_on_crew: AGENT_NOT_ON_CREW, |
| 1089 | 1089 | invalid_model: "that model name is not valid", |
| 1090 | 1090 | 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", | |
| 1091 | 1092 | invalid_budget: "the budget must be between 0 and 100 dollars", |
| 1092 | 1093 | }; |
| 1093 | 1094 |
src/web/chrome.ts +14 −2
| @@ -31,6 +31,9 @@ import { followLineWords } from "../actions/follow_words.ts"; | ||
| 31 | 31 | import { forkFollowMode } from "../core/fork_follow.ts"; |
| 32 | 32 | import { keptBehind, MINE_ANCHOR, ownsInTree } from "../core/following.ts"; |
| 33 | 33 | 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"; | |
| 34 | 37 | import { icon } from "./icons.ts"; |
| 35 | 38 | import { nearPages } from "./near_pages.ts"; |
| 36 | 39 | import { page, redirect } from "./layout.ts"; |
| @@ -367,7 +370,7 @@ export function scopeHeader( | ||
| 367 | 370 | ${repo === undefined ? null : audienceLine(ctx, repo, admin, base)} |
| 368 | 371 | ${when( |
| 369 | 372 | !options.compact && facts.description !== "", |
| 370 | () => html`<p class="muted small">${facts.description}</p>`, | |
| 373 | () => clamp(facts.description, "muted small"), | |
| 371 | 374 | )} |
| 372 | 375 | ${repo === undefined ? null : ancestryCrumb(ctx, repo)} |
| 373 | 376 | ${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( | ||
| 386 | 389 | )} |
| 387 | 390 | ${studio ? studioOriginNote(repo) : options.quiet ? null : whereRow(ctx, scope)} |
| 388 | 391 | ${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>`; | |
| 390 | 402 | } |
| 391 | 403 | |
| 392 | 404 | /** 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. | |
| 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 @@ | ||
| 27 | 27 | |
| 28 | 28 | import { emptyList } from "../empty_words.ts"; |
| 29 | 29 | import { binaryRefusal } from "../render/opens_with.ts"; |
| 30 | import { clamp } from "../clamp.ts"; | |
| 30 | 31 | import { mirrorJobFor, startMirrorJob } from "../../actions/origins.ts"; |
| 31 | 32 | import { forkOrigin } from "../../actions/contribute.ts"; |
| 32 | 33 | import { getOriginFor } from "../../core/origins.ts"; |
| @@ -568,7 +569,7 @@ function aboutRail(scope: RepoScope): Html { | ||
| 568 | 569 | return html`${card( |
| 569 | 570 | html`${when( |
| 570 | 571 | facts.description !== "", |
| 571 | () => html`<p class="mb">${facts.description}</p>`, | |
| 572 | () => clamp(facts.description, "mb"), | |
| 572 | 573 | )} |
| 573 | 574 | <div class="where-block"> |
| 574 | 575 | <h3>Where it lives</h3> |
src/web/pages/repo.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * path segment and can never smuggle a path of its own. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { clamp } from "../clamp.ts"; | |
| 11 | 12 | import { reviewCard } from "./review.ts"; |
| 12 | 13 | import { keyOf } from "../keymap.ts"; |
| 13 | 14 | import { DELETING_SAYS } from "../../core/repo_deleting.ts"; |
| @@ -1030,7 +1031,7 @@ function aboutCard( | ||
| 1030 | 1031 | <h2>About</h2> |
| 1031 | 1032 | ${when( |
| 1032 | 1033 | repo.description !== "", |
| 1033 | () => html`<p class="mb">${repo.description}</p>`, | |
| 1034 | () => clamp(repo.description, "mb"), | |
| 1034 | 1035 | )} |
| 1035 | 1036 | <dl class="rail-facts"> |
| 1036 | 1037 | ${fact("Visibility", html`${repo.visibility}`)} |
src/web/style/content.ts +10
| @@ -24,6 +24,16 @@ export const content = /* css */ ` | ||
| 24 | 24 | /* The by-wave link under the changelog filters: a thumb-sized target, no new class. */ |
| 25 | 25 | a[data-waves-link] { display: inline-flex; align-items: center; min-height: 44px; } |
| 26 | 26 | .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; } } | |
| 27 | 37 | .repo-head .tabs, .repo-head .repo-nav { margin-top: 12px; } |
| 28 | 38 | .repo-nav { display: flex; align-items: flex-start; gap: 4px; border-bottom: 1px solid var(--border); } |
| 29 | 39 | .repo-nav .tabs { margin-top: 0; border-bottom: 0; flex: 1 1 auto; } |
test/budgets/pages/owner-name-map.json added +5
test/budgets/pages/owner-name-next.json +2 −2
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "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)" | |
| 5 | 5 | } |
test/budgets/pages/owner-name-queue.json added +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("<b>"); | |
| 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", | ||
| 104 | 104 | const h = await head("/olive/yard"); |
| 105 | 105 | expect(h).toContain('<a class="muted" href="/olive">olive</a>'); |
| 106 | 106 | 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>`); | |
| 108 | 108 | expect(h).not.toContain('class="owner"'); |
| 109 | 109 | expect(h).not.toContain('class="slash"'); |
| 110 | 110 | }); |
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", () => { | ||
| 176 | 176 | const runs = await (await get("/alice/notes/runs")).text(); |
| 177 | 177 | // The same header on all three: the description, not the compact one. |
| 178 | 178 | 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>'); | |
| 180 | 180 | // No pull and no run is ever told, so only the issue list links to it. |
| 181 | 181 | expect(issues).toContain('href="/alice/notes/issues?word=told"'); |
| 182 | 182 | expect(pulls).not.toContain("word=told"); |
test/tui-autonomy.test.ts +1
| @@ -116,6 +116,7 @@ describe("autonomy in the terminal", () => { | ||
| 116 | 116 | const h = boot(erin); |
| 117 | 117 | await h.open(); |
| 118 | 118 | 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)."); | |
| 119 | 120 | await h.press("m"); |
| 120 | 121 | expect(h.text()).toContain("Set autonomy (now off)"); |
| 121 | 122 | expect(h.text()).toContain(AUTONOMY_SAID.autonomous); |
new above
offline
Principle 1: the sentence says what the clamp is for. The list of classes is fine. But no
docs/features/how-to covers the newbrieffield.