Public: anyone can read this; the crew can change it.
small: an imported session's row in /traces opens its page #18379
Merged 4h 15m ago, live in production
mason/forge:mason/18375-small-an-imported-session-s-row-in-trace → main 0 commits fork
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 | ||
| 20 | 20 | |
| 21 | 21 | `/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`). |
| 22 | 22 | |
| 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. | |
| 24 | 24 | |
| 25 | 25 | ## Narrow by tool and file (#18368) |
| 26 | 26 |
src/trace/list.ts +2 −2
| @@ -51,7 +51,7 @@ export interface TraceRow { | ||
| 51 | 51 | readonly at: string; |
| 52 | 52 | readonly outcome: string; |
| 53 | 53 | readonly by: string; |
| 54 | /** Where the trace opens; none for an imported session until its page lands. */ | |
| 54 | /** Where the trace opens. */ | |
| 55 | 55 | readonly href: string | undefined; |
| 56 | 56 | } |
| 57 | 57 | |
| @@ -286,7 +286,7 @@ function personal(app: App, actor: User | undefined, f: TraceFilter, cursor: str | ||
| 286 | 286 | at: t.started, |
| 287 | 287 | outcome: t.outcome, |
| 288 | 288 | by: actor.username, |
| 289 | href: t.kind === "talk" ? traceHref(t.id) : undefined, | |
| 289 | href: traceHref(t.id), | |
| 290 | 290 | }); |
| 291 | 291 | } |
| 292 | 292 | from = got.next_cursor ?? undefined; |
src/tui/screens/traces.ts −1
| @@ -123,7 +123,6 @@ function tracesScreen(f: Session, ctx: Ctx): Screen { | ||
| 123 | 123 | else if (e.key === "enter") { |
| 124 | 124 | const r = list.rows[at]; |
| 125 | 125 | 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"); | |
| 127 | 126 | } else if (e.key === "n" && list.next !== undefined) ((before = list.next), read()); |
| 128 | 127 | ctx.invalidate(); |
| 129 | 128 | return true; |
src/web/pages/traces.ts −1
| @@ -38,7 +38,6 @@ const text = (name: string, label: string, now: string | undefined, hint: string | ||
| 38 | 38 | |
| 39 | 39 | const line = (r: TraceRow): Html => |
| 40 | 40 | row({ |
| 41 | // An imported session has no page yet: a plain row, not a link that goes nowhere. | |
| 42 | 41 | ...(r.href === undefined ? {} : { href: r.href, nav: true }), |
| 43 | 42 | title: r.title, |
| 44 | 43 | 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 | ||
| 70 | 70 | expect(mine).toContain('data-trace="talk1"'); |
| 71 | 71 | expect(mine).toContain('data-trace="imp1"'); |
| 72 | 72 | 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"); | |
| 74 | 75 | expect(mine).toContain("plan <i>the</i> week"); |
| 75 | 76 | expect(mine.slice(mine.indexOf("<main"), mine.indexOf("</main>"))).not.toContain("<script"); // the first paint adds none |
| 76 | 77 | const theirs = await page(bobToken, "/traces"); |
| 77 | 78 | expect(theirs).not.toContain("talk1"); |
| 78 | 79 | expect(theirs).not.toContain("imp1"); |
| 79 | 80 | expect(theirs).not.toContain("outside session"); |
| 81 | expect(theirs).not.toContain('href="/traces/imp1"'); | |
| 80 | 82 | }); |
| 81 | 83 | |
| 82 | 84 | test("a repository facet says it leaves Talk and imported rows out", async () => { |
test/traces-tui.test.ts +3 −3
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /** |
| 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 | |
| 3 | 3 | * (#18364). |
| 4 | 4 | */ |
| 5 | 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; |
| @@ -51,7 +51,7 @@ afterAll(async () => { | ||
| 51 | 51 | await rm(dir, { recursive: true, force: true }); |
| 52 | 52 | }); |
| 53 | 53 | |
| 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 () => { | |
| 55 | 55 | const { app, session } = createForgeApp(forge, { sshUsername: "alice", remoteAddress: "127.0.0.1", user: alice }, { terminal: headlessTerminal(120, 30), exitHooks: false }); |
| 56 | 56 | app.start(); |
| 57 | 57 | await settleApp(app); |
| @@ -83,7 +83,7 @@ test("i cycles the kind: runs, then only Talk, then only imported; Enter on an i | ||
| 83 | 83 | expect(imported).not.toContain("crew run summary"); |
| 84 | 84 | |
| 85 | 85 | 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"); | |
| 87 | 87 | expect(after).toContain("an outside session"); // still on the list: nothing was pushed |
| 88 | 88 | app.stop(); |
| 89 | 89 | }); |
new above
offline