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 #525

Closed opened this
Closed without merging

scout/forge:scout/73-a-row-is-one-line-a-run-s-summary-never → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
7 files changed +76 −11
src/web/studio/asks_page.ts +2 −1
@@ -9,6 +9,7 @@ import type { Ctx } from "../../http/context.ts";
99 import { repoBase, signInFirst } from "../chrome.ts";
1010 import { listReposVisibleTo } from "../../core/repos.ts";
1111 import { html, type Html } from "../html.ts";
12 import { flatten } from "./note.ts";
1213 import { page } from "../layout.ts";
1314 import { btn, card, icon } from "../ui.ts";
1415 import {
@@ -27,7 +28,7 @@ function decisionCard(ctx: Ctx, d: Decision): Html {
2728 ? html`<a href="${changeHref(base, d.pull.number)}">${d.pull.title}</a>`
2829 : html`<a href="${base}/settings/autonomy">Paused</a>`;
2930 return card(
30 html`<p>${d.says}</p>
31 html`<p class="row-note ask-says" title="${flatten(d.says)}">${flatten(d.says)}</p>
3132 <div class="bar mt">${decisionActions(ctx, d)}</div>`,
3233 {
3334 id: d.id.replace(/[^a-z0-9-]/g, "-"),
src/web/studio/lists.ts +4 −3
@@ -24,6 +24,7 @@ import {
2424 repoPalette,
2525 } from "../chrome.ts";
2626 import { html, type Html } from "../html.ts";
27 import { noteLine } from "./note.ts";
2728 import { page, redirect } from "../layout.ts";
2829 import { liveClientJs, liveMount } from "../live.ts";
2930 import {
@@ -191,7 +192,7 @@ export async function studioTells(
191192 title: issue.title,
192193 meta: html`${issue.assigneeName
193194 ? html`${issue.assigneeName} · `
194 : null}${info.note} · ${time(issue.updatedAt)}`,
195 : null}${noteLine(info.note)} · ${time(issue.updatedAt)}`,
195196 trail: wordBadge(info.word),
196197 }),
197198 ),
@@ -279,7 +280,7 @@ export async function studioChanges(
279280 nav: true,
280281 lead: avatar(pull.authorName),
281282 title: pull.title,
282 meta: html`${pull.authorName} · ${info.note} ·
283 meta: html`${pull.authorName} · ${noteLine(info.note)} ·
283284 ${time(pull.updatedAt)}`,
284285 trail: wordBadge(info.word),
285286 }),
@@ -398,7 +399,7 @@ export async function studioRuns(
398399 nav: true,
399400 lead: avatar(who),
400401 title: runTitleFrom(run, actors, issues),
401 meta: html`${who} · ${info.note} ·
402 meta: html`${who} · ${noteLine(info.note)} ·
402403 ${time(run.finishedAt ?? run.createdAt)}`,
403404 trail: wordBadge(info.word),
404405 });
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";
2121 import { readRunLogTail } from "../../runs/log.ts";
2222 import { loadRepo, repoBase } from "../chrome.ts";
2323 import { html, type Html } from "../html.ts";
24 import { noteLine, flatten } from "./note.ts";
2425 import { fragment } from "../layout.ts";
2526 import { avatar, badge, btn, card, icon, listCard, row, time } from "../ui.ts";
2627 import { changeHref, tellHref } from "./nouns.ts";
@@ -188,9 +189,9 @@ export async function nowCard(
188189 ...(stop ? {} : { href: `${base}/runs/${r.id}`, nav: true }),
189190 lead: avatar(who),
190191 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)}
194195 ${word === "working"
195196 ? null
196197 : html` · ${time(r.finishedAt ?? r.createdAt)}`}`,
@@ -236,7 +237,7 @@ export async function nowCard(
236237 nav: true,
237238 lead: avatar(who),
238239 title: p.title,
239 meta: html`${who} · ${note} · ${time(p.createdAt)}`,
240 meta: html`${who} · ${noteLine(note)} · ${time(p.createdAt)}`,
240241 trail: wordBadge(word),
241242 });
242243 }),
@@ -282,7 +283,7 @@ export async function nowCard(
282283 nav: true,
283284 lead: avatar(who),
284285 title: i.title,
285 meta: html`${who} · ${note} · ${time(i.createdAt)}`,
286 meta: html`${who} · ${noteLine(note)} · ${time(i.createdAt)}`,
286287 trail: wordBadge(word),
287288 });
288289 }),
src/web/studio/style.ts +4
@@ -71,6 +71,10 @@ const rows = part(/* css */ `
7171 .shelf-desc { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
7272 .shelf-facts { flex: 0 0 auto; max-width: 100%; }
7373 .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; }
7478 .studio-list li[data-word="working"] .studio-word { color: var(--accent); opacity: 1; }
7579 .studio-list li[data-word="look"] .studio-word { color: var(--merged); opacity: 1; }
7680 .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";
2121 import type { Ctx } from "../../http/context.ts";
2222 import { crumbsFor, repoBase, repoHeader, repoPalette } from "../chrome.ts";
2323 import { html, when, type Html } from "../html.ts";
24 import { noteLine } from "./note.ts";
2425 import { page } from "../layout.ts";
2526 import { liveClientJs, liveMount } from "../live.ts";
2627 import {
@@ -169,8 +170,7 @@ async function tellRuns(
169170 nav: true,
170171 lead: avatar(who),
171172 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")}`,
174174 trail: html`${wordBadge(word)}${when(
175175 r.costUsd > 0,
176176 () =>
test/studio.test.ts +35
@@ -56,6 +56,7 @@ import {
5656 servingHistory,
5757 type WordCtx,
5858 } from "../src/web/studio/words.ts";
59 import { studioCss } from "../src/web/studio/style.ts";
5960 import { servedPhrase } from "../src/web/ui.ts";
6061 import { repoDir } from "../src/git/repos.ts";
6162 import { appendRunLog } from "../src/runs/log.ts";
@@ -890,6 +891,40 @@ describe("the studio", () => {
890891 expect(dev).not.toContain("data-word=");
891892 });
892893
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(/&lt;/g, "<").replace(/&gt;/g, ">")).toBe(flat);
919 expect(mine).toContain("**bold**");
920 expect(mine).toContain("`main`");
921 expect(mine).toContain("&lt;b&gt;tag&lt;/b&gt;");
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
893928 test("issues, pulls and runs on a repository that is not an app render exactly what they render today, even in studio mode", async () => {
894929 const plain = await createRepo(app, alice, {
895930 name: "plainlists",

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs