Public: anyone can read this; the crew can change it.
/apps at 390 px lists each app as one row: name, state word, crew activity in plain words #13080
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13004-apps-at-390-px-lists-each-app-as-one-row → main 11 commits fork 2 threads · 2 unresolved
10 files
changed +398
−25
docs/features/README.md +1
| @@ -190,6 +190,7 @@ Read with the guide page [Ship and undo](../guide-ship-and-undo.md). | ||
| 190 | 190 | Read with the guide page [](../guide-your-apps.md). |
| 191 | 191 | |
| 192 | 192 | - [](app-egress-refused.md) |
| 193 | - [](apps-crew-sentence.md) | |
| 193 | 194 | - [](own-source.md) |
| 194 | 195 | - [](own-code.md) |
| 195 | 196 | - [](absorb-review.md) |
docs/features/apps-crew-sentence.md added +13
| @@ -0,0 +1,13 @@ | ||
| 1 | # What the crew is doing, as one sentence per app | |
| 2 | ||
| 3 | On `/apps` each app's row says what the crew is doing in plain words, under its name, and the terminal says the same in **What the crew is doing** (Ctrl-K, `src/tui/screens/apps_crew.ts`). Both come from `crewLine` (`src/web/studio/crew_line.ts`) through `shelfRows` (`src/web/studio/shelf.ts`), so they cannot disagree. | |
| 4 | ||
| 5 | > Alice is working on Add the login page | |
| 6 | ||
| 7 | - **Words**: working, a change ready for a look, shipped, a problem, waiting. A row with none of these keeps its own line ("quiet — tell the crew something"). | |
| 8 | - **Who and what** are named only to someone who may direct the crew on that app (the same gate as the crew and its cost). Anyone else reads "The crew is working", with no name and no title. A sealed issue's title is shown only to those who may see it (`mayView`). | |
| 9 | - A name starts with a capital. A title longer than 60 characters is cut with an ellipsis in the row; the whole title is in the row's `title` attribute. | |
| 10 | - It is opt-in per page (`sentence` in `shelfRows`'s reads); Home's *Your apps* and an organisation's apps keep the bare word. | |
| 11 | - The terminal reads the sentence through `onSentence`, one call per row, from the same single batched read of titles. | |
| 12 | ||
| 13 | Tests: `test/apps-crew-sentence.test.ts`. |
src/tui/screens/apps_crew.ts added +96
| @@ -0,0 +1,96 @@ | ||
| 1 | /** | |
| 2 | * What the crew is doing on each app, in the terminal: the sentence under each | |
| 3 | * app's name on /apps ("Alice is working on Add the login page"), from the same | |
| 4 | * `crewLine` and the same gates as the web (`shelfRows`'s `onSentence`) — who and | |
| 5 | * what it is about only where the viewer may know. Enter opens the About card. | |
| 6 | */ | |
| 7 | ||
| 8 | import { appsForRepos } from "../../core/apps.ts"; | |
| 9 | import { listReposVisibleTo, type Repo } from "../../core/repos.ts"; | |
| 10 | import { shelfRows } from "../../web/studio/shelf.ts"; | |
| 11 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 12 | import { binding } from "../app/keys.ts"; | |
| 13 | import type { Session } from "../session.ts"; | |
| 14 | import { fill, len, split } from "../ui/layout.ts"; | |
| 15 | import { style } from "../term/style.ts"; | |
| 16 | import { truncate } from "../term/width.ts"; | |
| 17 | import { emptyState } from "../ui/widgets.ts"; | |
| 18 | import { aboutScreen } from "./about.ts"; | |
| 19 | import { ListState, drawList, type ListRow } from "./common.ts"; | |
| 20 | import type { PaletteEntry } from "./entries.ts"; | |
| 21 | import { local } from "./where.ts"; | |
| 22 | ||
| 23 | interface CrewRow { | |
| 24 | readonly repo: Repo; | |
| 25 | /** The sentence, or "" when the app has nothing moving to say. */ | |
| 26 | readonly says: string; | |
| 27 | } | |
| 28 | ||
| 29 | /** Every app the viewer may see, newest first, each with its sentence. */ | |
| 30 | export async function crewRows(f: Session): Promise<CrewRow[]> { | |
| 31 | const visible = listReposVisibleTo(f.db, f.user, { limit: 200, withoutArchived: true }); | |
| 32 | const withApp = appsForRepos(f.db, visible.map((r) => r.id)); | |
| 33 | const repos = visible.filter((r) => withApp.has(r.id)); | |
| 34 | const says = new Map<string, string>(); | |
| 35 | const url = new URL("http://forge.local/apps"); | |
| 36 | await shelfRows( | |
| 37 | { | |
| 38 | app: f.app, | |
| 39 | request: new Request(url.href), | |
| 40 | url, | |
| 41 | params: {}, | |
| 42 | auth: { user: f.user, scope: undefined, via: f.user === undefined ? ("none" as const) : ("session" as const) }, | |
| 43 | theme: undefined, | |
| 44 | }, | |
| 45 | repos, | |
| 46 | { onSentence: (id, sentence) => says.set(id, sentence) }, | |
| 47 | ); | |
| 48 | return repos.map((repo) => ({ repo, says: says.get(repo.id) ?? "" })); | |
| 49 | } | |
| 50 | ||
| 51 | export function appsCrewScreen(f: Session, ctx: Ctx): Screen { | |
| 52 | const state = new ListState(); | |
| 53 | let rows: CrewRow[] | undefined; | |
| 54 | void crewRows(f).then((r) => { | |
| 55 | rows = r; | |
| 56 | ctx.invalidate(); | |
| 57 | }); | |
| 58 | const screen: Screen = { | |
| 59 | title: "What the crew is doing", | |
| 60 | keys: [binding(["j", "k"], "move cursor"), binding(["enter"], "about")], | |
| 61 | render(area, s) { | |
| 62 | const c = ctx.theme.c; | |
| 63 | const [head, body] = split(area, "v", [len(1), fill(1)]); | |
| 64 | if (rows === undefined) return; | |
| 65 | if (rows.length === 0) { | |
| 66 | emptyState(s, body!, c, { title: "No apps yet." }); | |
| 67 | return; | |
| 68 | } | |
| 69 | s.text(head!.x, head!.y, truncate("enter opens the app", head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); | |
| 70 | const list: ListRow[] = rows.map((r) => ({ | |
| 71 | title: r.repo.name, | |
| 72 | secondary: r.says === "" ? "quiet" : r.says, | |
| 73 | })); | |
| 74 | drawList(s, body!, c, state, list); | |
| 75 | }, | |
| 76 | key(e) { | |
| 77 | if (rows === undefined) return false; | |
| 78 | if (state.key(e, rows.length)) return true; | |
| 79 | if (e.ctrl || e.alt || e.key !== "enter") return false; | |
| 80 | const row = rows[state.index]; | |
| 81 | if (row === undefined) return false; | |
| 82 | ctx.push(aboutScreen(f, ctx, screen, local(f, row.repo), undefined, "")); | |
| 83 | return true; | |
| 84 | }, | |
| 85 | }; | |
| 86 | return screen; | |
| 87 | } | |
| 88 | ||
| 89 | /** The sentence under each app on /apps, as a list. */ | |
| 90 | export const entry: PaletteEntry = { | |
| 91 | id: "apps-crew", | |
| 92 | title: "What the crew is doing", | |
| 93 | hint: "one plain sentence per app: who is on what", | |
| 94 | offered: () => true, | |
| 95 | run: (session, ctx) => ctx.push(appsCrewScreen(session, ctx)), | |
| 96 | }; |
src/tui/screens/entries.ts +5 −1
| @@ -13,6 +13,7 @@ import { entry as accountAccess } from "./account_access.ts"; | ||
| 13 | 13 | import { entry as agents } from "./agents.ts"; |
| 14 | 14 | import { entry as askData } from "./ask_data.ts"; |
| 15 | 15 | import { entry as archived } from "./archived.ts"; |
| 16 | import { entry as appsCrew } from "./apps_crew.ts"; | |
| 16 | 17 | import { entry as audit } from "./audit.ts"; |
| 17 | 18 | import { entry as appTemplates } from "./app_templates.ts"; |
| 18 | 19 | import { entry as dotfiles } from "./dotfiles.ts"; |
| @@ -186,6 +187,7 @@ export const ENTRIES: readonly PaletteEntry[] = [ | ||
| 186 | 187 | orgGrants, |
| 187 | 188 | agents, |
| 188 | 189 | archived, |
| 190 | appsCrew, | |
| 189 | 191 | invites, |
| 190 | 192 | billingLinks, |
| 191 | 193 | planRow, |
| @@ -225,7 +227,9 @@ export const ENTRIES: readonly PaletteEntry[] = [ | ||
| 225 | 227 | newIssue, |
| 226 | 228 | ]; |
| 227 | 229 | |
| 228 | /** Put each entry the session is offered into `commands`, after the command it names or at the end. */ | |
| 230 | /** | |
| 231 | * Put each entry the session is offered into `commands`, after the command it names or at the end. | |
| 232 | */ | |
| 229 | 233 | export function addEntries(commands: Command[], session: Session, ctx: Ctx): void { |
| 230 | 234 | const placed = new Map<string, number>(); |
| 231 | 235 | for (const e of ENTRIES) { |
src/web/pages/apps.ts +8 −3
| @@ -236,7 +236,7 @@ export async function appsList(ctx: Ctx): Promise<Response> { | ||
| 236 | 236 | shelfRows( |
| 237 | 237 | ctx, |
| 238 | 238 | shown.map((e) => e.repo), |
| 239 | { firstPreview: firstPreviews(ctx.app.db, shown.map((e) => e.record)), under: wake }, | |
| 239 | { firstPreview: firstPreviews(ctx.app.db, shown.map((e) => e.record)), under: wake, sentence: true }, | |
| 240 | 240 | ), |
| 241 | 241 | ); |
| 242 | 242 | const cost = timePhase(ctx.request, "cost", () => |
| @@ -731,14 +731,19 @@ export function previewSection( | ||
| 731 | 731 | </section>`; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | /** How loud a preview reads: danger when it failed or errs, attn when only its last deploy failed. */ | |
| 734 | /** | |
| 735 | * How loud a preview reads: danger when it failed or errs, attn when only its last deploy failed. | |
| 736 | */ | |
| 735 | 737 | export function envTone(env: EnvStatus): "danger" | "attn" | undefined { |
| 736 | 738 | if (env.state === "failed" || env.error !== undefined) return "danger"; |
| 737 | 739 | if (env.failedDeploy !== undefined) return "attn"; |
| 738 | 740 | return undefined; |
| 739 | 741 | } |
| 740 | 742 | |
| 741 | /** Where this pull's preview stands, with the way in: a plain block under an h2, the home page's language. */ | |
| 743 | /** | |
| 744 | * Where this pull's preview stands, with the way in: a plain block under an h2, the home page's | |
| 745 | * language. | |
| 746 | */ | |
| 742 | 747 | export function previewBlock(ctx: Ctx, repo: Repo, pull: Pull): Html { |
| 743 | 748 | const view = appView(ctx.app, ctx.auth.user, repo); |
| 744 | 749 | if (!view.ok) return html``; |
src/web/studio/crew_line.ts added +45
| @@ -0,0 +1,45 @@ | ||
| 1 | /** | |
| 2 | * What the crew is doing on an app, in a sentence a client with no technical | |
| 3 | * background can read: "Ada is working on the login page". Pure: a studio | |
| 4 | * word, who (when the viewer may know), and what it is about (when the viewer | |
| 5 | * may know) go in; plain text comes out, or undefined for a word that has no | |
| 6 | * plain sentence and keeps the row's own. It names none of the words a | |
| 7 | * stranger is never shown (`STRANGER_NEVER_SEES`). A name starts with a | |
| 8 | * capital, so a username reads as a name, not a typo. A title cut to fit a row | |
| 9 | * is shown whole in the row's title attribute (`shelfRows`). | |
| 10 | */ | |
| 11 | ||
Principle 8 and cleanliness: this comment promises a title attribute that nothing sets. Set it on the row's strong, or remove the claim. Truncating to 60 characters with no way to read the rest is a phone problem. |
||
| 12 | import type { Word } from "./words.ts"; | |
| 13 | ||
| 14 | /** A title short enough to sit in one row. */ | |
| 15 | const MAX_ABOUT = 60; | |
| 16 | ||
| 17 | function tidy(about: string | undefined): string | undefined { | |
| 18 | const text = (about ?? "").replace(/\s+/g, " ").trim(); | |
| 19 | if (text === "") return undefined; | |
| 20 | return text.length <= MAX_ABOUT ? text : `${text.slice(0, MAX_ABOUT - 1).trimEnd()}…`; | |
| 21 | } | |
| 22 | ||
| 23 | /** The sentence for one app's row; undefined when the word has none. */ | |
| 24 | export function crewLine( | |
| 25 | word: Word, | |
| 26 | who: string | undefined, | |
| 27 | about: string | undefined, | |
| 28 | ): string | undefined { | |
| 29 | const subject = who === undefined ? "The crew" : `${who.slice(0, 1).toUpperCase()}${who.slice(1)}`; | |
| 30 | const on = tidy(about); | |
| 31 | switch (word) { | |
| 32 | case "working": | |
| 33 | return on === undefined ? `${subject} is working` : `${subject} is working on ${on}`; | |
| 34 | case "look": | |
| 35 | return on === undefined ? `${subject} has a change ready for you` : `${on} is ready for a look`; | |
| 36 | case "shipped": | |
| 37 | return on === undefined ? `${subject} shipped a change` : `${subject} shipped ${on}`; | |
| 38 | case "stopped": | |
| 39 | return on === undefined ? `${subject} hit a problem` : `${subject} hit a problem with ${on}`; | |
| 40 | case "waiting": | |
| 41 | return on === undefined ? `${subject} is waiting` : `${on} is waiting`; | |
| 42 | default: | |
| 43 | return undefined; | |
| 44 | } | |
| 45 | } |
src/web/studio/shelf.ts +55 −16
| @@ -28,7 +28,9 @@ import { spanWords } from "../../apps/golden_path.ts"; | ||
| 28 | 28 | import { appsRuntime, type EnvStatus } from "../../apps/runtime.ts"; |
| 29 | 29 | import { appsForRepos, type AppRecord } from "../../core/apps.ts"; |
| 30 | 30 | import { reposWithBuilder } from "../../core/agents.ts"; |
| 31 | import { reposWithUnclaimedTell } from "../../core/issues.ts"; | |
| 31 | import { getIssuesByIds, reposWithUnclaimedTell } from "../../core/issues.ts"; | |
| 32 | import { mayView } from "../../core/sealed.ts"; | |
| 33 | import { crewLine } from "./crew_line.ts"; | |
| 32 | 34 | import { openPullsForRepos } from "../../core/pulls.ts"; |
| 33 | 35 | import { notePhase } from "../../core/route_timing.ts"; |
| 34 | 36 | import { enterableApps, ownerFactRepoIds, type Repo } from "../../core/repos.ts"; |
| @@ -67,6 +69,11 @@ export interface ShelfReads { | ||
| 67 | 69 | readonly firstPreview?: ReadonlyMap<string, number> | undefined; |
| 68 | 70 | /** Something to hang under a row, by repo id (the archived list's Wake). */ |
| 69 | 71 | readonly under?: ReadonlyMap<string, Html> | undefined; |
| 72 | /** Say what the crew is doing as a sentence ("Ada is working on the | |
| 73 | * login page") where the row would give the bare word. The /apps list. */ | |
| 74 | readonly sentence?: boolean | undefined; | |
| 75 | /** Hear each row's sentence by repo id (the terminal's screen); implies `sentence`. */ | |
| 76 | readonly onSentence?: ((repoId: string, sentence: string) => void) | undefined; | |
| 70 | 77 | } |
| 71 | 78 | |
| 72 | 79 | /** |
| @@ -231,6 +238,20 @@ export async function shelfRows( | ||
| 231 | 238 | (id) => !withBuilder.has(id), |
| 232 | 239 | ), |
| 233 | 240 | ); |
| 241 | // What each moving thing is about, for the sentence: one read for the | |
| 242 | // whole shelf, and only when the page asks for sentences. | |
| 243 | const wantsSentence = reads.sentence === true || reads.onSentence !== undefined; | |
| 244 | const abouts = wantsSentence | |
| 245 | ? getIssuesByIds( | |
| 246 | db, | |
| 247 | [ | |
| 248 | ...[...latestRuns.values()].flatMap((r) => | |
| 249 | r.issueId === null ? [] : [r.issueId], | |
| 250 | ), | |
| 251 | ...[...openPulls.values()].map((p) => p.id), | |
| 252 | ], | |
| 253 | ) | |
| 254 | : new Map(); | |
| 234 | 255 | lap("pulls"); |
| 235 | 256 | |
| 236 | 257 | const rows = await Promise.all( |
| @@ -313,24 +334,42 @@ export async function shelfRows( | ||
| 313 | 334 | // see this app is never invited to it, the same floor `ownerFacts` holds |
| 314 | 335 | // for who worked and what it cost. |
| 315 | 336 | const canTell = ownerFacts.has(repo.id); |
| 337 | const aboutIssue = useOpenPull | |
| 338 | ? abouts.get(openPull.id) | |
| 339 | : latest?.issueId == null | |
| 340 | ? undefined | |
| 341 | : abouts.get(latest.issueId); | |
| 342 | const about = | |
| 343 | canTell && aboutIssue !== undefined && mayView(db, repo, aboutIssue, user) | |
| 344 | ? aboutIssue.title | |
| 345 | : undefined; | |
| 346 | const sentence = | |
| 347 | wantsSentence && word !== undefined | |
| 348 | ? crewLine(word.word, who, about) | |
| 349 | : undefined; | |
| 350 | if (sentence !== undefined) reads.onSentence?.(repo.id, sentence); | |
| 351 | // When this moved last: an open change's own update, production's fact, | |
| 352 | // or the run's end. Only read for a row that has a word. | |
| 353 | const movedAt = (): string => | |
| 354 | useOpenPull | |
| 355 | ? openPull.updatedAt | |
| 356 | : useDeployFact | |
| 357 | ? deployFact!.at | |
| 358 | : latest!.finishedAt ?? latest!.createdAt; | |
| 359 | const quiet = stuck.has(repo.id) | |
| 360 | ? html`<span class="muted">open — ${NOBODY_ON_CREW} to take it</span>` | |
| 361 | : canTell | |
| 362 | ? html`<span class="muted">quiet — tell the crew something</span>` | |
| 363 | : html`<span class="muted">quiet</span>`; | |
| 316 | 364 | const happening = |
| 317 | 365 | word === undefined |
| 318 | ? stuck.has(repo.id) | |
| 319 | ? html`<span class="muted" | |
| 320 | >open — ${NOBODY_ON_CREW} to take it</span | |
| 321 | >` | |
| 322 | : canTell | |
| 323 | ? html`<span class="muted">quiet — tell the crew something</span>` | |
| 324 | : html`<span class="muted">quiet</span>` | |
| 325 | : html`<strong data-word="${word.word}">${word.word}</strong> | |
| 366 | ? quiet | |
| 367 | : sentence !== undefined | |
| 368 | ? html`<strong data-word="${word.word}" title="${about ?? sentence}">${sentence}</strong> | |
| 369 | ${word.word === "working" ? null : html`· ${time(movedAt())}`}` | |
| 370 | : html`<strong data-word="${word.word}">${word.word}</strong> | |
| 326 | 371 | ${who ? html`· ${who}` : null} |
| 327 | ${word.word === "working" | |
| 328 | ? html`· now` | |
| 329 | : useOpenPull | |
| 330 | ? html`· ${time(openPull.updatedAt)}` | |
| 331 | : useDeployFact | |
| 332 | ? html`· ${time(deployFact!.at)}` | |
| 333 | : html`· ${time(latest!.finishedAt ?? latest!.createdAt)}`}`; | |
| 372 | ${word.word === "working" ? html`· now` : html`· ${time(movedAt())}`}`; | |
| 334 | 373 | // Two apps can share a bare name across owners — a row for one that is |
| 335 | 374 | // not the viewer's own names its owner, everywhere a row can appear. |
| 336 | 375 | const mine = user !== undefined && repo.ownerId === user.id; |
test/apps-crew-sentence.test.ts added +159
| @@ -0,0 +1,159 @@ | ||
| 1 | /** | |
| 2 | * /apps says what the crew is doing as a plain sentence per app (#13004): | |
| 3 | * "Ada is working on Add the login page", no technical words. | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtempSync, rmSync } from "node:fs"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { enableApp } from "../src/actions/apps.ts"; | |
| 11 | import { createRepo } from "../src/actions/repos.ts"; | |
| 12 | import { createIssue } from "../src/core/issues.ts"; | |
| 13 | import { claimRun, createRun, finishRun } from "../src/core/runs.ts"; | |
| 14 | import { createUser, getUserByName, type User } from "../src/core/users.ts"; | |
| 15 | import type { Repo } from "../src/core/repos.ts"; | |
| 16 | import type { Ctx } from "../src/http/context.ts"; | |
| 17 | import { STRANGER_NEVER_SEES } from "../src/design/first_five_minutes.ts"; | |
| 18 | import { crewLine } from "../src/web/studio/crew_line.ts"; | |
| 19 | import { crewRows } from "../src/tui/screens/apps_crew.ts"; | |
| 20 | import type { Session } from "../src/tui/session.ts"; | |
| 21 | import { shelfRows } from "../src/web/studio/shelf.ts"; | |
| 22 | import { quietLogs } from "./helpers/globals.ts"; | |
| 23 | import { proveAll } from "./helpers/verified.ts"; | |
| 24 | ||
| 25 | quietLogs(); | |
| 26 | ||
| 27 | let root = ""; | |
| 28 | let app: App; | |
| 29 | let alice: User; | |
| 30 | let repo: Repo; | |
| 31 | ||
| 32 | const ctx = (): Ctx => ({ | |
| 33 | app, | |
| 34 | request: new Request("http://forge.test/apps"), | |
| 35 | url: new URL("http://forge.test/apps"), | |
| 36 | params: {}, | |
| 37 | auth: { user: alice, scope: undefined, via: "session" }, | |
| 38 | theme: undefined, | |
| 39 | }); | |
| 40 | ||
| 41 | beforeAll(async () => { | |
| 42 | root = mkdtempSync(join(tmpdir(), "forge-crew-sentence-")); | |
| 43 | app = createApp({ dataDir: root, port: 0 }); | |
| 44 | const u = await createUser(app.db, { | |
| 45 | origin: "seed", trusted: true, username: "alice", email: "[email protected]", | |
| 46 | password: "a-good-passphrase", adminIfFirst: true, | |
| 47 | }); | |
| 48 | if (!u.ok) throw new Error(u.error); | |
| 49 | alice = u.value; | |
| 50 | proveAll(app); | |
| 51 | const made = await createRepo(app, alice, { name: "shop", visibility: "public" }); | |
| 52 | if (!made.ok) throw new Error(String(made.error)); | |
| 53 | repo = made.value; | |
| 54 | const enabled = enableApp(app, alice, repo, { slug: "shop" }); | |
| 55 | if (!enabled.ok) throw new Error(String(enabled.error)); | |
| 56 | const issue = createIssue(app.db, { repoId: repo.id, authorId: alice.id, title: "Add the login page", kind: "issue" }); | |
| 57 | if (!issue.ok) throw new Error(issue.error); | |
| 58 | const run = createRun(app.db, { repoId: repo.id, kind: "agent", reason: "tell", issueId: issue.value.id, actorId: alice.id }); | |
| 59 | claimRun(app.db, run.id); | |
| 60 | }); | |
| 61 | afterAll(() => { | |
| 62 | app.close(); | |
| 63 | rmSync(root, { recursive: true, force: true }); | |
| 64 | }); | |
| 65 | ||
| 66 | const text = (h: { text: string }): string => h.text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " "); | |
| 67 | ||
| 68 | test("a row for a moving app says who is doing what, in words", async () => { | |
| 69 | const [plain] = await shelfRows(ctx(), [repo], { sentence: true }); | |
| 70 | expect(text(plain!)).toContain("Alice is working on Add the login page"); | |
| 71 | // Without the opt-in the shelf is what it always was. | |
| 72 | const [bare] = await shelfRows(ctx(), [repo]); | |
| 73 | expect(text(bare!)).not.toContain("is working on"); | |
| 74 | }); | |
| 75 | ||
| 76 | test("a reader who cannot direct the crew is not told what it is about", async () => { | |
| 77 | const bob = await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" }); | |
| 78 | if (!bob.ok) throw new Error(bob.error); | |
| 79 | const c = { ...ctx(), auth: { user: bob.value, scope: undefined, via: "session" as const } }; | |
| 80 | const [row] = await shelfRows(c, [repo], { sentence: true }); | |
| 81 | expect(text(row!)).not.toContain("login page"); | |
| 82 | expect(text(row!)).toContain("The crew is working"); | |
| 83 | }); | |
| 84 | ||
| 85 | test("every sentence is free of the words a stranger never sees", () => { | |
| 86 | const banned = new RegExp(`\\b(${STRANGER_NEVER_SEES.join("|")})`, "i"); | |
| 87 | for (const word of ["working", "look", "shipped", "stopped", "waiting"] as const) | |
| 88 | for (const who of [undefined, "ada"]) | |
| 89 | for (const about of [undefined, "the login page"]) { | |
| 90 | const line = crewLine(word, who, about); | |
| 91 | expect(line).toBeDefined(); | |
| 92 | expect(banned.test(line!)).toBe(false); | |
| 93 | } | |
| 94 | expect(crewLine("silent", "ada", "x")).toBeUndefined(); | |
| 95 | expect(crewLine("working", "ada", "x".repeat(200))!.length).toBeLessThan(90); | |
| 96 | }); | |
| 97 | ||
| 98 | /** A new app on the shelf with one pull written straight into the database, as shelf-forty does. */ | |
| 99 | async function appWithPull(name: string, title: string, sealed: boolean): Promise<Repo> { | |
| 100 | const made = await createRepo(app, alice, { name, visibility: "public" }); | |
| 101 | if (!made.ok) throw new Error(String(made.error)); | |
| 102 | const enabled = enableApp(app, alice, made.value, { slug: name }); | |
| 103 | if (!enabled.ok) throw new Error(String(enabled.error)); | |
| 104 | const issue = createIssue(app.db, { repoId: made.value.id, authorId: alice.id, title, kind: "pull", sealed }); | |
| 105 | if (!issue.ok) throw new Error(issue.error); | |
| 106 | app.db | |
| 107 | .query("INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id) VALUES (?1, 'main', 'work', ?2, ?3, ?4)") | |
| 108 | .run(issue.value.id, "0".repeat(40), "1".repeat(40), made.value.id); | |
| 109 | return made.value; | |
| 110 | } | |
| 111 | ||
| 112 | test("an open change reads by its title as waiting, to the one who directs the crew", async () => { | |
| 113 | const r = await appWithPull("menu", "Fix the menu", false); | |
| 114 | const [row] = await shelfRows(ctx(), [r], { sentence: true }); | |
| 115 | expect(text(row!)).toContain("Fix the menu is waiting"); | |
| 116 | // The whole title rides in the title attribute, for a phone where the row cuts it. | |
| 117 | expect(row!.text).toContain('title="Fix the menu"'); | |
| 118 | }); | |
| 119 | ||
| 120 | test("a sealed change's title is never shown to a reader, and a reader is not told who", async () => { | |
| 121 | const r = await appWithPull("vault", "Close the hole in login", true); | |
| 122 | const bob = await createUser(app.db, { origin: "seed", trusted: true, username: "carol", email: "[email protected]", password: "a-good-passphrase" }); | |
| 123 | if (!bob.ok) throw new Error(bob.error); | |
| 124 | const c = { ...ctx(), auth: { user: bob.value, scope: undefined, via: "session" as const } }; | |
| 125 | const [row] = await shelfRows(c, [r], { sentence: true }); | |
| 126 | expect(row!.text).not.toContain("hole"); | |
| 127 | expect(row!.text).not.toContain("Alice"); | |
| 128 | // Signed out too. | |
| 129 | const anon = { ...ctx(), auth: { user: undefined, scope: undefined, via: "none" as const } }; | |
| 130 | const [seen] = await shelfRows(anon, [r], { sentence: true }); | |
| 131 | expect(seen!.text).not.toContain("hole"); | |
| 132 | }); | |
| 133 | ||
| 134 | test("a run that failed reads as a problem with its title", async () => { | |
| 135 | const made = await createRepo(app, alice, { name: "broken", visibility: "public" }); | |
| 136 | if (!made.ok) throw new Error(String(made.error)); | |
| 137 | const enabled = enableApp(app, alice, made.value, { slug: "broken" }); | |
| 138 | if (!enabled.ok) throw new Error(String(enabled.error)); | |
| 139 | const issue = createIssue(app.db, { repoId: made.value.id, authorId: alice.id, title: "Add search", kind: "issue" }); | |
| 140 | if (!issue.ok) throw new Error(issue.error); | |
| 141 | const run = createRun(app.db, { repoId: made.value.id, kind: "agent", reason: "tell", issueId: issue.value.id, actorId: alice.id }); | |
| 142 | claimRun(app.db, run.id); | |
| 143 | finishRun(app.db, run.id, { state: "failed", summary: "boom" }); | |
| 144 | const [row] = await shelfRows(ctx(), [made.value], { sentence: true }); | |
| 145 | expect(text(row!)).toContain("Alice hit a problem with Add search"); | |
| 146 | }); | |
| 147 | ||
| 148 | test("the terminal says the same sentence, from the same gates", async () => { | |
| 149 | const f = { app, db: app.db, user: alice } as unknown as Session; | |
| 150 | const rows = await crewRows(f); | |
| 151 | const shop = rows.find((r) => r.repo.name === "shop")!; | |
| 152 | expect(shop.says).toBe("Alice is working on Add the login page"); | |
| 153 | const vault = rows.find((r) => r.repo.name === "vault")!; | |
| 154 | expect(vault.says).toContain("Close the hole in login"); | |
| 155 | const carol = getUserByName(app.db, "carol")!; | |
| 156 | const theirs = await crewRows({ app, db: app.db, user: carol } as unknown as Session); | |
| 157 | expect(theirs.find((r) => r.repo.name === "shop")!.says).toBe("The crew is working"); | |
| 158 | expect(theirs.map((r) => r.says).join(" ")).not.toContain("hole"); | |
| 159 | }); |
test/palette-roster.test.ts +6 −1
| @@ -193,6 +193,7 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 193 | 193 | ["lapsed", "Lapsed forges", "forges asleep until paid, when their data goes, pay again"], |
| 194 | 194 | ["codes", "Gift codes", "make a code that gives a plan for free, and revoke one"], |
| 195 | 195 | ["archived", "Archived repositories", "put away, not gone: open one or restore it"], |
| 196 | ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"], | |
| 196 | 197 | ["cloud", "Cloud accounts", "provider tokens, what they are used for, today's calls"], |
| 197 | 198 | ["pinned", "Pinned forges", "deploy, update and roll back a forge on your cloud"], |
| 198 | 199 | ["bets", "Bets", "back, stop and finish a repository\'s bets"], |
| @@ -289,6 +290,7 @@ test("a site-admin agent is offered the roster without the person-only entries", | ||
| 289 | 290 | ["traffic-sources", "Traffic sources", "where people come from and where they go, for the forge"], |
| 290 | 291 | ["audit", "Who can do what", "each app's doors from its contract.json: yes, own or no"], |
| 291 | 292 | ["archived", "Archived repositories", "put away, not gone: open one or restore it"], |
| 293 | ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"], | |
| 292 | 294 | ["plan-row", "Plan", "this forge's plan, and where its owner manages billing"], |
| 293 | 295 | ["cloud", "Cloud accounts", "provider tokens, what they are used for, today's calls"], |
| 294 | 296 | ["pinned", "Pinned forges", "deploy, update and roll back a forge on your cloud"], |
| @@ -383,6 +385,7 @@ test("a member person is offered the signed-in roster without the admin entries" | ||
| 383 | 385 | ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"], |
| 384 | 386 | ["audit", "Who can do what", "each app's doors from its contract.json: yes, own or no"], |
| 385 | 387 | ["archived", "Archived repositories", "put away, not gone: open one or restore it"], |
| 388 | ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"], | |
| 386 | 389 | ["claim-start", "Take an agent's work", "claim the repositories an agent started, from its one-time link"], |
| 387 | 390 | ["claim-link", "A fresh claim link for a forge I sent", "the old link stops; shown once"], |
| 388 | 391 | ["bulk", "Bulk actions", "your last bulk actions; u undoes one inside its day"], |
| @@ -442,6 +445,7 @@ test("signed out, the palette offers sign-in and the public entries", () => { | ||
| 442 | 445 | ["bugs", "Bugs", "open bugs and the bug clock"], |
| 443 | 446 | ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"], |
| 444 | 447 | ["audit", "Who can do what", "each app's doors from its contract.json: yes, own or no"], |
| 448 | ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"], | |
| 445 | 449 | ["front", "Front page", "the apps a first visitor sees, ranked; an admin pins or hides"], |
| 446 | 450 | ["origin-ahead", "New commits upstream", "mirrors whose origin has moved on: take them"], |
| 447 | 451 | ["front-milestones", "Milestones", "the biggest open milestones: how far, what landed this week"], |
| @@ -539,7 +543,8 @@ describe("on a pull's Files step the palette lists what the page offers this rea | ||
| 539 | 543 | for (const [tab, path] of [["Conversation", thread], ["Files", `${thread}/files`]] as const) { |
| 540 | 544 | test(`on the ${tab} tab a ${who}'s action rows are exactly the page's forms`, async () => { |
| 541 | 545 | const { rows, forms } = await read(path, kind()); |
| 542 | // The Files tab has no comment form of its own: its Comment row links to the Conversation's. | |
| 546 | // The Files tab has no comment form of its own: its Comment row links to the | |
| 547 | // Conversation's. | |
| 543 | 548 | const acts = rows.map((r) => r.t).filter((t) => !READING.includes(t) && !(tab === "Files" && t === "Comment")); |
| 544 | 549 | const same = (t: string) => (t === "Bring up to date" ? "Ship" : t); |
| 545 | 550 | expect(acts.map(same).sort()).toEqual([...new Set(forms)].sort()); |
test/studio-shipping.test.ts +10 −4
| @@ -305,10 +305,10 @@ describe("a stranger sees the app, not the owner's books", () => { | ||
| 305 | 305 | |
| 306 | 306 | test("the studio home names the crew for the owner, but only 'the crew' for a signed-in reader of the same public app", async () => { |
| 307 | 307 | const asStranger = await (await get("/apps", strangerCookie)).text(); |
| 308 | expect(asStranger).not.toContain("keeper"); | |
| 308 | expect(asStranger.toLowerCase()).not.toContain("keeper"); | |
| 309 | 309 | expect(asStranger).toContain("beacon"); |
| 310 | 310 | const asOwner = await (await get("/apps", ownerCookie)).text(); |
| 311 | expect(asOwner).toContain("keeper"); | |
| 311 | expect(asOwner.toLowerCase()).toContain("keeper"); | |
| 312 | 312 | expect(asOwner).toContain("beacon"); |
| 313 | 313 | }); |
| 314 | 314 | |
| @@ -1206,7 +1206,10 @@ describe("previewLatency: the median seconds from push to serving", () => { | ||
| 1206 | 1206 | app.db.query("DELETE FROM run WHERE repo_id = ?1").run(repo.id); |
| 1207 | 1207 | }); |
| 1208 | 1208 | |
| 1209 | /** A deploy run stamped with a known push instant and, unless null, known started/serving instants. */ | |
| 1209 | /** | |
| 1210 | * A deploy run stamped with a known push instant and, unless null, known started/serving | |
| 1211 | * instants. | |
| 1212 | */ | |
| 1210 | 1213 | const seedDeploy = ( |
| 1211 | 1214 | createdAt: string, |
| 1212 | 1215 | startedAt: string | null, |
| @@ -1523,7 +1526,10 @@ describe("the studio's own words for how fast a change reaches its preview", () | ||
| 1523 | 1526 | redirect: "manual", |
| 1524 | 1527 | }); |
| 1525 | 1528 | |
| 1526 | /** A deploy run stamped with a known push instant and serving instant, and unless null a known started instant. */ | |
| 1529 | /** | |
| 1530 | * A deploy run stamped with a known push instant and serving instant, and unless null a known | |
| 1531 | * started instant. | |
| 1532 | */ | |
| 1527 | 1533 | const seedDeploy = ( |
| 1528 | 1534 | createdAt: string, |
| 1529 | 1535 | startedAt: string | null, |
new above
offline
Both doors: the terminal's apps screen needs the same sentence, and the how-to belongs in docs/features/<name>.md with a row in docs/features/README.md.