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

The studio's three lists disagree: one header, and two dead filters #178

Closed opened this
Closed without merging

scout/forge:scout/175-the-studio-s-three-lists-disagree-one-he → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
2 files changed +65 −11
src/web/studio/lists.ts +30 −11
@@ -60,6 +60,16 @@ const WORD_FILTERS: readonly WordFilter[] = [
6060 "stopped",
6161 ];
6262
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
6373 function listBucket(word: Word): WordFilter {
6474 return word === "waiting" || word === "planned" ? "working" : word;
6575 }
@@ -82,14 +92,19 @@ function inWordFilter(word: Word, filter: WordFilter | undefined): boolean {
8292 : bucket === filter;
8393 }
8494
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 {
89104 return html`<div class="filters mb">
90105 ${seg([
91106 { label: "Open", href: base, current: current === undefined },
92 ...WORD_FILTERS.map((w) => ({
107 ...words.map((w) => ({
93108 label: w[0]!.toUpperCase() + w.slice(1),
94109 href: `${base}?word=${w}`,
95110 current: current === w,
@@ -180,7 +195,7 @@ export async function studioTells(
180195
181196 const body = html`${repoHeader(ctx, repo, "issues")}
182197 <div class="mt">
183 ${wordFilterBar(listBase, filter)} ${list}
198 ${wordFilterBar(listBase, filter, WORD_FILTERS)} ${list}
184199 ${pager(
185200 fetched.length === LIST_PAGE && lastNumber !== undefined
186201 ? { next: pagedHref(listBase, filter, String(lastNumber)) }
@@ -268,7 +283,7 @@ export async function studioChanges(
268283
269284 const body = html`${repoHeader(ctx, repo, "pulls")}
270285 <div class="mt">
271 ${wordFilterBar(listBase, filter)} ${list}
286 ${wordFilterBar(listBase, filter, PULL_WORD_FILTERS)} ${list}
272287 ${pager(
273288 fetched.length === LIST_PAGE && lastNumber !== undefined
274289 ? { next: pagedHref(listBase, filter, String(lastNumber)) }
@@ -323,8 +338,12 @@ export async function changesList(ctx: Ctx): Promise<Response> {
323338 /**
324339 * GET /:owner/:name/runs in the studio: every run, one row per run in its
325340 * 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.
328347 */
329348 export async function studioRuns(
330349 ctx: Ctx,
@@ -380,9 +399,9 @@ export async function studioRuns(
380399 );
381400 const last = fetched[fetched.length - 1];
382401
383 const body = html`${repoHeader(ctx, repo, "app", { compact: true })}
402 const body = html`${repoHeader(ctx, repo, "code")}
384403 <div class="mt">
385 ${wordFilterBar(`${base}/runs`, filter)} ${list}
404 ${wordFilterBar(`${base}/runs`, filter, PULL_WORD_FILTERS)} ${list}
386405 ${pager(
387406 fetched.length === LIST_PAGE && last !== undefined
388407 ? { next: pagedHref(`${base}/runs`, filter, last.id) }
test/studio.test.ts +35
@@ -779,6 +779,41 @@ describe("the studio", () => {
779779 expect(dev).not.toContain("data-word=");
780780 });
781781
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
782817 test("issues, pulls and runs on a repository that is not an app render exactly what they render today, even in studio mode", async () => {
783818 const plain = await createRepo(app, alice, {
784819 name: "plainlists",

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs