Public: anyone can read this; the crew can change it.
A row is one line: a run's summary never becomes a paragraph on the app page #9964
scout/forge:scout/73-a-row-is-one-line-a-run-s-summary-never → main 12 commits fork
8 files
changed +102
−15
docs/design/areas/runs.md +1
| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | # Runs |
| 2 | 2 | |
| 3 | - `.row-note` — free text an agent wrote (a run's summary, or a word's note taken from one) inside a §5 row's meta: one line clamped by CSS with an ellipsis, whitespace collapsed, escaped, never rendered as markdown, its whole text in `title`, and narrower than the meta so the who and when after it stay visible (#73). Written by `noteLine()` in `src/web/studio/note.ts` (the runs list, *Now* and a tell's runs). Styled in `src/web/style/components.ts` (list rows). | |
| 3 | 4 | - `.check-words` — the run page's live tests line under the step list: reserves one line of height (1.4em) so the pin slot and log never move as the words arrive. |
| 4 | 5 | |
| 5 | 6 | ## A run's page at 390 px (#9347) |
src/web/studio/lists.ts +2 −1
| @@ -41,6 +41,7 @@ import { | ||
| 41 | 41 | signInHref, |
| 42 | 42 | } from "../chrome.ts"; |
| 43 | 43 | import { html, when, type Html } from "../html.ts"; |
| 44 | import { noteLine } from "./note.ts"; | |
| 44 | 45 | import { page } from "../layout.ts"; |
| 45 | 46 | import { liveClientJs, liveMount } from "../live.ts"; |
| 46 | 47 | import { |
| @@ -866,7 +867,7 @@ export async function runsListPage(ctx: Ctx, repo: Repo): Promise<Response> { | ||
| 866 | 867 | ? html`${run.commitOid.slice(0, 7)} · ${checkState(run)} |
| 867 | 868 | ${when(durationText(run), (d) => html` · took ${d}`)} · |
| 868 | 869 | ${time(run.finishedAt ?? run.createdAt)}` |
| 869 | : html`${run.kind === "agent" ? html`${who} · ` : null}${run.state === "queued" ? whatRunWaitsOn(run) : info.note} | |
| 870 | : html`${run.kind === "agent" ? html`${who} · ` : null}${run.state === "queued" ? whatRunWaitsOn(run) : noteLine(info.note)} | |
| 870 | 871 | · ${time(run.finishedAt ?? run.createdAt)}`, |
| 871 | 872 | trail: wordBadge(info.word), |
| 872 | 873 | }); |
src/web/studio/note.ts added +26
| @@ -0,0 +1,26 @@ | ||
| 1 | /** | |
| 2 | * A row is one line (#73). Free text an agent wrote — a run's summary, the | |
| 3 | * note a word carries from it — goes through here before it sits in a row's | |
| 4 | * meta: whitespace and newlines collapsed to single spaces, bounded | |
| 5 | * generously, escaped by `html`, and the whole of it in the title | |
| 6 | * attribute. Never rendered as markdown: a backtick stays a backtick. The | |
| 7 | * clamp itself is CSS (`.row-note` in `style/components.ts`), so a screen | |
| 8 | * reader and hover keep the text and the who and when beside it keep their | |
| 9 | * place. The transcript, one click from the row, has the whole summary. | |
| 10 | */ | |
| 11 | import { html, type Html } from "../html.ts"; | |
| 12 | ||
| 13 | /** The most characters of a note a row carries; past it the page would only grow. */ | |
| 14 | export const NOTE_MAX = 2000; | |
| 15 | ||
| 16 | /** One readable line: newlines and runs of space become a single space. */ | |
| 17 | export function flatten(text: string): string { | |
| 18 | const flat = text.replace(/\s+/g, " ").trim(); | |
| 19 | return flat.length > NOTE_MAX ? `${flat.slice(0, NOTE_MAX - 1)}…` : flat; | |
| 20 | } | |
| 21 | ||
| 22 | /** The note as a clamped, escaped span; the whole text is its title. */ | |
| 23 | export function noteLine(text: string): Html { | |
| 24 | const flat = flatten(text); | |
| 25 | return html`<span class="row-note" title="${flat}">${flat}</span>`; | |
| 26 | } |
src/web/studio/now.ts +6 −5
| @@ -24,6 +24,7 @@ import { readRunLogTail } from "../../runs/log.ts"; | ||
| 24 | 24 | import { mayReadRunLog } from "../../actions/runs.ts"; |
| 25 | 25 | import { loadRepo, repoBase } from "../chrome.ts"; |
| 26 | 26 | import { html, type Html } from "../html.ts"; |
| 27 | import { flatten, noteLine } from "./note.ts"; | |
| 27 | 28 | import { fragment, missingFragment } from "../layout.ts"; |
| 28 | 29 | import { avatar, badge, btn, card, icon, listCard, row, time } from "../ui.ts"; |
| 29 | 30 | import { changeHref, tellHref } from "./nouns.ts"; |
| @@ -206,9 +207,9 @@ export async function nowCard( | ||
| 206 | 207 | ...(stop ? {} : { href: `${base}/runs/${r.id}`, nav: true }), |
| 207 | 208 | lead: avatar(who), |
| 208 | 209 | title: stop |
| 209 | ? html`<a href="${base}/runs/${r.id}">${about?.title ?? note}</a>` | |
| 210 | : (about?.title ?? note), | |
| 211 | meta: html`${who} · ${word === "working" ? "working now" : note} | |
| 210 | ? html`<a href="${base}/runs/${r.id}">${about?.title ?? flatten(note)}</a>` | |
| 211 | : (about?.title ?? flatten(note)), | |
| 212 | meta: html`${who} · ${word === "working" ? "working now" : noteLine(note)} | |
| 212 | 213 | ${word === "working" |
| 213 | 214 | ? null |
| 214 | 215 | : html` · ${time(r.finishedAt ?? r.createdAt)}`}`, |
| @@ -251,7 +252,7 @@ export async function nowCard( | ||
| 251 | 252 | nav: true, |
| 252 | 253 | lead: avatar(who), |
| 253 | 254 | title: i.title, |
| 254 | meta: html`${who} · ${note} · ${time(i.createdAt)}`, | |
| 255 | meta: html`${who} · ${noteLine(note)} · ${time(i.createdAt)}`, | |
| 255 | 256 | trail: wordBadge(word), |
| 256 | 257 | }); |
| 257 | 258 | }); |
| @@ -270,7 +271,7 @@ export async function nowCard( | ||
| 270 | 271 | nav: true, |
| 271 | 272 | lead: avatar(who), |
| 272 | 273 | title: p.title, |
| 273 | meta: html`${who} · ${note} · ${time(p.createdAt)}`, | |
| 274 | meta: html`${who} · ${noteLine(note)} · ${time(p.createdAt)}`, | |
| 274 | 275 | trail: wordBadge(word), |
| 275 | 276 | }); |
| 276 | 277 | }), |
src/web/studio/tell.ts +2 −2
| @@ -49,6 +49,7 @@ import { repoDir } from "../../git/repos.ts"; | ||
| 49 | 49 | import type { Ctx } from "../../http/context.ts"; |
| 50 | 50 | import { crumbsFor, repoBase, repoHeader, repoPalette } from "../chrome.ts"; |
| 51 | 51 | import { html, when, type Html } from "../html.ts"; |
| 52 | import { noteLine } from "./note.ts"; | |
| 52 | 53 | import { threadLine } from "../describe.ts"; |
| 53 | 54 | import { page } from "../layout.ts"; |
| 54 | 55 | import { liveClientJs, liveMount } from "../live.ts"; |
| @@ -353,8 +354,7 @@ async function tellRuns( | ||
| 353 | 354 | nav: true, |
| 354 | 355 | lead: avatar(who), |
| 355 | 356 | title: html`${who} <span class="muted">${reasonWords(r.reason)}</span>`, |
| 356 | meta: html`${duration ? html`${duration} · ` : null}${r.summary || | |
| 357 | "no summary yet"}`, | |
| 357 | meta: html`${duration ? html`${duration} · ` : null}${noteLine(r.summary || "no summary yet")}`, | |
| 358 | 358 | trail: html`${wordBadge(word)}${when( |
| 359 | 359 | r.costUsd > 0, |
| 360 | 360 | () => |
src/web/style/components.ts +6
| @@ -466,6 +466,12 @@ a.row:hover .row-title { color: var(--accent); } | ||
| 466 | 466 | font-variant-numeric: tabular-nums; |
| 467 | 467 | } |
| 468 | 468 | .row-meta .byline { display: inline; } |
| 469 | /* A note an agent wrote (#73): its own clamped line inside the meta, leaving | |
| 470 | room for the who and when after it; the whole text is the title. */ | |
| 471 | .row-note { | |
| 472 | display: inline-block; max-width: min(60ch, calc(100% - 14ch)); vertical-align: bottom; | |
| 473 | overflow: hidden; text-overflow: ellipsis; white-space: nowrap; | |
| 474 | } | |
| 469 | 475 | .row-facts { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 0; font-size: 12.5px; color: var(--muted-fg); line-height: 1.5; } |
| 470 | 476 | .row-facts > div { display: flex; gap: 6px; min-width: 0; } |
| 471 | 477 | .row-facts dt { font-weight: 550; } |
test/studio.test.ts +43
| @@ -614,6 +614,49 @@ describe("the studio", () => { | ||
| 614 | 614 | expect(studio).toContain(`href="/alice/notes/runs/${run.id}"`); |
| 615 | 615 | }); |
| 616 | 616 | |
| 617 | test("a run's summary is one clamped line in its row: whole text in the title, markdown characters literal, the time after it", async () => { | |
| 618 | const scout = getUserByName(app.db, "scout")!; | |
| 619 | const run = createRun(app.db, { | |
| 620 | repoId: repo.id, | |
| 621 | kind: "agent", | |
| 622 | actorId: scout.id, | |
| 623 | reason: "assigned", | |
| 624 | }); | |
| 625 | claimRun(app.db, run.id); | |
| 626 | const report = Array.from( | |
| 627 | { length: 12 }, | |
| 628 | (_, i) => | |
| 629 | `line ${i}: **bold** \`main\` [link](http://x.test) <b>tag</b> done`, | |
| 630 | ).join("\n"); | |
| 631 | expect(report.length).toBeGreaterThan(600); | |
| 632 | finishRun(app.db, run.id, { state: "failed", summary: report }); | |
| 633 | // The run table keeps the first 500 characters; the row carries all of those. | |
| 634 | const flat = report.slice(0, 500).replace(/\s+/g, " ").trim(); | |
| 635 | ||
| 636 | const page = await (await get("/alice/notes/runs?state=failed")).text(); | |
| 637 | const at = page.indexOf(`href="/alice/notes/runs/${run.id}"`); | |
| 638 | expect(at).toBeGreaterThan(-1); | |
| 639 | const mine = page.slice(at, page.indexOf("</li>", at)); | |
| 640 | // One line: the note is its own clamped span, no newline survives in it. | |
| 641 | const span = /<span class="row-note" title="([^"]*)">([^<]*)<\/span>/.exec(mine); | |
| 642 | expect(span).not.toBeNull(); | |
| 643 | const unescape = (s: string) => | |
| 644 | s.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&"); | |
| 645 | expect(unescape(span![1]!)).toBe(flat); | |
| 646 | expect(unescape(span![2]!)).toBe(flat); | |
| 647 | // Text, not source: markdown characters literal, markup escaped. | |
| 648 | expect(mine).toContain("**bold**"); | |
| 649 | expect(mine).toContain("`main`"); | |
| 650 | expect(mine).toContain("<b>tag</b>"); | |
| 651 | expect(mine).not.toContain("<b>tag</b>"); | |
| 652 | expect(mine).not.toContain("<strong>"); | |
| 653 | expect(mine).not.toContain('href="http://x.test"'); | |
| 654 | // The when comes after the note, outside its clamp. | |
| 655 | expect(mine.slice(mine.indexOf("</span>", mine.indexOf("row-note")))).toContain("<time"); | |
| 656 | const css = await (await fetch(`${base}${stylesheetAsset().path}`)).text(); | |
| 657 | expect(css).toMatch(/\.row-note \{[^}]*text-overflow: ellipsis[^}]*white-space: nowrap/); | |
| 658 | }); | |
| 659 | ||
| 617 | 660 | test("a change that no longer merges into its base says so, and offers no Ship — a mergeable green pull is unchanged", async () => { |
| 618 | 661 | const scout = getUserByName(app.db, "scout")!; |
| 619 | 662 | const base1 = await commitToBranch(app, alice, repo, { |
test/traffic-truth.test.ts +16 −7
| @@ -359,6 +359,15 @@ test("an anonymous page at a full commit is the same bytes twice, with no cookie | ||
| 359 | 359 | expect(a).not.toMatch(/csrf|nonce=|203\.0\.113/i); |
| 360 | 360 | }); |
| 361 | 361 | |
| 362 | // Each request of the pinned-route tests comes from its own address: a | |
| 363 | // stranger's deep reads are budgeted per address, and while a loaded | |
| 364 | // machine runs the loop late the budget is a quarter (`crawl.ts`), so | |
| 365 | // one loopback address would be refused part-way and the test would | |
| 366 | // judge the limiter, not the cache header. | |
| 367 | let freshAddress = 0; | |
| 368 | const fresh = (path: string, headers: Record<string, string> = {}) => | |
| 369 | get(path, { "x-forwarded-for": `198.51.100.${(freshAddress++ % 250) + 1}`, ...headers }); | |
| 370 | ||
| 362 | 371 | test("each pinned route is shared when anonymous and never otherwise", async () => { |
| 363 | 372 | const session = `forge_session=${createSession(app.db, alice.id).token}`; |
| 364 | 373 | for (const path of [ |
| @@ -368,7 +377,7 @@ test("each pinned route is shared when anonymous and never otherwise", async () | ||
| 368 | 377 | `media/${sha}/a.txt`, |
| 369 | 378 | ]) { |
| 370 | 379 | const url = `/alice/open/${path}`; |
| 371 | const anonymous = await get(url); | |
| 380 | const anonymous = await fresh(url); | |
| 372 | 381 | expect([ |
| 373 | 382 | path, |
| 374 | 383 | anonymous.status, |
| @@ -383,7 +392,7 @@ test("each pinned route is shared when anonymous and never otherwise", async () | ||
| 383 | 392 | { cookie: "forge_session=expired" }, |
| 384 | 393 | { authorization: "Bearer nothing" }, |
| 385 | 394 | ]) { |
| 386 | const res = await get(url, headers); | |
| 395 | const res = await fresh(url, headers); | |
| 387 | 396 | expect([ |
| 388 | 397 | path, |
| 389 | 398 | Object.keys(headers)[0], |
| @@ -395,7 +404,7 @@ test("each pinned route is shared when anonymous and never otherwise", async () | ||
| 395 | 404 | ]); |
| 396 | 405 | } |
| 397 | 406 | // A branch name moves. |
| 398 | const moving = await get(`/alice/open/${path.replace(sha, "main")}`); | |
| 407 | const moving = await fresh(`/alice/open/${path.replace(sha, "main")}`); | |
| 399 | 408 | expect(moving.headers.get("cache-control") ?? "").not.toContain( |
| 400 | 409 | "immutable", |
| 401 | 410 | ); |
| @@ -406,10 +415,10 @@ test("each pinned route is shared when anonymous and never otherwise", async () | ||
| 406 | 415 | test("a private repository is never shared, to its owner or to anyone else", async () => { |
| 407 | 416 | const session = `forge_session=${createSession(app.db, alice.id).token}`; |
| 408 | 417 | for (const path of [`tree/${shutSha}`, `blob/${shutSha}/a.txt`, `raw/${shutSha}/a.txt`, `media/${shutSha}/a.txt`]) { |
| 409 | const own = await get(`/alice/shut/${path}`, { cookie: session }); | |
| 418 | const own = await fresh(`/alice/shut/${path}`, { cookie: session }); | |
| 410 | 419 | expect([path, own.status]).toEqual([path, 200]); |
| 411 | 420 | expect(own.headers.get("cache-control") ?? "").not.toContain("public"); |
| 412 | const stranger = await get(`/alice/shut/${path}`); | |
| 421 | const stranger = await fresh(`/alice/shut/${path}`); | |
| 413 | 422 | expect(stranger.status).toBe(404); |
| 414 | 423 | expect(stranger.headers.get("cache-control") ?? "").not.toContain("public"); |
| 415 | 424 | } |
| @@ -417,9 +426,9 @@ test("a private repository is never shared, to its owner or to anyone else", asy | ||
| 417 | 426 | |
| 418 | 427 | test("a repository that turns private stops being shared on its next answer", async () => { |
| 419 | 428 | const pinned = `/alice/open/raw/${sha}/a.txt`; |
| 420 | expect((await get(pinned)).headers.get("cache-control")).toBe(SHARED); | |
| 429 | expect((await fresh(pinned)).headers.get("cache-control")).toBe(SHARED); | |
| 421 | 430 | app.db.run("UPDATE repo SET visibility = 'private' WHERE id = ?1", [getRepo(app.db, "alice", "open")!.id]); |
| 422 | const after = await get(pinned); | |
| 431 | const after = await fresh(pinned); | |
| 423 | 432 | expect(after.status).toBe(404); |
| 424 | 433 | expect(after.headers.get("cache-control") ?? "").not.toContain("public"); |
| 425 | 434 | app.db.run("UPDATE repo SET visibility = 'public' WHERE id = ?1", [getRepo(app.db, "alice", "open")!.id]); |
new above
offline