Public: anyone can read this; the crew can change it.
The studio's three lists disagree: one header, and two dead filters #178
scout/forge:scout/175-the-studio-s-three-lists-disagree-one-he → main 1 commit fork
2 files
changed +65
−11
src/web/studio/lists.ts +30 −11
| @@ -60,6 +60,16 @@ const WORD_FILTERS: readonly WordFilter[] = [ | ||
| 60 | 60 | "stopped", |
| 61 | 61 | ]; |
| 62 | 62 | |
| 63 | /** The vocabulary a list built on `pullWord`/`runWord` can filter by: | |
| 64 | * every word but *told*. Neither function ever hands that word back — | |
| 65 | * `runWord` reaches *told* only by way of `tellWord`, which it never calls | |
| 66 | * — so the changes and runs lists share this rather than each hard-coding | |
| 67 | * their own copy of the five; only the tells list, built on `tellWord`, | |
| 68 | * gets the full `WORD_FILTERS`. */ | |
| 69 | const PULL_WORD_FILTERS: readonly WordFilter[] = WORD_FILTERS.filter( | |
| 70 | (w) => w !== "told", | |
| 71 | ); | |
| 72 | ||
| 63 | 73 | function listBucket(word: Word): WordFilter { |
| 64 | 74 | return word === "waiting" || word === "planned" ? "working" : word; |
| 65 | 75 | } |
| @@ -82,14 +92,19 @@ function inWordFilter(word: Word, filter: WordFilter | undefined): boolean { | ||
| 82 | 92 | : bucket === filter; |
| 83 | 93 | } |
| 84 | 94 | |
| 85 | /** A filter bar of five words, each a link carrying `?word=` — never a | |
| 86 | * form, so the filter lives in the address and can be shared. No filter | |
| 87 | * reads as "Open": what is open and moving. */ | |
| 88 | function wordFilterBar(base: string, current: WordFilter | undefined): Html { | |
| 95 | /** A filter bar of `words`, each a link carrying `?word=` — never a form, | |
| 96 | * so the filter lives in the address and can be shared. No filter reads as | |
| 97 | * "Open": what is open and moving. One component for all three lists; | |
| 98 | * which words it offers is this argument, never a bar copied per list. */ | |
| 99 | function wordFilterBar( | |
| 100 | base: string, | |
| 101 | current: WordFilter | undefined, | |
| 102 | words: readonly WordFilter[], | |
| 103 | ): Html { | |
| 89 | 104 | return html`<div class="filters mb"> |
| 90 | 105 | ${seg([ |
| 91 | 106 | { label: "Open", href: base, current: current === undefined }, |
| 92 | ...WORD_FILTERS.map((w) => ({ | |
| 107 | ...words.map((w) => ({ | |
| 93 | 108 | label: w[0]!.toUpperCase() + w.slice(1), |
| 94 | 109 | href: `${base}?word=${w}`, |
| 95 | 110 | current: current === w, |
| @@ -180,7 +195,7 @@ export async function studioTells( | ||
| 180 | 195 | |
| 181 | 196 | const body = html`${repoHeader(ctx, repo, "issues")} |
| 182 | 197 | <div class="mt"> |
| 183 | ${wordFilterBar(listBase, filter)} ${list} | |
| 198 | ${wordFilterBar(listBase, filter, WORD_FILTERS)} ${list} | |
| 184 | 199 | ${pager( |
| 185 | 200 | fetched.length === LIST_PAGE && lastNumber !== undefined |
| 186 | 201 | ? { next: pagedHref(listBase, filter, String(lastNumber)) } |
| @@ -268,7 +283,7 @@ export async function studioChanges( | ||
| 268 | 283 | |
| 269 | 284 | const body = html`${repoHeader(ctx, repo, "pulls")} |
| 270 | 285 | <div class="mt"> |
| 271 | ${wordFilterBar(listBase, filter)} ${list} | |
| 286 | ${wordFilterBar(listBase, filter, PULL_WORD_FILTERS)} ${list} | |
| 272 | 287 | ${pager( |
| 273 | 288 | fetched.length === LIST_PAGE && lastNumber !== undefined |
| 274 | 289 | ? { next: pagedHref(listBase, filter, String(lastNumber)) } |
| @@ -323,8 +338,12 @@ export async function changesList(ctx: Ctx): Promise<Response> { | ||
| 323 | 338 | /** |
| 324 | 339 | * GET /:owner/:name/runs in the studio: every run, one row per run in its |
| 325 | 340 | * studio word — who ran it, when it last moved, and the transcript as the |
| 326 | * row's own link. `?word=` narrows it; `?mode=dev` reads dev's list, | |
| 327 | * unchanged. | |
| 341 | * row's own link. `?word=` narrows it, from the same vocabulary the changes | |
| 342 | * list offers (`runWord` reaches *told* only through `pullWord`, which never | |
| 343 | * hands it back); `?mode=dev` reads dev's list, unchanged. The header is the | |
| 344 | * same shape as the other two studio lists, and marks *Studio* — the tab | |
| 345 | * this list lives under — current, never the app tab studio mode does not | |
| 346 | * show. | |
| 328 | 347 | */ |
| 329 | 348 | export async function studioRuns( |
| 330 | 349 | ctx: Ctx, |
| @@ -380,9 +399,9 @@ export async function studioRuns( | ||
| 380 | 399 | ); |
| 381 | 400 | const last = fetched[fetched.length - 1]; |
| 382 | 401 | |
| 383 | const body = html`${repoHeader(ctx, repo, "app", { compact: true })} | |
| 402 | const body = html`${repoHeader(ctx, repo, "code")} | |
| 384 | 403 | <div class="mt"> |
| 385 | ${wordFilterBar(`${base}/runs`, filter)} ${list} | |
| 404 | ${wordFilterBar(`${base}/runs`, filter, PULL_WORD_FILTERS)} ${list} | |
| 386 | 405 | ${pager( |
| 387 | 406 | fetched.length === LIST_PAGE && last !== undefined |
| 388 | 407 | ? { next: pagedHref(`${base}/runs`, filter, last.id) } |
test/studio.test.ts +35
| @@ -779,6 +779,41 @@ describe("the studio", () => { | ||
| 779 | 779 | expect(dev).not.toContain("data-word="); |
| 780 | 780 | }); |
| 781 | 781 | |
| 782 | test("the three studio lists agree on their header, and only the tells list offers Told", async () => { | |
| 783 | const tells = await (await get("/alice/notes/tells")).text(); | |
| 784 | const changes = await (await get("/alice/notes/changes")).text(); | |
| 785 | const runs = await (await get("/alice/notes/runs")).text(); | |
| 786 | ||
| 787 | // Same shape: the repo's own description, not the compact header that | |
| 788 | // drops it, on all three. | |
| 789 | expect(tells).toContain('<p class="repo-desc">a place for notes</p>'); | |
| 790 | expect(changes).toContain('<p class="repo-desc">a place for notes</p>'); | |
| 791 | expect(runs).toContain('<p class="repo-desc">a place for notes</p>'); | |
| 792 | ||
| 793 | // The tab strip marks where the reader actually is: the runs list lives | |
| 794 | // under the Studio tab (there is no App tab in studio mode), never a | |
| 795 | // claim to be the app page. | |
| 796 | expect(runs).toContain('href="/alice/notes"\n aria-current="page"'); | |
| 797 | expect(runs).not.toContain(">App<"); | |
| 798 | ||
| 799 | // Told is the tells list's own filter — nobody has picked a tell up | |
| 800 | // yet — and no row on the changes or runs list can ever carry it, so | |
| 801 | // their filter bars never offer it (the tab strip still says "Told", | |
| 802 | // the tab to the tells list itself — this is the filter bar beneath it). | |
| 803 | expect(tells).toContain('href="/alice/notes/tells?word=told"'); | |
| 804 | expect(changes).not.toContain('href="/alice/notes/changes?word=told"'); | |
| 805 | expect(runs).not.toContain('href="/alice/notes/runs?word=told"'); | |
| 806 | ||
| 807 | // A URL asking for it directly still answers, with the list's own empty | |
| 808 | // state, never an error — it is a URL people may hold. | |
| 809 | const toldChanges = await get("/alice/notes/changes?word=told"); | |
| 810 | expect(toldChanges.status).toBe(200); | |
| 811 | expect(await toldChanges.text()).toContain("Nothing matches this filter yet."); | |
| 812 | const toldRuns = await get("/alice/notes/runs?word=told"); | |
| 813 | expect(toldRuns.status).toBe(200); | |
| 814 | expect(await toldRuns.text()).toContain("Nothing matches this filter yet."); | |
| 815 | }); | |
| 816 | ||
| 782 | 817 | test("issues, pulls and runs on a repository that is not an app render exactly what they render today, even in studio mode", async () => { |
| 783 | 818 | const plain = await createRepo(app, alice, { |
| 784 | 819 | name: "plainlists", |
new above
offline