Public: anyone can read this; the crew can change it.
Bridge v1: home becomes operable — select any tile, row or figure and act in place, keyboard first #16898
Check · Review · Land · Live done — Landed and live in production.
bridge-v1 → main 0 commits 3 threads · 3 unresolved
15 files
changed +653
−29
- docs/design/areas/home-flow.md
- docs/design/attention-budget.json
- docs/features/bridge.md
- scripts/doorless-allow.json
- src/flow/lanes_read.ts
- src/flow/slots.ts
- src/web/bridge_client.ts
- src/web/flow_slots.ts
- src/web/pages/capacity.ts
- src/web/pages/home_flow.ts
- src/web/pages/home_flow_style.ts
- src/web/pages/home_table.ts
- test/bridge.test.ts
- test/flow-slots.test.ts
- test/pages-budget.test.ts
docs/design/areas/home-flow.md +1
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | - `.lane-times` — one line under the health, "now 18m · typical 9m" (the median age of the cards the viewer can see, and the median time cards spent in it over 24 hours; a viewer who is not a forge admin sees "typical —"). It is one line tall, empty where there is nothing to say. `.lane-bottleneck` — the word "Slowest" at `--fg` weight in the head of the lane whose now median is furthest above its typical (`data-bottleneck` on the lane); at most one lane wears it. A tile's clock is its age in the lane. |
| 17 | 17 | - `.lane-list` — the lane's tiles, in the order the next worker takes them. |
| 18 | 18 | - `.lane-more`, `.lane-more-link`, `.lane-more-lg`, `.lane-more-md`, `.lane-more-sm`, `.lane-toggle`, `.lane-all` — what lies past the tiles. On a desk "N more" opens the table filtered to the lane. On a phone a lane shows its first four tiles (two lines each: the title, then the app, who has it and where it is, with the clock beside the title); with script "Show all N" opens the lane in place up to twelve tiles, then "All N in the table", and the lane keeps `data-open` through every redraw; without script "N more" is the table link. |
| 19 | - `.br-bar`, `.br-body`, `.br-head`, `.br-verbs`, `.br-said` — the bridge (`src/web/bridge_client.ts`): the selected tile's verbs in one bar under the lanes, each a button with its key (`data-shortcut`, so `?` lists them), docked at the foot of the screen with the safe area under it. It is empty and hidden until a tile is selected (`j`/`k`, a focus, or a first tap on a phone); a selected tile wears an accent outline (`data-selected`). No motion: it is used many times a day. | |
| 19 | 20 | - `.tile`, `.tile-link`, `.tile-top`, `.tile-app`, `.tile-no`, `.tile-clock`, `.tile-title`, `.tile-hint`, `.tile-who` — one change: the app and number, how long it has been in this lane, its title in plain words, who has it and one sentence of where it is. `data-key` is stable across lanes, so the page glides a tile from the lane it left to the lane it reached (`home_flow_client.ts`); `data-state` is `waiting`, `active` (a pulse on the clock) or `done` (live). |
| 20 | 21 | - `.hf-forges` — the hosted forges in one line: how many, how many awake, any that is awake but silent. |
| 21 | 22 | - `.hf-foot` — a line saying what the page shows, and the way to the feed. |
docs/design/attention-budget.json +5 −5
| @@ -1,16 +1,16 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "home": { |
| 3 | 3 | "390": { |
| 4 | "words": 324, | |
| 5 | "blocks": 54, | |
| 4 | "words": 339, | |
| 5 | "blocks": 55, | |
| 6 | 6 | "colours": 7 |
| 7 | 7 | }, |
| 8 | 8 | "1280": { |
| 9 | "words": 324, | |
| 10 | "blocks": 54, | |
| 9 | "words": 339, | |
| 10 | "blocks": 55, | |
| 11 | 11 | "colours": 7 |
| 12 | 12 | }, |
| 13 | "note": "Raised by 11 words and 1 block for the first-week line (To start: three links), shown to an admin in a forge's first week only (#13460); and by 27 words and 4 blocks for the Ship time card and its one-line disclosure (#14649)." | |
| 13 | "note": "Raised by 11 words and 1 block for the first-week line (To start: three links), shown to an admin in a forge's first week only (#13460); by 27 words and 4 blocks for the Ship time card and its one-line disclosure (#14649); and by 15 words and 1 block for the slots under the lanes, an admin's figures to set from the keyboard (Bridge v1)." | |
| 14 | 14 | }, |
| 15 | 15 | "repository": { |
| 16 | 16 | "390": { |
docs/features/bridge.md added +20
| @@ -0,0 +1,20 @@ | ||
| 1 | --- | |
| 2 | topic: Getting around: keys, the palette and search | |
| 3 | row: The bridge: act on a tile from home | |
| 4 | --- | |
| 5 | # The bridge: act on a tile from home | |
| 6 | ||
| 7 | The owner, of home: "the one thing i actually feel proud of… but then from there i feel like i have little to no control other than telling an agent my thoughts". Home's lanes are now the bridge: the tile you are on has its verbs in one bar under the lanes, each a key, and every verb is an action that already exists on its own page. | |
| 8 | ||
| 9 | - **Select.** `j` and `k` move between tiles (each tile's link is a row, `data-nav`), a focus selects, and on a phone the first tap selects and the second opens. Escape, or focus anywhere else, clears. A lane the live stream redraws keeps the selection: the tile with the same key, wherever it moved. | |
| 10 | - **A run** (Building, Checks, Review): `w` watch it live (its run page), `h` take the wheel (its run page at the steer box, where words reach the running agent), `s` stop. A stopped run offers `r` Queue it again. | |
| 11 | - **An issue:** `a` assign (its page's assignee field), `e` sharpen (the planner plans it again), `p` park (behind the Later gate). Sharpen and park answer with their receipt, where Undo is. | |
| 12 | - **A figure** (an admin's): the slots under the lanes, checks and crew runs (`src/web/flow_slots.ts`), are selectable too. `-` and `+` turn the setting and the bar says, labelled an estimate, how long a new run would wait at it ("Estimate: a new check would wait about 6m with 8 slots (44m now). Checks cost nothing extra."): what waits now, worked off at the median run's length over the 24 hours, that many at a time. Enter sets it through Capacity's own save, and the estimate is kept with the change (its reason); `z` puts it back. Each figure then says how the last change's estimate held up ("since then a new one waited ~5m"), and when it was more than twice off either way it says so and calls the next estimate rough. | |
| 13 | - **A pull:** `m` merge, `x` close, `u` bring it up to date, `b` send it back (its review box: a send-back needs words). A merge is the one verb that asks for a second `m`, because it is not undone; everything else applies at once and answers with what was done and its receipt (where close's Undo is). | |
| 14 | - Stop, queue again, close, sharpen, park and merge go through home's one action route, `POST /home/act` (`src/web/pages/home_table.ts`), as the table's action bar does; Update posts the pull's own update route. The bar's keys are buttons that exist only while a tile is selected, so `?` lists them and no key is taken from home otherwise (`t` stays Tell the crew). The bar has no motion and docks at the foot of the screen, above the safe area. | |
| 15 | - **In the terminal** the tile verbs are on the run and pull screens (`src/tui/screens/runs.ts`, `src/tui/screens/pull.ts`); the dashboard (`src/tui/screens/dashboard.ts`) is the terminal's home. The slots are set on the Capacity screen (`src/tui/screens/capacity.ts`: `e` on `checks.concurrency` or `crew.concurrency`, then `y`), without the estimate or its Undo: those are on the page only, for now. | |
| 16 | - **Who sees it:** the slots and their figures are a forge admin's, read and drawn for one only; anyone else's home has none. The bar's answers are said in one live region that is on the page from the start, so a screen reader announces each, and a figure is a named group ("Checks slots, 4"). | |
| 17 | ||
| 18 | Later: steering the running agent from the bar itself, a live terminal of the run (the take-the-wheel the owner means), an assignee picker in the bar, and figures beyond the slots. | |
| 19 | ||
| 20 | Proof: `test/bridge.test.ts`. |
scripts/doorless-allow.json −1
src/flow/lanes_read.ts +6
| @@ -86,6 +86,11 @@ export interface LaneItem { | ||
| 86 | 86 | readonly born: string | null; |
| 87 | 87 | /** The open issues this one waits for, ascending; absent when none (#13641). */ |
| 88 | 88 | readonly waits?: readonly number[]; |
| 89 | /** | |
| 90 | * The run this tile is, in the lanes of runs (building, checks, review): what Stop and Watch act | |
| 91 | * on. | |
| 92 | */ | |
| 93 | readonly runId?: string; | |
| 89 | 94 | } |
| 90 | 95 | |
| 91 | 96 | export interface LaneRead { |
| @@ -239,6 +244,7 @@ function item( | ||
| 239 | 244 | beat: r.beat, |
| 240 | 245 | issueId: r.issue_id, |
| 241 | 246 | born: r.born, |
| 247 | ...(r.run_id === undefined ? {} : { runId: r.run_id }), | |
| 242 | 248 | ...over, |
| 243 | 249 | }; |
| 244 | 250 | } |
src/flow/slots.ts +79 −5
| @@ -15,6 +15,7 @@ import type { App } from "../app.ts"; | ||
| 15 | 15 | import { capacityValues } from "../core/capacity.ts"; |
| 16 | 16 | import { forgeRepo } from "../core/forge_repo.ts"; |
| 17 | 17 | import { repoPace } from "../crew/autonomy_pace.ts"; |
| 18 | import { median } from "./estimate_score.ts"; | |
| 18 | 19 | |
| 19 | 20 | /** The instants the 24 hours are read at: one each quarter hour, oldest first. */ |
| 20 | 21 | export const SLOT_POINTS = 96; |
| @@ -41,6 +42,45 @@ export interface SlotLine { | ||
| 41 | 42 | readonly points: readonly SlotPoint[]; |
| 42 | 43 | /** The crew's pace, when it allows fewer slots than the setting. */ |
| 43 | 44 | readonly pace?: { readonly allows: number; readonly why: string }; |
| 45 | /** | |
| 46 | * The median time a run of this kind took, start to end, over the 24 hours; null when none ended. | |
| 47 | */ | |
| 48 | readonly medianRunMs: number | null; | |
| 49 | /** | |
| 50 | * The last estimate a change of this setting was made on, and what happened since: kept honest. | |
| 51 | */ | |
| 52 | readonly lastEstimate?: { readonly at: string; readonly slots: number; readonly saidMs: number; readonly actualMs: number | null }; | |
| 53 | } | |
| 54 | ||
| 55 | const KEY: Readonly<Record<SlotLine["kind"], "checks.concurrency" | "crew.concurrency">> = { checks: "checks.concurrency", crew: "crew.concurrency" }; | |
| 56 | ||
| 57 | /** | |
| 58 | * An estimate of how long a new run would wait at `slots`: what waits now, worked off at the | |
| 59 | * median run's length, `slots` at a time. A plain model (one queue, every run alike): it is said | |
| 60 | * as an estimate, recorded with the change it is made for, and checked against what happened. | |
| 61 | */ | |
| 62 | export function waitEstimate(l: Pick<SlotLine, "waiting" | "medianRunMs">, slots: number): number | null { | |
| 63 | if (l.medianRunMs === null || slots < 1) return null; | |
| 64 | return Math.round((l.waiting * l.medianRunMs) / slots); | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * An estimate read back from the words a change was made with (the bridge writes them: "Estimate: a | |
| 69 | * new check waits ~6m at 8 slots (360 s)."), or undefined for a change made without one. | |
| 70 | */ | |
| 71 | export function estimateOf(reason: string): { slots: number; ms: number } | undefined { | |
| 72 | const m = /^Estimate: a new [a-z ]+ waits ~.+? at (\d+) slots \((\d+) s\)\./.exec(reason); | |
| 73 | return m === null ? undefined : { slots: Number(m[1]), ms: Number(m[2]) * 1000 }; | |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * Whether what happened was more than twice off what was said, either way: then the next estimate | |
| 78 | * says so. | |
| 79 | */ | |
| 80 | export function offByMore(e: NonNullable<SlotLine["lastEstimate"]>): boolean { | |
| 81 | if (e.actualMs === null) return false; | |
| 82 | const ratio = Math.max(e.actualMs, 1) / Math.max(e.saidMs, 1); | |
| 83 | return Math.max(ratio, 1 / ratio) > 2; | |
| 44 | 84 | } |
| 45 | 85 | |
| 46 | 86 | /** Busy at or over the line with something waiting: full, and the queue is what that costs. */ |
| @@ -97,9 +137,35 @@ export function slotLine(kind: SlotLine["kind"], slots: number, runs: readonly R | ||
| 97 | 137 | oldestAt: waitingNow.reduce<string | null>((o, r) => (o === null || r.created_at < o ? r.created_at : o), null), |
| 98 | 138 | medianWaitMs: mid, |
| 99 | 139 | points, |
| 140 | medianRunMs: median(runs.filter((r) => r.started_at !== null && r.finished_at !== null).map((r) => t(r.finished_at) - t(r.started_at!))), | |
| 100 | 141 | }; |
| 101 | 142 | } |
| 102 | 143 | |
| 144 | /** | |
| 145 | * The median wait, asked to started, of what started after `at`: what a change's estimate is | |
| 146 | * checked by. | |
| 147 | */ | |
| 148 | function waitedSince(runs: readonly Row[], at: string): number | null { | |
| 149 | return median(runs.filter((r) => r.started_at !== null && r.started_at > at).map((r) => Date.parse(r.started_at!) - Date.parse(r.created_at))); | |
| 150 | } | |
| 151 | ||
| 152 | /** | |
| 153 | * The newest change of each setting that was made on an estimate, one row per setting (SQLite takes | |
| 154 | * the bare columns from the row with MAX(at)): one statement. | |
| 155 | */ | |
| 156 | function lastEstimates(db: Database): Map<string, { at: string; slots: number; ms: number }> { | |
| 157 | const out = new Map<string, { at: string; slots: number; ms: number }>(); | |
| 158 | for (const c of db | |
| 159 | .query<{ key: string; at: string; reason: string }, []>( | |
| 160 | "SELECT key, MAX(at) AS at, reason FROM forge_setting_change WHERE key IN ('checks.concurrency', 'crew.concurrency') AND reason LIKE 'Estimate:%' GROUP BY key", | |
| 161 | ) | |
| 162 | .all()) { | |
| 163 | const e = estimateOf(c.reason); | |
| 164 | if (e !== undefined) out.set(c.key, { at: c.at, ...e }); | |
| 165 | } | |
| 166 | return out; | |
| 167 | } | |
| 168 | ||
| 103 | 169 | /** The setting as a count: what is in force now, so the line moves the moment it is changed. */ |
| 104 | 170 | const slotsOf = (v: string): number => Math.max(1, Number(v) || 1); |
| 105 | 171 | |
| @@ -123,16 +189,24 @@ function paceOf(app: App, now: Date): { slots: number; reason: string } | undefi | ||
| 123 | 189 | } |
| 124 | 190 | |
| 125 | 191 | /** |
| 126 | * Checks, then the crew: their lines at `now`. Two statements (the settings, the runs) and the | |
| 127 | * crew's pace, which is kept a minute. | |
| 192 | * Checks, then the crew: their lines at `now`, each with the last estimate it was changed on and | |
| 193 | * what happened since. Three statements (the settings, the runs, the estimates), and the crew's | |
| 194 | * pace, kept a minute, unless `pace` is false (home, which draws no pace). | |
| 128 | 195 | */ |
| 129 | export function readSlots(app: App, now: Date = new Date()): SlotLine[] { | |
| 196 | export function readSlots(app: App, now: Date = new Date(), o: { readonly pace?: boolean } = {}): SlotLine[] { | |
| 130 | 197 | const since = new Date(now.getTime() - SLOT_POINTS * STEP_MS).toISOString(); |
| 131 | 198 | const set = capacityValues(app.db, ["checks.concurrency", "crew.concurrency"] as const); |
| 132 | 199 | const runs = rows(app.db, since); |
| 133 | const checks = slotLine("checks", slotsOf(set["checks.concurrency"]), runs.filter((r) => r.kind === "check"), now.getTime()); | |
| 200 | const said = lastEstimates(app.db); | |
| 201 | const line = (kind: SlotLine["kind"], mine: readonly Row[]): SlotLine => { | |
| 202 | const l = slotLine(kind, slotsOf(set[KEY[kind]]), mine, now.getTime()); | |
| 203 | const e = said.get(KEY[kind]); | |
| 204 | return e === undefined ? l : { ...l, lastEstimate: { at: e.at, slots: e.slots, saidMs: e.ms, actualMs: waitedSince(mine, e.at) } }; | |
| 205 | }; | |
| 206 | const checks = line("checks", runs.filter((r) => r.kind === "check")); | |
| 134 | 207 | const crewSlots = slotsOf(set["crew.concurrency"]); |
| 135 | const crew = slotLine("crew", crewSlots, runs.filter((r) => r.kind === "agent"), now.getTime()); | |
| 208 | const crew = line("crew", runs.filter((r) => r.kind === "agent")); | |
| 209 | if (o.pace === false) return [checks, crew]; | |
| 136 | 210 | const paced = paceOf(app, now); |
| 137 | 211 | const allows = paced === undefined ? crewSlots : Math.min(crewSlots, paced.slots); |
| 138 | 212 | return [checks, allows < crewSlots && paced !== undefined && paced.reason !== "" ? { ...crew, pace: { allows, why: paced.reason } } : crew]; |
src/web/bridge_client.ts added +211
| @@ -0,0 +1,211 @@ | ||
| 1 | /** | |
| 2 | * The bridge (the owner: "i could rip a crew member off a terminal and fire the guns myself"): on | |
| 3 | * home's lanes, the tile or figure a person is on has its verbs in one bar under the lanes, each a | |
| 4 | * key. The selection is the shell's own: `j`/`k` move between tiles and figures (they are | |
| 5 | * `data-nav` rows), a tap or a focus selects; Escape or focus elsewhere clears. Every verb is an | |
| 6 | * action that already exists at its own page, so with no script each tile is still a link to where | |
| 7 | * they are. | |
| 8 | * | |
| 9 | * A run (building, checks, review): `w` watches it live (its page), `h` takes the wheel (its page | |
| 10 | * at the steer box, where words reach the running agent; steering from the bar itself, and a live | |
| 11 | * terminal of the run, come later), `s` stops it and `r` queues it again. | |
| 12 | * | |
| 13 | * An issue: `a` assigns it (its page's assignee field), `e` sharpens it (the planner plans it | |
| 14 | * again), `p` parks it (behind the Later gate). | |
| 15 | * | |
| 16 | * A pull: `m` merges it, the one verb that asks for a second `m`, because a merge is not undone; | |
| 17 | * `x` closes it, `u` brings it up to date (its update route), `b` sends it back (its review box: | |
| 18 | * a send-back needs words). | |
| 19 | * | |
| 20 | * A slots figure (an admin's): `-` and `+` turn the setting, Enter sets it with its estimate (a new | |
| 21 | * run's wait at that setting, said as an estimate) kept with the change, `z` puts it back; the | |
| 22 | * figure says how the last estimate held up, and when it was more than twice off. | |
| 23 | * | |
| 24 | * Stop, queue again, close, sharpen, park and merge go through home's one action route (`POST | |
| 25 | * /home/act`, `home_table.ts`): applied at once, answered with what was done and the receipt, where | |
| 26 | * Undo is. The bar's keys are `data-shortcut` buttons that exist only while something is selected, | |
| 27 | * so the shell clicks them, `?` lists them, and no key is taken from a page without a selection | |
| 28 | * (`t` stays Tell the crew). A swapped lane keeps the selection: the tile with the same key is | |
| 29 | * selected again. The bar has no motion: it is what a person does many times a day. | |
| 30 | */ | |
| 31 | import { html } from "./html.ts"; | |
| 32 | ||
| 33 | /** The bar's one place on home: empty until a tile is selected. */ | |
| 34 | export const bridgeBar = html`<div class="br-bar" id="bridge" role="region" aria-label="What you can do to the selected tile" hidden><div class="br-body" data-body></div><p class="br-said small" data-said aria-live="polite"></p></div>`; | |
| 35 | ||
| 36 | export const bridgeJs = /* js */ ` | |
| 37 | (function () { | |
| 38 | var bar = document.getElementById('bridge'); | |
| 39 | if (!bar) return; | |
| 40 | // What a verb did is said in the bar's one live region, which is on the page from the start, so a | |
| 41 | // screen reader announces each answer; the rest of the bar is drawn into its body. | |
| 42 | var body = bar.querySelector('[data-body]'), said = bar.querySelector('[data-said]'); | |
| 43 | var D = document, sel = null, armed = 0; | |
| 44 | var coarse = window.matchMedia && window.matchMedia('(pointer: coarse)').matches; | |
| 45 | var LANE = { asked: 'Asked', building: 'Building', checks: 'Checks', review: 'Review', landing: 'Landing', live: 'Live' }; | |
| 46 | function tileOf(el) { return el && el.closest ? el.closest('.tile[data-key], .sl[data-nav]') : null; } | |
| 47 | function keyOf(t) { return t.classList.contains('sl') ? 'slots:' + t.getAttribute('data-kind') : t.getAttribute('data-key'); } | |
| 48 | // The forge's own way to say a span (flow/pipeline.ts span): 45s, 12m, 3h 5m, 2d 4h. | |
| 49 | function span(ms) { | |
| 50 | var s = Math.max(0, Math.round(ms / 1000)); if (s < 60) return s + 's'; | |
| 51 | var m = Math.floor(s / 60); if (m < 60) return m + 'm'; | |
| 52 | var h = Math.floor(m / 60); if (h < 48) return m % 60 === 0 ? h + 'h' : h + 'h ' + (m % 60) + 'm'; | |
| 53 | return Math.floor(h / 24) + 'd ' + (h % 24) + 'h'; | |
| 54 | } | |
| 55 | function el(tag, cls, text) { var e = D.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; } | |
| 56 | function verb(k, label, act) { | |
| 57 | var b = el(act.href ? 'a' : 'button', 'btn', null); | |
| 58 | if (act.href) b.href = act.href; else b.type = 'button'; | |
| 59 | b.setAttribute('data-size', 'sm'); | |
| 60 | b.setAttribute('data-shortcut', k); | |
| 61 | b.appendChild(el('kbd', null, k)); b.appendChild(D.createTextNode(' ' + label)); | |
| 62 | if (act.run) b.addEventListener('click', function (e) { e.preventDefault(); act.run(b); }); | |
| 63 | return b; | |
| 64 | } | |
| 65 | function say(text, extra) { | |
| 66 | said.textContent = text; | |
| 67 | if (extra) { said.appendChild(D.createTextNode(' ')); said.appendChild(extra); } | |
| 68 | } | |
| 69 | function act(op, ids, then) { | |
| 70 | var body = new URLSearchParams(); | |
| 71 | body.set('op', op); body.set('phase', 'apply'); | |
| 72 | ids.forEach(function (id) { body.append('ids', id); }); | |
| 73 | say('Doing it…'); | |
| 74 | fetch('/home/act', { method: 'POST', body: body, credentials: 'same-origin', headers: { accept: 'application/json' } }) | |
| 75 | .then(function (r) { return r.json().catch(function () { return { ok: false, error: 'That did not go through (' + r.status + ').' }; }); }) | |
| 76 | .then(function (j) { | |
| 77 | if (!j.ok) { say(j.error || 'That did not go through. Nothing changed.'); return; } | |
| 78 | var a = null; | |
| 79 | if (j.receipt) { a = el('a', null, j.reversible ? 'Receipt and Undo' : 'Receipt'); a.href = j.receipt; } | |
| 80 | say(j.summary || 'Done.', a); | |
| 81 | if (then) then(); | |
| 82 | }) | |
| 83 | .catch(function () { say('Could not reach the forge. Nothing changed.'); }); | |
| 84 | } | |
| 85 | // A verb with a route of its own (Update): the form it already is, posted from here. | |
| 86 | function post(url, done) { | |
| 87 | say('Doing it…'); | |
| 88 | fetch(url, { method: 'POST', body: new URLSearchParams(), credentials: 'same-origin', headers: { accept: 'application/json' } }) | |
| 89 | .then(function (r) { return r.json().catch(function () { return {}; }).then(function (j) { say(r.ok && j.ok !== false ? (j.flash || done) : (j.error || 'That did not go through (' + r.status + '). Nothing changed.')); }); }) | |
| 90 | .catch(function () { say('Could not reach the forge. Nothing changed.'); }); | |
| 91 | } | |
| 92 | function verbsFor(t) { | |
| 93 | var d = t.dataset, out = [], base = '/' + d.repo; | |
| 94 | if (d.run) { | |
| 95 | out.push(verb('w', 'Watch live', { href: base + '/runs/' + d.run })); | |
| 96 | out.push(verb('h', 'Take the wheel', { href: base + '/runs/' + d.run + '#run-steer' })); | |
| 97 | out.push(verb('s', 'Stop', { run: function () { | |
| 98 | act('stop', [d.run], function () { | |
| 99 | var again = verb('r', 'Queue it again', { run: function () { act('requeue', [d.run]); } }); | |
| 100 | bar.querySelector('[data-verbs]').appendChild(again); | |
| 101 | }); | |
| 102 | } })); | |
| 103 | } | |
| 104 | if (d.kind === 'issue' && d.number && d.issue) { | |
| 105 | out.push(verb('a', 'Assign', { href: base + '/issues/' + d.number + '#f-assignee' })); | |
| 106 | out.push(verb('e', 'Sharpen', { run: function () { act('replan', [d.issue]); } })); | |
| 107 | out.push(verb('p', 'Park', { run: function () { act('later', [d.issue]); } })); | |
| 108 | } | |
| 109 | if (d.kind === 'pull' && d.number && d.issue) { | |
| 110 | out.push(verb('m', 'Merge', { run: function (b) { | |
| 111 | if (Date.now() - armed < 5000) { armed = 0; act('ship', [d.issue]); return; } | |
| 112 | armed = Date.now(); | |
| 113 | say('Press m again to merge #' + d.number + ': a merge is not undone.'); | |
| 114 | } })); | |
| 115 | out.push(verb('x', 'Close', { run: function () { act('close', [d.issue]); } })); | |
| 116 | out.push(verb('u', 'Update', { run: function () { post(base + '/pulls/' + d.number + '/update', 'Asked the crew to bring #' + d.number + ' up to date.'); } })); | |
| 117 | out.push(verb('b', 'Send back', { href: base + '/pulls/' + d.number + '#review' })); | |
| 118 | } | |
| 119 | return out; | |
| 120 | } | |
| 121 | // A figure (a slots line): its setting, turned here, with the estimate said before and recorded with | |
| 122 | // the change after, so what was promised can be held to what happens (flow/slots.ts estimateOf). | |
| 123 | var WORD = { checks: 'check', crew: 'crew run' }, NAME = { checks: 'Checks', crew: 'Crew runs' }, KEY = { checks: 'checks.concurrency', crew: 'crew.concurrency' }; | |
| 124 | function figure(t) { | |
| 125 | var d = t.dataset, kind = d.kind, from = Number(d.slots), n = from; | |
| 126 | var run = d.runMs === '' ? null : Number(d.runMs), waiting = Number(d.waiting); | |
| 127 | function est(k) { return run === null ? null : Math.round(waiting * run / k); } | |
| 128 | var head = el('p', 'br-head', null), verbs = el('div', 'br-verbs', null); | |
| 129 | verbs.setAttribute('data-verbs', ''); | |
| 130 | var line = el('p', 'br-said small', ''); | |
| 131 | function show() { | |
| 132 | head.replaceChildren(el('strong', null, NAME[kind] + ' slots'), D.createTextNode(' ' + from + (n === from ? '' : ' → ' + n))); | |
| 133 | var e = est(n), now = est(from); | |
| 134 | line.textContent = e === null ? 'No ' + WORD[kind] + ' has finished in 24 hours, so there is no estimate yet.' | |
| 135 | : 'Estimate: a new ' + WORD[kind] + ' would wait about ' + span(e) + ' with ' + n + ' slots (' + span(now) + ' now). ' + (kind === 'checks' ? 'Checks cost nothing extra.' : 'More crew runs at once use the week faster.') + (d.off === '1' ? ' The last estimate was more than twice off, so take this one as rough.' : ''); | |
| 136 | } | |
| 137 | verbs.appendChild(verb('-', 'Fewer', { run: function () { if (n > 1) { n--; show(); } } })); | |
| 138 | verbs.appendChild(verb('+', 'More', { run: function () { if (n < 64) { n++; show(); } } })); | |
| 139 | verbs.appendChild(verb('Enter', 'Set', { run: function () { | |
| 140 | if (n === from) { say('Nothing to change.'); return; } | |
| 141 | var e = est(n), form = new URLSearchParams(); | |
| 142 | form.set('key', KEY[kind]); form.set('value', String(n)); | |
| 143 | if (e !== null) form.set('reason', 'Estimate: a new ' + WORD[kind] + ' waits ~' + span(e) + ' at ' + n + ' slots (' + Math.round(e / 1000) + ' s).'); | |
| 144 | var was = from; | |
| 145 | say('Setting it…'); | |
| 146 | fetch('/settings/capacity', { method: 'POST', body: form, credentials: 'same-origin', headers: { accept: 'application/json' } }) | |
| 147 | .then(function (r) { return r.json().catch(function () { return { ok: false, flash: 'That did not go through (' + r.status + '). Nothing changed.' }; }); }) | |
| 148 | .then(function (j) { | |
| 149 | if (!j.ok) { say(j.flash || 'That did not go through. Nothing changed.'); return; } | |
| 150 | from = n; d.slots = String(n); show(); | |
| 151 | var undo = verb('z', 'Undo', { run: function () { | |
| 152 | var back = new URLSearchParams(); back.set('key', KEY[kind]); back.set('value', String(was)); back.set('reason', 'Undone from home.'); | |
| 153 | fetch('/settings/capacity', { method: 'POST', body: back, credentials: 'same-origin', headers: { accept: 'application/json' } }) | |
| 154 | .then(function (r2) { return r2.json().catch(function () { return { ok: false }; }); }) | |
| 155 | .then(function (j2) { if (j2.ok) { from = n = was; d.slots = String(was); show(); say('Put back to ' + was + ' slots.'); } else say(j2.flash || 'That did not go through. It stays at ' + from + '.'); }); | |
| 156 | } }); | |
| 157 | verbs.appendChild(undo); | |
| 158 | say(NAME[kind] + ' slots ' + was + ' → ' + n + ': from the next run on. The estimate is kept with the change, to be checked against what happens.'); | |
| 159 | }) | |
| 160 | .catch(function () { say('Could not reach the forge. Nothing changed.'); }); | |
| 161 | } })); | |
| 162 | show(); | |
| 163 | body.replaceChildren(head, line, verbs); said.textContent = ''; | |
| 164 | bar.hidden = false; | |
| 165 | } | |
| 166 | function draw(t) { | |
| 167 | if (t.classList.contains('sl')) { figure(t); return; } | |
| 168 | var d = t.dataset; | |
| 169 | var head = el('p', 'br-head', null); | |
| 170 | head.appendChild(el('strong', null, d.repo + (d.number ? ' #' + d.number : ''))); | |
| 171 | head.appendChild(D.createTextNode(' · ' + (LANE[d.lane] || d.lane))); | |
| 172 | var verbs = el('div', 'br-verbs', null); | |
| 173 | verbs.setAttribute('data-verbs', ''); | |
| 174 | var list = verbsFor(t); | |
| 175 | if (list.length === 0) verbs.appendChild(el('span', 'muted small', 'Nothing to do from here: open it with Enter.')); | |
| 176 | list.forEach(function (b) { verbs.appendChild(b); }); | |
| 177 | body.replaceChildren(head, verbs); said.textContent = ''; | |
| 178 | bar.hidden = false; | |
| 179 | } | |
| 180 | function select(t) { | |
| 181 | if (!t) return; | |
| 182 | if (sel !== keyOf(t)) { armed = 0; sel = keyOf(t); draw(t); } | |
| 183 | D.querySelectorAll('[data-selected]').forEach(function (x) { if (x !== t) x.removeAttribute('data-selected'); }); | |
| 184 | t.setAttribute('data-selected', ''); | |
| 185 | } | |
| 186 | function clear() { | |
| 187 | sel = null; armed = 0; bar.hidden = true; body.replaceChildren(); said.textContent = ''; | |
| 188 | D.querySelectorAll('[data-selected]').forEach(function (x) { x.removeAttribute('data-selected'); }); | |
| 189 | } | |
| 190 | D.addEventListener('focusin', function (e) { | |
| 191 | var t = tileOf(e.target); | |
| 192 | if (t) select(t); | |
| 193 | else if (sel && !bar.contains(e.target)) clear(); | |
| 194 | }); | |
| 195 | // On a phone the first tap selects and the second opens: the bar is where a thumb is. | |
| 196 | D.addEventListener('click', function (e) { | |
| 197 | var t = tileOf(e.target); | |
| 198 | if (!t || !coarse || e.metaKey || e.ctrlKey) return; | |
| 199 | if (sel !== keyOf(t)) { e.preventDefault(); select(t); } | |
| 200 | }, true); | |
| 201 | D.addEventListener('keydown', function (e) { if (e.key === 'Escape' && sel && !e.defaultPrevented) clear(); }); | |
| 202 | // A lane swapped by the live stream keeps the selection: the tile with the same key, wherever it moved. | |
| 203 | new MutationObserver(function () { | |
| 204 | if (!sel || sel.indexOf('slots:') === 0) return; | |
| 205 | var t = D.querySelector('.tile[data-key="' + (window.CSS && CSS.escape ? CSS.escape(sel) : sel) + '"]'); | |
| 206 | if (!t) { clear(); return; } | |
| 207 | t.setAttribute('data-selected', ''); | |
| 208 | if (!D.activeElement || D.activeElement === D.body) { var a = t.querySelector('a'); if (a) a.focus({ preventScroll: true }); } | |
| 209 | }).observe(D.querySelector('.hf-lanes') || D.body, { childList: true, subtree: true }); | |
| 210 | })(); | |
| 211 | `; |
src/web/flow_slots.ts +20 −6
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | import { html, type Html } from "./html.ts"; |
| 10 | 10 | import { badge } from "./ui.ts"; |
| 11 | 11 | import { span } from "../flow/pipeline.ts"; |
| 12 | import { isFull, SLOT_POINTS, type SlotLine } from "../flow/slots.ts"; | |
| 12 | import { isFull, offByMore, SLOT_POINTS, waitEstimate, type SlotLine } from "../flow/slots.ts"; | |
| 13 | 13 | |
| 14 | 14 | const NAME: Readonly<Record<SlotLine["kind"], string>> = { checks: "Checks", crew: "Crew runs" }; |
| 15 | 15 | const H = 32; |
| @@ -54,10 +54,21 @@ function chart(l: SlotLine): Html { | ||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | * One kind's line: the headline figure, what waits, the pace when it holds the crew back, the | |
| 58 | * picture. | |
| 57 | * The last change's estimate against what happened since, in one line, so a promise is checked in | |
| 58 | * the open; more than twice off either way says so. | |
| 59 | 59 | */ |
| 60 | function line(l: SlotLine, now: number): Html { | |
| 60 | function kept(l: SlotLine): Html | null { | |
| 61 | const e = l.lastEstimate; | |
| 62 | if (e === undefined) return null; | |
| 63 | const since = e.actualMs === null ? "nothing has started since" : `since then a new one waited ~${span(e.actualMs)}`; | |
| 64 | return html`<p class="sl-say small" data-estimate ${offByMore(e) ? html`data-off` : null}>Last change's estimate: ~${span(e.saidMs)} at ${String(e.slots)} slots; ${since}${offByMore(e) ? ", more than twice off: take the next estimate as rough" : ""}.</p>`; | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * One kind's line. For an admin it is also a figure the bridge can select (`bridge_client.ts`): | |
| 69 | * what waits, the median run, and the wait estimated at today's setting ride on it as data. | |
| 70 | */ | |
| 71 | function line(l: SlotLine, now: number, admin = false): Html { | |
| 61 | 72 | const full = isFull(l); |
| 62 | 73 | // What waits, the median wait and the pace, each only when there is one: a free lane is its |
| 63 | 74 | // count. |
| @@ -66,7 +77,9 @@ function line(l: SlotLine, now: number): Html { | ||
| 66 | 77 | ...(l.medianWaitMs === null ? [] : [`median wait ${span(l.medianWaitMs)} (last hour)`]), |
| 67 | 78 | ...(l.pace === undefined ? [] : [html`<span data-pace="${String(l.pace.allows)}">pace allows ${String(l.pace.allows)}: ${l.pace.why}</span>`]), |
| 68 | 79 | ]; |
| 69 | return html`<div class="sl" data-kind="${l.kind}" ${full ? html`data-full` : null}> | |
| 80 | const est = waitEstimate(l, l.slots); | |
| 81 | const pick = admin ? html` tabindex="0" role="group" aria-label="${NAME[l.kind]} slots, ${String(l.slots)}" data-nav data-slots="${String(l.slots)}" data-waiting="${String(l.waiting)}" data-run-ms="${l.medianRunMs === null ? "" : String(Math.round(l.medianRunMs))}" data-wait-ms="${est === null ? "" : String(est)}" data-off="${l.lastEstimate !== undefined && offByMore(l.lastEstimate) ? "1" : ""}"` : null; | |
| 82 | return html`<div class="sl" data-kind="${l.kind}" ${full ? html`data-full` : null}${pick}> | |
| 70 | 83 | <p class="sl-head"> |
| 71 | 84 | <strong>${NAME[l.kind]}</strong> |
| 72 | 85 | <span class="sl-used" data-busy="${String(l.busy)}" data-slots="${String(l.slots)}" |
| @@ -74,6 +87,7 @@ function line(l: SlotLine, now: number): Html { | ||
| 74 | 87 | >${full ? html` ${badge("full", { tone: "danger" })}` : null} |
| 75 | 88 | ${says.length === 0 ? null : html`<span class="sl-say small">${says.map((s, i) => html`${i === 0 ? "" : " · "}${s}`)}</span>`} |
| 76 | 89 | </p> |
| 90 | ${kept(l)} | |
| 77 | 91 | ${chart(l)} |
| 78 | 92 | </div>`; |
| 79 | 93 | } |
| @@ -84,7 +98,7 @@ function line(l: SlotLine, now: number): Html { | ||
| 84 | 98 | */ |
| 85 | 99 | export function slotsBlock(lines: readonly SlotLine[], now: number, admin: boolean): Html { |
| 86 | 100 | return html`<div class="sl-block" id="slots" aria-label="Slots against what fills them"> |
| 87 | ${lines.map((l) => line(l, now))} | |
| 101 | ${lines.map((l) => line(l, now, admin))} | |
| 88 | 102 | ${admin |
| 89 | 103 | ? html`<p class="sl-foot small"> |
| 90 | 104 | <a class="btn" data-size="sm" href="/settings/capacity">Change capacity</a> |
src/web/pages/capacity.ts +13 −3
| @@ -218,6 +218,16 @@ const ERRORS: Record<string, string> = { | ||
| 218 | 218 | }; |
| 219 | 219 | |
| 220 | 220 | // POST /settings/capacity |
| 221 | /** | |
| 222 | * A save's answer: the flash on this page, or, asked for JSON (the bridge's figure on home), the | |
| 223 | * same words with whether it was saved. | |
| 224 | */ | |
| 225 | function answer(ctx: Ctx, f: { readonly message: string; readonly tone?: "danger" }): Response { | |
| 226 | if ((ctx.request.headers.get("accept") ?? "").includes("application/json")) | |
| 227 | return Response.json({ ok: f.tone !== "danger", flash: f.message }, { status: f.tone === "danger" ? 422 : 200, headers: { "cache-control": "no-store" } }); | |
| 228 | return flashTo(ctx, "/settings/capacity", f); | |
| 229 | } | |
| 230 | ||
| 221 | 231 | export async function capacitySet(ctx: Ctx): Promise<Response> { |
| 222 | 232 | const denied = requireAdmin(ctx); |
| 223 | 233 | if (denied) return denied; |
| @@ -260,7 +270,7 @@ export async function capacitySet(ctx: Ctx): Promise<Response> { | ||
| 260 | 270 | const checked = checkCapacity(ctx.app, ctx.auth.user, job.key, job.value, reason); |
| 261 | 271 | if (!checked.ok && checked.error === "not_found") return notFoundPage(ctx); |
| 262 | 272 | if (!checked.ok) |
| 263 | return flashTo(ctx, "/settings/capacity", { | |
| 273 | return answer(ctx, { | |
| 264 | 274 | tone: "danger", |
| 265 | 275 | message: `Nothing saved. ${job.key}: ${ERRORS[checked.error] ?? "That could not be set."}`, |
| 266 | 276 | }); |
| @@ -270,7 +280,7 @@ export async function capacitySet(ctx: Ctx): Promise<Response> { | ||
| 270 | 280 | const changed = changeCapacity(ctx.app, ctx.auth.user, job.key, job.value, reason); |
| 271 | 281 | if (!changed.ok && changed.error === "not_found") return notFoundPage(ctx); |
| 272 | 282 | if (!changed.ok) |
| 273 | return flashTo(ctx, "/settings/capacity", { | |
| 283 | return answer(ctx, { | |
| 274 | 284 | tone: "danger", |
| 275 | 285 | message: `${said.length === 0 ? "" : `Saved ${said.join("; ")}. `}${job.key}: ${ERRORS[changed.error] ?? "That could not be set."}`, |
| 276 | 286 | }); |
| @@ -281,5 +291,5 @@ export async function capacitySet(ctx: Ctx): Promise<Response> { | ||
| 281 | 291 | : `${job.key}: ${from || "auto"} → ${to || "auto"}, ${effectOf(ctx.app, changed.value.key, to === "" ? bootDefault(ctx.app.db, changed.value.key) : to)}, from the next pick on`, |
| 282 | 292 | ); |
| 283 | 293 | } |
| 284 | return flashTo(ctx, "/settings/capacity", { message: `${said.join("; ")}.` }); | |
| 294 | return answer(ctx, { message: `${said.join("; ")}.` }); | |
| 285 | 295 | } |
src/web/pages/home_flow.ts +18 −4
| @@ -51,6 +51,9 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 51 | 51 | import { signInFirst } from "../chrome.ts"; |
| 52 | 52 | import { figure as fig } from "../figure.ts"; |
| 53 | 53 | import { homeFlowJs } from "./home_flow_client.ts"; |
| 54 | import { bridgeBar, bridgeJs } from "../bridge_client.ts"; | |
| 55 | import { slotsBlock } from "../flow_slots.ts"; | |
| 56 | import { readSlots } from "../../flow/slots.ts"; | |
| 54 | 57 | import { behaviorsJs } from "../behaviors.ts"; |
| 55 | 58 | import { liveRegionsJs } from "../client.ts"; |
| 56 | 59 | import { html, type Html } from "../html.ts"; |
| @@ -125,14 +128,20 @@ const TONE_DOT = { | ||
| 125 | 128 | stuck: "danger", |
| 126 | 129 | } as const; |
| 127 | 130 | |
| 128 | function tile(i: LaneView["items"][number], now: number): Html { | |
| 131 | /** The lanes whose tiles are runs: there a tile names its run, for Stop and Watch. */ | |
| 132 | const RUN_LANES: ReadonlySet<LaneKey> = new Set(["building", "checks", "review"]); | |
| 133 | ||
| 134 | function tile(i: LaneView["items"][number], now: number, lane: LaneKey): Html { | |
| 129 | 135 | const no = |
| 130 | 136 | i.number === null |
| 131 | 137 | ? null |
| 132 | 138 | : html` <span class="tile-no">#${String(i.number)}</span>`; |
| 133 | return html`<li class="tile" data-key="${i.key}" data-state="${i.state}"> | |
| 139 | // What the bridge's bar (`bridge_client.ts`) reads to offer this tile's verbs: nothing here acts. | |
| 140 | const run = RUN_LANES.has(lane) ? (i.runId ?? "") : ""; | |
| 141 | return html`<li class="tile" data-key="${i.key}" data-state="${i.state}" data-lane="${lane}" data-kind="${i.kind}" data-repo="${i.repo}" data-number="${i.number === null ? "" : String(i.number)}" data-issue="${i.issueId ?? ""}" data-run="${run}"> | |
| 134 | 142 | <a |
| 135 | 143 | class="tile-link" |
| 144 | data-nav | |
| 136 | 145 | href="${i.href}" |
| 137 | 146 | title="${i.repo}${i.number === null ? "" : ` #${i.number}`}: ${i.title}" |
| 138 | 147 | > |
| @@ -228,7 +237,7 @@ export function laneRegion( | ||
| 228 | 237 | ${shown === 0 |
| 229 | 238 | ? null |
| 230 | 239 | : html`<ol class="lane-list"> |
| 231 | ${view.items.map((i) => tile(i, now))} | |
| 240 | ${view.items.map((i) => tile(i, now, key))} | |
| 232 | 241 | </ol>`} |
| 233 | 242 | ${total <= 4 |
| 234 | 243 | ? null |
| @@ -551,6 +560,9 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 551 | 560 | const after = html`${ctx.url.searchParams.has("all") ? html`<p class="small muted" id="lean-home"><a href="/">Just my apps</a></p>` : null}${focusLine(ctx, user)}${requestsCard(ctx, "home")} |
| 552 | 561 | ${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>`} |
| 553 | 562 | ${startedFromLine(ctx.app.db, ctx.app.config.dataDir, user)}`; |
| 563 | // The slots are a forge admin's: read and drawn for one only, so no one else sees the queue, the | |
| 564 | // estimates, or a figure whose Enter would be refused. | |
| 565 | const slots = view === "lanes" && wide ? slotsBlock(readSlots(ctx.app, new Date(now), { pace: false }), now, wide) : null; | |
| 554 | 566 | const forges = wide ? await timePhaseAsync(ctx.request, "forges", () => forgesRegion(ctx.app, false)) : null; |
| 555 | 567 | let main: Html; |
| 556 | 568 | const q = parseTable(ctx.url.searchParams); |
| @@ -575,18 +587,20 @@ export async function homeFlowPage(ctx: Ctx, known?: { readonly spawned: Awaited | ||
| 575 | 587 | </header> |
| 576 | 588 | ${mine ? askedSection(ctx, user) : null} |
| 577 | 589 | ${main} |
| 590 | ${slots} | |
| 578 | 591 | ${before} |
| 579 | 592 | ${strip} |
| 580 | 593 | ${deskStrip(ctx.app.db, readableNotes(ctx.app, ctx.auth.user))} |
| 581 | 594 | ${after} |
| 582 | 595 | ${wide ? figuresSection(picture, now) : null} |
| 583 | 596 | ${forges} |
| 597 | ${view === "lanes" ? bridgeBar : null} | |
| 584 | 598 | <p class="hf-foot small muted"> |
| 585 | 599 | <span>${view === "table" ? "Every item of every lane, one row each; sort, filter and search are in the address, so a link is a view." : "Each lane is a step a change takes; a tile moves on by itself when its work does."}</span> |
| 586 | 600 | <a href="/feed">The feed</a> |
| 587 | 601 | </p> |
| 588 | 602 | </div>`; |
| 589 | const res = page({ ctx, title: "Home", body, wide: true, scriptJs: `${liveRegionsJs}\n${homeFlowJs}\n${behaviorsJs}` }); | |
| 603 | const res = page({ ctx, title: "Home", body, wide: true, scriptJs: `${liveRegionsJs}\n${homeFlowJs}\n${bridgeJs}\n${behaviorsJs}` }); | |
| 590 | 604 | // The view asked for in the address is remembered for the next visit. |
| 591 | 605 | if (asked) { |
| 592 | 606 | res.headers.append("set-cookie", setCookie(VIEW_COOKIE, view, { maxAge: 31536000, secure: secureFor(ctx.url, ctx.app.config.url) })); |
src/web/pages/home_flow_style.ts +10
| @@ -58,6 +58,16 @@ export const homeFlowCss = /* css */ ` | ||
| 58 | 58 | @media (hover: hover) and (pointer: fine) { .tile:hover { border-color: var(--border-strong); } } |
| 59 | 59 | .tile[data-state="active"] { border-left: 2px solid var(--accent); } |
| 60 | 60 | .tile[data-state="done"] { border-left: 2px solid var(--success); } |
| 61 | /* The bridge (bridge_client.ts): the selected tile, and the bar of its verbs under the lanes. No motion. */ | |
| 62 | .tile[data-selected] { outline: 2px solid var(--accent); outline-offset: 1px; } | |
| 63 | .br-bar { position: sticky; bottom: 0; display: grid; gap: 4px; margin: 12px 0 0; padding: 8px 16px max(8px, env(safe-area-inset-bottom)); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; background: var(--card); box-shadow: var(--shadow-2); } | |
| 64 | .br-bar[hidden] { display: none; } | |
| 65 | .br-body { display: grid; gap: 4px; } | |
| 66 | .br-head, .br-said { margin: 0; } | |
| 67 | .br-said { min-height: 1.25rem; color: var(--muted-fg); } | |
| 68 | .br-verbs { display: flex; flex-wrap: wrap; gap: 8px; } | |
| 69 | .br-verbs .btn { min-height: 44px; gap: 6px; } | |
| 70 | .br-verbs kbd { font-size: var(--fs-min); } | |
| 61 | 71 | .tile-link { display: flex; flex-direction: column; gap: 4px; min-height: 44px; padding: 8px 12px; color: var(--fg); } |
| 62 | 72 | @media (hover: hover) and (pointer: fine) { .tile-link:hover { color: var(--fg); } } |
| 63 | 73 | .tile-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-width: 0; font-size: var(--fs-min); line-height: 16px; } |
src/web/pages/home_table.ts +22 −3
| @@ -67,6 +67,21 @@ export const BULK = { | ||
| 67 | 67 | reason: false, |
| 68 | 68 | hint: "Merges each whose check is green; a merge is not undone.", |
| 69 | 69 | }, |
| 70 | // A run's: the bridge's Stop, and the way back from it (`bridge_client.ts`). | |
| 71 | stop: { | |
| 72 | verb: "cancel", | |
| 73 | label: "Stop", | |
| 74 | kinds: ["run"], | |
| 75 | reason: false, | |
| 76 | hint: "Stops the run; Queue it again starts it over.", | |
| 77 | }, | |
| 78 | requeue: { | |
| 79 | verb: "requeue", | |
| 80 | label: "Queue it again", | |
| 81 | kinds: ["run"], | |
| 82 | reason: false, | |
| 83 | hint: "Starts a stopped crew run over.", | |
| 84 | }, | |
| 70 | 85 | replan: { |
| 71 | 86 | verb: "replan", |
| 72 | 87 | label: "Hand to the planner", |
| @@ -280,7 +295,8 @@ export function tableRegion( | ||
| 280 | 295 | |
| 281 | 296 | /** The search box, and the action bar the page's script shows while rows are picked: nothing in them is live, so a swap never reaches them. */ |
| 282 | 297 | export function tableTools(q: TableQuery): Html { |
| 283 | const actions = Object.entries(BULK).map(([op, a]) => ({ | |
| 298 | // A run's verbs are the bridge's (a tile's run); the table's rows are issues and pulls. | |
| 299 | const actions = Object.entries(BULK).filter(([, a]) => !(a.kinds as readonly string[]).includes("run")).map(([op, a]) => ({ | |
| 284 | 300 | op, |
| 285 | 301 | label: a.label, |
| 286 | 302 | kinds: a.kinds, |
| @@ -357,6 +373,9 @@ export function tableTag( | ||
| 357 | 373 | |
| 358 | 374 | // ---- the action bar's one route ---- |
| 359 | 375 | |
| 376 | /** What the ids of an action name: runs for a run's verb, issues (and pulls) for the rest. */ | |
| 377 | const kindOf = (a: { readonly kinds: readonly string[] }): "run" | "issue" => (a.kinds.includes("run") ? "run" : "issue"); | |
| 378 | ||
| 360 | 379 | const json = (status: number, body: unknown): Response => |
| 361 | 380 | Response.json(body, { |
| 362 | 381 | status, |
| @@ -405,7 +424,7 @@ export async function homeActPost(ctx: Ctx): Promise<Response> { | ||
| 405 | 424 | }; |
| 406 | 425 | const query = `home: ${ids.length} picked`; |
| 407 | 426 | if (field(form, "phase") !== "apply") { |
| 408 | const plan = previewFleetIds(ctx.app, user, "issue", ids, query, verb); | |
| 427 | const plan = previewFleetIds(ctx.app, user, kindOf(action), ids, query, verb); | |
| 409 | 428 | if (!plan.ok) |
| 410 | 429 | return json(plan.error.code === "unauthorized" ? 401 : 422, { |
| 411 | 430 | ok: false, |
| @@ -425,7 +444,7 @@ export async function homeActPost(ctx: Ctx): Promise<Response> { | ||
| 425 | 444 | .map((r) => ({ label: r.label, why: r.reason })), |
| 426 | 445 | }); |
| 427 | 446 | } |
| 428 | const applied = await applyFleetIds(ctx.app, user, "issue", ids, query, verb); | |
| 447 | const applied = await applyFleetIds(ctx.app, user, kindOf(action), ids, query, verb); | |
| 429 | 448 | if (!applied.ok) |
| 430 | 449 | return json(applied.error.code === "unauthorized" ? 401 : 422, { |
| 431 | 450 | ok: false, |
test/bridge.test.ts added +245
| @@ -0,0 +1,245 @@ | ||
| 1 | /** | |
| 2 | * The bridge on home's lanes (`web/bridge_client.ts`): every tile carries what its verbs need and | |
| 3 | * is a `data-nav` row, the bar exists empty, and Stop goes through home's one action route as a | |
| 4 | * run's verb with Queue it again as its way back. In a real Chromium (skipped where none starts, | |
| 5 | * failed in the forge's own check): j selects a tile and the bar offers its verbs as keys; s stops | |
| 6 | * a run at once; m asks for a second m before a merge; Escape clears; a swapped lane keeps the | |
| 7 | * selection; on a phone the first tap selects instead of opening. | |
| 8 | */ | |
| 9 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 10 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 11 | import { tmpdir } from "node:os"; | |
| 12 | import { join } from "node:path"; | |
| 13 | import { createApp, type App } from "../src/app.ts"; | |
| 14 | import { createSession } from "../src/core/sessions.ts"; | |
| 15 | import { findChromium } from "../src/looks/capture.ts"; | |
| 16 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 17 | import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts"; | |
| 18 | import { quietLogs } from "./helpers/globals.ts"; | |
| 19 | import { seedHomeFlow, type HomeFlowSeed } from "./helpers/home-flow-seed.ts"; | |
| 20 | import { setCapacity } from "../src/core/capacity.ts"; | |
| 21 | import { estimateOf, offByMore, readSlots, waitEstimate } from "../src/flow/slots.ts"; | |
| 22 | import { slotsBlock } from "../src/web/flow_slots.ts"; | |
| 23 | import { bridgeJs } from "../src/web/bridge_client.ts"; | |
| 24 | ||
| 25 | quietLogs(); | |
| 26 | const found = findChromium(); | |
| 27 | const chromium = found !== undefined && chromiumRuns(found) ? found : undefined; | |
| 28 | const skip = chromium === undefined && (process.env["FORGE_CHECK"] ?? "") === ""; | |
| 29 | if (skip) console.log("SKIPPING: no chromium that starts on this machine, so the bridge's keys are not driven"); | |
| 30 | ||
| 31 | let dir: string; | |
| 32 | let app: App; | |
| 33 | let servers: Servers; | |
| 34 | let seed: HomeFlowSeed; | |
| 35 | let token = ""; | |
| 36 | ||
| 37 | beforeAll(async () => { | |
| 38 | dir = await mkdtemp(join(tmpdir(), "forge-bridge-")); | |
| 39 | app = createApp({ dataDir: dir, port: 0 }); | |
| 40 | seed = await seedHomeFlow(app); | |
| 41 | servers = await serve(app); | |
| 42 | token = createSession(app.db, seed.owner.id).token; | |
| 43 | }, 30_000); | |
| 44 | afterAll(async () => { | |
| 45 | servers.stop(); | |
| 46 | app.close(); | |
| 47 | await rm(dir, { recursive: true, force: true }); | |
| 48 | }); | |
| 49 | ||
| 50 | const lanes = () => fetch(`${servers.url}/?view=lanes`, { headers: { cookie: `forge_session=${token}` } }).then((r) => r.text()); | |
| 51 | const act = (op: string, id: string) => | |
| 52 | fetch(`${servers.url}/home/act`, { method: "POST", body: new URLSearchParams({ op, phase: "apply", ids: id }), headers: { cookie: `forge_session=${token}`, origin: servers.url, accept: "application/json" } }).then((r) => r.json() as Promise<{ ok: boolean; summary?: string; error?: string }>); | |
| 53 | const tiles = (page: string) => [...page.matchAll(/<li class="tile"([^>]*)>/g)].map((m) => Object.fromEntries([...m[1]!.matchAll(/data-([a-z]+)="([^"]*)"/g)].map((a) => [a[1]!, a[2]!]))); | |
| 54 | ||
| 55 | test("each tile says what its verbs need, its link is a row j and k move to, and the bar waits empty", async () => { | |
| 56 | const page = await lanes(); | |
| 57 | // Empty until a tile is chosen, but its live region is there from the start, so answers are | |
| 58 | // announced. | |
| 59 | expect(page).toContain('<div class="br-bar" id="bridge" role="region" aria-label="What you can do to the selected tile" hidden><div class="br-body" data-body></div><p class="br-said small" data-said aria-live="polite"></p></div>'); | |
| 60 | const all = tiles(page); | |
| 61 | expect(all.length).toBeGreaterThan(0); | |
| 62 | for (const t of all) { | |
| 63 | expect(Object.keys(t)).toEqual(expect.arrayContaining(["key", "lane", "kind", "repo", "issue", "run"])); | |
| 64 | // A run's lanes name the run; the others name none. | |
| 65 | expect(t["run"] === "").toBe(!["building", "checks", "review"].includes(t["lane"]!)); | |
| 66 | } | |
| 67 | expect(page).toMatch(/class="tile-link"\s+data-nav/); | |
| 68 | }); | |
| 69 | ||
| 70 | test("Stop is a run's verb on home's one route, and Queue it again is its way back", async () => { | |
| 71 | const building = tiles(await lanes()).find((t) => t["lane"] === "building" && t["run"] !== "")!; | |
| 72 | const stopped = await act("stop", building["run"]!); | |
| 73 | expect(stopped.ok).toBe(true); | |
| 74 | expect(stopped.summary).toContain("Stop: 1 done"); | |
| 75 | expect(app.db.query<{ state: string }, [string]>("SELECT state FROM run WHERE id = ?1").get(building["run"]!)?.state).toBe("cancelled"); | |
| 76 | // The route takes a run's way back too; the seed's run has no agent left to take it, which it | |
| 77 | // says. | |
| 78 | const again = await act("requeue", building["run"]!); | |
| 79 | expect(again.ok).toBe(true); | |
| 80 | expect(again.summary).toMatch(/^Queue it again: /); | |
| 81 | }); | |
| 82 | ||
| 83 | const inPage = (width: number, expression: string) => | |
| 84 | evaluateLoaded(chromium!, `${servers.url}/?view=lanes`, { width, height: 900 }, [{ name: "forge_session", value: token }], expression, "light", width < 500).then((v) => JSON.parse(v)); | |
| 85 | const WAIT = "const wait = (f, ms = 2000) => new Promise((ok) => { const t0 = performance.now(); const t = setInterval(() => { if (f() || performance.now() - t0 > ms) { clearInterval(t); ok(); } }, 25); });"; | |
| 86 | const KEY = "const key = (k) => document.dispatchEvent(new KeyboardEvent('keydown', { key: k, bubbles: true, cancelable: true }));"; | |
| 87 | // A headless page has no window focus: the focus a key gives is sent as the browser would. | |
| 88 | const PICK = "const pick = (t) => { const a = t.querySelector('a'); a.focus(); a.dispatchEvent(new FocusEvent('focusin', { bubbles: true })); };"; | |
| 89 | ||
| 90 | test.skipIf(skip)("keys: j selects and the bar offers the tile's verbs; m asks again before a merge; s stops at once; Escape clears; a swapped lane keeps the selection", async () => { | |
| 91 | if (chromium === undefined) throw new Error("no Chromium starts in this check, so the bridge is not driven: the check's image must carry one (FORGE_CHROMIUM)"); | |
| 92 | const s = await inPage(1280, `(async () => { | |
| 93 | ${WAIT} ${KEY} ${PICK} | |
| 94 | await wait(() => document.querySelector('.tile[data-key]')); | |
| 95 | const bar = document.getElementById('bridge'); | |
| 96 | const out = {}; | |
| 97 | const run = document.querySelector('.tile[data-lane="building"][data-run]:not([data-run=""])'); | |
| 98 | pick(run); | |
| 99 | out.runBar = !bar.hidden; | |
| 100 | out.runVerbs = [...bar.querySelectorAll('[data-shortcut]')].map((b) => b.getAttribute('data-shortcut') + ' ' + b.textContent.trim().replace(/^\\S+\\s+/, '')); | |
| 101 | out.selected = run.hasAttribute('data-selected'); | |
| 102 | key('s'); | |
| 103 | await wait(() => (bar.querySelector('[data-said]')?.textContent ?? '').startsWith('Stop')); | |
| 104 | out.stopped = bar.querySelector('[data-said]').textContent; | |
| 105 | out.again = !!bar.querySelector('[data-shortcut="r"]'); | |
| 106 | const pull = document.querySelector('.tile[data-kind="pull"]'); | |
| 107 | pick(pull); | |
| 108 | out.pullVerbs = [...bar.querySelectorAll('[data-shortcut]')].map((b) => b.getAttribute('data-shortcut')); | |
| 109 | key('m'); | |
| 110 | out.armed = bar.querySelector('[data-said]').textContent; | |
| 111 | key('m'); | |
| 112 | await wait(() => !(bar.querySelector('[data-said]')?.textContent ?? '').startsWith('Press m')); | |
| 113 | out.merged = bar.querySelector('[data-said]').textContent; | |
| 114 | // A live swap of the pull's lane: the same key is selected again. | |
| 115 | const list = pull.closest('ol'); | |
| 116 | list.innerHTML = list.innerHTML; | |
| 117 | await wait(() => document.querySelector('.tile[data-key="' + pull.getAttribute('data-key') + '"][data-selected]')); | |
| 118 | out.kept = !!document.querySelector('.tile[data-key="' + pull.getAttribute('data-key') + '"][data-selected]'); | |
| 119 | key('Escape'); | |
| 120 | out.cleared = bar.hidden && !document.querySelector('.tile[data-selected]'); | |
| 121 | return JSON.stringify(out); | |
| 122 | })()`); | |
| 123 | const seen = JSON.stringify(s); | |
| 124 | expect(s.runBar, seen).toBe(true); | |
| 125 | expect(s.selected, seen).toBe(true); | |
| 126 | expect(s.runVerbs, seen).toEqual(expect.arrayContaining(["w Watch live", "h Take the wheel", "s Stop"])); | |
| 127 | expect(s.stopped, seen).toContain("Stop: 1 done"); | |
| 128 | expect(s.again, seen).toBe(true); | |
| 129 | expect(s.pullVerbs, seen).toEqual(expect.arrayContaining(["m", "x", "u", "b"])); | |
| 130 | expect(s.armed, seen).toContain("Press m again to merge"); | |
| 131 | expect(s.armed, seen).toContain("a merge is not undone"); | |
| 132 | expect(s.merged, seen).not.toContain("Press m again"); | |
| 133 | expect(s.kept, seen).toBe(true); | |
| 134 | expect(s.cleared, seen).toBe(true); | |
| 135 | }, 30_000); | |
| 136 | ||
| 137 | test.skipIf(skip)("on a phone the first tap selects and the bar docks at the foot; the second tap opens", async () => { | |
| 138 | if (chromium === undefined) throw new Error("no Chromium starts in this check, so the bridge is not driven: the check's image must carry one (FORGE_CHROMIUM)"); | |
| 139 | const s = await inPage(390, `(async () => { | |
| 140 | ${WAIT} | |
| 141 | await wait(() => document.querySelector('.tile[data-key] a')); | |
| 142 | const a = document.querySelector('.tile[data-key] a'); | |
| 143 | const tap = new MouseEvent('click', { bubbles: true, cancelable: true }); | |
| 144 | a.dispatchEvent(tap); | |
| 145 | const bar = document.getElementById('bridge'); | |
| 146 | const box = bar.getBoundingClientRect(); | |
| 147 | return JSON.stringify({ held: tap.defaultPrevented, shown: !bar.hidden, position: getComputedStyle(bar).position, sw: document.documentElement.scrollWidth, minH: Math.min(...[...bar.querySelectorAll('.btn')].map((b) => b.getBoundingClientRect().height)) }); | |
| 148 | })()`); | |
| 149 | const seen = JSON.stringify(s); | |
| 150 | expect(s.held, seen).toBe(true); | |
| 151 | expect(s.shown, seen).toBe(true); | |
| 152 | expect(s.position, seen).toBe("sticky"); | |
| 153 | expect(s.sw, seen).toBeLessThanOrEqual(390); | |
| 154 | if (Number.isFinite(s.minH)) expect(s.minH, seen).toBeGreaterThanOrEqual(44); | |
| 155 | }, 30_000); | |
| 156 | ||
| 157 | test("an estimate is a plain model, said with the figure it can be checked by, and read back from the change", () => { | |
| 158 | expect(waitEstimate({ waiting: 17, medianRunMs: 600_000 }, 4)).toBe(2_550_000); | |
| 159 | expect(waitEstimate({ waiting: 17, medianRunMs: 600_000 }, 8)).toBe(1_275_000); | |
| 160 | expect(waitEstimate({ waiting: 3, medianRunMs: null }, 4)).toBeNull(); | |
| 161 | // The words the bridge records a change with, read back as the figure they can be checked by. | |
| 162 | expect(bridgeJs).toContain("'Estimate: a new ' + WORD[kind] + ' waits ~' + span(e) + ' at ' + n + ' slots (' + Math.round(e / 1000) + ' s).'"); | |
| 163 | expect(estimateOf("Estimate: a new check waits ~21m at 8 slots (1275 s).")).toEqual({ slots: 8, ms: 1_275_000 }); | |
| 164 | expect(estimateOf("Estimate: a new crew run waits ~2h 5m at 3 slots (7500 s).")).toEqual({ slots: 3, ms: 7_500_000 }); | |
| 165 | expect(estimateOf("Undone from home.")).toBeUndefined(); | |
| 166 | expect(offByMore({ at: "", slots: 8, saidMs: 360_000, actualMs: 1_140_000 })).toBe(true); | |
| 167 | expect(offByMore({ at: "", slots: 8, saidMs: 360_000, actualMs: 100_000 })).toBe(true); | |
| 168 | expect(offByMore({ at: "", slots: 8, saidMs: 360_000, actualMs: 500_000 })).toBe(false); | |
| 169 | expect(offByMore({ at: "", slots: 8, saidMs: 360_000, actualMs: null })).toBe(false); | |
| 170 | const line = { kind: "checks" as const, slots: 8, busy: 2, waiting: 0, oldestAt: null, medianWaitMs: null, points: [], medianRunMs: 600_000, lastEstimate: { at: "", slots: 8, saidMs: 360_000, actualMs: 1_140_000 } }; | |
| 171 | const drawn = slotsBlock([line], Date.now(), true).text; | |
| 172 | expect(drawn).toContain("Last change's estimate: ~6m at 8 slots; since then a new one waited ~19m, more than twice off: take the next estimate as rough."); | |
| 173 | expect(drawn).toContain('data-off="1"'); | |
| 174 | }); | |
| 175 | ||
| 176 | test("a change made on an estimate is held to it: the figure says what was said and what happened, and says when it was twice off", async () => { | |
| 177 | setCapacity(app.db, "crew.concurrency", "3", seed.owner.id, "Estimate: a new crew run waits ~1s at 3 slots (1 s)."); | |
| 178 | const crew = readSlots(app, new Date(), { pace: false })[1]!; | |
| 179 | expect(crew.lastEstimate).toMatchObject({ slots: 3, saidMs: 1000 }); | |
| 180 | const page = await lanes(); | |
| 181 | expect(page).toContain("Last change's estimate: ~1s at 3 slots"); | |
| 182 | expect(page).toMatch(/class="sl" data-kind="checks"[^>]* tabindex="0" role="group" aria-label="Checks slots, \d+" data-nav/); | |
| 183 | // Several estimate changes to one setting do not hide the other's newest. | |
| 184 | for (let i = 0; i < 25; i++) setCapacity(app.db, "checks.concurrency", String(4 + (i % 2)), seed.owner.id, `Estimate: a new check waits ~1s at ${String(4 + (i % 2))} slots (1 s).`); | |
| 185 | expect(readSlots(app, new Date(), { pace: false })[1]!.lastEstimate).toMatchObject({ slots: 3, saidMs: 1000 }); | |
| 186 | // Asked for JSON, a capacity save answers whether it was saved, in its words. | |
| 187 | const save = (value: string) => fetch(`${servers.url}/settings/capacity`, { method: "POST", body: new URLSearchParams({ key: "checks.concurrency", value }), headers: { cookie: `forge_session=${token}`, origin: servers.url, accept: "application/json" } }); | |
| 188 | const good = await save("5"); | |
| 189 | expect(good.status).toBe(200); | |
| 190 | expect(((await good.json()) as { ok: boolean }).ok).toBe(true); | |
| 191 | const bad = await save("-3"); | |
| 192 | expect(bad.status).toBe(422); | |
| 193 | expect(((await bad.json()) as { ok: boolean; flash: string }).flash).toContain("Nothing saved."); | |
| 194 | }); | |
| 195 | ||
| 196 | test("the slots are a forge admin's: a member's home has no slots, no figure and no estimate", async () => { | |
| 197 | const member = app.db.query<{ id: string; is_admin: number }, []>("SELECT id, is_admin FROM user WHERE username = 'scout'").get()!; | |
| 198 | expect(member.is_admin).toBe(0); | |
| 199 | const page = await fetch(`${servers.url}/?view=lanes`, { headers: { cookie: `forge_session=${createSession(app.db, member.id).token}` } }).then((r) => r.text()); | |
| 200 | expect(page).toContain('class="tile"'); | |
| 201 | expect(page).not.toContain('id="slots"'); | |
| 202 | expect(page).not.toContain("data-slots"); | |
| 203 | expect(page).not.toContain("Last change's estimate"); | |
| 204 | }); | |
| 205 | ||
| 206 | test.skipIf(skip)("keys on a figure: + turns the setting with its estimate, Enter sets it and keeps the estimate with the change, z puts it back; an issue tile offers assign, sharpen and park", async () => { | |
| 207 | if (chromium === undefined) throw new Error("no Chromium starts in this check, so the bridge is not driven: the check's image must carry one (FORGE_CHROMIUM)"); | |
| 208 | setCapacity(app.db, "checks.concurrency", "4", seed.owner.id); | |
| 209 | const s = await inPage(1280, `(async () => { | |
| 210 | ${WAIT} ${KEY} | |
| 211 | const pickEl = (el) => { el.focus(); el.dispatchEvent(new FocusEvent('focusin', { bubbles: true })); }; | |
| 212 | await wait(() => document.querySelector('.tile[data-key]')); | |
| 213 | const bar = document.getElementById('bridge'); | |
| 214 | const out = {}; | |
| 215 | const issue = document.querySelector('.tile[data-kind="issue"] a'); | |
| 216 | if (issue) { pickEl(issue); out.issueVerbs = [...bar.querySelectorAll('[data-shortcut]')].map((b) => b.getAttribute('data-shortcut')); } | |
| 217 | pickEl(document.querySelector('.sl[data-kind="checks"]')); | |
| 218 | out.head0 = bar.querySelector('.br-head').textContent; | |
| 219 | key('+'); | |
| 220 | out.head1 = bar.querySelector('.br-head').textContent; | |
| 221 | out.estimate = [...bar.querySelectorAll('.br-said')].map((p) => p.textContent).join(' | '); | |
| 222 | key('Enter'); | |
| 223 | await wait(() => (bar.querySelector('[data-said]')?.textContent ?? '').includes('→')); | |
| 224 | out.set = bar.querySelector('[data-said]').textContent; | |
| 225 | key('z'); | |
| 226 | await wait(() => (bar.querySelector('[data-said]')?.textContent ?? '').startsWith('Put back')); | |
| 227 | out.undone = bar.querySelector('[data-said]').textContent; | |
| 228 | return JSON.stringify(out); | |
| 229 | })()`); | |
| 230 | const seen = JSON.stringify(s); | |
| 231 | if (s.issueVerbs) expect(s.issueVerbs, seen).toEqual(expect.arrayContaining(["a", "e", "p"])); | |
| 232 | expect(s.head0, seen).toBe("Checks slots 4"); | |
| 233 | expect(s.head1, seen).toBe("Checks slots 4 → 5"); | |
| 234 | expect(s.set, seen).toContain("Checks slots 4 → 5"); | |
| 235 | expect(s.undone, seen).toBe("Put back to 4 slots."); | |
| 236 | const changes = app.db.query<{ to_value: string; reason: string }, []>("SELECT to_value, reason FROM forge_setting_change WHERE key = 'checks.concurrency' ORDER BY rowid DESC LIMIT 2").all(); | |
| 237 | expect(changes[0]).toMatchObject({ to_value: "4", reason: "Undone from home." }); | |
| 238 | expect(changes[1]!.to_value).toBe("5"); | |
| 239 | // Recorded with the estimate when there was a finished check to estimate from; said as one either | |
| 240 | // way. | |
| 241 | if (changes[1]!.reason !== "") expect(changes[1]!.reason).toMatch(/^Estimate: a new check waits ~\S+ at 5 slots \(\d+ s\)\.$/); | |
| 242 | // The bar says it in plain words; the machine-readable form is only in the saved reason. | |
| 243 | expect(s.estimate, seen).toMatch(/Estimate: a new check would wait about \S+ with 5 slots \(\S+ now\)\. Checks cost nothing extra\.|no estimate yet/); | |
| 244 | expect(s.estimate, seen).not.toMatch(/\$0|machine| s\)/); | |
| 245 | }, 30_000); |
test/flow-slots.test.ts +2 −2
| @@ -131,9 +131,9 @@ test("the line is the live setting: raising checks.concurrency moves it at once" | ||
| 131 | 131 | expect(readSlots(app).map((l) => l.kind)).toEqual(["checks", "crew"]); |
| 132 | 132 | }); |
| 133 | 133 | |
| 134 | test("read warm, the slots cost two statements: the settings, and the runs of both kinds; the pace is kept a minute", async () => { | |
| 134 | test("read warm, the slots cost three statements: the settings, the runs of both kinds and the estimates; the pace is kept a minute", async () => { | |
| 135 | 135 | readSlots(app); |
| 136 | expect(await statements(app.db, () => void readSlots(app))).toBe(2); | |
| 136 | expect(await statements(app.db, () => void readSlots(app))).toBe(3); | |
| 137 | 137 | }); |
| 138 | 138 | |
| 139 | 139 | test("/boards draws the slots above the pipeline, with Change capacity one step away, and a palette row for Capacity", async () => { |
test/pages-budget.test.ts +1
| @@ -61,6 +61,7 @@ const HEAVIER: Record<string, { statements?: number; git?: number }> = { | ||
| 61 | 61 | "/next": { statements: 90 }, // a new page: measured 90 warm over the fixture's repositories, one ranking per administered repository, at most GROUPS_MAX = 5 (#15870) |
| 62 | 62 | "/:owner/:name/next": { statements: 63 }, // -3 (#15913): the waiting offers and outsider reports ride the page's own writer check, the open-pull ceiling and count are one statement; -6 (#15940): the page's repository read once per request, the palette lists skip counts, the runs tab reuses the app read; +2: the waiting offers and the decision check beside the reports (#15887); +1: the size limits of held issues, one read of both (#15845); +2: the waiting outsider reports, the decider check and the list (#15840); +1: whether the repository is archived (#14305); +1: the wallet row, one read of the monthly cap (#13529); +1: the growth line, one read for the week, the open counts and the planner pause (#12290, #12867) |
| 63 | 63 | "/:owner/:name/pulls/:number": { statements: 115 }, // +1: what a green pull waits for (#15812), and the head's check is read once for it, the next actor and the step (#15913); +1: whether the reports door is closed, one primary-key read per request, never from memory (#15053); +1: whether the repository is archived (#14305); +1: the desk hold on the pull, one read of the notes that link it (#12536); +1: whether a repository is the forge's own copy, one read of the source setting for the tell box (#12037); +1: the paused sentence, one read of a queued paused run on the pull (#12010); +1: the header Talk count (#10327); +1: the landing line (#10860); +1: whether a reviewer is seated, read only when Require review is off and the pull would otherwise wait on one; the page loads no crew besides (#11666) |
| 64 | "/flow": { statements: 61 }, // +1 over the default: the estimates the slots were last changed on, one read of both settings' changes, so each line says how its estimate held up (Bridge v1) | |
| 64 | 65 | "/talk": { statements: 62 }, // +1 on a conversation with no message yet, as the fixture's is: the person's unsent files (a picture shared from a phone, #16311) ride the read of the sent ones, so a conversation with messages pays nothing more; +1: the conversation's own plan, pinned at the top, one primary-key read (#16575) |
| 65 | 66 | "/api/v1/asks": { statements: 61 }, // +1: the stopped apps someone asked for, one read of the viewer's archived repositories (#12277) |
| 66 | 67 | "/board": { statements: 72 }, // +1: the forge-copy read for the tell box (#12037); +1: the vitals read the database's growth (#12025); +6: the money line (#510) — one settings read, then the month's and the 30 days' meter, storage and ledger reads; constant in the number of apps |
new above
offline
A focusable div with no role or name is announced as nothing. Add
role="group"andaria-label("Checks slots, 4 of 4 busy") on the admin figure.