Public: anyone can read this; the crew can change it.
Asks and crew answers fold into the core: what waits for a person is a state on an issue or pull, shown where that issue or pull already is #13838
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/13787-asks-and-crew-answers-fold-into-the-core → main 10 commits fork 4 threads · 4 unresolved
59 files
changed +405
−224
AGENTS.md +2
| @@ -55,4 +55,6 @@ The capacity setting `children.awake` (boot default `FORGE_CHILD_AWAKE_MAX`) cou | ||
| 55 | 55 | |
| 56 | 56 | An app token's requests go behind people's and repeat reads are 304s (`src/http/app_turn.ts`, `repeat_reads.ts`, `perf/asking.ts`): see `docs/features/app-asking.md`. |
| 57 | 57 | `src/core/reports.ts`: `closedSet`, the ids of repositories whose owner closed reports from outside (#12321), read once per database and kept by `setReportsClosed`, the only writer, so every repository page's head link costs no statement; at most one id per closed repository, gone on restart (the rows are `report_closed`). `src/core/contribute_token.ts`: `openSet`, the ids of repositories that allow outside agents, read once per database and kept by `setContributeOpen`, the only writer, at most one id per allowing repository, gone on restart; a raw SQL write to `contribute_open` bypasses it. The terminal door for reports is `r` on the outside agents screen (`setOutsideReports`, admins). |
| 58 | ||
| 59 | `src/web/studio/waiting_on_me.ts`: `waitingRows`, each viewer's issues and pulls that wait for them, held 10 seconds per viewer (at most 500 viewers, gone on restart) so the board's live lanes share one `decisionsFor` read; the terminal door is `src/tui/screens/waiting_for_me.ts` (palette entry for any person). | |
| 58 | 60 | `src/crew/beat.ts`: `lastBeat`, when each repository's beat last ran, and `declared`, the `beat` last read from each default branch with the commit it came from (#13709); at most one entry each per repository, gone on restart (a restart beats once at once; the declaration is a file in git). |
docs/features/README.md +1
| @@ -146,6 +146,7 @@ Read with the guide page [Tell the crew](../guide-tell-the-crew.md). | ||
| 146 | 146 | - [](people.md) |
| 147 | 147 | - [](file-holds.md) |
| 148 | 148 | - [](maintain.md) |
| 149 | - [](waits-for-me.md) | |
| 149 | 150 | - [](preview-dirs.md) |
| 150 | 151 | - [](asks-mute-undo.md) |
| 151 | 152 | - [](next-up.md) |
docs/features/waits-for-me.md added +14
| @@ -0,0 +1,14 @@ | ||
| 1 | # See what waits for you (#13787) | |
| 2 | ||
| 3 | - **On the board.** Open `/?waits=me` (the header's "Waiting" link, the chord `g q`, the | |
| 4 | manifest shortcut) or press "Waiting for me" beside the app filter. The board shows only the | |
| 5 | cards that wait for you; press "Waiting for me · show all" to leave it. Live lane updates carry the filter. | |
| 6 | - **In the terminal.** The palette's "Waiting for me" lists the same issues and pulls with what | |
| 7 | each waits for; `W` on the dashboard opens the board view on the web. | |
| 8 | - **One read.** Both use `waitingRows` in `web/studio/waiting_on_me.ts`, the same | |
| 9 | `decisionsFor` read the pull page's status line uses. It is held 10 seconds per viewer, and a lane's | |
| 10 | ETag carries a digest of the set, so a change is never answered 304. | |
| 11 | - **`/asks`** redirects to the board view. A step answered there (a bulk receipt, a mute, a | |
| 12 | hand-over) still lands on the list it answered, once. | |
| 13 | - **Standing still** (a repository behind its pulls, an app turned off a moment ago, runs the | |
| 14 | host gave up on) is on `/apps`. |
src/actions/talk_decisions.ts +2 −2
| @@ -38,7 +38,7 @@ export function asksWhatNeedsMe(text: string): boolean { | ||
| 38 | 38 | */ |
| 39 | 39 | export function actionHref(d: Decision): string { |
| 40 | 40 | const base = repoBase(d.repo); |
| 41 | if (d.kind === "proposal") return "/asks"; | |
| 41 | if (d.kind === "proposal") return "/?waits=me"; | |
| 42 | 42 | return d.pull !== undefined ? changeHref(base, d.pull.number) : d.issue !== undefined ? `${base}/issues/${d.issue.number}` : `${base}/settings/autonomy`; |
| 43 | 43 | } |
| 44 | 44 | |
| @@ -62,6 +62,6 @@ export function decisionsAnswer(app: App, user: User): string { | ||
| 62 | 62 | const thing = d.pull?.title ?? d.issue?.title ?? d.proposal?.title ?? d.repo.name; |
| 63 | 63 | return `${i + 1}. [${plain(thing)}](${actionHref(d)}) — ${plain(d.short)}. **${primaryLabel(d)}**`; |
| 64 | 64 | }); |
| 65 | const more = rows.length > shown.length ? `\n\n[${rows.length - shown.length} more in your inbox](/asks)` : ""; | |
| 65 | const more = rows.length > shown.length ? `\n\n[${rows.length - shown.length} more in your inbox](/?waits=me)` : ""; | |
| 66 | 66 | return `${rows.length === 1 ? "One thing waits" : `${rows.length} things wait`} on you:\n\n${lines.join("\n")}${more}`; |
| 67 | 67 | } |
src/flow/lanes.ts +6 −1
| @@ -399,12 +399,16 @@ export interface Viewing { | ||
| 399 | 399 | readonly repos: readonly string[]; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | /** The picture filtered for `viewer`, and to `only` (an `owner/name`) when the filter is set. */ | |
| 402 | /** | |
| 403 | * The picture filtered for `viewer`, to `only` (an `owner/name`) when the filter is set, and to the | |
| 404 | * cards in `waiting` (keys `repoId#number`) when they are those that wait for the viewer. | |
| 405 | */ | |
| 403 | 406 | export function viewFor( |
| 404 | 407 | db: Database, |
| 405 | 408 | viewer: User, |
| 406 | 409 | picture: LanePicture, |
| 407 | 410 | only: string | null = null, |
| 411 | waiting?: ReadonlySet<string>, | |
| 408 | 412 | ): Viewing { |
| 409 | 413 | const ids = new Set<string>(); |
| 410 | 414 | for (const k of LANES) |
| @@ -433,6 +437,7 @@ export function viewFor( | ||
| 433 | 437 | const full = `${repo.ownerName}/${repo.name}`; |
| 434 | 438 | seen.add(full); |
| 435 | 439 | if (only !== null && full !== only) continue; |
| 440 | if (waiting !== undefined && (i.number === null || !waiting.has(`${i.repoId}#${String(i.number)}`))) continue; | |
| 436 | 441 | const base = `/${repo.ownerName}/${repo.name}`; |
| 437 | 442 | const href = |
| 438 | 443 | i.number === null |
src/http/server.ts +2 −2
| @@ -349,7 +349,7 @@ import { | ||
| 349 | 349 | asksListen, |
| 350 | 350 | asksMute, |
| 351 | 351 | asksFilter, |
| 352 | asksPage, | |
| 352 | asksMoved, | |
| 353 | 353 | } from "../web/studio/asks_page.ts"; |
| 354 | 354 | import { keeperAnswer } from "../web/studio/keeper_row.ts"; |
| 355 | 355 | import { homeArchive, homeArchived, homeArchiveUndo } from "../web/studio/home_archive.ts"; |
| @@ -1029,7 +1029,7 @@ export function buildRouter(): Router<Handler> { | ||
| 1029 | 1029 | // The board's tokens line, opened: what the spend bought (core/returns.ts). |
| 1030 | 1030 | router.add("GET", "/board/returns", returnsPage); |
| 1031 | 1031 | // One screen for "is everything fine?": what asks the viewer (docs/STUDIO.md). |
| 1032 | router.add("GET", "/asks", asksPage); | |
| 1032 | router.add("GET", "/asks", asksMoved); | |
| 1033 | 1033 | router.add("POST", "/asks/bulk", asksBulkSubmit); |
| 1034 | 1034 | router.add("POST", "/asks/bulk/:id/undo", asksBulkUndo); |
| 1035 | 1035 | router.add("POST", "/asks/listen", asksListen); |
src/tui/screens/dashboard.ts +1 −1
| @@ -1464,7 +1464,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen { | ||
| 1464 | 1464 | return true; |
| 1465 | 1465 | } |
| 1466 | 1466 | if (e.key === "W" && asksLine !== undefined) { |
| 1467 | openOnWeb(f, ctx, "/asks", "Asks"); | |
| 1467 | openOnWeb(f, ctx, "/?waits=me", "Waiting"); | |
| 1468 | 1468 | return true; |
| 1469 | 1469 | } |
| 1470 | 1470 | if (e.key === "A" && f.user) { |
src/tui/screens/entries.ts +2
| @@ -71,6 +71,7 @@ import { entry as footing } from "./footing.ts"; | ||
| 71 | 71 | import { entry as maintenanceWeek } from "./maintenanceweek.ts"; |
| 72 | 72 | import { entry as offsite } from "./offsite.ts"; |
| 73 | 73 | import { entry as waiting } from "./waiting.ts"; |
| 74 | import { entry as waitingForMe } from "./waiting_for_me.ts"; | |
| 74 | 75 | import { entry as slowPagesEntry } from "./slowpages.ts"; |
| 75 | 76 | import { entry as maintenance } from "./maintenance.ts"; |
| 76 | 77 | import { entry as maintainRuns } from "./maintainruns.ts"; |
| @@ -146,6 +147,7 @@ export const ENTRIES: readonly PaletteEntry[] = [ | ||
| 146 | 147 | maintenanceWeek, |
| 147 | 148 | offsite, |
| 148 | 149 | waiting, |
| 150 | waitingForMe, | |
| 149 | 151 | slowPagesEntry, |
| 150 | 152 | telemetry, |
| 151 | 153 | resilience, |
src/tui/screens/waiting_for_me.ts added +55
| @@ -0,0 +1,55 @@ | ||
| 1 | /** | |
| 2 | * Waiting for me, from the palette: the issues and pulls that wait for the signed-in person, | |
| 3 | * the same `waitingRows` read the board's `/?waits=me` filters its cards by. Read-only; a row | |
| 4 | * says where it is, so the person opens it from its repository. | |
| 5 | */ | |
| 6 | ||
| 7 | import { waitingRows, type WaitingRow } from "../../web/studio/waiting_on_me.ts"; | |
| 8 | import type { Ctx, Screen } from "../app/app.ts"; | |
| 9 | import { binding } from "../app/keys.ts"; | |
| 10 | import type { Session } from "../session.ts"; | |
| 11 | import { style } from "../term/style.ts"; | |
| 12 | import { Scroll, drawLines, hitScroll } from "./common.ts"; | |
| 13 | import type { PaletteEntry } from "./entries.ts"; | |
| 14 | ||
| 15 | const mayRead = (session: Session): boolean => session.user !== undefined && session.user.kind !== "agent"; | |
| 16 | ||
| 17 | /** The rows as text lines: one per card, "owner/name#7 title" then what it waits for. */ | |
| 18 | export function waitingForMeLines(rows: readonly WaitingRow[]): string[] { | |
| 19 | return rows.flatMap((r) => [`${r.repo}#${String(r.number)} ${r.kind === "pull" ? "pull" : "issue"}: ${r.title}`, ` ${r.short}`]); | |
| 20 | } | |
| 21 | ||
| 22 | export function waitingForMeScreen(ctx: Ctx, rows: readonly WaitingRow[]): Screen { | |
| 23 | const scroll = new Scroll(); | |
| 24 | const lines = rows.length === 0 ? ["Nothing waits for you."] : waitingForMeLines(rows); | |
| 25 | return { | |
| 26 | title: "Waiting for me", | |
| 27 | keys: [binding(["j", "k"], "scroll"), binding(["esc", "q"], "back")], | |
| 28 | render(area, s) { | |
| 29 | const c = ctx.theme.c; | |
| 30 | const spans = lines.map((text) => [{ text, style: style(text.startsWith(" ") || rows.length === 0 ? c.mutedFg : c.fg, c.bg) }]); | |
| 31 | drawLines(s, area, c, scroll, spans); | |
| 32 | hitScroll(ctx, area, scroll, lines.length); | |
| 33 | }, | |
| 34 | key(e) { | |
| 35 | if (scroll.key(e, lines.length)) return true; | |
| 36 | if (e.key === "esc" || e.key === "q") { | |
| 37 | ctx.pop(); | |
| 38 | return true; | |
| 39 | } | |
| 40 | return false; | |
| 41 | }, | |
| 42 | }; | |
| 43 | } | |
| 44 | ||
| 45 | export const entry: PaletteEntry = { | |
| 46 | id: "waiting-for-me", | |
| 47 | title: "Waiting for me", | |
| 48 | hint: "issues and pulls that wait for you", | |
| 49 | after: ["pulls-to-land", "flow"], | |
| 50 | offered: mayRead, | |
| 51 | run: (session, ctx) => { | |
| 52 | if (session.user === undefined) return; | |
| 53 | ctx.push(waitingForMeScreen(ctx, waitingRows({ app: session.app, auth: { user: session.user } }, session.user))); | |
| 54 | }, | |
| 55 | }; |
src/web/go_pages.ts +1 −1
| @@ -28,7 +28,7 @@ export const GO_PAGES: readonly GoPage[] = [ | ||
| 28 | 28 | { name: "Board", href: "/board", who: "user" }, |
| 29 | 29 | { name: "Boards", href: "/boards", who: "admin", palette: "Boards" }, |
| 30 | 30 | { name: "Flow", href: "/flow", who: "admin", key: "f" }, |
| 31 | { name: "Asks", href: "/asks", who: "user", key: "q" }, | |
| 31 | { name: "Waiting", href: "/?waits=me", who: "user", key: "q" }, | |
| 32 | 32 | { name: "Asked", href: "/asked", who: "user", palette: "What you asked for" }, |
| 33 | 33 | { name: "Notes", href: "/notes", who: "user", palette: "Notes" }, |
| 34 | 34 | { name: "Talk", href: "/talk", who: "user", key: "t", palette: "Talk to the forge" }, |
src/web/layout.ts +1 −1
| @@ -714,7 +714,7 @@ function topbar( | ||
| 714 | 714 | <span class="topbar-tools"> |
| 715 | 715 | ${tools ?? html`${searchBar()} |
| 716 | 716 | ${user |
| 717 | ? html`${talkButton(ctx, user, about)}<a class="small" href="/asks" data-shortcut="g q" ${hintAttr("g q")}>Asks</a | |
| 717 | ? html`${talkButton(ctx, user, about)}<a class="small" href="/?waits=me" data-shortcut="g q" ${hintAttr("g q")}>Waiting</a | |
| 718 | 718 | >${newMenu(ctx)}${userMenu( |
| 719 | 719 | ctx, |
| 720 | 720 | user, |
src/web/pages/apps.ts +2
| @@ -12,6 +12,7 @@ | ||
| 12 | 12 | * 404 for everyone. |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | import { appsStanding } from "../studio/standing.ts"; | |
| 15 | 16 | import { stepsOf } from "../../core/review_steps.ts"; |
| 16 | 17 | import { USERNAME_PATTERN } from "../username_pattern.ts"; |
| 17 | 18 | import { sshOn } from "../../settings/ssh.ts"; |
| @@ -258,6 +259,7 @@ export async function appsList(ctx: Ctx): Promise<Response> { | ||
| 258 | 259 | sub: APPS_PURPOSE, |
| 259 | 260 | })} |
| 260 | 261 | ${cost} |
| 262 | ${when(ctx.auth.user, (user) => appsStanding(ctx, user))} | |
| 261 | 263 | ${filters} |
| 262 | 264 | ${archivedView |
| 263 | 265 | ? html`<p class="muted small mb"><a href="/apps">Back to apps</a></p>` |
src/web/pages/board.ts +2 −2
| @@ -484,7 +484,7 @@ function reviewNotes(ctx: Ctx, scope: BoardScope): Note[] { | ||
| 484 | 484 | { |
| 485 | 485 | key: `review:${w.repo.id}`, |
| 486 | 486 | need: true, |
| 487 | line: html`<a data-need href="/asks" | |
| 487 | line: html`<a data-need href="/?waits=me" | |
| 488 | 488 | >${dot("attn")} <b>${w.repo.name}</b>: ${w.none ? "No reviewer: agent pulls wait for you" : w.paused ? "The reviewer is paused: agent pulls wait for you" : "agent pulls wait for your review"}${w.waiting === 0 || w.since === null |
| 489 | 489 | ? null |
| 490 | 490 | : html` · <b>${w.waiting}</b> waiting since ${w.since.slice(0, 10)}`}</a |
| @@ -507,7 +507,7 @@ function asksStrip(ctx: Ctx): Html | null { | ||
| 507 | 507 | if (!user) return null; |
| 508 | 508 | const m = askMeasureWeek(ctx.app.db, user.id); |
| 509 | 509 | if (asksMeasureEmpty(m)) return null; |
| 510 | return html`<a class="muted small" id="asks-measure" href="/asks" | |
| 510 | return html`<a class="muted small" id="asks-measure" href="/?waits=me" | |
| 511 | 511 | >Asks, ${ASKS_WINDOW_DAYS} days: ${asksMeasureParts(m).map( |
| 512 | 512 | (p, i) => html`${i === 0 ? "" : " · "}<b>${p.n}</b> ${p.label}`, |
| 513 | 513 | )}</a |
src/web/pages/home_flow.ts +29 −24
| @@ -56,9 +56,8 @@ import { parseTable, tableParams, tableRows, type TableQuery } from "../../flow/ | ||
| 56 | 56 | import { TABLE_LIVE, tableRegion, tableTag, tableTools } from "./home_table.ts"; |
| 57 | 57 | import { readableNotes } from "../../actions/desk.ts"; |
| 58 | 58 | import { deskStrip } from "../desk_strip.ts"; |
| 59 | import { heldLine } from "../studio/held.ts"; | |
| 60 | import { interruptedOutLine } from "../studio/interrupted_out.ts"; | |
| 61 | import { listReposWritableTo } from "../../core/repos.ts"; | |
| 59 | import { askedSection } from "../studio/standing.ts"; | |
| 60 | import { waitingOnMe, waitsDigest } from "../studio/waiting_on_me.ts"; | |
| 62 | 61 | import { chart, figuresGrid, figuresSection } from "./home_figures.ts"; |
| 63 | 62 | import { tellBox } from "../studio/living.ts"; |
| 64 | 63 | import { requestsCard } from "../requests_card.ts"; |
| @@ -93,7 +92,10 @@ const filterOf = (url: URL): string | null => { | ||
| 93 | 92 | return APP_SLUG.test(v) ? v : null; |
| 94 | 93 | }; |
| 95 | 94 | |
| 96 | const query = (only: string | null): string => (only === null ? "" : `&app=${encodeURIComponent(only)}`); | |
| 95 | const query = (only: string | null, mine = false): string => `${only === null ? "" : `&app=${encodeURIComponent(only)}`}${mine ? "&waits=me" : ""}`; | |
| 96 | ||
| 97 | /** `?waits=me`: only the cards that wait for this person (what `/asks` used to list). */ | |
| 98 | const waitsOf = (url: URL): boolean => url.searchParams.get("waits") === "me"; | |
| 97 | 99 | |
| 98 | 100 | /** |
| 99 | 101 | * A stretch of time as a clock the page keeps: the words the server uses, redrawn by the page's |
| @@ -162,6 +164,7 @@ export function laneRegion( | ||
| 162 | 164 | only: string | null, |
| 163 | 165 | _admin: boolean, |
| 164 | 166 | now: number, |
| 167 | mine = false, | |
| 165 | 168 | ): Html { |
| 166 | 169 | const key = view.key; |
| 167 | 170 | const shown = view.items.length; |
| @@ -180,7 +183,7 @@ export function laneRegion( | ||
| 180 | 183 | data-count="${String(view.total)}" |
| 181 | 184 | aria-label="${label}" |
| 182 | 185 | data-live="${LANE_LIVE[key]}" |
| 183 | data-live-src="/live/lane?s=${key}${query(only)}" | |
| 186 | data-live-src="/live/lane?s=${key}${query(only, mine)}" | |
| 184 | 187 | ${scope} |
| 185 | 188 | > |
| 186 | 189 | <header class="lane-head"> |
| @@ -275,14 +278,14 @@ const things = (n: number, one: string, many: string): string => `${String(n)} $ | ||
| 275 | 278 | |
| 276 | 279 | /** |
| 277 | 280 | * The one line, in the page's header: how many things are broken about the forge and how many |
| 278 | * people are stopped, each count a link to its list on `/asks`. Nothing at all when there is | |
| 279 | * nothing: a healthy forge's home opens on its lanes. | |
| 281 | * people are stopped, the problems link to the system page and the people to the board's "waiting | |
| 282 | * for me" view. Nothing at all when there is nothing: a healthy forge's home opens on its lanes. | |
| 280 | 283 | */ |
| 281 | 284 | export function needLine(broken: readonly { says: string; href: string }[], asked: number): Html | null { |
| 282 | 285 | if (broken.length === 0 && asked === 0) return null; |
| 283 | 286 | return html`<p class="hf-need" id="hf-need" role="status"><span class="dot" data-tone="${broken.length === 0 ? "attn" : "danger"}"></span>${ |
| 284 | broken.length === 0 ? null : html`<a href="/asks#forge-broken">${things(broken.length, "problem", "problems")} with the forge</a><span class="hf-need-first">${broken[0]!.says}</span>` | |
| 285 | }${asked === 0 ? null : html`<a href="/asks#asked">${things(asked, "person is", "people are")} stopped until you answer</a>`}</p>`; | |
| 287 | broken.length === 0 ? null : html`<a href="/system">${things(broken.length, "problem", "problems")} with the forge</a><span class="hf-need-first">${broken[0]!.says}</span>` | |
| 288 | }${asked === 0 ? null : html`<a href="/?waits=me">${things(asked, "person is", "people are")} stopped until you answer</a>`}</p>`; | |
| 286 | 289 | } |
| 287 | 290 | |
| 288 | 291 | /** |
| @@ -444,7 +447,7 @@ export async function forgesRegion(app: App, wait: boolean): Promise<Html> { | ||
| 444 | 447 | * opened, so no list of them is written out as text. |
| 445 | 448 | * Without scripts, an app's `owner/name` is typed. |
| 446 | 449 | */ |
| 447 | function filterForm(repos: readonly string[], only: string | null): Html { | |
| 450 | function filterForm(repos: readonly string[], only: string | null, mine = false): Html { | |
| 448 | 451 | return html`<form class="hf-filter" method="get" action="/" id="hf-filter"> |
| 449 | 452 | <label class="hf-filter-label" for="hf-app">Show</label> |
| 450 | 453 | <select class="input" id="hf-app" aria-label="Show one app, or everything" data-apps="${repos.join(",")}"> |
| @@ -452,7 +455,9 @@ function filterForm(repos: readonly string[], only: string | null): Html { | ||
| 452 | 455 | ${only === null ? null : html`<option value="${only}" selected>${only}</option>`} |
| 453 | 456 | </select> |
| 454 | 457 | <noscript><input class="input" name="app" placeholder="owner/name" aria-label="An app, as owner/name" /><button class="btn" type="submit">Show</button></noscript> |
| 455 | </form>`; | |
| 458 | ${mine ? html`<input type="hidden" name="waits" value="me" />` : null} | |
| 459 | </form> | |
| 460 | <a class="small" id="hf-waits" href="/?view=lanes${mine ? "" : "&waits=me"}${only === null ? "" : `&app=${encodeURIComponent(only)}`}" ${mine ? html`aria-current="true"` : null}>${mine ? "Waiting for me · show all" : "Waiting for me"}</a>`; | |
| 456 | 461 | } |
| 457 | 462 | |
| 458 | 463 | /** |
| @@ -486,10 +491,11 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 486 | 491 | if (user === undefined) return signInFirst(ctx); |
| 487 | 492 | const { view, asked } = viewOf(ctx); |
| 488 | 493 | const only = filterOf(ctx.url); |
| 494 | const mine = waitsOf(ctx.url); | |
| 489 | 495 | const now = Date.now(); |
| 490 | 496 | const picture = await timePhaseAsync(ctx.request, "picture", () => lanePicture(ctx.app.db, optionsOf(ctx), "page", now)); |
| 491 | 497 | const rendering = performance.now(); |
| 492 | const viewing = picture === undefined ? undefined : timePhase(ctx.request, "viewing", () => viewFor(ctx.app.db, user, picture, view === "table" ? null : only)); | |
| 498 | const viewing = picture === undefined ? undefined : timePhase(ctx.request, "viewing", () => viewFor(ctx.app.db, user, picture, view === "table" ? null : only, mine ? waitingOnMe(ctx, user) : undefined)); | |
| 493 | 499 | // A spawned forge's owner is a client: the forge-wide figures are not theirs to see, whole home |
| 494 | 500 | // or lean. |
| 495 | 501 | const spawned = known !== undefined ? known.spawned : await timePhaseAsync(ctx.request, "spawned", () => spawnedForge(ctx.app)); |
| @@ -506,12 +512,9 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 506 | 512 | ${spawned === undefined ? firstWeekBlock(ctx.app.db, user) : null} |
| 507 | 513 | <div class="hf-tell">${tellBox(ctx, user)}</div>`; |
| 508 | 514 | // A client who asked for the whole home (`?all=1`) has a way back to their apps. |
| 509 | const after = html`${ctx.url.searchParams.has("all") ? html`<p class="small muted" id="lean-home"><a href="/">Just my apps</a></p>` : null}${requestsCard(ctx, "home")}${timePhase(ctx.request, "held", () => heldLine(ctx, user))} | |
| 515 | const after = html`${ctx.url.searchParams.has("all") ? html`<p class="small muted" id="lean-home"><a href="/">Just my apps</a></p>` : null}${requestsCard(ctx, "home")} | |
| 510 | 516 | ${spawned?.url === undefined ? null : html`<p class="small muted" id="forge-address">Your forge: <a href="${spawned.url}">${new URL(spawned.url).host}</a></p>`} |
| 511 | 517 | ${startedFromLine(ctx.app.db, ctx.app.config.dataDir, user)}`; |
| 512 | // A run the host stopped is named, with its way to try again, while it is within the day: the one | |
| 513 | // place the web offers that. | |
| 514 | const stopped = user.kind === "agent" ? null : timePhase(ctx.request, "stopped", () => interruptedOutLine(ctx, listReposWritableTo(ctx.app.db, user, { withoutArchived: true, limit: 200 }))); | |
| 515 | 518 | const forges = wide ? await timePhaseAsync(ctx.request, "forges", () => forgesRegion(ctx.app, false)) : null; |
| 516 | 519 | let main: Html; |
| 517 | 520 | const q = parseTable(ctx.url.searchParams); |
| @@ -520,7 +523,7 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 520 | 523 | } else if (view === "table") { |
| 521 | 524 | main = html`${tableTools(q)}${tableRegion(tableRows(viewing, tableInput(picture, now)), q, now)}`; |
| 522 | 525 | } else { |
| 523 | main = html`<div class="hf-lanes">${LANES.map((k) => laneRegion(viewing.lanes[k], healthOf(viewing.lanes[k], picture, now), only, user.isAdmin, now))}</div>`; | |
| 526 | main = html`<div class="hf-lanes">${LANES.map((k) => laneRegion(viewing.lanes[k], healthOf(viewing.lanes[k], picture, now), only, user.isAdmin, now, mine))}</div>`; | |
| 524 | 527 | } |
| 525 | 528 | const body = html`<div class="hf" id="hf" data-view="${view}"> |
| 526 | 529 | <header class="hf-head"> |
| @@ -529,14 +532,14 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 529 | 532 | <p class="hf-live muted" id="hf-live" data-state="connecting"><span class="dot"></span><span class="hf-live-text">Updates as it happens</span></p> |
| 530 | 533 | </div> |
| 531 | 534 | ${viewSwitch(view, only)} |
| 532 | ${view === "lanes" ? filterForm(viewing?.repos ?? [], only) : null} | |
| 535 | ${view === "lanes" ? filterForm(viewing?.repos ?? [], only, mine) : null} | |
| 533 | 536 | ${need} |
| 534 | 537 | </header> |
| 538 | ${mine ? askedSection(ctx, user) : null} | |
| 535 | 539 | ${main} |
| 536 | 540 | ${before} |
| 537 | 541 | ${strip} |
| 538 | 542 | ${deskStrip(ctx.app.db, readableNotes(ctx.app, ctx.auth.user))} |
| 539 | ${stopped} | |
| 540 | 543 | ${after} |
| 541 | 544 | ${wide ? figuresSection(picture, now) : null} |
| 542 | 545 | ${forges} |
| @@ -587,9 +590,9 @@ export async function liveTableFragment(ctx: Ctx): Promise<Response> { | ||
| 587 | 590 | * and this filter, and the minute (its ages are in |
| 588 | 591 | * minutes). A lane that has not changed answers 304 without being drawn. |
| 589 | 592 | */ |
| 590 | function laneTag(picture: LanePicture, key: LaneKey, viewer: string, only: string | null, now: number): string { | |
| 593 | function laneTag(picture: LanePicture, key: LaneKey, viewer: string, only: string | null, now: number, mine = ""): string { | |
| 591 | 594 | const b = picture.builders; |
| 592 | return Bun.hash(`${picture.versions[key]}|${picture.moved[key]}|${b.running}/${b.slots}|${viewer}|${only ?? ""}|${Math.floor(now / 60_000)}`).toString(36); | |
| 595 | return Bun.hash(`${picture.versions[key]}|${picture.moved[key]}|${b.running}/${b.slots}|${viewer}|${only ?? ""}|${mine}|${Math.floor(now / 60_000)}`).toString(36); | |
| 593 | 596 | } |
| 594 | 597 | |
| 595 | 598 | // GET /live/lane?s=<lane>[&app=owner/name] — one lane alone, for the region that shows it. |
| @@ -606,14 +609,16 @@ export async function liveLaneFragment(ctx: Ctx): Promise<Response> { | ||
| 606 | 609 | const picture = await timePhaseAsync(ctx.request, "picture", () => lanePicture(ctx.app.db, optionsOf(ctx), "lane", now)); |
| 607 | 610 | const rendering = performance.now(); |
| 608 | 611 | if (picture === undefined) return fragment(readingLane(key, only), { request: ctx.request }); |
| 609 | const tag = laneTag(picture, key, user.isAdmin ? "admin" : user.id, only, now); | |
| 612 | const mine = waitsOf(ctx.url); | |
| 613 | const waits = mine ? waitingOnMe(ctx, user) : undefined; | |
| 614 | const tag = laneTag(picture, key, user.isAdmin ? "admin" : user.id, only, now, waits === undefined ? "" : waitsDigest(waits)); | |
| 610 | 615 | if (ctx.request.headers.get("if-none-match") === `"${tag}"`) { |
| 611 | 616 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 612 | 617 | return new Response(null, { status: 304, headers: { etag: `"${tag}"`, "cache-control": "no-store" } }); |
| 613 | 618 | } |
| 614 | const viewing = timePhase(ctx.request, "viewing", () => viewFor(ctx.app.db, user, picture, only)); | |
| 619 | const viewing = timePhase(ctx.request, "viewing", () => viewFor(ctx.app.db, user, picture, only, waits)); | |
| 615 | 620 | const view = viewing.lanes[key]; |
| 616 | const res = fragment(laneRegion(view, healthOf(view, picture, now), only, user.isAdmin, now), { request: ctx.request, etag: tag }); | |
| 621 | const res = fragment(laneRegion(view, healthOf(view, picture, now), only, user.isAdmin, now, mine), { request: ctx.request, etag: tag }); | |
| 617 | 622 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 618 | 623 | return res; |
| 619 | 624 | } |
src/web/pages/pull.ts +5 −4
| @@ -1586,15 +1586,16 @@ export async function stuckSubmit(ctx: Ctx): Promise<Response> { | ||
| 1586 | 1586 | const form = await readForm(ctx, "rw"); |
| 1587 | 1587 | if (form instanceof Response) return form; |
| 1588 | 1588 | const choice = field(form, "choice"); |
| 1589 | // Back to where the form was: the asks page, or this repository's pulls; nothing else is | |
| 1589 | // Back to where the form was: the apps list, or this repository's pulls; nothing else is | |
| 1590 | 1590 | // honoured, and anything else goes home. |
| 1591 | 1591 | const next = field(form, "next"); |
| 1592 | const dest = next === "/asks" || next === `${repoBase(repo)}/pulls` ? next : "/"; | |
| 1592 | const dest = next === "/apps" || next === `${repoBase(repo)}/pulls` ? next : "/"; | |
| 1593 | 1593 | if (!isPileChoice(choice)) return flashTo(ctx, dest, { tone: "danger", message: "Choose re-check, hand to builders, close, or turn the app off." }); |
| 1594 | 1594 | const reason = field(form, "reason"); |
| 1595 | 1595 | const done = await takePileChoice(ctx.app, ctx.auth.user, repo.id, choice, reason === "" ? {} : { reason }); |
| 1596 | // Turned off from /asks, the page comes back with the app's row saying so and the way back on. | |
| 1597 | if (!("error" in done) && done.choice === "off" && dest === "/asks") return redirect(`/asks?off=${encodeURIComponent(repo.id)}#standing`); | |
| 1596 | // Turned off from the apps list, the page comes back with the app's row saying so and the way | |
| 1597 | // back on. | |
| 1598 | if (!("error" in done) && done.choice === "off" && dest === "/apps") return redirect(`/apps?off=${encodeURIComponent(repo.id)}#standing`); | |
| 1598 | 1599 | return flashTo( |
| 1599 | 1600 | ctx, |
| 1600 | 1601 | dest, |
src/web/standards.ts +1 −1
| @@ -378,7 +378,7 @@ export function webManifest(ctx: Ctx): Response { | ||
| 378 | 378 | // A long-press on the installed icon: what is on the owner, or a |
| 379 | 379 | // word with the forge's agents, one tap from the home screen. |
| 380 | 380 | shortcuts: [ |
| 381 | { name: "On you", short_name: "On you", url: "/asks", icons: [{ src: "/icons/forge-192.png", sizes: "192x192", type: "image/png" }] }, | |
| 381 | { name: "On you", short_name: "On you", url: "/?waits=me", icons: [{ src: "/icons/forge-192.png", sizes: "192x192", type: "image/png" }] }, | |
| 382 | 382 | { name: "Talk", short_name: "Talk", url: "/talk", icons: [{ src: "/icons/forge-192.png", sizes: "192x192", type: "image/png" }] }, |
| 383 | 383 | ], |
| 384 | 384 | // The default light theme's ground, read from the theme registry |
src/web/studio/asks_page.ts +23 −14
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | |
| 10 | 10 | import { askedAsleep, asleepLine, type Asleep } from "../../actions/needs_asleep.ts"; |
| 11 | 11 | import { UNDO_LABEL, VERB_WORDS } from "../../actions/asks_words.ts"; |
| 12 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; | |
| 12 | import { notePhase, timePhase } from "../../core/route_timing.ts"; | |
| 13 | 13 | import type { WaitingFor } from "../../core/waiting_for.ts"; |
| 14 | 14 | import { |
| 15 | 15 | applyAsksBulk, |
| @@ -49,7 +49,6 @@ import { | ||
| 49 | 49 | ownerFactRepoIds, |
| 50 | 50 | } from "../../core/repos.ts"; |
| 51 | 51 | import { html, type Html } from "../html.ts"; |
| 52 | import { standingSections } from "./standing.ts"; | |
| 53 | 52 | import { noteLine } from "./note.ts"; |
| 54 | 53 | import { page, redirect } from "../layout.ts"; |
| 55 | 54 | import { emptyList } from "../empty_words.ts"; |
| @@ -269,10 +268,13 @@ function here(ctx: Ctx): string { | ||
| 269 | 268 | return ctx.url.pathname === "/asks" && rest !== "" ? `/asks?${rest}` : "/asks"; |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | /** A `back` worth following after a mute: `/asks` or `/asks?…`, nothing else. */ | |
| 271 | /** | |
| 272 | * A `back` worth following after a mute: `/asks`, `/asks?…` or the board's `/?waits=me`, nothing | |
| 273 | * else. | |
| 274 | */ | |
| 273 | 275 | function asksBack(form: Parameters<typeof backTo>[0]): string { |
| 274 | 276 | const back = backTo(form, "/asks"); |
| 275 | return back === "/asks" || (back.startsWith("/asks?") && !back.includes("#")) ? back : "/asks"; | |
| 277 | return back === "/asks" || back === "/?waits=me" || (back.startsWith("/asks?") && !back.includes("#")) ? back : "/asks"; | |
| 276 | 278 | } |
| 277 | 279 | |
| 278 | 280 | /** The same page with one flash key set, the others cleared. */ |
| @@ -452,14 +454,11 @@ export interface AsksTop { | ||
| 452 | 454 | readonly reason?: string; |
| 453 | 455 | } |
| 454 | 456 | |
| 455 | /** GET /asks — what needs you as its own page: the home's section and its | |
| 456 | * live script; `?op=<id>` (a bulk action's receipt) rides along. */ | |
| 457 | export function asksPage(ctx: Ctx): Response { | |
| 458 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); | |
| 459 | return renderAsks(ctx, timePhase(ctx.request, "top", () => homeTop(ctx))); | |
| 460 | } | |
| 461 | ||
| 462 | /** The asks page, with a bulk step's preview or receipt on top. */ | |
| 457 | /** | |
| 458 | * A bulk step's preview or receipt, drawn where the step was answered (the POST's own response): | |
| 459 | * the asks list with the step on top. There is no GET page for it; `/asks` redirects to the | |
| 460 | * kanban's "waits for me" view. | |
| 461 | */ | |
| 463 | 462 | function renderAsks(ctx: Ctx, top: AsksTop | undefined): Response { |
| 464 | 463 | const user = ctx.auth.user; |
| 465 | 464 | if (!user) return signInFirst(ctx); |
| @@ -467,14 +466,24 @@ function renderAsks(ctx: Ctx, top: AsksTop | undefined): Response { | ||
| 467 | 466 | const rendering = performance.now(); |
| 468 | 467 | const response = page({ |
| 469 | 468 | ctx, |
| 470 | title: "Asks", | |
| 471 | body: html`<div class="stack"><h1 class="sr-only">Asks</h1>${muteFlash(ctx, user)}${onYouRegion(ctx, user, undefined, section.body)}${standingSections(ctx, user)}<p class="small muted"><a href="/review">Review: one row per ask</a></p></div>`, | |
| 469 | title: "Waiting for you", | |
| 470 | body: html`<div class="stack"><h1 class="sr-only">Waiting for you</h1>${muteFlash(ctx, user)}${onYouRegion(ctx, user, undefined, section.body)}<p class="small muted"><a href="/?waits=me">Back to the board</a></p></div>`, | |
| 472 | 471 | scriptJs: `${liveClientJs}\n${liveRegionsJs}\n${section.scriptJs}`, |
| 473 | 472 | }); |
| 474 | 473 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 475 | 474 | return response; |
| 476 | 475 | } |
| 477 | 476 | |
| 477 | /** | |
| 478 | * GET /asks — gone as a page: what waits for a person is a state of the cards on the kanban, so it | |
| 479 | * redirects there. Only an answer to a step taken (a bulk receipt, a mute, a hand-over) still lands | |
| 480 | * on what it answered. | |
| 481 | */ | |
| 482 | export function asksMoved(ctx: Ctx): Response { | |
| 483 | const answers = ["op", "decided", ...FLASH_KEYS].some((k) => ctx.url.searchParams.has(k)); | |
| 484 | return answers ? renderAsks(ctx, homeTop(ctx)) : redirect("/?waits=me"); | |
| 485 | } | |
| 486 | ||
| 478 | 487 | /** The receipt `?op=<id>` names on the home, when it is the viewer's own. */ |
| 479 | 488 | export function homeTop(ctx: Ctx): AsksTop | undefined { |
| 480 | 489 | const decided = ctx.url.searchParams.get("decided"); |
src/web/studio/review_page.ts +2 −2
| @@ -159,9 +159,9 @@ export function reviewPage(ctx: Ctx): Response { | ||
| 159 | 159 | icon: "issue", |
| 160 | 160 | title: "Nothing to review", |
| 161 | 161 | note: "When the crew needs a person, it shows up here.", |
| 162 | action: html`<a class="btn" href="/asks">All asks</a>`, | |
| 162 | action: html`<a class="btn" href="/?waits=me">All that wait for you</a>`, | |
| 163 | 163 | }) |
| 164 | : html`${listCard(rows)}<p class="small muted">Keys: j / k move, ${key("m", "Merge the focused row", "merge")}, ${key("c", "Close the focused row", "close")}, ${key("r", "Request changes on the focused row", "request changes")} · <a href="/asks">All asks, with their buttons</a></p>`}`; | |
| 164 | : html`${listCard(rows)}<p class="small muted">Keys: j / k move, ${key("m", "Merge the focused row", "merge")}, ${key("c", "Close the focused row", "close")}, ${key("r", "Request changes on the focused row", "request changes")} · <a href="/?waits=me">All that wait for you, on the board</a></p>`}`; | |
Indentation of this branch was broken by the edit. |
||
| 165 | 165 | const response = page({ ctx, title: "Review", body, scriptJs: asks.length === 0 ? "" : REVIEW_KEYS_JS }); |
| 166 | 166 | notePhase(ctx.request, "render", performance.now() - rendering); |
| 167 | 167 | return response; |
src/web/studio/standing.ts +19 −38
| @@ -1,47 +1,25 @@ | ||
| 1 | 1 | /** |
| 2 | * What `/asks` lists that the home page does not draw: the forge's own problems, the people | |
| 3 | * stopped until this viewer changes a setting, and what stands still (a repository behind its | |
| 4 | * pulls, an approved pull that has not landed). The home's one line counts the first two and links | |
| 5 | * here (`needLine` in `web/pages/home_flow.ts`); the third is never on the home. Each row leads to | |
| 6 | * the exact control, and a repository standing still offers its choices as buttons | |
| 7 | * (`POST /:owner/:name/stuck`, `crew/stuck_pile.ts`), the last of them turning the app off. | |
| 2 | * What waits for a person that is not an issue or a pull, drawn where it belongs: the people | |
| 3 | * stopped until this viewer changes a setting, on the "waiting for me" view of the kanban | |
| 4 | * (`/?waits=me`), and what stands still (a repository behind its pulls, an approved pull that has | |
| 5 | * not landed, a run the host gave up on) on the apps list, as each app's state and action. A | |
| 6 | * repository standing still offers its choices as buttons (`POST /:owner/:name/stuck`, | |
| 7 | * `crew/stuck_pile.ts`), the last of them turning the app off. | |
| 8 | 8 | */ |
| 9 | 9 | import { asksToAnswer } from "../../actions/ask_admin.ts"; |
| 10 | 10 | import { standingNeeds, STUCK_CHOICES } from "../../actions/needs.ts"; |
| 11 | import { canAdmin, getRepoById } from "../../core/repos.ts"; | |
| 11 | import { canAdmin, getRepoById, listReposWritableTo } from "../../core/repos.ts"; | |
| 12 | 12 | import type { User } from "../../core/users.ts"; |
| 13 | 13 | import { OFF_SAYS, PILE_CHOICES } from "../../crew/stuck_pile.ts"; |
| 14 | import { FORGE_BROKEN } from "../../flow/alarms.ts"; | |
| 15 | import { forgeCeiling } from "../../flow/ceiling.ts"; | |
| 16 | 14 | import type { Ctx } from "../../http/context.ts"; |
| 17 | import { running } from "../../kernel/version.ts"; | |
| 18 | import { proofNotice } from "../../release/prove.ts"; | |
| 19 | 15 | import { html, type Html } from "../html.ts"; |
| 20 | 16 | import { btn } from "../ui.ts"; |
| 21 | import { cachedAlarms } from "./alarm_lines.ts"; | |
| 22 | 17 | import { adminAskNeed } from "./ask_admin.ts"; |
| 23 | ||
| 24 | /** | |
| 25 | * What is broken about the forge itself, for an admin: the proof's alarm and the fired alarms of | |
| 26 | * `FORGE_BROKEN`, each linked to where it is acted on. The list the home's count links to. | |
| 27 | */ | |
| 28 | function brokenSection(ctx: Ctx, user: User, now: number): Html | null { | |
| 29 | if (!user.isAdmin) return null; | |
| 30 | const proof = proofNotice(ctx.app.config.dataDir, running().version, now); | |
| 31 | const rows = [ | |
| 32 | ...(proof?.tone === "alarm" ? [{ says: proof.sentence, href: "/releases#proof" }] : []), | |
| 33 | ...cachedAlarms(ctx.app.db, new Date(now), forgeCeiling(ctx.app.config), ctx.app.config.dataDir).filter((a) => FORGE_BROKEN.has(a.key)), | |
| 34 | ]; | |
| 35 | if (rows.length === 0) return null; | |
| 36 | return html`<section class="stack" id="forge-broken"> | |
| 37 | <h2>Problems with the forge</h2> | |
| 38 | <ul class="list setting-list">${rows.map((r) => html`<li><a href="${r.href}">${r.says}</a></li>`)}</ul> | |
| 39 | </section>`; | |
| 40 | } | |
| 18 | import { interruptedOutLine } from "./interrupted_out.ts"; | |
| 41 | 19 | |
| 42 | 20 | /** The people stopped until this viewer changes a setting, each with its control and "Not now". */ |
| 43 | function askedSection(ctx: Ctx, user: User): Html | null { | |
| 44 | const asked = asksToAnswer(ctx.app, user).map((a, n) => adminAskNeed(a, n, "/asks")); | |
| 21 | export function askedSection(ctx: Ctx, user: User): Html | null { | |
| 22 | const asked = asksToAnswer(ctx.app, user).map((a, n) => adminAskNeed(a, n, "/?waits=me")); | |
| 45 | 23 | if (asked.length === 0) return null; |
| 46 | 24 | return html`<section class="stack" id="asked"> |
| 47 | 25 | <h2>Stopped until you answer</h2> |
| @@ -50,7 +28,7 @@ function askedSection(ctx: Ctx, user: User): Html | null { | ||
| 50 | 28 | } |
| 51 | 29 | |
| 52 | 30 | /** |
| 53 | * The row an app turned off a moment ago leaves where its row was (`?off=<repo id>`, set by | |
| 31 | * The row an app turned off a moment ago leaves where its row was (`/apps?off=<repo id>`, set by | |
| 54 | 32 | * `stuckSubmit`): that it is off, and one button that turns it back on through the repository's |
| 55 | 33 | * own restore (`POST /:owner/:name/settings/archive`). Nothing for a repository that is not off or |
| 56 | 34 | * that this viewer does not administer. |
| @@ -60,7 +38,7 @@ function offRow(ctx: Ctx, user: User): Html | null { | ||
| 60 | 38 | if (repo === undefined || repo.archivedAt === null || !canAdmin(ctx.app.db, repo, user)) return null; |
| 61 | 39 | const ref = `${repo.ownerName}/${repo.name}`; |
| 62 | 40 | return html`<form class="bar" method="post" action="/${ref}/settings/archive" data-standing-off="${repo.id}" role="status"> |
| 63 | <input type="hidden" name="archived" value="0" /><input type="hidden" name="to" value="/asks" /> | |
| 41 | <input type="hidden" name="archived" value="0" /><input type="hidden" name="to" value="/apps" /> | |
| 64 | 42 | <span>${ref} is off.</span> |
| 65 | 43 | ${btn("Turn it back on", { size: "sm" })} |
| 66 | 44 | </form>`; |
| @@ -83,7 +61,7 @@ function stillSection(ctx: Ctx, user: User): Html | null { | ||
| 83 | 61 | return html`<div class="stack" data-standing="${n.id}"> |
| 84 | 62 | <p>${n.sentence} <a href="${n.link}">See them</a></p> |
| 85 | 63 | <form class="bar" method="post" action="${base}/stuck"> |
| 86 | <input type="hidden" name="next" value="/asks" /> | |
| 64 | <input type="hidden" name="next" value="/apps" /> | |
| 87 | 65 | ${PILE_CHOICES.map((choice, i) => (choice === "off" && (repo === undefined || !canAdmin(ctx.app.db, repo, user)) ? null : btn(STUCK_CHOICES[i]!, { size: "sm", name: "choice", value: choice })))} |
| 88 | 66 | </form> |
| 89 | 67 | </div>`; |
| @@ -94,7 +72,10 @@ function stillSection(ctx: Ctx, user: User): Html | null { | ||
| 94 | 72 | </section>`; |
| 95 | 73 | } |
| 96 | 74 | |
| 97 | /** The three sections, in the order the home's line counts them; nothing when all are empty. */ | |
| 98 | export function standingSections(ctx: Ctx, user: User, now = Date.now()): Html { | |
| 99 | return html`${brokenSection(ctx, user, now)}${askedSection(ctx, user)}${stillSection(ctx, user)}`; | |
| 75 | /** | |
| 76 | * What stands still on the apps list, with the runs the host gave up on; nothing when neither is. | |
| 77 | */ | |
| 78 | export function appsStanding(ctx: Ctx, user: User): Html { | |
| 79 | const stopped = user.kind === "agent" ? null : interruptedOutLine(ctx, listReposWritableTo(ctx.app.db, user, { withoutArchived: true, limit: 200 })); | |
| 80 | return html`${stillSection(ctx, user)}${stopped}`; | |
| 100 | 81 | } |
src/web/studio/waiting_on_me.ts added +68
| @@ -0,0 +1,68 @@ | ||
| 1 | /** | |
| 2 | * What waits for a person, as the set of issues and pulls it is a state of: the | |
| 3 | * kanban's "waits for me" filter reads it (`/?waits=me`), and the terminal's | |
| 4 | * "Waiting for me" screen lists the same rows. One read of the same decisions the | |
| 5 | * pull page's status line is drawn from; nothing else is computed. | |
| 6 | * | |
| 7 | * The read walks the viewer's visible repositories (200 at most), so it is held | |
| 8 | * for `HOLD_MS` per viewer: the board's live lanes ask on every poll and share one read. | |
| 9 | */ | |
| 10 | ||
| 11 | import type { Database } from "bun:sqlite"; | |
| 12 | import { listReposVisibleTo } from "../../core/repos.ts"; | |
| 13 | import type { User } from "../../core/users.ts"; | |
| 14 | import { decisionsFor } from "./decisions.ts"; | |
| 15 | import type { Reader } from "../pages/looks.ts"; | |
| 16 | ||
outdated
decisionsFor over 200 repos per live lane request; measure against the 50 ms budget or cache per viewer. |
||
| 17 | /** One card that waits: where it is, what it is, and what it waits for. */ | |
| 18 | export interface WaitingRow { | |
| 19 | readonly key: string; | |
| 20 | readonly repo: string; | |
| 21 | readonly number: number; | |
| 22 | readonly kind: "pull" | "issue"; | |
| 23 | readonly title: string; | |
| 24 | readonly short: string; | |
| 25 | } | |
| 26 | ||
| 27 | /** How long one viewer's read is reused. */ | |
| 28 | const HOLD_MS = 10_000; | |
| 29 | const held = new WeakMap<Database, Map<string, { at: number; rows: WaitingRow[] }>>(); | |
| 30 | ||
| 31 | /** The key a card is known by in the set: its repository and number. */ | |
| 32 | export const waitKey = (repoId: string, number: number): string => `${repoId}#${String(number)}`; | |
| 33 | ||
| 34 | /** The cards that wait for `user`, in the order the decisions rank them. */ | |
| 35 | export function waitingRows(ctx: Reader, user: User, now = Date.now()): WaitingRow[] { | |
| 36 | const db = ctx.app.db; | |
| 37 | const mine = held.get(db) ?? new Map<string, { at: number; rows: WaitingRow[] }>(); | |
| 38 | held.set(db, mine); | |
| 39 | const kept = mine.get(user.id); | |
| 40 | if (kept !== undefined && now - kept.at < HOLD_MS) return kept.rows; | |
| 41 | const repos = listReposVisibleTo(db, user, { limit: 200, withoutArchived: true }); | |
| 42 | const rows: WaitingRow[] = []; | |
| 43 | for (const d of decisionsFor(ctx, repos, { noPictures: true })) { | |
| 44 | const thing = d.pull ?? d.issue; | |
| 45 | if (thing === undefined) continue; | |
| 46 | rows.push({ | |
| 47 | key: waitKey(d.repo.id, thing.number), | |
| 48 | repo: `${d.repo.ownerName}/${d.repo.name}`, | |
| 49 | number: thing.number, | |
| 50 | kind: d.pull === undefined ? "issue" : "pull", | |
| 51 | title: thing.title, | |
| 52 | short: d.short, | |
| 53 | }); | |
| 54 | } | |
| 55 | if (mine.size > 500) mine.clear(); | |
| 56 | mine.set(user.id, { at: now, rows }); | |
| 57 | return rows; | |
| 58 | } | |
| 59 | ||
| 60 | /** The issues and pulls (by `waitKey`) that wait for `user`. */ | |
| 61 | export function waitingOnMe(ctx: Reader, user: User): Set<string> { | |
| 62 | return new Set(waitingRows(ctx, user).map((r) => r.key)); | |
| 63 | } | |
| 64 | ||
| 65 | /** A short digest of a set, for an ETag: a lane that shows it changes when it does. */ | |
| 66 | export function waitsDigest(set: ReadonlySet<string>): string { | |
| 67 | return Bun.hash([...set].sort().join("|")).toString(36); | |
| 68 | } |
test/a11y-landmarks.test.ts +1 −1
| @@ -53,7 +53,7 @@ afterAll(async () => { | ||
| 53 | 53 | // Signed out: the public shell, the not-found shell (failed_page) and the sign-in forms. |
| 54 | 54 | const SIGNED_OUT = ["/", "/signin", "/signup", "/explore", "/search", "/no-such-page-here"]; |
| 55 | 55 | // Signed in (as the admin): the authenticated shell and its topbar tools. |
| 56 | const SIGNED_IN = ["/", "/feed", "/asks", "/notes", "/talk", "/map", "/settings", "/system", "/family"]; | |
| 56 | const SIGNED_IN = ["/", "/feed", "/notes", "/talk", "/map", "/settings", "/system", "/family"]; | |
| 57 | 57 | |
| 58 | 58 | async function layout(path: string, signedIn: boolean): Promise<string> { |
| 59 | 59 | const res = await fetch(`${servers.url}${path}`, { |
test/approval-moved-inbox.test.ts +1 −1
| @@ -74,7 +74,7 @@ describe("the inbox row of an approved pull", () => { | ||
| 74 | 74 | }; |
| 75 | 75 | const row = () => askLinesFor(app.db, alice).find((r) => r.items.includes(`look:${pull.id}`)); |
| 76 | 76 | /** The asks page: the inbox, where each ask is drawn with its short line. */ |
| 77 | const asks = async () => (await http.handle(new Request("http://forge.test/asks", { headers: { cookie } }))).text(); | |
| 77 | const asks = async () => (await http.handle(new Request("http://forge.test/live/on-you", { headers: { cookie } }))).text(); | |
| 78 | 78 | |
| 79 | 79 | beforeAll(async () => { |
| 80 | 80 | dataDir = await mkdtemp(join(tmpdir(), "forge-approval-moved-")); |
test/ask-admin.test.ts +3 −3
| @@ -183,13 +183,13 @@ test("the page: a guest presses the button, the admin's home counts it, /asks sa | ||
| 183 | 183 | expect(stateOf()).toBe("asked"); |
| 184 | 184 | // The home counts it in its one line and links to the list; the list says it, with the control. |
| 185 | 185 | const home = await get(world, world.viewers.admin, "/"); |
| 186 | expect(home.body).toMatch(/<a href="\/asks#asked">(?:1 person is|\d+ people are) stopped until you answer<\/a>/); | |
| 186 | expect(home.body).toMatch(/<a href="\/\?waits=me">(?:1 person is|\d+ people are) stopped until you answer<\/a>/); | |
| 187 | 187 | expect(home.body.includes("carol asks for a model key")).toBe(false); |
| 188 | const asks = await get(world, world.viewers.admin, "/asks"); | |
| 188 | const asks = await get(world, world.viewers.admin, "/?waits=me"); | |
| 189 | 189 | const asked = asks.body.slice(asks.body.indexOf('id="asked"')); |
| 190 | 190 | expect(asked.includes("carol asks for a model key: the crew cannot start without one")).toBe(true); |
| 191 | 191 | expect(asked.includes('href="/settings/crew#crew-key"')).toBe(true); |
| 192 | expect(asked.includes('name="back" value="/asks"')).toBe(true); | |
| 192 | expect(asked.includes('name="back" value="/?waits=me"')).toBe(true); | |
| 193 | 193 | // A member cannot answer what is the admins'. |
| 194 | 194 | await get(world, world.viewers.member, "/asks/admin/later", form({ username: "carol", want: "crew_key", subject: "", back: "/" })); |
| 195 | 195 | expect(stateOf()).toBe("asked"); |
test/ask-filters.test.ts +1 −1
| @@ -129,7 +129,7 @@ describe("ask filters", () => { | ||
| 129 | 129 | |
| 130 | 130 | test("the page: one tap hides, says how many are hidden, and one tap clears", async () => { |
| 131 | 131 | clearAskFilters(app.db, alice.id); |
| 132 | const page = () => fetch(`${servers.url}/asks`, { headers: { cookie: `${cookie}; forge_mode=studio` } }).then((r) => r.text()); | |
| 132 | const page = () => fetch(`${servers.url}/live/on-you`, { headers: { cookie: `${cookie}; forge_mode=studio` } }).then((r) => r.text()); | |
| 133 | 133 | const first = await page(); |
| 134 | 134 | // Offered once for the list, not under every row: a clear form is absent, the two picks are not. |
| 135 | 135 | expect(first.split('action="/asks/filter"').length - 1).toBe(2); |
test/asks-bulk.test.ts +1 −1
| @@ -353,7 +353,7 @@ describe("acting on many asks at once", () => { | ||
| 353 | 353 | test("the page: select, preview, do it, undo", async () => { |
| 354 | 354 | await greenPull(open, "Page one"); |
| 355 | 355 | await greenPull(open, "Page two"); |
| 356 | const asks = await fetch(`${servers.url}/asks`, { | |
| 356 | const asks = await fetch(`${servers.url}/live/on-you`, { | |
| 357 | 357 | headers: { cookie: `${aliceCookie}; forge_mode=studio` }, |
| 358 | 358 | }).then((r) => r.text()); |
| 359 | 359 | expect(asks).toContain('id="asks-bulk"'); |
test/asks-counts.test.ts +1 −1
| @@ -216,7 +216,7 @@ describe("home's asks are read grouped, and once", () => { | ||
| 216 | 216 | }; |
| 217 | 217 | |
| 218 | 218 | const home = async () => { |
| 219 | const response = await fetch(`${servers.url}/asks`, { headers: { cookie } }); | |
| 219 | const response = await fetch(`${servers.url}/live/on-you`, { headers: { cookie } }); | |
| 220 | 220 | expect(response.status).toBe(200); |
| 221 | 221 | return response.text(); |
| 222 | 222 | }; |
test/asks-expiry.test.ts +7 −7
| @@ -126,7 +126,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 126 | 126 | pears = await botPull("pears", [{ path: "PEARS.md", content: "pears\n" }]); |
| 127 | 127 | green(apples); |
| 128 | 128 | green(pears); |
| 129 | const page = await get("/asks"); | |
| 129 | const page = await get("/live/on-you"); | |
| 130 | 130 | expect(sentence(page)).toBe("1 thing needs you"); |
| 131 | 131 | expect(headerCount(page)).toBe(1); |
| 132 | 132 | expect(page).toContain("2 green changes wait for your look"); |
| @@ -152,7 +152,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 152 | 152 | // card at all, so there is nothing to mute. |
| 153 | 153 | const fragment = await get("/live/feed"); |
| 154 | 154 | expect(fragment).not.toContain('data-kind="ask"'); |
| 155 | const home = await get("/asks"); | |
| 155 | const home = await get("/live/on-you"); | |
| 156 | 156 | expect(home).toContain('<section id="needs-you"'); |
| 157 | 157 | const at = home.indexOf('<section id="needs-you"'); |
| 158 | 158 | expect(home.slice(at, home.indexOf("</section>", at))).not.toContain( |
| @@ -169,7 +169,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 169 | 169 | repoId: repo.id, |
| 170 | 170 | actorId: null, |
| 171 | 171 | }); |
| 172 | let page = await get("/asks"); | |
| 172 | let page = await get("/live/on-you"); | |
| 173 | 173 | expect(sentence(page)).toBe("All fine"); |
| 174 | 174 | expect(headerCount(page)).toBe(0); |
| 175 | 175 | expect(askLinesFor(app.db, aliceUser)).toHaveLength(0); |
| @@ -179,7 +179,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 179 | 179 | // A new check on one of them: that one asks again, on its own. |
| 180 | 180 | await tick(); |
| 181 | 181 | green(apples); |
| 182 | page = await get("/asks"); | |
| 182 | page = await get("/live/on-you"); | |
| 183 | 183 | expect(sentence(page)).toBe("1 thing needs you"); |
| 184 | 184 | const pinned = page.slice( |
| 185 | 185 | page.indexOf('<section id="needs-you"'), |
| @@ -203,7 +203,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 203 | 203 | repoId: repo.id, |
| 204 | 204 | actorId: null, |
| 205 | 205 | }); |
| 206 | expect(sentence(await get("/asks"))).toBe("All fine"); | |
| 206 | expect(sentence(await get("/live/on-you"))).toBe("All fine"); | |
| 207 | 207 | // The merge box is the change's Files step (#628). |
| 208 | 208 | const change = await get( |
| 209 | 209 | `/${repo.ownerName}/${repo.name}/pulls/${apples.number}/files`, |
| @@ -231,7 +231,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 231 | 231 | }); |
| 232 | 232 | await sweepStaleAsks(app); |
| 233 | 233 | expect(askLinesFor(app.db, aliceUser)).toHaveLength(0); |
| 234 | expect(sentence(await get("/asks"))).toBe("All fine"); | |
| 234 | expect(sentence(await get("/live/on-you"))).toBe("All fine"); | |
| 235 | 235 | // The feed and the MCP's asks carry no green line for it either. |
| 236 | 236 | expect( |
| 237 | 237 | readFeed(app.db, aliceUser, { limit: 50 }).items.some( |
| @@ -241,7 +241,7 @@ describe("asks that expire, hold and collapse", () => { | ||
| 241 | 241 | expect(JSON.stringify(asksAnswer({ app, auth: { user: aliceUser } } as never, aliceUser))).not.toContain("is green"); |
| 242 | 242 | // Assigned to alice, the home's one list says it conflicts, never ready. |
| 243 | 243 | setAssignee(app.db, plums.id, aliceUser.id); |
| 244 | const home = await get("/asks"); | |
| 244 | const home = await get("/live/on-you"); | |
| 245 | 245 | expect(home).toContain("conflicts with main"); |
| 246 | 246 | expect(askLinesFor(app.db, aliceUser).map((l) => l.waitingFor.word)).toEqual(["conflicts with main"]); |
| 247 | 247 | // Its own page still says why it cannot ship. |
test/asks-mute.test.ts +1 −1
| @@ -64,7 +64,7 @@ describe("muting a repository's asks", () => { | ||
| 64 | 64 | return ((await res.json()) as { rows: unknown[] }).rows; |
| 65 | 65 | }; |
| 66 | 66 | const home = async () => |
| 67 | await fetch(`${servers.url}/asks`, { headers: headers(cookie) }).then((r) => r.text()); | |
| 67 | await fetch(`${servers.url}/live/on-you`, { headers: headers(cookie) }).then((r) => r.text()); | |
| 68 | 68 | |
| 69 | 69 | const signIn = async (username: string) => { |
| 70 | 70 | const res = await fetch(`${servers.url}/signin`, { |
test/asks-rank.test.ts +7 −7
| @@ -204,7 +204,7 @@ describe("asks that earn their place", () => { | ||
| 204 | 204 | expect(row.words).toEqual(ASK_WORDS.look); |
| 205 | 205 | expect(row.words.options.length).toBeGreaterThan(0); |
| 206 | 206 | } |
| 207 | const asks = await page("/asks"); | |
| 207 | const asks = await page("/live/on-you"); | |
| 208 | 208 | expect(asks).toContain("If nobody acts, it waits; nothing ships."); |
| 209 | 209 | expect(asks).toContain("<b>security</b>"); |
| 210 | 210 | // The long sentence the card used to repeat is gone. |
| @@ -236,7 +236,7 @@ describe("asks that earn their place", () => { | ||
| 236 | 236 | for (const name of ["r4", "r5", "r6"]) |
| 237 | 237 | await greenPull(name, `Work in ${name}`); |
| 238 | 238 | // What needs you is pinned on the home (#634): count its own cards. |
| 239 | const home = await page("/asks"); | |
| 239 | const home = await page("/live/on-you"); | |
| 240 | 240 | const asks = home.slice(home.indexOf('<section id="needs-you"')); |
| 241 | 241 | const cards = (s: string) => (s.match(/class="card[" ]/g) ?? []).length; |
| 242 | 242 | // Two before the phone's "more", three more inside it before the wide |
| @@ -250,7 +250,7 @@ describe("asks that earn their place", () => { | ||
| 250 | 250 | // "more" sits inside it, and the stylesheet hides each where it is not. |
| 251 | 251 | // (An ask's own "More" closes a details too: look past those, to the last.) |
| 252 | 252 | expect(wide!.indexOf('id="asks-more"')).toBeLessThan(wide!.lastIndexOf("</details>")); |
| 253 | const css = await (await fetch(`${servers.url}${home.match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); | |
| 253 | const css = await (await fetch(`${servers.url}${(await page("/")).match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); | |
| 254 | 254 | // Only where the browser can hold a details element open: an older one |
| 255 | 255 | // keeps both summaries, so no ask is out of reach. |
| 256 | 256 | const held = css.slice(css.indexOf("@supports selector(::details-content) {")); |
| @@ -329,7 +329,7 @@ describe("asks that earn their place", () => { | ||
| 329 | 329 | const board = await page("/board"); |
| 330 | 330 | // The whole strip, so a drift in its markup fails here: the link, the window, the bold figures and their separators. |
| 331 | 331 | expect(board).toMatch( |
| 332 | /<a class="muted small" id="asks-measure" href="\/asks"\s*>Asks, 7 days: <b>6<\/b> raised · <b>1<\/b> acted on · <b>1<\/b> dismissed · <b>1<\/b> went by themselves<\/a\s*>/, | |
| 332 | /<a class="muted small" id="asks-measure" href="\/\?waits=me"\s*>Asks, 7 days: <b>6<\/b> raised · <b>1<\/b> acted on · <b>1<\/b> dismissed · <b>1<\/b> went by themselves<\/a\s*>/, | |
| 333 | 333 | ); |
| 334 | 334 | const fromMcp = await mcpAsks(); |
| 335 | 335 | expect(fromMcp.measure.raised).toBe(6); |
| @@ -340,13 +340,13 @@ describe("asks that earn their place", () => { | ||
| 340 | 340 | expect((await mcpAsks()).measure.raised).toBe(6); |
| 341 | 341 | }); |
| 342 | 342 | test("an ask is §5's card with §5's buttons and no ask-* class", async () => { |
| 343 | const home = await page("/asks"); | |
| 343 | const home = await page("/live/on-you"); | |
| 344 | 344 | const asks = home.slice(home.indexOf('<section id="needs-you"')); |
| 345 | 345 | expect(asks).toMatch(/<div\s+class="card"\s+id="look-/); |
| 346 | 346 | expect(asks).toContain("<b>Ready to ship</b> · "); |
| 347 | 347 | expect(asks).toMatch(/class="bar mt">\s*<button[^>]*data-variant="primary"/); |
| 348 | 348 | expect(asks).not.toMatch(/class="[^"]*\bask-(card|acts|kind|pick|group|more-acts|waiting|meta|short)\b/); |
| 349 | const css = await (await fetch(`${servers.url}${home.match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); | |
| 349 | const css = await (await fetch(`${servers.url}${(await page("/")).match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); | |
| 350 | 350 | expect(css).not.toMatch(/\.ask-/); |
| 351 | 351 | // The markup lost the .needs-you class (#4189): no selector may still need it. |
| 352 | 352 | expect(css).not.toMatch(/\.needs-you\b/); |
| @@ -356,7 +356,7 @@ describe("asks that earn their place", () => { | ||
| 356 | 356 | // The security pull went red above; a new green one joins it in a row of two. |
| 357 | 357 | check(security, "ok"); |
| 358 | 358 | await greenPull("security", "Another change here"); |
| 359 | const asks = await page("/asks"); | |
| 359 | const asks = await page("/live/on-you"); | |
| 360 | 360 | expect(asks).toContain("2 green changes wait for your look"); |
| 361 | 361 | expect(asks).toContain("<b>security</b>: \u201cWiden the board id\u201d"); |
| 362 | 362 | const group = asks.slice(asks.indexOf("2 green changes wait for your look")); |
test/asks-timing.test.ts +7 −13
| @@ -1,4 +1,4 @@ | ||
| 1 | /** `/asks` names session, top, asks and render in Server-Timing (#3764). */ | |
| 1 | /** `/asks` redirects to the board's "waits for me" view; the old page's phases went with it. */ | |
| 2 | 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 3 | import { mkdtempSync, rmSync } from "node:fs"; |
| 4 | 4 | import { tmpdir } from "node:os"; |
| @@ -71,10 +71,7 @@ afterAll(() => { | ||
| 71 | 71 | rmSync(root, { recursive: true, force: true }); |
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | const names = (res: Response): string[] => | |
| 75 | (res.headers.get("server-timing") ?? "").split(", ").map((p) => p.split(";")[0]!); | |
| 76 | ||
| 77 | test("GET /asks names its phases for someone with an ask", async () => { | |
| 74 | test("/asks is gone as a page: it redirects to the board's waits-for-me view", async () => { | |
| 78 | 75 | const signin = await fetch(`${servers.url}/signin`, { |
| 79 | 76 | method: "POST", |
| 80 | 77 | headers: { origin: servers.url }, |
| @@ -82,16 +79,13 @@ test("GET /asks names its phases for someone with an ask", async () => { | ||
| 82 | 79 | redirect: "manual", |
| 83 | 80 | }); |
| 84 | 81 | const cookie = (signin.headers.get("set-cookie") ?? "").split(";")[0]!; |
| 85 | const res = await fetch(`${servers.url}/asks`, { headers: { cookie } }); | |
| 86 | const body = await res.text(); | |
| 87 | expect(res.status).toBe(200); | |
| 88 | expect(body).toContain("Work"); | |
| 89 | expect(names(res)).toEqual(expect.arrayContaining(["app", "session", "top", "asks", "render"])); | |
| 82 | const res = await fetch(`${servers.url}/asks`, { headers: { cookie }, redirect: "manual" }); | |
| 83 | expect(res.status).toBe(303); | |
| 84 | expect(res.headers.get("location")).toBe("/?waits=me"); | |
| 90 | 85 | }); |
| 91 | 86 | |
| 92 | test("signed out, /asks still redirects and names session", async () => { | |
| 87 | test("signed out, /asks redirects the same way", async () => { | |
| 93 | 88 | const res = await fetch(`${servers.url}/asks`, { redirect: "manual" }); |
| 94 | 89 | expect(res.status).toBe(303); |
| 95 | expect(res.headers.get("location")).toContain("/signin"); | |
| 96 | expect(names(res)).toContain("session"); | |
| 90 | expect(res.headers.get("location")).toBe("/?waits=me"); | |
| 97 | 91 | }); |
test/asks-waiting-for.test.ts +1 −1
| @@ -150,7 +150,7 @@ describe("the word on a row", () => { | ||
| 150 | 150 | expect(text).toContain("ready to land"); |
| 151 | 151 | expect(text).toContain("waitingFor"); |
| 152 | 152 | |
| 153 | const page = await (await fetch(`${servers.url}/asks`, { headers: { cookie } })).text(); | |
| 153 | const page = await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie } })).text(); | |
| 154 | 154 | expect(page).toContain('data-waiting="ready to land"'); |
| 155 | 155 | expect(page).toContain('<span class="sr-only">waiting for </span>ready to land'); |
| 156 | 156 | expect(page).toContain("ready to land · on you"); |
test/asks-waiting.test.ts +1 −1
| @@ -167,7 +167,7 @@ describe("asks that wait on a person", () => { | ||
| 167 | 167 | }); |
| 168 | 168 | const cookie = (signed.headers.get("set-cookie") ?? "").split(";")[0]!; |
| 169 | 169 | const page = await ( |
| 170 | await fetch(`${servers.url}/asks`, { headers: { cookie: `${cookie}; forge_mode=studio` } }) | |
| 170 | await fetch(`${servers.url}/live/on-you`, { headers: { cookie: `${cookie}; forge_mode=studio` } }) | |
| 171 | 171 | ).text(); |
| 172 | 172 | expect(page).toContain("Waiting"); |
| 173 | 173 | expect(page).toContain("Advised idle"); |
test/asks.test.ts +15 −17
| @@ -102,21 +102,19 @@ describe("the asks page", () => { | ||
| 102 | 102 | }); |
| 103 | 103 | |
| 104 | 104 | test("when nothing asks, it says All fine, and so does the header", async () => { |
| 105 | const page = await get(alice, "/asks"); | |
| 105 | const page = await get(alice, "/live/on-you"); | |
| 106 | 106 | expect(sentence(page)).toBe("All fine"); |
| 107 | 107 | expect(headerCount(page)).toBe(0); |
| 108 | expect(await get(alice, "/asks")).not.toContain('<section id="needs-you"'); | |
| 108 | expect(await get(alice, "/live/on-you")).not.toContain('<section id="needs-you"'); | |
| 109 | 109 | }); |
| 110 | 110 | |
| 111 | test("/asks is its own page: the needs-you section in its live region, and a signed-out reader is sent to sign in, no asks", async () => { | |
| 111 | test("/asks redirects to the board's waits-for-me view; the needs-you section lives in its live region", async () => { | |
| 112 | 112 | const response = await fetch(`${servers.url}/asks`, { redirect: "manual" }); |
| 113 | 113 | expect(response.status).toBe(303); |
| 114 | expect(response.headers.get("location")).toContain("/signin"); | |
| 115 | const page = await get(alice, "/asks"); | |
| 114 | expect(response.headers.get("location")).toBe("/?waits=me"); | |
| 115 | const page = await get(alice, "/live/on-you"); | |
| 116 | 116 | expect(page).toContain('id="live-on-you"'); |
| 117 | 117 | expect(page).toContain('data-live-src="/live/on-you"'); |
| 118 | expect(page).toContain("<title>"); | |
| 119 | expect(page).toContain('<h1 class="sr-only">Asks</h1>'); | |
| 120 | 118 | expect(page).toContain('id="asks-sentence"'); |
| 121 | 119 | const door = await (await fetch(`${servers.url}/`)).text(); |
| 122 | 120 | expect(door).not.toContain('id="needs-you"'); |
| @@ -150,7 +148,7 @@ describe("the asks page", () => { | ||
| 150 | 148 | claimRun(app.db, run.id); |
| 151 | 149 | finishRun(app.db, run.id, { state: "failed", summary: "red" }); |
| 152 | 150 | // Failed but the crew is still trying: that is working, not an ask. |
| 153 | expect(sentence(await get(alice, "/asks"))).toBe("All fine"); | |
| 151 | expect(sentence(await get(alice, "/live/on-you"))).toBe("All fine"); | |
| 154 | 152 | recordDecision(app.db, { |
| 155 | 153 | kind: "retry", |
| 156 | 154 | repoId: repo.id, |
| @@ -161,7 +159,7 @@ describe("the asks page", () => { | ||
| 161 | 159 | by: "rule", |
| 162 | 160 | ms: 1, |
| 163 | 161 | }); |
| 164 | const page = await get(alice, "/asks"); | |
| 162 | const page = await get(alice, "/live/on-you"); | |
| 165 | 163 | expect(sentence(page)).toBe("1 thing needs you"); |
| 166 | 164 | expect(page).toContain("Bot did a thing"); |
| 167 | 165 | expect(headerCount(page)).toBe(1); |
| @@ -174,10 +172,10 @@ describe("the asks page", () => { | ||
| 174 | 172 | expect(page).toMatch(/<form [^>]*method="post"/); |
| 175 | 173 | // The home counts it in the header's Asks link; the dev dashboard's |
| 176 | 174 | // own "needs you" line went with the dashboard (#625). |
| 177 | const home = await get(alice, "/asks"); | |
| 175 | const home = await get(alice, "/live/on-you"); | |
| 178 | 176 | expect(headerCount(home)).toBe(1); |
| 179 | 177 | // Bob can read the public repository but cannot write it: not his ask. |
| 180 | expect(sentence(await get(bob, "/asks"))).toBe("All fine"); | |
| 178 | expect(sentence(await get(bob, "/live/on-you"))).toBe("All fine"); | |
| 181 | 179 | }); |
| 182 | 180 | |
| 183 | 181 | test("a forge health problem is a card for an admin and for no one else", async () => { |
| @@ -185,11 +183,11 @@ describe("the asks page", () => { | ||
| 185 | 183 | app.db |
| 186 | 184 | .query("UPDATE run SET created_at = ?1 WHERE state = 'queued'") |
| 187 | 185 | .run(new Date(Date.now() - 3 * 3_600_000).toISOString()); |
| 188 | const admin = await get(alice, "/asks"); | |
| 186 | const admin = await get(alice, "/live/on-you"); | |
| 189 | 187 | expect(admin).toContain("behind one lane"); |
| 190 | 188 | expect(sentence(admin)).toBe("2 things need you"); |
| 191 | 189 | expect(headerCount(admin)).toBe(2); |
| 192 | const other = await get(bob, "/asks"); | |
| 190 | const other = await get(bob, "/live/on-you"); | |
| 193 | 191 | expect(other).not.toContain("behind one lane"); |
| 194 | 192 | expect(sentence(other)).toBe("All fine"); |
| 195 | 193 | }); |
| @@ -235,17 +233,17 @@ describe("the asks page", () => { | ||
| 235 | 233 | ms: 1, |
| 236 | 234 | }); |
| 237 | 235 | const card = `id="ask-stopped:${pull.id}"`; |
| 238 | expect(await get(alice, "/asks")).toContain(card); | |
| 236 | expect(await get(alice, "/live/on-you")).toContain(card); | |
| 239 | 237 | // The re-run passes: the stop is answered, and the pull is green. |
| 240 | 238 | check("ok"); |
| 241 | 239 | resolveOpen(app.db, pull.id, "retry", "green"); |
| 242 | const green = await get(alice, "/asks"); | |
| 240 | const green = await get(alice, "/live/on-you"); | |
| 243 | 241 | expect(green).not.toContain(card); |
| 244 | 242 | expect(green).toContain(`id="ask-look:${pull.id}"`); |
| 245 | 243 | // Red again, before anything new is decided: the old stop is spent, and |
| 246 | 244 | // the crew's tries are what the card is counted from. |
| 247 | 245 | check("failed"); |
| 248 | expect(await get(alice, "/asks")).not.toContain(card); | |
| 246 | expect(await get(alice, "/live/on-you")).not.toContain(card); | |
| 249 | 247 | }); |
| 250 | 248 | |
| 251 | 249 | test("a green change's card says what its tests did", async () => { |
| @@ -299,7 +297,7 @@ describe("the asks page", () => { | ||
| 299 | 297 | .run(made.value.id); |
| 300 | 298 | const ids = decisionsFor({ app, auth: { user: alice0 } } as unknown as Ctx, [repo]).map((d) => d.id); |
| 301 | 299 | expect(ids.some((id) => id.startsWith("setting:"))).toBe(false); |
| 302 | expect(await get(alice, "/asks")).not.toContain("Put back"); | |
| 300 | expect(await get(alice, "/live/on-you")).not.toContain("Put back"); | |
| 303 | 301 | const res = await fetch(`${servers.url}/asks/setting`, { |
| 304 | 302 | method: "POST", |
| 305 | 303 | headers: { cookie: alice, origin: servers.url }, |
test/backup-card-pages.test.ts +1 −1
| @@ -88,7 +88,7 @@ describe("a broken branch's card, read by a site admin who is not a writer", () | ||
| 88 | 88 | }); |
| 89 | 89 | |
| 90 | 90 | test("/asks links the branch to its row and says who may act once", async () => { |
| 91 | const page = await get(admin, "/asks"); | |
| 91 | const page = await get(admin, "/live/on-you"); | |
| 92 | 92 | expect(page).toContain(link); |
| 93 | 93 | expect(page.split(String(html`${SETTLE}`)).length - 1).toBe(1); |
| 94 | 94 | }); |
test/calm-home.test.ts +1 −1
| @@ -115,7 +115,7 @@ test("home and board paint no alert, banner or danger notice for the odd setting | ||
| 115 | 115 | test("no reviewer is the board's one line, a link and not an alert", async () => { |
| 116 | 116 | const body = await get("/board"); |
| 117 | 117 | expect(body.split("No reviewer: agent pulls wait for you").length - 1).toBe(1); |
| 118 | expect(body).toMatch(/<a data-need href="\/asks"[^>]*>[^<]*<[^>]*>[^<]*<\/span>?/s); | |
| 118 | expect(body).toMatch(/<a data-need href="\/\?waits=me"[^>]*>[^<]*<[^>]*>[^<]*<\/span>?/s); | |
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | 121 | test("a stalled flow card renders on home with its one action, and is spared", async () => { |
test/conflict-words.test.ts +1 −1
| @@ -36,7 +36,7 @@ describe("a conflicted pull says its conflicts first", () => { | ||
| 36 | 36 | let pull: Pull; |
| 37 | 37 | |
| 38 | 38 | const asks = async (): Promise<string> => { |
| 39 | const response = await fetch(`${servers.url}/asks`, { headers: { cookie }, redirect: "manual" }); | |
| 39 | const response = await fetch(`${servers.url}/live/on-you`, { headers: { cookie }, redirect: "manual" }); | |
| 40 | 40 | expect(response.status).toBe(200); |
| 41 | 41 | return (await response.text()).replace(/\s+/g, " "); |
| 42 | 42 | }; |
test/empty-states.test.ts +2 −2
| @@ -104,7 +104,7 @@ test("each list's one link says its own next step, in one sentence", async () => | ||
| 104 | 104 | |
| 105 | 105 | test("the five lists take their empty sentence from one table, each with a single link", async () => { |
| 106 | 106 | // people: the signed-in admin is always one, so test/keys-people-list.test.ts holds its sentence |
| 107 | const pages: Record<string, string> = { board: "/boards", inbox: "/asks", runs: "/root/fresh/runs", apps: "/apps" }; | |
| 107 | const pages: Record<string, string> = { board: "/boards", inbox: "/live/on-you", runs: "/root/fresh/runs", apps: "/apps" }; | |
| 108 | 108 | for (const [kind, path] of Object.entries(pages)) { |
| 109 | 109 | const w = EMPTY_WORDS[kind as keyof typeof EMPTY_WORDS]; |
| 110 | 110 | const blocks = emptyBlocks(await (await fetch(servers.url + path, { headers: { cookie } })).text()); |
| @@ -142,7 +142,7 @@ const ALLOWED: Readonly<Record<string, string>> = { | ||
| 142 | 142 | "/root/fresh/forks": "the Fork button in the repository's header is the one door", |
| 143 | 143 | }; |
| 144 | 144 | const EMPTY_PAGES = [ |
| 145 | "/apps", "/boards", "/asks", "/audit", "/displays", "/explore", "/settings/subscriptions", | |
| 145 | "/apps", "/boards", "/audit", "/displays", "/explore", "/settings/subscriptions", | |
| 146 | 146 | "/root/fresh/issues", "/root/fresh/pulls", "/root/fresh/runs", "/root/fresh/branches", |
| 147 | 147 | "/root/fresh/commits", "/root/fresh/releases", "/root/fresh/forks", |
| 148 | 148 | ]; |
test/forges-memory.test.ts +2 −2
| @@ -141,7 +141,7 @@ describe("the forges' sizes together against the machine's memory", () => { | ||
| 141 | 141 | `<p class="muted small" role="status" data-memory-over>${line}</p>`, |
| 142 | 142 | ); |
| 143 | 143 | // The needs-you stack, on /asks and as the home draws it (/live/on-you): one alert line. |
| 144 | for (const path of ["/asks", "/live/on-you"]) { | |
| 144 | for (const path of ["/live/on-you"]) { | |
| 145 | 145 | const page = await get(path); |
| 146 | 146 | expect(page.status).toBe(200); |
| 147 | 147 | expect(count(page.text)).toBe(1); |
| @@ -187,7 +187,7 @@ describe("the forges' sizes together against the machine's memory", () => { | ||
| 187 | 187 | |
| 188 | 188 | test("with room nothing is said anywhere, and nothing is refused either", async () => { |
| 189 | 189 | machineGiB = 64; |
| 190 | for (const path of ["/forges", "/asks", "/live/on-you"]) { | |
| 190 | for (const path of ["/forges", "/live/on-you"]) { | |
| 191 | 191 | const page = await get(path); |
| 192 | 192 | expect(page.status).toBe(200); |
| 193 | 193 | expect(count(page.text)).toBe(0); |
test/hand-decider.test.ts +1 −1
| @@ -81,7 +81,7 @@ describe("let the decider answer a hand-over", () => { | ||
| 81 | 81 | redirect: "manual", |
| 82 | 82 | }); |
| 83 | 83 | |
| 84 | const home = async (path = "/asks"): Promise<string> => | |
| 84 | const home = async (path = "/live/on-you"): Promise<string> => | |
| 85 | 85 | (await (await fetch(`${servers.url}${path}`, { headers: { cookie } })).text()).replace(/\s+/g, " "); |
| 86 | 86 | |
| 87 | 87 | beforeAll(async () => { |
test/handover-give-back.test.ts +1 −1
| @@ -107,7 +107,7 @@ describe("give a handed-over pull back to the crew", () => { | ||
| 107 | 107 | askLinesFor(app.db, owner).some((r) => r.items.includes(`handover:${pullId}`)); |
| 108 | 108 | |
| 109 | 109 | const page = async (): Promise<string> => |
| 110 | (await (await fetch(`${servers.url}/asks`, { headers: { cookie } })).text()).replace(/\s+/g, " "); | |
| 110 | (await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie } })).text()).replace(/\s+/g, " "); | |
| 111 | 111 | |
| 112 | 112 | const post = (ask: string, headers: Record<string, string> = {}, as = cookie) => |
| 113 | 113 | fetch(`${servers.url}/asks/give-back`, { |
test/holds.test.ts +1 −1
| @@ -747,7 +747,7 @@ describe("a hold is set, shown and lifted", () => { | ||
| 747 | 747 | // What needs you, pinned on the home (#634), is the part to read: the |
| 748 | 748 | // feed below it may well mention the change as news. |
| 749 | 749 | const asks = async (cookie: string) => { |
| 750 | const home = await page("/asks", cookie); | |
| 750 | const home = await page("/live/on-you", cookie); | |
| 751 | 751 | const at = home.indexOf('<section id="needs-you"'); |
| 752 | 752 | return at === -1 ? "" : home.slice(at, home.indexOf("</section>", at)); |
| 753 | 753 | }; |
test/home-feed.test.ts +9 −7
| @@ -212,7 +212,7 @@ describe("home is the feed", () => { | ||
| 212 | 212 | shortcuts: { name: string; short_name: string; url: string; icons: { src: string }[] }[]; |
| 213 | 213 | }; |
| 214 | 214 | expect(manifest.shortcuts.map((s) => [s.short_name, s.url])).toEqual([ |
| 215 | ["On you", "/asks"], | |
| 215 | ["On you", "/?waits=me"], | |
| 216 | 216 | ["Talk", "/talk"], |
| 217 | 217 | ]); |
| 218 | 218 | for (const s of manifest.shortcuts) { |
| @@ -221,6 +221,8 @@ describe("home is the feed", () => { | ||
| 221 | 221 | const signedIn = await get(s.url, aliceCookie); |
| 222 | 222 | expect(signedIn.status).toBe(200); |
| 223 | 223 | const anon = await fetch(`${servers.url}${s.url}`, { redirect: "manual" }); |
| 224 | // The board's "waiting for me" view is the home: signed out it is the home's own sign-in. | |
| 225 | if (s.url.startsWith("/?")) continue; | |
| 224 | 226 | expect(anon.status).toBe(303); |
| 225 | 227 | expect(anon.headers.get("location")).toBe(`/signin?next=${encodeURIComponent(s.url)}`); |
| 226 | 228 | } |
| @@ -452,10 +454,10 @@ describe("home is the feed", () => { | ||
| 452 | 454 | expect(page).not.toContain("live-on-you"); |
| 453 | 455 | expect(home).not.toContain("things need you"); |
| 454 | 456 | expect(home).not.toContain("data-pick"); |
| 455 | expect(home).toContain('href="/asks"'); | |
| 456 | const link = home.match(/<a[^>]*href="\/asks"[^>]*>([^<]*)(?:<kbd class="keyhint">.*?<\/kbd>)?<\/a\s*>/s); | |
| 457 | expect(home).toContain('href="/?waits=me"'); | |
| 458 | const link = home.match(/<a[^>]*href="\/\?waits=me"[^>]*>([^<]*)(?:<kbd class="keyhint">.*?<\/kbd>)?<\/a\s*>/s); | |
| 457 | 459 | expect(link).not.toBeNull(); |
| 458 | expect(link![1]!.trim()).toBe("Asks"); | |
| 460 | expect(link![1]!.trim()).toBe("Waiting"); | |
| 459 | 461 | // Nothing after the link, up to the next tag, is a number. |
| 460 | 462 | const after = home.slice(home.indexOf(link![0]) + link![0].length); |
| 461 | 463 | expect(after.slice(0, after.indexOf("<")).trim()).not.toMatch(/\d/); |
| @@ -463,7 +465,7 @@ describe("home is the feed", () => { | ||
| 463 | 465 | const chords = [...page.matchAll(/data-shortcut="([^"]+)"/g)].map((m) => m[1]); |
| 464 | 466 | expect(chords).toContain("g q"); |
| 465 | 467 | expect(new Set(chords).size).toBe(chords.length); |
| 466 | const asks = await (await get("/asks", aliceCookie)).text(); | |
| 468 | const asks = await (await get("/live/on-you", aliceCookie)).text(); | |
| 467 | 469 | for (const title of titles) expect(asks).toContain(title); |
| 468 | 470 | }); |
| 469 | 471 | |
| @@ -473,7 +475,7 @@ describe("home is the feed", () => { | ||
| 473 | 475 | if (!one.ok || !two.ok) throw new Error("issues"); |
| 474 | 476 | for (const [repo, issue] of [[garden, one.value], [vault, two.value]] as const) |
| 475 | 477 | expect(assignIssue(app, alice, repo, issue, alice).ok).toBe(true); |
| 476 | const text = await (await get("/asks", aliceCookie)).text(); | |
| 478 | const text = await (await get("/live/on-you", aliceCookie)).text(); | |
| 477 | 479 | const card = text.slice(text.indexOf('id="live-on-you"')).replace(/\s+/g, " "); |
| 478 | 480 | expect(card).toContain("things need you"); |
| 479 | 481 | expect(card).toContain("assigned to you"); |
| @@ -491,7 +493,7 @@ describe("home is the feed", () => { | ||
| 491 | 493 | expect(text).toContain("fleet.operated"); |
| 492 | 494 | expect(text).toContain("data-pick"); |
| 493 | 495 | // Alone, a single row stays a plain link. |
| 494 | const bobCard = await (await get("/asks", bobCookie)).text(); | |
| 496 | const bobCard = await (await get("/live/on-you", bobCookie)).text(); | |
| 495 | 497 | expect(bobCard).not.toContain('id="asks-bulk"'); |
| 496 | 498 | }); |
| 497 | 499 | }); |
test/home-flow.test.ts +3 −8
| @@ -368,14 +368,14 @@ describe("a proof that did not pass is told in words, with its own record, and r | ||
| 368 | 368 | expect(html).not.toContain('class="hf-need"'); |
| 369 | 369 | expect(html).not.toContain("sign-up limit"); |
| 370 | 370 | expect(html).not.toContain("start=rate"); |
| 371 | expect(await (await get("/asks", owner)).text()).not.toContain('id="forge-broken"'); | |
| 371 | expect(await (await get("/live/on-you", owner)).text()).not.toContain('id="forge-broken"'); | |
| 372 | 372 | }); |
| 373 | 373 | |
| 374 | test("a public address that did not answer as the release is the forge broken: one line in the header with a count, and /asks lists it", async () => { | |
| 374 | test("a public address that did not answer as the release is the forge broken: one line in the header with a count, and it links to the system page", async () => { | |
| 375 | 375 | await write({ failure: "https://f/a.css expected 200 (status 500)" }); |
| 376 | 376 | const html = await (await get("/", owner)).text(); |
| 377 | 377 | const need = html.match(/<p class="hf-need"[\s\S]*?<\/p>/)?.[0] ?? ""; |
| 378 | expect(need).toContain('<a href="/asks#forge-broken">1 problem with the forge</a>'); | |
| 378 | expect(need).toContain('<a href="/system">1 problem with the forge</a>'); | |
| 379 | 379 | expect(need).toContain("is not serving as it should"); |
| 380 | 380 | expect(need).toContain('data-tone="danger"'); |
| 381 | 381 | expect(html.match(/class="hf-need"/g)?.length).toBe(1); |
| @@ -383,13 +383,8 @@ describe("a proof that did not pass is told in words, with its own record, and r | ||
| 383 | 383 | const head = html.indexOf('<header class="hf-head">'); |
| 384 | 384 | expect(html.indexOf('class="hf-need"')).toBeGreaterThan(head); |
| 385 | 385 | expect(html.indexOf('class="hf-need"')).toBeLessThan(html.indexOf("</header>", head)); |
| 386 | const asks = await (await get("/asks", owner)).text(); | |
| 387 | const listed = asks.slice(asks.indexOf('id="forge-broken"')); | |
| 388 | expect(listed).toContain("<h2>Problems with the forge</h2>"); | |
| 389 | expect(listed).toMatch(/<a href="\/releases#proof">[^<]*is not serving as it should/); | |
| 390 | 386 | // a person who cannot administer the forge is not told of it, on either page |
| 391 | 387 | expect(await (await get("/", bob)).text()).not.toContain('class="hf-need"'); |
| 392 | expect(await (await get("/asks", bob)).text()).not.toContain('id="forge-broken"'); | |
| 393 | 388 | }); |
| 394 | 389 | |
| 395 | 390 | test("the releases page opens on the proof's record: where it stopped, what happened, when it tries again, and a way to try now", async () => { |
test/home-interrupted-out.test.ts +3 −3
| @@ -1,4 +1,4 @@ | ||
| 1 | /** Home names a run given up after interruptions, with Try again (#11583). */ | |
| 1 | /** The apps list names a run given up after interruptions, with Try again (#11583). */ | |
| 2 | 2 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| 3 | 3 | import { mkdtemp, rm } from "node:fs/promises"; |
| 4 | 4 | import { tmpdir } from "node:os"; |
| @@ -24,7 +24,7 @@ let cookie: string; | ||
| 24 | 24 | let repoId: string; |
| 25 | 25 | let botId: string; |
| 26 | 26 | |
| 27 | const home = async () => (await fetch(`${servers.url}/`, { headers: { cookie } })).text(); | |
| 27 | const home = async () => (await fetch(`${servers.url}/apps`, { headers: { cookie } })).text(); | |
| 28 | 28 | |
| 29 | 29 | function failedRun(title: string, summary: string, finishedAt: string) { |
| 30 | 30 | const made = createIssue(app.db, { repoId, authorId: alice.id, title, kind: "issue" }); |
| @@ -92,7 +92,7 @@ test("a stranger sees no line", async () => { | ||
| 92 | 92 | const r = await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" }); |
| 93 | 93 | if (!r.ok) throw new Error(r.error); |
| 94 | 94 | const bob = `forge_session=${createSession(app.db, r.value.id).token}`; |
| 95 | expect(await (await fetch(`${servers.url}/`, { headers: { cookie: bob } })).text()).not.toContain("interrupted-out"); | |
| 95 | expect(await (await fetch(`${servers.url}/apps`, { headers: { cookie: bob } })).text()).not.toContain("interrupted-out"); | |
| 96 | 96 | }); |
| 97 | 97 | |
| 98 | 98 | test("the Try again route refuses a cross-origin post", async () => { |
test/hotkey-hints.test.ts +3 −3
| @@ -23,7 +23,7 @@ const inlineHints = (page: string): { menu: boolean }[] => | ||
| 23 | 23 | test("no page draws a hint in the flow outside a menu, so hints cannot shift it", async () => { |
| 24 | 24 | const repo = f.repos[0]!; |
| 25 | 25 | let hinted = 0; |
| 26 | for (const path of ["/", "/feed", "/apps", "/asks", `/${repo.ownerName}/${repo.name}`, `/${repo.ownerName}/${repo.name}/issues`, `/${repo.ownerName}/${repo.name}/pulls`]) { | |
| 26 | for (const path of ["/", "/feed", "/apps", "/review", `/${repo.ownerName}/${repo.name}`, `/${repo.ownerName}/${repo.name}/issues`, `/${repo.ownerName}/${repo.name}/pulls`]) { | |
| 27 | 27 | const page = await get(path); |
| 28 | 28 | expect(inlineHints(page).filter((h) => !h.menu)).toEqual([]); |
| 29 | 29 | hinted += (page.match(/data-hint="/g) ?? []).length; |
| @@ -103,10 +103,10 @@ test("the chip's text is not part of the element's name; a single key is announc | ||
| 103 | 103 | expect(String(hintAttr("g h"))).toBe('data-hint="g h"'); |
| 104 | 104 | }); |
| 105 | 105 | |
| 106 | test("signed in, the top bar's Talk icon and Asks carry their hints", async () => { | |
| 106 | test("signed in, the top bar's Talk icon and Waiting carry their hints", async () => { | |
| 107 | 107 | const page = await get("/"); |
| 108 | 108 | expect(page).toMatch(/aria-label="Talk to the forge" data-shortcut="g t" data-hint="Talk to the forge · g t"/); |
| 109 | expect(page).toMatch(/href="\/asks" data-shortcut="g q" data-hint="g q"/); | |
| 109 | expect(page).toMatch(/href="\/\?waits=me" data-shortcut="g q" data-hint="g q"/); | |
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | test("hover and focus show a hint with no script: the rule is CSS alone", () => { |
test/later-gate.test.ts +2 −6
| @@ -100,7 +100,7 @@ describe("the Later gate in plain sight", () => { | ||
| 100 | 100 | expect(heldLine({ app } as unknown as Ctx, alice)).toBeNull(); |
| 101 | 101 | }); |
| 102 | 102 | |
| 103 | test("a new gate shows up on home: how many, who set it", async () => { | |
| 103 | test("a new gate is counted on its held page, and home no longer draws a held line", async () => { | |
| 104 | 104 | const a = open("Later thing one"); |
| 105 | 105 | const b = open("Later thing two"); |
| 106 | 106 | expect(linkIssue(app, alice, fresh(), current(a), gate).ok).toBe(true); |
| @@ -108,11 +108,7 @@ describe("the Later gate in plain sight", () => { | ||
| 108 | 108 | const hold = gateHold(app.db, fresh())!; |
| 109 | 109 | expect(hold.held).toBe(2); |
| 110 | 110 | expect(hold.by).toBe("alice"); |
| 111 | const home = await get("/"); | |
| 112 | expect(home).toContain('id="held-line"'); | |
| 113 | expect(home).toContain("2 issues are held"); | |
| 114 | expect(home).toContain("set by alice"); | |
| 115 | expect(home).toContain("/alice/engine/held"); | |
| 111 | expect(await get("/")).not.toContain('id="held-line"'); | |
| 116 | 112 | }); |
| 117 | 113 | |
| 118 | 114 | test("a held issue says so at its top with Lift, and Lift lifts it", async () => { |
test/mcp-asks-card-decide.test.ts +1 −1
| @@ -39,7 +39,7 @@ const rpc = async (token: string, name: string, args: Record<string, unknown>) = | ||
| 39 | 39 | return (await res.json()) as any; |
| 40 | 40 | }; |
| 41 | 41 | const page = async (): Promise<string> => |
| 42 | (await (await fetch(`${servers.url}/asks`, { headers: { cookie: `${cookie}; forge_mode=studio` } })).text()).replace(/\s+/g, " "); | |
| 42 | (await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie: `${cookie}; forge_mode=studio` } })).text()).replace(/\s+/g, " "); | |
| 43 | 43 | |
| 44 | 44 | beforeAll(async () => { |
| 45 | 45 | dataDir = await mkdtemp(join(tmpdir(), "forge-asks-card-")); |
test/no-alarm-banner.test.ts +3 −4
| @@ -162,9 +162,9 @@ const said = (html: string): string => | ||
| 162 | 162 | const ALARMS: readonly { readonly alarm: string; readonly says: string; readonly pages: readonly string[] }[] = [ |
| 163 | 163 | { alarm: "disk full", says: "disk has 0.0% free", pages: ["/", "/alice/forge/next", "/alice/forge", "/system"] }, |
| 164 | 164 | { alarm: "disk full, as the board needs it", says: "Disk is nearly full", pages: ["/board"] }, |
| 165 | { alarm: "backup overdue", says: "the bucket refused", pages: ["/asks", "/board"] }, | |
| 165 | { alarm: "backup overdue", says: "the bucket refused", pages: ["/board"] }, | |
| 166 | 166 | // The home (the lanes first, since 2026-11-15) counts what is broken about the forge in one |
| 167 | // quiet line, with the first of them beside the count; each sentence in full is on /asks, and | |
| 167 | // quiet line, with the first of them beside the count; each sentence in full is on /board and | |
| 168 | 168 | // every alarm's on /boards. |
| 169 | 169 | { alarm: "what is broken, as home counts it", says: "2 problems with the forge", pages: ["/"] }, |
| 170 | 170 | { alarm: "bug past its clock", says: "Bug past its clock: alice/forge#1", pages: ["/boards"] }, |
| @@ -179,8 +179,7 @@ const PAGES = ["/", "/alice/forge/next", "/alice/forge", "/board", "/boards", "/ | ||
| 179 | 179 | test("each alarm is raised, said on its page, and no page draws a banner for any of them", async () => { |
| 180 | 180 | const w = await open(0); |
| 181 | 181 | const html = new Map<string, string>(); |
| 182 | // /asks is read for its words alone: its own cards are not this file's to judge. | |
| 183 | for (const path of [...PAGES, "/asks"]) { | |
| 182 | for (const path of PAGES) { | |
| 184 | 183 | const page = await read(w, path); |
| 185 | 184 | expect(page).toContain("<main"); |
| 186 | 185 | html.set(path, page); |
test/palette-roster.test.ts +3 −1
| @@ -128,10 +128,11 @@ test("a site-admin person is offered the whole roster", () => { | ||
| 128 | 128 | ["system", "System", "the machine now: CPU, memory, disks, processes"], |
| 129 | 129 | ["pulls-to-land", "Pulls to land", "approved pulls, stale crew pulls, unproposed work"], |
| 130 | 130 | ["valves", "Valves", "the week's budget as a valve per repository; turn one and the crew obeys"], |
| 131 | ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"], | |
| 131 | ["waiting-for-me", "Waiting for me", "issues and pulls that wait for you"], | |
| 132 | 132 | ["refused-asks", "Refused first asks", "the last 20 first asks turned away"], |
| 133 | 133 | ["disks", "Disks", "machines' disk readings: 30-day write rate and projected rated-TBW date"], |
| 134 | 134 | ["telemetry", "Telemetry", "which agents may read flow and system; enter flips the grant"], |
| 135 | ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"], | |
| 135 | 136 | ["stalls", "Main-thread stalls", "the last hour's stall ms by route"], |
| 136 | 137 | ["footing", "What the forge stands on", "each piece on another machine, in the order it would break the forge"], |
| 137 | 138 | ["maintenanceweek", "Maintenance, last 7 days", "what each maintenance worker found and did this week"], |
| @@ -409,6 +410,7 @@ test("a member person is offered the signed-in roster without the admin entries" | ||
| 409 | 410 | ["payments", "Payments", "what was charged for the forges you claimed"], |
| 410 | 411 | ["bugs", "Bugs", "open bugs and the bug clock"], |
| 411 | 412 | ["health-voice", "Health — spoken", "how the forge is, in two plain sentences"], |
| 413 | ["waiting-for-me", "Waiting for me", "issues and pulls that wait for you"], | |
| 412 | 414 | ["audit", "Who can do what", "each app's doors from its contract.json: yes, own or no"], |
| 413 | 415 | ["archived", "Archived repositories", "put away, not gone: open one or restore it"], |
| 414 | 416 | ["apps-crew", "What the crew is doing", "one plain sentence per app: who is on what"], |
test/planner-declined.test.ts +2 −2
| @@ -215,7 +215,7 @@ describe("the planner declined, waiting for a person", () => { | ||
| 215 | 215 | `garden: the planner declined the direction and waits for you (issue #${direction.number})`, |
| 216 | 216 | ); |
| 217 | 217 | expect(await shown(bob)).not.toContain("the planner declined"); |
| 218 | const asks = await page(aliceCookie, "/asks"); | |
| 218 | const asks = await page(aliceCookie, "/live/on-you"); | |
| 219 | 219 | expect(asks).toContain("The planner declined the direction"); |
| 220 | 220 | expect(asks).toContain( |
| 221 | 221 | `/alice/garden/issues/${direction.number}#comment-body`, |
| @@ -249,7 +249,7 @@ describe("the planner declined, waiting for a person", () => { | ||
| 249 | 249 | test("an ask quotes the planner's words as one escaped, clamped line, whole in its title (#10199)", async () => { |
| 250 | 250 | const words = "nothing to plan:\n\n - `main` is **done**\n - see [the map](http://x.test) <b>now</b>"; |
| 251 | 251 | decline(words, new Date().toISOString()); |
| 252 | const asks = await page(await signIn("alice"), "/asks"); | |
| 252 | const asks = await page(await signIn("alice"), "/live/on-you"); | |
| 253 | 253 | const flat = "nothing to plan: - `main` is **done** - see [the map](http://x.test) <b>now</b>"; |
| 254 | 254 | expect(asks).toContain(`The planner declined the direction: \u201c<span class="row-note" title="${flat}">${flat}</span>\u201d.`); |
| 255 | 255 | expect(asks).not.toContain("<b>now</b>"); |
test/proposal-card.test.ts +2 −2
| @@ -113,7 +113,7 @@ describe("a wave proposal is one inbox card", () => { | ||
| 113 | 113 | const [row] = rows(); |
| 114 | 114 | expect(row!.proposal!.title).toBe("Refused wave"); |
| 115 | 115 | expect(row!.proposal!.issues).toEqual(["First <b>step</b>", "Second step"]); |
| 116 | const page = await (await fetch(`${servers.url}/asks`, { headers: { cookie: `${aliceCookie}; forge_mode=studio` } })).text(); | |
| 116 | const page = await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie: `${aliceCookie}; forge_mode=studio` } })).text(); | |
| 117 | 117 | expect(page).toContain("First <b>step</b>"); |
| 118 | 118 | expect(page).toContain("because <script>"); |
| 119 | 119 | expect(page).not.toContain("<b>step</b>"); |
| @@ -157,7 +157,7 @@ describe("a wave proposal is one inbox card", () => { | ||
| 157 | 157 | test("home shows the Redirect box on the card, and Later's way back", async () => { |
| 158 | 158 | const id = propose("Home wave"); |
| 159 | 159 | const get = async () => |
| 160 | (await (await fetch(`${servers.url}/asks`, { headers: { cookie: `${aliceCookie}; forge_mode=studio` } })).text()); | |
| 160 | (await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie: `${aliceCookie}; forge_mode=studio` } })).text()); | |
| 161 | 161 | expect(await get()).toContain(`/asks/proposal/${id}/redirect`); |
| 162 | 162 | await post(aliceCookie, `/asks/proposal/${id}/later`, [["back", "/"]]); |
| 163 | 163 | const page = await get(); |
test/review-page.test.ts −5
| @@ -161,11 +161,6 @@ test("signed out, /review sends to sign-in", async () => { | ||
| 161 | 161 | expect(res.headers.get("location")).toContain("/signin"); |
| 162 | 162 | }); |
| 163 | 163 | |
| 164 | test("the asks page links to /review", async () => { | |
| 165 | const res = await fetch(`${servers.url}/asks`, { headers: { cookie } }); | |
| 166 | expect(await res.text()).toContain('href="/review"'); | |
| 167 | }); | |
| 168 | ||
| 169 | 164 | test("each row says what the crew advises and why, or that it has not advised yet", async () => { |
| 170 | 165 | const body = await (await fetch(`${servers.url}/review`, { headers: { cookie } })).text(); |
| 171 | 166 | const rows = body.split("<li").filter((r) => r.includes('class="row"')); |
test/review-wait.test.ts +1 −1
| @@ -35,7 +35,7 @@ describe("a green agent pull and its reviewer", () => { | ||
| 35 | 35 | |
| 36 | 36 | const home = async (): Promise<string> => |
| 37 | 37 | ( |
| 38 | await (await fetch(`${servers.url}/asks`, { headers: { cookie } })).text() | |
| 38 | await (await fetch(`${servers.url}/live/on-you`, { headers: { cookie } })).text() | |
| 39 | 39 | ).replace(/\s+/g, " "); |
| 40 | 40 | const wordCtx = (): WordCtx => ({ db: app.db }) as unknown as WordCtx; |
| 41 | 41 |
test/server-timing-sweep.test.ts +1
| @@ -42,6 +42,7 @@ const NOT_PAGES = new Set([ | ||
| 42 | 42 | * by redirecting. |
| 43 | 43 | */ |
| 44 | 44 | const REDIRECTS = new Set([ |
| 45 | "/asks", | |
| 45 | 46 | "/.well-known/change-password", |
| 46 | 47 | "/alice/forge/changes", |
| 47 | 48 | "/alice/forge/files", |
test/stuck-pile-doors.test.ts +16 −16
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /** |
| 2 | * The doors of a repository standing still (#12611): its row on `/asks`, the MCP `forge` tool and | |
| 3 | * the terminal's needs screen each take one choice about it, turning the app off among them, and | |
| 4 | * each refuses who may not and plans before it acts. The home draws none of it: its lanes come | |
| 2 | * The doors of a repository standing still (#12611): its row on the apps list, the MCP `forge` tool | |
| 3 | * and the terminal's needs screen each take one choice about it, turning the app off among them, | |
| 4 | * and each refuses who may not and plans before it acts. The home draws none of it: its lanes come | |
| 5 | 5 | * first, on every width. |
| 6 | 6 | */ |
| 7 | 7 | import { afterAll, beforeAll, beforeEach, expect, test } from "bun:test"; |
| @@ -98,44 +98,44 @@ test("the home: the lanes are the first thing under the header, on a phone as on | ||
| 98 | 98 | expect(html).not.toContain(`action="${path}/stuck"`); |
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | test("/asks lists it under Standing still: the calm sentence, its choices as buttons, what turning off does, and the approved pull", async () => { | |
| 101 | test("/apps lists it under Standing still: the calm sentence, its choices as buttons, what turning off does, and the approved pull", async () => { | |
| 102 | 102 | approve(9); |
| 103 | const html = await page("/asks"); | |
| 103 | const html = await page("/apps"); | |
| 104 | 104 | const still = html.slice(html.indexOf('id="standing"')); |
| 105 | 105 | expect(still).toContain("<h2>Standing still</h2>"); |
| 106 | 106 | expect(still).toContain(`${path.slice(1)}: 3 pulls nobody has touched since `); |
| 107 | 107 | expect(still).toContain("Nothing new can start there until they move."); |
| 108 | 108 | expect(still).toContain(`action="${path}/stuck"`); |
| 109 | expect(still).toContain('name="next" value="/asks"'); | |
| 109 | expect(still).toContain('name="next" value="/apps"'); | |
| 110 | 110 | for (const [value, label] of [["recheck", "Re-check its pulls"], ["builders", "Hand its pulls to builders"], ["close", "Close its stale pulls"], ["off", "Turn this app off"]]) |
| 111 | 111 | expect(still).toMatch(new RegExp(`<button[^>]*name="choice"[^>]*value="${value}"[^>]*>[\\s\\S]*?${label}`)); |
| 112 | 112 | expect(still).toContain(OFF_SAYS); |
| 113 | 113 | expect(still).toMatch(new RegExp(`href="${path}/pulls/${n}"[^>]*>[^<]*was approved 9 days ago and has not landed`)); |
| 114 | 114 | expect(still).not.toMatch(/is stuck/); |
| 115 | 115 | // Someone who cannot write there is shown none of it. |
| 116 | expect(await page("/asks", f.peerCookie)).not.toContain('id="standing"'); | |
| 116 | expect(await page("/apps", f.peerCookie)).not.toContain('id="standing"'); | |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | 119 | test("Turn this app off: the row's button archives the repository, its row is gone from every door, and nothing counts it", async () => { |
| 120 | const off = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "off", next: "/asks" }); | |
| 120 | const off = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "off", next: "/apps" }); | |
| 121 | 121 | expect(off.status).toBe(303); |
| 122 | expect(off.headers.get("location")).toBe(`/asks?off=${repoId}#standing`); | |
| 122 | expect(off.headers.get("location")).toBe(`/apps?off=${repoId}#standing`); | |
| 123 | 123 | expect(getRepoById(f.app.db, repoId)!.archivedAt).not.toBeNull(); |
| 124 | 124 | expect(open()).toBe(3); |
| 125 | 125 | forgetStuckRepos(f.app.db); |
| 126 | expect(await page("/asks")).not.toContain(`action="${path}/stuck"`); | |
| 126 | expect(await page("/apps")).not.toContain(`action="${path}/stuck"`); | |
| 127 | 127 | // Where its row was, the page says it is off and offers the way back in one button. |
| 128 | const there = await page(`/asks?off=${repoId}`); | |
| 128 | const there = await page(`/apps?off=${repoId}`); | |
| 129 | 129 | const row = there.slice(there.indexOf(`data-standing-off="${repoId}"`) - 200).slice(0, 900); |
| 130 | 130 | expect(row).toContain(`action="${path}/settings/archive"`); |
| 131 | 131 | expect(row).toContain('name="archived" value="0"'); |
| 132 | 132 | expect(row).toContain(`${path.slice(1)} is off.`); |
| 133 | 133 | expect(row).toContain("Turn it back on"); |
| 134 | 134 | // Someone who does not administer it is offered nothing. |
| 135 | expect(await page(`/asks?off=${repoId}`, f.peerCookie)).not.toContain("data-standing-off"); | |
| 135 | expect(await page(`/apps?off=${repoId}`, f.peerCookie)).not.toContain("data-standing-off"); | |
| 136 | 136 | expect(needsStack({ app: f.app }, f.owner).filter((x) => x.id.startsWith("stuck:"))).toEqual([]); |
| 137 | 137 | // Off already, there is nothing left to choose about it. |
| 138 | const again = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "close", next: "/asks" }); | |
| 138 | const again = await post({ origin: f.base, cookie: f.ownerCookie }, { choice: "close", next: "/apps" }); | |
| 139 | 139 | expect(again.status).toBe(303); |
| 140 | 140 | expect(open()).toBe(3); |
| 141 | 141 | // The button: one press and the app is on again, its row back with its choices. |
| @@ -143,13 +143,13 @@ test("Turn this app off: the row's button archives the repository, its row is go | ||
| 143 | 143 | method: "POST", |
| 144 | 144 | redirect: "manual", |
| 145 | 145 | headers: { "content-type": "application/x-www-form-urlencoded", origin: f.base, cookie: f.ownerCookie }, |
| 146 | body: new URLSearchParams({ archived: "0", to: "/asks" }), | |
| 146 | body: new URLSearchParams({ archived: "0", to: "/apps" }), | |
| 147 | 147 | }); |
| 148 | 148 | expect(on.status).toBe(303); |
| 149 | expect(on.headers.get("location")).toBe("/asks"); | |
| 149 | expect(on.headers.get("location")).toBe("/apps"); | |
| 150 | 150 | expect(getRepoById(f.app.db, repoId)!.archivedAt).toBeNull(); |
| 151 | 151 | forgetStuckRepos(f.app.db); |
| 152 | const back = await page(`/asks?off=${repoId}`); | |
| 152 | const back = await page(`/apps?off=${repoId}`); | |
| 153 | 153 | expect(back).toContain(`action="${path}/stuck"`); |
| 154 | 154 | expect(back).not.toContain("data-standing-off"); |
| 155 | 155 | }); |
test/talk-decisions.test.ts +3 −3
| @@ -117,13 +117,13 @@ describe("talk answers what needs me", () => { | ||
| 117 | 117 | } |
| 118 | 118 | const text = await answer(alice, "inbox"); |
| 119 | 119 | expect(text.split("\n").filter((l) => /^\d+\. \[/.test(l)).length).toBe(DECISIONS_MAX); |
| 120 | expect(text).toMatch(/\[\d+ more in your inbox\]\(\/asks\)/); | |
| 120 | expect(text).toMatch(/\[\d+ more in your inbox\]\(\/\?waits=me\)/); | |
| 121 | 121 | }); |
| 122 | 122 | |
| 123 | test("a proposal row links /asks with Approve", () => { | |
| 123 | test("a proposal row links the waits-for-me view with Approve", () => { | |
| 124 | 124 | const proposal: Proposal = { id: "1", repoId: repo.id, authorId: alice.id, title: "Plan", why: "", issues: [], state: "pending", createdAt: "2026-11-14T00:00:00.000Z" }; |
| 125 | 125 | const d: Decision = { kind: "proposal", id: "proposal:1", repo, proposal, who: "planner", says: "", short: 'proposes "Plan"', consequence: KIND_TIER.proposal, waiting: { word: "a decision", on: "you" } }; |
| 126 | expect(actionHref(d)).toBe("/asks"); | |
| 126 | expect(actionHref(d)).toBe("/?waits=me"); | |
| 127 | 127 | expect(primaryLabel(d)).toBe("Approve"); |
| 128 | 128 | }); |
| 129 | 129 |
test/tui-yours-asks.test.ts +1 −1
| @@ -135,7 +135,7 @@ describe("terminal On you: the week's asks", () => { | ||
| 135 | 135 | try { |
| 136 | 136 | expect(t.text()).toContain("W asks on the web"); |
| 137 | 137 | await t.key("W"); |
| 138 | expect(t.text()).toContain("Asks is on the web at /asks"); | |
| 138 | expect(t.text()).toContain("Waiting is on the web at /?waits=me"); | |
| 139 | 139 | } finally { |
| 140 | 140 | t.app.stop(); |
| 141 | 141 | } |
test/waits-for-me.test.ts added +54
| @@ -0,0 +1,54 @@ | ||
| 1 | /** | |
| 2 | * What waits for a person: one read shared by the board's filter and the terminal's list; the | |
| 3 | * read is held per viewer, and a lane's ETag carries the set so a change is never answered 304. | |
| 4 | */ | |
| 5 | ||
| 6 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 7 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 8 | import { tmpdir } from "node:os"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { createApp, type App as Forge } from "../src/app.ts"; | |
| 11 | import type { User } from "../src/core/users.ts"; | |
| 12 | import { Session } from "../src/tui/session.ts"; | |
| 13 | import { waitingForMeLines, entry } from "../src/tui/screens/waiting_for_me.ts"; | |
| 14 | import { waitingRows, waitsDigest } from "../src/web/studio/waiting_on_me.ts"; | |
| 15 | import { quietLogs } from "./helpers/globals.ts"; | |
| 16 | import { seedAdmin } from "./helpers/admin.ts"; | |
| 17 | ||
| 18 | quietLogs(); | |
| 19 | ||
| 20 | let dir: string; | |
| 21 | let forge: Forge; | |
| 22 | let alice: User; | |
| 23 | ||
| 24 | beforeAll(async () => { | |
| 25 | dir = await mkdtemp(join(tmpdir(), "forge-waits-me-")); | |
| 26 | forge = createApp({ dataDir: dir, port: 0 }); | |
| 27 | const a = await seedAdmin(forge, { username: "alice", email: "[email protected]", password: "a-long-passphrase" }); | |
| 28 | if (!a.ok) throw new Error("signup failed"); | |
| 29 | alice = a.value; | |
| 30 | }); | |
| 31 | afterAll(async () => { | |
| 32 | await rm(dir, { recursive: true, force: true }); | |
| 33 | }); | |
| 34 | ||
| 35 | test("the digest changes with the set and not with its order", () => { | |
| 36 | expect(waitsDigest(new Set(["a#1", "b#2"]))).toBe(waitsDigest(new Set(["b#2", "a#1"]))); | |
| 37 | expect(waitsDigest(new Set(["a#1"]))).not.toBe(waitsDigest(new Set(["a#1", "a#2"]))); | |
| 38 | expect(waitsDigest(new Set())).not.toBe(waitsDigest(new Set(["a#1"]))); | |
| 39 | }); | |
| 40 | ||
| 41 | test("the read is held for a moment per viewer, then read again", () => { | |
| 42 | const reader = { app: forge, auth: { user: alice } }; | |
| 43 | const t = Date.now(); | |
| 44 | const first = waitingRows(reader, alice, t); | |
| 45 | expect(waitingRows(reader, alice, t + 1_000)).toBe(first); | |
| 46 | expect(waitingRows(reader, alice, t + 60_000)).not.toBe(first); | |
| 47 | }); | |
| 48 | ||
| 49 | test("the terminal lists each card with what it waits for, and offers itself to people only", () => { | |
| 50 | const lines = waitingForMeLines([{ key: "r#7", repo: "a/b", number: 7, kind: "pull", title: "Add x", short: "ready to land" }]); | |
| 51 | expect(lines).toEqual(["a/b#7 pull: Add x", " ready to land"]); | |
| 52 | expect(entry.offered(new Session(forge, { sshUsername: "alice", remoteAddress: "127.0.0.1", user: alice }))).toBe(true); | |
| 53 | expect(entry.offered(new Session(forge, { sshUsername: "guest", remoteAddress: "127.0.0.1" }))).toBe(false); | |
| 54 | }); |
test/web-apps.test.ts +3 −3
| @@ -961,11 +961,11 @@ describe("apps, runs and the crew on the web", () => { | ||
| 961 | 961 | form: { assignee: "alice" }, |
| 962 | 962 | }); |
| 963 | 963 | expect(assigned.status).toBe(303); |
| 964 | const dash = await bodyOf(alice, "/asks"); | |
| 964 | const dash = await bodyOf(alice, "/live/on-you"); | |
| 965 | 965 | expect(dash).toContain('<section id="needs-you"'); |
| 966 | 966 | expect(dash).toMatch(/<h2 id="asks-sentence">\d+ things? needs? you<\/h2>/); |
| 967 | 967 | expect(dash).toContain("Say hello"); |
| 968 | expect(await bodyOf(bob, "/asks")).not.toContain('<section id="needs-you"'); | |
| 968 | expect(await bodyOf(bob, "/live/on-you")).not.toContain('<section id="needs-you"'); | |
| 969 | 969 | |
| 970 | 970 | // Needs you: a pull the crew opened, in a repository alice can write. |
| 971 | 971 | expect(addToCrew(app, aliceUser, hello, "bot").ok).toBe(true); |
| @@ -986,7 +986,7 @@ describe("apps, runs and the crew on the web", () => { | ||
| 986 | 986 | // racing to finish here: when it does, the dashboard links to /asks |
| 987 | 987 | // rather than listing it (test/asks.test.ts holds that page to account). |
| 988 | 988 | // Bob can read the public repo but not write it: not his inbox. |
| 989 | expect(await bodyOf(bob, "/asks")).not.toContain('<section id="needs-you"'); | |
| 989 | expect(await bodyOf(bob, "/live/on-you")).not.toContain('<section id="needs-you"'); | |
| 990 | 990 | }); |
| 991 | 991 | |
| 992 | 992 | test("the assignee select offers the people who can read the repository", async () => { |
new above
offline
backTo only accepts /asks paths, so the '/?waits=me' back value is coerced to /asks and redirected again. Accept the new path.