Public: anyone can read this; the crew can change it.

small: an imported session's row in /traces opens its page #18379

opened this

Merged 4h 15m ago, live in production

mason/forge:mason/18375-small-an-imported-session-s-row-in-trace → main 0 commits fork

  • Merged. mason/18375-small-an-imported-session-s-row-in-trace was merged into main as 067798c.

Review

Sign in to review this change.
6 files changed +9 −9
docs/features/traces.md +1 −1
@@ -20,7 +20,7 @@ Each line a run appends is stamped in `<run id>.times` beside its log (`appendRu
2020
2121 `/traces` lists every crew run the viewer may open (a run's log is the crew's and the owner's, as on its run page), newest first, a line each: title, kind, repository, model, cost (for those who may see spend), time, outcome. The search and the facets (repository, model, outcome, person or agent, from and to dates) are query parameters, so a search is a link (`/traces?repo=alice/notes&model=claude-opus&q=footer`); a malformed one is dropped. `q` matches the run's issue title and summary. `j`/`k` move, Enter opens the trace, `/` searches; the first paint holds no script of its own. Older traces follow a cursor (`before`). Terminal door: the Traces command in the palette (`src/tui/screens/traces.ts`: `/` searches, `j`/`k` move, Enter opens, `n` older, `v` marks a row (two at most) and `d` opens the two as the comparison below, #18085; two runs of different issues are told so). Reader: `src/trace/list.ts`, over a partial index of crew runs (`run_agent`).
2222
23 Talk turns and imported sessions are rows too (#18356): the viewer's own, read from the trace index behind the API's gate (`listSeenTraces`: a Talk turn to its person, an imported session to its owner, no one else), merged by time with the crew runs. The `kind` facet (`run`, `talk`, `imported`; the Kind select under Filters, `i` in the terminal) narrows to one; a malformed one is dropped. A Talk row opens `/traces/<id>`; an imported row is plain text until its page lands. The repository facet leaves out Talk and imported rows (they have no repository). Older pages carry both places in one opaque `before`; one this list did not write starts the list over. Not yet: archived turns in the search, and a JSON twin of the list.
23 Talk turns and imported sessions are rows too (#18356): the viewer's own, read from the trace index behind the API's gate (`listSeenTraces`: a Talk turn to its person, an imported session to its owner, no one else), merged by time with the crew runs. The `kind` facet (`run`, `talk`, `imported`; the Kind select under Filters, `i` in the terminal) narrows to one; a malformed one is dropped. A Talk row and an imported row open `/traces/<id>`. The repository facet leaves out Talk and imported rows (they have no repository). Older pages carry both places in one opaque `before`; one this list did not write starts the list over. Not yet: archived turns in the search, and a JSON twin of the list.
2424
2525 ## Narrow by tool and file (#18368)
2626
src/trace/list.ts +2 −2
@@ -51,7 +51,7 @@ export interface TraceRow {
5151 readonly at: string;
5252 readonly outcome: string;
5353 readonly by: string;
54 /** Where the trace opens; none for an imported session until its page lands. */
54 /** Where the trace opens. */
5555 readonly href: string | undefined;
5656 }
5757
@@ -286,7 +286,7 @@ function personal(app: App, actor: User | undefined, f: TraceFilter, cursor: str
286286 at: t.started,
287287 outcome: t.outcome,
288288 by: actor.username,
289 href: t.kind === "talk" ? traceHref(t.id) : undefined,
289 href: traceHref(t.id),
290290 });
291291 }
292292 from = got.next_cursor ?? undefined;
src/tui/screens/traces.ts −1
@@ -123,7 +123,6 @@ function tracesScreen(f: Session, ctx: Ctx): Screen {
123123 else if (e.key === "enter") {
124124 const r = list.rows[at];
125125 if (r?.href !== undefined) openOnWeb(f, ctx, r.href, "the trace");
126 else if (r !== undefined) ctx.toast("an imported session has no page yet", "attn");
127126 } else if (e.key === "n" && list.next !== undefined) ((before = list.next), read());
128127 ctx.invalidate();
129128 return true;
src/web/pages/traces.ts −1
@@ -38,7 +38,6 @@ const text = (name: string, label: string, now: string | undefined, hint: string
3838
3939 const line = (r: TraceRow): Html =>
4040 row({
41 // An imported session has no page yet: a plain row, not a link that goes nowhere.
4241 ...(r.href === undefined ? {} : { href: r.href, nav: true }),
4342 title: r.title,
4443 titleAttr: r.title,
test/traces-kinds.test.ts +3 −1
@@ -70,13 +70,15 @@ test("a Talk turn and an imported session show for their person and for no one e
7070 expect(mine).toContain('data-trace="talk1"');
7171 expect(mine).toContain('data-trace="imp1"');
7272 expect(mine).toContain('href="/traces/talk1"');
73 expect(mine).not.toContain('href="/traces/imp1"'); // its page is the next issue: plain text
73 expect(mine).toContain('href="/traces/imp1"');
74 expect(listTraces(app, alice, {}).rows.find((r) => r.id === "imp1")?.href).toBe("/traces/imp1");
7475 expect(mine).toContain("plan &lt;i&gt;the&lt;/i&gt; week");
7576 expect(mine.slice(mine.indexOf("<main"), mine.indexOf("</main>"))).not.toContain("<script"); // the first paint adds none
7677 const theirs = await page(bobToken, "/traces");
7778 expect(theirs).not.toContain("talk1");
7879 expect(theirs).not.toContain("imp1");
7980 expect(theirs).not.toContain("outside session");
81 expect(theirs).not.toContain('href="/traces/imp1"');
8082 });
8183
8284 test("a repository facet says it leaves Talk and imported rows out", async () => {
test/traces-tui.test.ts +3 −3
@@ -1,5 +1,5 @@
11 /**
2 * The terminal's Traces screen: `i` cycles the kind, and an imported session has no page to open
2 * The terminal's Traces screen: `i` cycles the kind, and an imported session opens like a Talk turn
33 * (#18364).
44 */
55 import { afterAll, beforeAll, expect, test } from "bun:test";
@@ -51,7 +51,7 @@ afterAll(async () => {
5151 await rm(dir, { recursive: true, force: true });
5252 });
5353
54 test("i cycles the kind: runs, then only Talk, then only imported; Enter on an imported session says it has no page", async () => {
54 test("i cycles the kind: runs, then only Talk, then only imported; Enter on an imported session says where its page is", async () => {
5555 const { app, session } = createForgeApp(forge, { sshUsername: "alice", remoteAddress: "127.0.0.1", user: alice }, { terminal: headlessTerminal(120, 30), exitHooks: false });
5656 app.start();
5757 await settleApp(app);
@@ -83,7 +83,7 @@ test("i cycles the kind: runs, then only Talk, then only imported; Enter on an i
8383 expect(imported).not.toContain("crew run summary");
8484
8585 const after = await press("enter");
86 expect(after).toContain("an imported session has no page yet");
86 expect(after).toContain("the trace is on the web at /traces/imp1");
8787 expect(after).toContain("an outside session"); // still on the list: nothing was pushed
8888 app.stop();
8989 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs