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

/waves filters to one app with ?app=, and the filter is a link on each wave's app name #14474

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/14457-waves-filters-to-one-app-with-app-and-th → main 5 commits fork 2 threads · 2 unresolved

  • Merged. scout/14457-waves-filters-to-one-app-with-app-and-th was merged into main as ff8e2ae.

Review

Sign in to review this change.
10 files changed +247 −23
docs/MCP.md +2
@@ -425,6 +425,8 @@ answers
425425 | `ui://forge/reports` | `reports` (listing) | Waiting reports from outsiders: one row each, its state and who filed it, linked to the repository's reports. |
426426 | `ui://forge/usage` | `usage` | The window's figures as rows: runs, cost and tokens, by agent for a repo, or today and last 24 hours with each account's headroom. |
427427
428 `waves` also reads `app` (a repository name, or `owner/name`): only the waves carrying a change you can read in that app. An unknown, malformed or unreadable app lists none, the same as the page's `/<owner>/<name>/waves?app=`.
429
428430 **Who controls what (#11956).** The host (ChatGPT, Claude) controls the frame around a card: its size limits, border, theme variables, whether it opens a `ui://` page at all, and the tool's name and description in its picker (so a generic line such as "Find issues, pulls…" is the tool's `description`, which is for the model and is held to the size ceiling; the card cannot change it). Forge controls what is inside the frame: `structuredContent.card` (`title`, `status`, `rows` of `label`, `value`, `link`, `depth`, `actions`) and the one page that draws it (`CARD_SHELL`). A host that does not render `ui://` pages shows only the text answer, so the text always carries the full data; the card is a summary of it. Not promised: fonts, per-row colour, truncation by the host, or any widget beyond title, status, rows, links and buttons. Not tested in the live ChatGPT connector from the build sandbox; the wording was checked against the card model only. The page is one document for both hosts (`text/html;profile=mcp-app`, which ChatGPT's current docs name too): every style is inline in both colour schemes, it names no network address (`_meta.ui.csp` is empty, `prefersBorder` false), it reads ChatGPT's `window.openai.toolOutput` and theme on load as well as the MCP Apps `ui/initialize` bridge, and `tools/list` carries `openai/outputTemplate` beside `_meta.ui.resourceUri`. A host caches a template by its URI: after a release, reconnect the connector (ChatGPT: refresh it in Settings) to refetch it. `test/card-offline.test.ts` holds each page to this.
429431 **Card vocabulary.** *title*: what this is (`Pulls`, or `#7 the pull's title` for one thing, cut at 90 characters on a word with `…`; the whole title is in the text answer). *status*: the one line every row shares, counts first (`5 open · 2 red · 3 green`, `healthy · 3 running · 1 queued`). *row label*: the identity (`#7 title`, `owner/name`), linked when it has a page. *row value*: only what differs from the other rows, `·`-separated, state words in plain language (`check green`, `no check`, `approved`), never a state the status line already said. *actions*: buttons that call a tool.
430432 The Runs card (`runs`) is one row per run, newest first: glyph, kind, the issue or pull and its title, then the state as a word with how long it ran (or has been running), linked to the run page; failed runs lead the status line. The Plan card (`map`) shows one row per pillar with
docs/design/areas/waves.md +7
@@ -17,3 +17,10 @@ highlight's why as the one sentence under it (omitted when empty), and
1717 `version · date · N pulls` as a muted trail. No tooltip repeats it. No new
1818 class and no CSS beyond the wrapping above. The terminal's waves screen
1919 (`src/tui/screens/waves.ts`) is unchanged.
20
21 ## One app's waves (#14457)
22
23 `?app=` names its filter with the shared `seg` over the list: `All` (back to
24 the whole list) and the app, `aria-current`. An unknown or malformed app reads
25 `Unknown app`; the text asked for is never echoed. Each wave's apps sit in the
26 row's `after` slot as plain links, outside the row's own link. No new class.
docs/features/wave-app-filter.md added +16
@@ -0,0 +1,16 @@
1 ---
2 topic: Tell the crew
3 row: One app's changes in a wave
4 ---
5 # One app's changes in a wave
6
7 The waves list narrows to one app in every door. A wave is kept when it carries a change you can read in that app; a file that is not a wave is hidden while filtering.
8
9 - **Page:** `/<owner>/<name>/waves?app=<name or owner/name>`, or tap an app name beside a wave. `All` above the list removes the filter.
10 - **Terminal:** on the waves screen press `a`; it steps through the apps the waves carry, then back to all.
11 - **MCP:** `waves` with `app`.
12 - An app that is unknown, malformed or one you cannot read lists nothing, the same for all three.
13
14 Try it: open `/trevato/forge/waves`, tap an app name, then `All`.
15
16 All doors decide with `wavesInApp` in `src/story/waves.ts`.
src/http/mcp/tools/waves.ts +6 −3
@@ -1,4 +1,4 @@
1 import { pullRefs, readWave, readWaves } from "../../../story/waves.ts";
1 import { pullRefs, readWave, readWaves, wavesInApp } from "../../../story/waves.ts";
22 import { VERSION as WAVE_VERSION } from "../../../story/wave.ts";
33 import { repoDir } from "../../../git/repos.ts";
44 import { movedForViewer, waveProgress } from "../../../story/wave_moved.ts";
@@ -10,13 +10,14 @@ import { good, bad, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts"
1010
1111 export const tool: Tool = {
1212 name: "waves",
13 doc: "`{ repo, version? }`: the repository's waves newest first (version, date, headline; a broken file is `{ version, error }`), or with `version` one wave: headline, progress, highlights with their why, pull numbers (with the `ui://forge/wave` card); a private repository is not found to a stranger",
13 doc: "`{ repo, version?, app? }`: the repository's waves newest first (`app`: only waves with a change you can read in that app, `name` or `owner/name`; unknown: none) (version, date, headline; a broken file is `{ version, error }`), or with `version` one wave: headline, progress, highlights with their why, pull numbers (with the `ui://forge/wave` card); a private repository is not found to a stranger",
1414 description: "Waves; `version`: one.",
1515 inputSchema: {
1616 type: "object",
1717 properties: {
1818 repo: REPO_ARG,
1919 version: { type: "string", maxLength: 64 },
20 app: { type: "string", maxLength: 201 },
2021 },
2122 required: ["repo"],
2223 },
@@ -27,7 +28,9 @@ export const tool: Tool = {
2728 const dir = repoDir(ctx.app.reposRoot, repo.ownerName, repo.name);
2829 const version = args["version"];
2930 if (version === undefined) {
30 const entries = await readWaves(dir, repo.defaultBranch);
31 let entries = await readWaves(dir, repo.defaultBranch);
32 if (args["app"] !== undefined)
33 entries = wavesInApp(entries, args["app"], (w) => carriedPulls(ctx.app.db, pullRefs(w), user));
3134 return good({
3235 repo: repo.ownerName + "/" + repo.name,
3336 waves: entries.map((e) =>
src/story/waves.ts +35
@@ -6,6 +6,7 @@
66 */
77
88 import { readerFor, listTree } from "../git/read.ts";
9 import { isSafeName } from "../git/guard.ts";
910 import { parseWave, VERSION as WAVE_VERSION, type Wave } from "./wave.ts";
1011
1112 /** A page, not an archive: more files than this are not read. */
@@ -227,3 +228,37 @@ export function backToWave(from: string | null): { href: string; version: string
227228 if (!m || !WAVE_VERSION.test(m[3]!)) return null;
228229 return { href: wavePath(m[1]!, m[2]!, m[3]!), version: m[3]! };
229230 }
231
232 /**
233 * The app a `?app=` / `app` argument names: a repository name, or `owner/name`. Anything that is
234 * not one is null (the empty filter, never an error), so user text is checked before it is used.
235 */
236 export function parseAppFilter(raw: unknown): string | null {
237 if (typeof raw !== "string" || raw.length > 201) return null;
238 const parts = raw.split("/");
239 if (parts.length > 2 || !parts.every((p) => isSafeName(p))) return null;
240 return raw;
241 }
242
243 /** Whether a visible pull sits in the app (`name`, or `owner/name`). */
244 export const inApp = (p: { owner: string; name: string }, app: string): boolean =>
245 app.includes("/") ? `${p.owner}/${p.name}` === app : p.name === app;
246
247 /** The distinct apps a wave's visible pulls sit in, as `owner/name`, in first-seen order. */
248 export function appsOf(pulls: readonly { owner: string; name: string }[]): string[] {
249 return [...new Set(pulls.map((p) => `${p.owner}/${p.name}`))];
250 }
251
252 /**
253 * The waves carrying a change the viewer can read in `app` (`carriedIn` is the gated pull list of
254 * one wave). A file that is not a wave, an unparseable `app` and an app nobody can read all give
255 * nothing, so the three look alike.
256 */
257 export function wavesInApp(
258 entries: readonly WaveEntry[],
259 raw: unknown,
260 carriedIn: (w: Wave) => readonly { owner: string; name: string }[],
261 ): WaveEntry[] {
262 const app = parseAppFilter(raw);
263 return entries.filter((e) => e.ok && app !== null && carriedIn(e.wave).some((p) => inApp(p, app)));
264 }
src/tui/screens/waves.ts +22 −5
@@ -16,7 +16,7 @@ import { milestonePath, planNow } from "../../story/wave_plan.ts";
1616 import { repoBase } from "../../web/chrome.ts";
1717 import { waitingKeys } from "../../release/landings.ts";
1818 import { carriedPulls, inLandingOrder, pullPath, type CarriedPull } from "../../story/wave_pulls.ts";
19 import { pullRefs, readWave, readWaves, sizeWords, waveLine, waveSize, type WaveEntry } from "../../story/waves.ts";
19 import { pullRefs, readWave, readWaves, sizeWords, waveLine, waveSize, appsOf, wavesInApp, type WaveEntry } from "../../story/waves.ts";
2020 import { FIRST_WAVE_BUTTON, FIRST_WAVE_TELL, NO_WAVES, landedSentence, waveSentence } from "../../story/words.ts";
2121 import type { RepoSource } from "../../view/source.ts";
2222 import type { Ctx, Screen } from "../app/app.ts";
@@ -185,9 +185,15 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
185185 let shipped = new Map<string, string>();
186186 let loaded = false;
187187 const state = new ListState();
188 /** The app the list is narrowed to (`a` cycles through the apps the waves carry), as `?app=`. */
189 let app: string | null = null;
190 let apps: string[] = [];
191 /** The waves shown: all, or those with a change in `app`, by the page's rule. */
192 const shown = (): WaveEntry[] =>
193 app === null ? entries : wavesInApp(entries, app, (w) => carriedPulls(f.db, pullRefs(w), f.user));
188194
189195 const openAt = (i: number): void => {
190 const entry = entries[i];
196 const entry = shown()[i];
191197 if (entry === undefined || repo === undefined) return;
192198 runAsync(ctx, async () => {
193199 // Same gate as the list, re-checked: the screen outlives a change of access.
@@ -236,6 +242,8 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
236242 e.ok ? [[e.file, shippedWords(shippedOf(carriedPulls(f.db, pullRefs(e.wave), f.user), waiting))] as const] : [],
237243 ),
238244 );
245 apps = [...new Set(entries.flatMap((e) => (e.ok ? appsOf(carriedPulls(f.db, pullRefs(e.wave), f.user)) : [])))];
246 if (app !== null && !apps.includes(app)) app = null;
239247 loaded = true;
240248 ctx.invalidate();
241249 };
@@ -297,6 +305,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
297305 binding(["j", "k"], "move"),
298306 binding(["enter"], "open"),
299307 binding(["c"], "cut a wave"),
308 ...(apps.length > 0 ? [binding(["a"], "filter by app")] : []),
300309 ...(askable() ? [binding(["t"], "tell the crew to write the first wave")] : []),
301310 binding(["r"], "refresh"),
302311 ];
@@ -314,7 +323,7 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
314323 head!.x,
315324 head!.y,
316325 truncate(
317 `${sourceName(src)} · ${plural(entries.length, "wave")}`,
326 `${sourceName(src)} · ${plural(shown().length, "wave")}${app === null ? "" : ` in ${plain(app)} (a: next app)`}`,
318327 head!.w,
319328 ),
320329 style(c.mutedFg, c.bg),
@@ -332,12 +341,20 @@ export function wavesScreen(f: Session, ctx: Ctx, src: RepoSource): Screen {
332341 });
333342 return;
334343 }
335 const rows = waveRows(entries, (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 }, (e) => shipped.get(e.file) ?? "");
344 const rows = waveRows(shown(), (e) => sizes.get(e.file) ?? { pulls: 0, apps: 0 }, (e) => shipped.get(e.file) ?? "");
336345 drawList(s, body!, c, state, rows);
337346 hitList(ctx, body!, state, rows.length, { open: openAt });
338347 },
339348 key(e) {
340 if (state.key(e, entries.length)) return true;
349 if (e.key === "a" && !e.ctrl && !e.alt && apps.length > 0) {
350 // None, then each app in turn, then none again: the page's Clear is the last step.
351 const at = app === null ? -1 : apps.indexOf(app);
352 app = at + 1 >= apps.length ? null : apps[at + 1]!;
353 state.index = 0;
354 ctx.invalidate();
355 return true;
356 }
357 if (state.key(e, shown().length)) return true;
341358 if (e.key === "enter") {
342359 openAt(state.index);
343360 return true;
src/web/pages/waves.ts +31 −15
@@ -19,12 +19,12 @@ import { VERSION, type Wave } from "../../story/wave.ts";
1919 import { movedWithPulls, type MovedMilestone, shippedOf, shippedWords, waveProgress, widestMoved } from "../../story/wave_moved.ts";
2020 import { waveDuration } from "../../story/wave_duration.ts";
2121 import { carriedPulls, inLandingOrder, pullPath } from "../../story/wave_pulls.ts";
22 import { fromWave, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts";
22 import { appsOf, fromWave, inApp, parseAppFilter, pullRefs, readWave, readWaves, sizeWords, waveSize } from "../../story/waves.ts";
2323 import { FIRST_WAVE_BUTTON, FIRST_WAVE_TELL, NO_WAVES, landedSentence, waveSentence } from "../../story/words.ts";
2424 import { loadRepo, notFoundPage, repoBase, scopeHeader } from "../chrome.ts";
2525 import { escapeHtml, html, type Html } from "../html.ts";
2626 import { page } from "../layout.ts";
27 import { btn, empty, listCard, row } from "../ui.ts";
27 import { btn, empty, listCard, row, seg } from "../ui.ts";
2828 import { localScope } from "../scope.ts";
2929 import { milestoneHref, planFor, progress } from "./milestones.ts";
3030 import { nearMilestones, standingLine } from "./milestones_near.ts";
@@ -42,13 +42,14 @@ export const WAVES_CSS = `[data-waves] { overflow-wrap: anywhere; }
4242 * One wave on the list: its headline, the first highlight's why as the one sentence under it, and
4343 * version, date and pull count as a muted trail.
4444 */
45 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }, shipped = "") {
45 export function waveRow(w: Wave, href: string, size: { pulls: number; apps: number }, shipped = "", apps: readonly Html[] = []) {
4646 const why = w.highlights[0]?.why;
4747 return row({
4848 href,
4949 nav: true,
5050 title: w.headline,
5151 ...(why === undefined || why === "" ? {} : { meta: html`${why}` }),
52 ...(apps.length === 0 ? {} : { after: html`${apps.map((a, i) => html`${i === 0 ? "" : " "}${a}`)}` }),
5253 trail: html`<span class="muted small">${w.version} · ${w.date} · <span data-wave-size>${sizeWords(size)}</span>${shipped === "" ? "" : html` · <span data-wave-shipped>${shipped}</span>`}</span>`,
5354 });
5455 }
@@ -70,23 +71,40 @@ export async function wavesPage(ctx: Ctx): Promise<Response> {
7071 : `${repoBase(repo)}/blob/${encodeURIComponent(branch)}/waves/${encodeURIComponent(file)}`;
7172
7273 const waiting = waitingKeys(ctx.app.db);
73 const rows = entries.map((e) => {
74 // `?app=` narrows to the waves carrying a pull the viewer can read in that app. An unknown,
75 // unreadable or malformed app matches nothing: the empty state, the same for all three.
76 const asked = ctx.url.searchParams.get("app");
77 const filtering = asked !== null && asked !== "";
78 const app = filtering ? parseAppFilter(asked) : null;
79 const listHref = `${repoBase(repo)}/waves`;
80 const rows = entries.flatMap((e) => {
7481 if (!e.ok)
75 return row({
76 href: fileHref(e.file),
77 nav: true,
78 title: e.file,
79 meta: html`Not a wave: ${e.reason}`,
80 });
82 return filtering
83 ? []
84 : [row({ href: fileHref(e.file), nav: true, title: e.file, meta: html`Not a wave: ${e.reason}` })];
8185 // The wave's own page lists these same pulls, so the two agree.
8286 const carried = carriedPulls(ctx.app.db, pullRefs(e.wave), ctx.auth.user);
83 return waveRow(e.wave, fileHref(e.file), waveSize(carried), shippedWords(shippedOf(carried, waiting)));
87 if (filtering && (app === null || !carried.some((p) => inApp(p, app)))) return [];
88 // The app names sit beside the row, outside its link: a link cannot hold links.
89 const links = appsOf(carried).map((a) => html`<a data-wave-app href="${listHref}?app=${encodeURIComponent(a)}">${a}</a>`);
90 return [waveRow(e.wave, fileHref(e.file), waveSize(carried), shippedWords(shippedOf(carried, waiting)), links)];
8491 });
92 // The set filter is named as the list's tabs are: All, then the app, current. A malformed app is
93 // never echoed.
94 const filterLine = filtering
95 ? seg([
96 { label: "All", href: listHref, current: false },
97 { label: app ?? "Unknown app", href: app === null ? listHref : `${listHref}?app=${encodeURIComponent(app)}`, current: true },
98 ])
99 : "";
85100
86101 const body = html`${scopeHeader(ctx, scope, "none", { compact: true })}
87102 <div class="mt" data-waves>
88103 <h1 class="sr-only">Waves</h1>
89 ${entries.length === 0
104 ${filterLine}
105 ${rows.length === 0 && filtering
106 ? empty({ title: "No waves for that app" })
107 : entries.length === 0
90108 ? empty({
91109 title: "No waves yet",
92110 note: NO_WAVES,
@@ -100,9 +118,7 @@ export async function wavesPage(ctx: Ctx): Promise<Response> {
100118 }
101119 : {}),
102120 })
103 : html`<ul class="list">
104 ${rows}
105 </ul>`}
121 : html`<ul class="list">${rows}</ul>`}
106122 </div>`;
107123
108124 const response = page({
test/mcp-waves.test.ts +39
@@ -11,6 +11,7 @@ import { createUser } from "../src/core/users.ts";
1111 import { serve, type Servers } from "../src/http/server.ts";
1212 import { writeWave } from "../src/story/wave.ts";
1313 import { quietLogs } from "./helpers/globals.ts";
14 import { mergedPull, waveNaming } from "./helpers/wave-pulls.ts";
1415
1516 quietLogs();
1617
@@ -66,6 +67,19 @@ beforeAll(async () => {
6667 if (name === "svc") files.push({ path: "waves/broken.md", content: "nope" });
6768 ok(await commitToBranch(app, owner, repo, { message: "waves", files }));
6869 }
70 // A wave naming a readable pull (mix) and one in a private app (hid), for the app filter.
71 const mix = ok(await createRepo(app.db, app.reposRoot, { ownerId: owner.id, name: "mix", visibility: "public" }));
72 const hid = ok(await createRepo(app.db, app.reposRoot, { ownerId: owner.id, name: "hid", visibility: "private" }));
73 for (const r of [mix, hid]) ok(await commitToBranch(app, owner, r, { message: "init", files: [{ path: "README.md", content: "hi\n" }] }));
74 const shown = await mergedPull(app, owner, mix, "Shown work");
75 const hidden = await mergedPull(app, owner, hid, "Hidden work");
76 const named = (version: string, refs: { owner: string; name: string; number: number }[]) =>
77 ({ path: `waves/${version}.md`, content: waveNaming(version, refs) });
78 ok(await commitToBranch(app, owner, mix, { message: "waves", files: [
79 named("1.0.0", [{ owner: "ada", name: "mix", number: shown }]),
80 named("1.1.0", [{ owner: "ada", name: "hid", number: hidden }]),
81 { path: "waves/broken.md", content: "nope" },
82 ] }));
6983 tok["owner"] = createToken(app.db, owner.id, "ro", "ro").token;
7084 tok["stranger"] = createToken(app.db, stranger.id, "ro", "ro").token;
7185 }, 30_000);
@@ -112,3 +126,28 @@ test("a private repository is not found to someone who cannot read it", async ()
112126 expect(r.error).toContain("not_found");
113127 expect((await mcp(tok["stranger"]!, { repo: "ada/secret", version: "0.9.0" })).error).toContain("not_found");
114128 });
129
130 test("app keeps the waves with a readable change in that app", async () => {
131 const versions = async (t: string, app?: string) =>
132 (await mcp(t, { repo: "ada/mix", ...(app === undefined ? {} : { app }) })).value.waves.map((w: any) => w.version);
133 // Unfiltered: both waves and the file that is not a wave.
134 expect(await versions(tok["stranger"]!)).toEqual(["1.1.0", "1.0.0", "broken"]);
135 // A filter keeps the match, by name or owner/name, and drops the file that is not a wave.
136 expect(await versions(tok["stranger"]!, "mix")).toEqual(["1.0.0"]);
137 expect(await versions(tok["stranger"]!, "ada/mix")).toEqual(["1.0.0"]);
138 expect(await versions(tok["owner"]!, "mix")).toEqual(["1.0.0"]);
139 });
140
141 test("a private app is empty for a stranger and matched for its owner", async () => {
142 const versions = async (t: string, app: string) =>
143 (await mcp(t, { repo: "ada/mix", app })).value.waves.map((w: any) => w.version);
144 expect(await versions(tok["stranger"]!, "hid")).toEqual([]);
145 expect(await versions(tok["owner"]!, "hid")).toEqual(["1.1.0"]);
146 expect(await versions(tok["owner"]!, "ada/hid")).toEqual(["1.1.0"]);
147 });
148
149 test("an unknown or malformed app is empty, not an error", async () => {
150 for (const app of ["nope", "ada/nope", "../x", "a/b/c"])
151 expect((await mcp(tok["owner"]!, { repo: "ada/mix", app })).value.waves).toEqual([]);
152 expect((await mcp(tok["stranger"]!, { repo: "ada/secret", app: "secret" })).error).toContain("not_found");
153 });
test/tui-waves.test.ts +52
@@ -379,6 +379,58 @@ describe("waves in the terminal", () => {
379379 expect(await hasBranch(pub)).toBe(false);
380380 });
381381
382 test("a narrows the list to one app's waves, cycles through to all, and never offers an app the viewer cannot read", async () => {
383 const r = await createRepo(forge, alice, { name: "apps", visibility: "public" });
384 if (!r.ok) throw new Error("repo failed");
385 const repo = r.value;
386 await commitToBranch(forge, alice, repo, { message: "init", files: [{ path: "README.md", content: "hi\n" }] });
387 const here = await mergedPull(forge, alice, repo, "Here work");
388 const hidden = await mergedPull(forge, alice, priv, "Hidden work");
389 await commitToBranch(forge, alice, repo, {
390 message: "waves",
391 files: [
392 { path: "waves/0.1.0.md", content: waveNaming("0.1.0", [{ owner: "alice", name: "apps", number: here }]) },
393 { path: "waves/0.2.0.md", content: waveNaming("0.2.0", [{ owner: "alice", name: "priv", number: hidden }]) },
394 ],
395 });
396 const row = (v: string) => `${v} · 2026-03-05 · Mixed`;
397
398 // The owner reads both apps: a, a, a is one app, the other, then all again.
399 const owner = await open(alice, repo, ["a", "a", "a"]);
400 owner.stop();
401 expect(owner.text).toContain("2 waves");
402 expect(owner.text).toContain("a filter by app");
403 const named = owner.after.slice(0, 2).map((t) => (t.includes("in alice/apps") ? "apps" : t.includes("in alice/priv") ? "priv" : "none"));
404 expect(named.sort()).toEqual(["apps", "priv"]);
405 for (const t of owner.after.slice(0, 2)) {
406 expect(t).toContain("1 wave in alice/");
407 if (t.includes("in alice/apps")) {
408 expect(t).toContain(row("0.1.0"));
409 expect(t).not.toContain(row("0.2.0"));
410 } else {
411 expect(t).toContain(row("0.2.0"));
412 expect(t).not.toContain(row("0.1.0"));
413 }
414 }
415 const all = owner.after[2]!;
416 expect(all).toContain("2 waves");
417 expect(all).not.toContain(" in alice/");
418 expect(all).toContain(row("0.1.0"));
419 expect(all).toContain(row("0.2.0"));
420
421 // An outsider is offered only the public app: a narrows to it, a again returns to all.
422 const outsider = await open(bob, repo, ["a", "a", "a"]);
423 outsider.stop();
424 const [first, second, third] = outsider.after;
425 expect(first).toContain("1 wave in alice/apps");
426 expect(first).toContain(row("0.1.0"));
427 expect(first).not.toContain(row("0.2.0"));
428 for (const t of outsider.after) expect(t).not.toContain("alice/priv");
429 expect(second).toContain("2 waves");
430 expect(second).not.toContain(" in alice/");
431 expect(third).toContain("1 wave in alice/apps");
432 });
433
382434 test("a live browse says waves are only read on this forge", async () => {
383435 const h = await open(alice, pub, [], true);
384436 h.stop();
test/waves-page.test.ts +37
@@ -126,6 +126,43 @@ describe("waves page", () => {
126126 expect(body).toContain("Tenth");
127127 });
128128
129 test("?app= lists only waves with a change in that app, and each app name links to it", async () => {
130 const all = await (await get("/alice/pub/waves")).text();
131 expect(all).toContain('data-wave-app ');
132 expect(all).toContain('href="/alice/pub/waves?app=alice%2Fpub"');
133 const body = await (await get("/alice/pub/waves?app=pub")).text();
134 expect(body).toContain("0.1.0 ·");
135 expect(body).not.toContain("Tenth");
136 // A file that is not a wave is hidden while filtering, and listed again once cleared.
137 expect(body).not.toContain("broken.md");
138 expect(all).toContain("broken.md");
139 // The set filter is the shared `seg`: All clears it, the app is the current one.
140 expect(body).toContain('class="seg"');
141 expect(body).toMatch(/href="\/alice\/pub\/waves"\s*>All</);
142 expect(body).toMatch(/href="\/alice\/pub\/waves\?app=pub"\s*aria-current="page"\s*>pub</);
143 expect(all).not.toMatch(/>All</);
144 });
145
146 test("an unknown or malformed app is the empty state, not an error", async () => {
147 for (const app of ["nope", "../x", "a/b/c", "<script>x</script>"]) {
148 const res = await get(`/alice/pub/waves?app=${encodeURIComponent(app)}`);
149 expect(res.status).toBe(200);
150 const body = await res.text();
151 expect(body).toContain("No waves for that app");
152 expect(body).not.toContain("<script>x</script>");
153 }
154 });
155
156 test("an app the viewer cannot read is the same empty state", async () => {
157 const anon = await (await get("/alice/pub/waves?app=priv", false)).text();
158 const unknown = await (await get("/alice/pub/waves?app=nope", false)).text();
159 expect(anon).toContain("No waves for that app");
160 expect(anon).not.toContain("alice/priv");
161 expect(unknown).toContain("No waves for that app");
162 // The owner can read it, so for them it filters.
163 expect(await (await get("/alice/pub/waves?app=priv")).text()).toContain("0.1.0 ·");
164 });
165
129166 test("settings links to the list from the Cut a wave card", async () => {
130167 const body = await (await get("/alice/pub/settings")).text();
131168 expect(body).toContain('href="/alice/pub/waves"');

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs