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

The feed can be narrowed to one app from a link on any post's app name #14531

opened this

Check · Review · Land · Live — No review yet. Next: reviewer, no review yet.

Ready to land

scout/forge:scout/14516-the-feed-can-be-narrowed-to-one-app-from → main 7 commits fork

This pull asks to reach lab--forge-trevato-apps.open-platform.sh. Its preview and check reach what main reaches; the new host opens when the pull lands.

Review

Sign in to review this change.
5 files changed +97 −5
src/feed/app_filter.ts +6
@@ -29,3 +29,9 @@ export function appFilterOf(db: Database, viewer: User, raw: string | null): App
2929
3030 /** Whether `raw` is shaped like an app name: what a variant key may carry. */
3131 export const isAppName = (raw: string): boolean => raw.length <= 140 && APP.test(raw);
32
33 /**
34 * The plain line a narrowed feed leads with: the web page's and the MCP feed tool's, in the same
35 * words.
36 */
37 export const onlyLine = (app: string): string => `Only ${app}`;
src/http/mcp/tools/feed.ts +9 −2
@@ -1,12 +1,13 @@
11 import { FEED_LIMIT_DEFAULT, FEED_LIMIT_MAX, parseCursor, readFeed } from "../../../feed/feed.ts";
22 import { parseBefore, readTimeline } from "../../../feed/timeline.ts";
33 import { CURSOR_NOT_ISSUED } from "../../../actions/feed_words.ts";
4 import { appFilterOf, APP_UNKNOWN_LINE, onlyLine } from "../../../feed/app_filter.ts";
45 import { feedDigest } from "../../../web/studio/since.ts";
56 import { good, bad, type Tool, CHIP_ARGS, chipArgs, str } from "../shared.ts";
67
78 export const tool: Tool = {
89 name: "feed",
9 doc: "`{ limit?, cursor?, before?, hide_kinds?, hide_people? }`: your home timeline — tells, replies, runs, changes and looks — ranked, with who, what, why and a link; the same items as `GET /api/v1/feed`; `before` (a `next_cursor`, or `now`) reads the log newest first instead of ranked, as constant-cost pages with no repeat or skip; `digest` (first page only) is home's \"Since you were here\" card, `{ heading, lines: [{ repo, says, href }] }` or null; `quietRuns` counts agent runs of the last 24 h that pushed, opened or said nothing, which the timeline leaves out; an item with `lines: [{ text, link }]` and `more` is a folded burst (3+ issues one author opened in one repository within 2 minutes: `planned N issues in owner/name`, linking to its map) — `lines` are the first three, `more` the rest",
10 doc: "`{ limit?, cursor?, before?, app?, hide_kinds?, hide_people? }`: your home timeline — tells, replies, runs, changes and looks — ranked, with who, what, why and a link; the same items as `GET /api/v1/feed`; `before` (a `next_cursor`, or `now`) reads the log newest first instead of ranked, as constant-cost pages with no repeat or skip; `app` (`owner/name`) narrows the ranked page to it, with `filter`; unknown leaves it whole; not with `before`; `digest` (first page only) is home's \"Since you were here\" card, `{ heading, lines: [{ repo, says, href }] }` or null; `quietRuns` counts agent runs of the last 24 h that pushed, opened or said nothing, which the timeline leaves out; an item with `lines: [{ text, link }]` and `more` is a folded burst (3+ issues one author opened in one repository within 2 minutes: `planned N issues in owner/name`, linking to its map) — `lines` are the first three, `more` the rest",
1011 description:
1112 "Your ranked home timeline; `cursor` pages; saved filter applies.",
1213 inputSchema: {
@@ -15,6 +16,7 @@ export const tool: Tool = {
1516 limit: { type: "integer", minimum: 1, maximum: FEED_LIMIT_MAX },
1617 cursor: { type: "string" },
1718 before: { type: "string" },
19 app: { type: "string", maxLength: 140 },
1820 ...CHIP_ARGS,
1921 },
2022 },
@@ -30,7 +32,11 @@ export const tool: Tool = {
3032 const cursor = given === undefined ? undefined : parseCursor(str(given));
3133 if (given !== undefined && cursor === undefined)
3234 return bad("invalid", CURSOR_NOT_ISSUED);
35 const rawApp = args["app"];
36 const only = rawApp === undefined ? ({ kind: "none" } as const) : appFilterOf(ctx.app.db, user, str(rawApp));
37 const filter = only.kind === "app" ? onlyLine(only.app) : only.kind === "unknown" ? APP_UNKNOWN_LINE : undefined;
3338 const rawBefore = args["before"];
39 if (rawBefore !== undefined && only.kind === "app") return bad("invalid", "app narrows the ranked page; leave before out");
3440 if (rawBefore !== undefined) {
3541 const before = parseBefore(str(rawBefore));
3642 if (before === undefined || given !== undefined) return bad("invalid", CURSOR_NOT_ISSUED);
@@ -45,8 +51,9 @@ export const tool: Tool = {
4551 const page = readFeed(ctx.app.db, user, {
4652 limit,
4753 ...(chips === undefined ? {} : { chips }),
54 ...(only.kind === "app" ? { repoId: only.repo.id } : {}),
4855 ...(cursor === undefined ? {} : { cursor }),
4956 });
50 return good({ ...page, ...(cursor === undefined ? { digest: feedDigest(ctx.app.db, user, Date.now()) } : {}) });
57 return good({ ...page, ...(filter === undefined ? {} : { filter }), ...(cursor === undefined ? { digest: feedDigest(ctx.app.db, user, Date.now()) } : {}) });
5158 },
5259 };
src/web/studio/feed.ts +1 −1
@@ -421,7 +421,7 @@ function filterLine(filter: AppFilter): Html | null {
421421 if (filter.kind === "none") return null;
422422 if (filter.kind === "unknown") return html`<p class="small muted" data-app-filter="unknown">${APP_UNKNOWN_LINE}</p>`;
423423 return html`<p class="bar small" data-app-filter="${filter.app}">
424 <span>Showing <a href="/${filter.app}">${filter.app}</a></span>
424 <span>Only <a href="/${filter.app}">${filter.app}</a></span>
425425 <a href="/feed">Clear</a>
426426 </p>`;
427427 }
test/feed-filter.test.ts +2 −2
@@ -58,7 +58,7 @@ describe("the one-app feed filter", () => {
5858 test("a readable app shows only its items, with the line and a clear link", async () => {
5959 const body = await (await get("/feed?app=alice/open")).text();
6060 expect(body).toContain('data-app-filter="alice/open"');
61 expect(body).toContain("Showing");
61 expect(body).toContain("Only <a");
6262 expect(body).toContain('href="/feed">Clear');
6363 expect(body).toContain("hello from open");
6464 expect(body).not.toContain("hello from other");
@@ -69,7 +69,7 @@ describe("the one-app feed filter", () => {
6969 const priv = await (await get("/feed?app=alice/secret")).text();
7070 for (const body of [unknown, priv]) {
7171 expect(body).toContain(APP_UNKNOWN_LINE);
72 expect(body).not.toContain("Showing");
72 expect(body).not.toContain("Only <a");
7373 expect(body).not.toContain("hello from secret");
7474 expect(body).toContain("hello from other");
7575 }

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs