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 #530
scout/forge:scout/73-a-row-is-one-line-a-run-s-summary-never → main 2 commits fork
7 files
changed +76
−11
src/web/studio/asks_page.ts +2 −1
| @@ -9,6 +9,7 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 9 | 9 | import { repoBase, signInFirst } from "../chrome.ts"; |
| 10 | 10 | import { listReposVisibleTo } from "../../core/repos.ts"; |
| 11 | 11 | import { html, type Html } from "../html.ts"; |
| 12 | import { flatten } from "./note.ts"; | |
| 12 | 13 | import { page } from "../layout.ts"; |
| 13 | 14 | import { btn, card, icon } from "../ui.ts"; |
| 14 | 15 | import { |
| @@ -27,7 +28,7 @@ function decisionCard(ctx: Ctx, d: Decision): Html { | ||
| 27 | 28 | ? html`<a href="${changeHref(base, d.pull.number)}">${d.pull.title}</a>` |
| 28 | 29 | : html`<a href="${base}/settings/autonomy">Paused</a>`; |
| 29 | 30 | return card( |
| 30 | html`<p>${d.says}</p> | |
| 31 | html`<p class="row-note ask-says" title="${flatten(d.says)}">${flatten(d.says)}</p> | |
| 31 | 32 | <div class="bar mt">${decisionActions(ctx, d)}</div>`, |
| 32 | 33 | { |
| 33 | 34 | id: d.id.replace(/[^a-z0-9-]/g, "-"), |
src/web/studio/lists.ts +4 −3
| @@ -24,6 +24,7 @@ import { | ||
| 24 | 24 | repoPalette, |
| 25 | 25 | } from "../chrome.ts"; |
| 26 | 26 | import { html, type Html } from "../html.ts"; |
| 27 | import { noteLine } from "./note.ts"; | |
| 27 | 28 | import { page, redirect } from "../layout.ts"; |
| 28 | 29 | import { liveClientJs, liveMount } from "../live.ts"; |
| 29 | 30 | import { |
| @@ -191,7 +192,7 @@ export async function studioTells( | ||
| 191 | 192 | title: issue.title, |
| 192 | 193 | meta: html`${issue.assigneeName |
| 193 | 194 | ? html`${issue.assigneeName} · ` |
| 194 | : null}${info.note} · ${time(issue.updatedAt)}`, | |
| 195 | : null}${noteLine(info.note)} · ${time(issue.updatedAt)}`, | |
| 195 | 196 | trail: wordBadge(info.word), |
| 196 | 197 | }), |
| 197 | 198 | ), |
| @@ -279,7 +280,7 @@ export async function studioChanges( | ||
| 279 | 280 | nav: true, |
| 280 | 281 | lead: avatar(pull.authorName), |
| 281 | 282 | title: pull.title, |
| 282 | meta: html`${pull.authorName} · ${info.note} · | |
| 283 | meta: html`${pull.authorName} · ${noteLine(info.note)} · | |
| 283 | 284 | ${time(pull.updatedAt)}`, |
| 284 | 285 | trail: wordBadge(info.word), |
| 285 | 286 | }), |
| @@ -398,7 +399,7 @@ export async function studioRuns( | ||
| 398 | 399 | nav: true, |
| 399 | 400 | lead: avatar(who), |
| 400 | 401 | title: runTitleFrom(run, actors, issues), |
| 401 | meta: html`${who} · ${info.note} · | |
| 402 | meta: html`${who} · ${noteLine(info.note)} · | |
| 402 | 403 | ${time(run.finishedAt ?? run.createdAt)}`, |
| 403 | 404 | trail: wordBadge(info.word), |
| 404 | 405 | }); |
src/web/studio/note.ts added +23
| @@ -0,0 +1,23 @@ | ||
| 1 | /** | |
| 2 | * A row is one line. Free text an agent wrote (a run's summary, a pull's | |
| 3 | * title) goes through here before it sits in a row's meta or an ask card: | |
| 4 | * whitespace collapsed to single spaces, bounded generously, escaped by | |
| 5 | * `html`, and shown whole in the title attribute. The clamp itself is CSS | |
| 6 | * (`.row-note` in `style.ts`), so a screen reader and hover keep the text. | |
| 7 | */ | |
| 8 | import { html, type Html } from "../html.ts"; | |
| 9 | ||
| 10 | /** The most characters of a note the page carries; the transcript has the rest. */ | |
| 11 | export const NOTE_MAX = 2000; | |
| 12 | ||
| 13 | /** One readable line: newlines and runs of space become a single space. */ | |
| 14 | export function flatten(text: string): string { | |
| 15 | const flat = text.replace(/\s+/g, " ").trim(); | |
| 16 | return flat.length > NOTE_MAX ? `${flat.slice(0, NOTE_MAX - 1)}…` : flat; | |
| 17 | } | |
| 18 | ||
| 19 | /** The note as a clamped, escaped span; the whole text is its title. */ | |
| 20 | export function noteLine(text: string): Html { | |
| 21 | const flat = flatten(text); | |
| 22 | return html`<span class="row-note" title="${flat}">${flat}</span>`; | |
| 23 | } |
src/web/studio/now.ts +6 −5
| @@ -21,6 +21,7 @@ import type { Ctx } from "../../http/context.ts"; | ||
| 21 | 21 | import { readRunLogTail } from "../../runs/log.ts"; |
| 22 | 22 | import { loadRepo, repoBase } from "../chrome.ts"; |
| 23 | 23 | import { html, type Html } from "../html.ts"; |
| 24 | import { noteLine, flatten } from "./note.ts"; | |
| 24 | 25 | import { fragment } from "../layout.ts"; |
| 25 | 26 | import { avatar, badge, btn, card, icon, listCard, row, time } from "../ui.ts"; |
| 26 | 27 | import { changeHref, tellHref } from "./nouns.ts"; |
| @@ -188,9 +189,9 @@ export async function nowCard( | ||
| 188 | 189 | ...(stop ? {} : { href: `${base}/runs/${r.id}`, nav: true }), |
| 189 | 190 | lead: avatar(who), |
| 190 | 191 | title: stop |
| 191 | ? html`<a href="${base}/runs/${r.id}">${about?.title ?? note}</a>` | |
| 192 | : (about?.title ?? note), | |
| 193 | meta: html`${who} · ${word === "working" ? "working now" : note} | |
| 192 | ? html`<a href="${base}/runs/${r.id}">${about?.title ?? flatten(note)}</a>` | |
| 193 | : (about?.title ?? flatten(note)), | |
| 194 | meta: html`${who} · ${word === "working" ? "working now" : noteLine(note)} | |
| 194 | 195 | ${word === "working" |
| 195 | 196 | ? null |
| 196 | 197 | : html` · ${time(r.finishedAt ?? r.createdAt)}`}`, |
| @@ -236,7 +237,7 @@ export async function nowCard( | ||
| 236 | 237 | nav: true, |
| 237 | 238 | lead: avatar(who), |
| 238 | 239 | title: p.title, |
| 239 | meta: html`${who} · ${note} · ${time(p.createdAt)}`, | |
| 240 | meta: html`${who} · ${noteLine(note)} · ${time(p.createdAt)}`, | |
| 240 | 241 | trail: wordBadge(word), |
| 241 | 242 | }); |
| 242 | 243 | }), |
| @@ -282,7 +283,7 @@ export async function nowCard( | ||
| 282 | 283 | nav: true, |
| 283 | 284 | lead: avatar(who), |
| 284 | 285 | title: i.title, |
| 285 | meta: html`${who} · ${note} · ${time(i.createdAt)}`, | |
| 286 | meta: html`${who} · ${noteLine(note)} · ${time(i.createdAt)}`, | |
| 286 | 287 | trail: wordBadge(word), |
| 287 | 288 | }); |
| 288 | 289 | }), |
src/web/studio/style.ts +4
| @@ -71,6 +71,10 @@ const rows = part(/* css */ ` | ||
| 71 | 71 | .shelf-desc { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } |
| 72 | 72 | .shelf-facts { flex: 0 0 auto; max-width: 100%; } |
| 73 | 73 | .row-meta .studio-word { font-family: inherit; font-size: inherit; opacity: 1; font-weight: 560; } |
| 74 | /* A row is one line: the note takes what room the word, who and when leave | |
| 75 | and ends in an ellipsis; the whole text is the title attribute. */ | |
| 76 | .row-note { display: inline-block; max-width: min(46ch, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; } | |
| 77 | .ask-says { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: normal; overflow-wrap: anywhere; max-width: none; } | |
| 74 | 78 | .studio-list li[data-word="working"] .studio-word { color: var(--accent); opacity: 1; } |
| 75 | 79 | .studio-list li[data-word="look"] .studio-word { color: var(--merged); opacity: 1; } |
| 76 | 80 | .studio-list li[data-word="stopped"] .studio-word { color: var(--danger, #c33); opacity: 1; } |
src/web/studio/tell.ts +2 −2
| @@ -21,6 +21,7 @@ import { repoDir } from "../../git/repos.ts"; | ||
| 21 | 21 | import type { Ctx } from "../../http/context.ts"; |
| 22 | 22 | import { crumbsFor, repoBase, repoHeader, repoPalette } from "../chrome.ts"; |
| 23 | 23 | import { html, when, type Html } from "../html.ts"; |
| 24 | import { noteLine } from "./note.ts"; | |
| 24 | 25 | import { page } from "../layout.ts"; |
| 25 | 26 | import { liveClientJs, liveMount } from "../live.ts"; |
| 26 | 27 | import { |
| @@ -169,8 +170,7 @@ async function tellRuns( | ||
| 169 | 170 | nav: true, |
| 170 | 171 | lead: avatar(who), |
| 171 | 172 | title: html`${who} <span class="muted">${reasonWords(r.reason)}</span>`, |
| 172 | meta: html`${duration ? html`${duration} · ` : null}${r.summary || | |
| 173 | "no summary yet"}`, | |
| 173 | meta: html`${duration ? html`${duration} · ` : null}${noteLine(r.summary || "no summary yet")}`, | |
| 174 | 174 | trail: html`${wordBadge(word)}${when( |
| 175 | 175 | r.costUsd > 0, |
| 176 | 176 | () => |
test/studio.test.ts +35
| @@ -56,6 +56,7 @@ import { | ||
| 56 | 56 | servingHistory, |
| 57 | 57 | type WordCtx, |
| 58 | 58 | } from "../src/web/studio/words.ts"; |
| 59 | import { studioCss } from "../src/web/studio/style.ts"; | |
| 59 | 60 | import { servedPhrase } from "../src/web/ui.ts"; |
| 60 | 61 | import { repoDir } from "../src/git/repos.ts"; |
| 61 | 62 | import { appendRunLog } from "../src/runs/log.ts"; |
| @@ -890,6 +891,40 @@ describe("the studio", () => { | ||
| 890 | 891 | expect(dev).not.toContain("data-word="); |
| 891 | 892 | }); |
| 892 | 893 | |
| 894 | test("a run's summary is one clamped line in its row: whole text in the title, markdown characters literal", async () => { | |
| 895 | const scout = getUserByName(app.db, "scout")!; | |
| 896 | const run = createRun(app.db, { | |
| 897 | repoId: repo.id, | |
| 898 | kind: "agent", | |
| 899 | actorId: scout.id, | |
| 900 | reason: "assigned", | |
| 901 | }); | |
| 902 | claimRun(app.db, run.id); | |
| 903 | const report = Array.from( | |
| 904 | { length: 12 }, | |
| 905 | (_, i) => `line ${i}: **bold** \`main\` [link](http://x.test) <b>tag</b> done`, | |
| 906 | ).join("\n"); | |
| 907 | expect(report.length).toBeGreaterThan(600); | |
| 908 | finishRun(app.db, run.id, { state: "ok", summary: report }); | |
| 909 | const flat = getRun(app.db, run.id)!.summary.replace(/\s+/g, " ").trim(); | |
| 910 | ||
| 911 | const page = await (await get("/alice/notes/runs")).text(); | |
| 912 | const rowHtml = page.slice(page.indexOf(`/alice/notes/runs/${run.id}"`)); | |
| 913 | const end = rowHtml.indexOf("</li>"); | |
| 914 | const mine = rowHtml.slice(0, end); | |
| 915 | expect(mine).toContain('class="row-note"'); | |
| 916 | expect(mine).not.toContain("\n line 1:"); | |
| 917 | const title = /class="row-note" title="([^"]*)"/.exec(mine)?.[1] ?? ""; | |
| 918 | expect(title.replace(/</g, "<").replace(/>/g, ">")).toBe(flat); | |
| 919 | expect(mine).toContain("**bold**"); | |
| 920 | expect(mine).toContain("`main`"); | |
| 921 | expect(mine).toContain("<b>tag</b>"); | |
| 922 | expect(mine).not.toContain("<b>tag</b>"); | |
| 923 | expect(mine).not.toContain("<strong>"); | |
| 924 | expect(mine).not.toContain('href="http://x.test"'); | |
| 925 | expect(studioCss).toMatch(/\.row-note \{[^}]*text-overflow: ellipsis[^}]*white-space: nowrap/); | |
| 926 | }); | |
| 927 | ||
| 893 | 928 | test("issues, pulls and runs on a repository that is not an app render exactly what they render today, even in studio mode", async () => { |
| 894 | 929 | const plain = await createRepo(app, alice, { |
| 895 | 930 | name: "plainlists", |
new above
offline