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

Pinned repositories list only what the viewer may read, and a stale pin can be removed #15017

Merged opened this

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

Merged

scout/forge:scout/14967-pinned-repositories-list-only-what-the-v → main 5 commits fork 1 thread · 1 unresolved

  • Merged. scout/14967-pinned-repositories-list-only-what-the-v was merged into main as 6b7374e.

Review

Sign in to review this change.
8 files changed +309 −67
docs/features/pins-lost-access.md added +15
@@ -0,0 +1,15 @@
1 ---
2 topic: What a forge is
3 row: Pinned repositories: a pin to a repository you lost access to
4 ---
5 # Pinned repositories: a pin to a repository you lost access to
6
7 A pin (the repositories `forge sync` keeps on your machine) outlives the access it was made with. When a repository you pinned goes private, or you are taken off it, the pin stays but is hidden: no list names it, so nothing you pinned can tell you about a repository you may no longer see.
8
9 You can still take it off:
10
11 - **Terminal**: the first screen's machine pane ends with one nameless row, "N pins no longer available · d clears". Move to it and press `d` (or `enter`), then choose **Unpin**: every such pin comes off at once. The row never names the repositories.
12 - **API**: `DELETE /api/v1/user/pins/<owner>/<name>` answers 204 for your own pin, readable or not. A repository you never pinned answers 404 whether or not it exists.
13 - **MCP**: `pins` with `{ action: "unpin", repo: "owner/name" }`, on the same terms.
14
15 `GET /api/v1/user/pins` and the MCP `pins` list leave a hidden pin out. Get access back and it shows again.
src/http/api/user.ts +13 −10
@@ -18,7 +18,7 @@ import { listAssignedTo } from "../../core/issues.ts";
1818 import { nextStepsFor } from "../../core/next-steps.ts";
1919 import { listKeys, publicKey } from "../../core/keys.ts";
2020 import { listOrgsForUser } from "../../core/orgs.ts";
21 import { canRead, getReposByIds } from "../../core/repos.ts";
21 import { canRead, getRepo, getReposByIds, readableRepoIds } from "../../core/repos.ts";
2222 import { notePhase, takeSessionTime, timePhase, timePhaseAsync } from "../../core/route_timing.ts";
2323 import { mayView } from "../../core/sealed.ts";
2424 import { emailVerified, RESEND_AFTER_MS } from "../../core/verify.ts";
@@ -757,19 +757,19 @@ export function userRoutes(router: Router<Handler>): void {
757757 const window = keyedWindow(ctx);
758758 if (window instanceof Response) return window;
759759 const user = ctx.auth.user;
760 const { pins, repos } = timePhase(ctx.request, "pins", () => {
760 const { pins, repos, readable } = timePhase(ctx.request, "pins", () => {
761761 const pins = listPinned(ctx.app, user);
762 // One query for every pinned repo, not one per pin.
763 const repos = getReposByIds(
764 ctx.app.db,
765 pins.map((pin) => pin.repoId),
766 );
767 return { pins, repos };
762 const ids = pins.map((pin) => pin.repoId);
763 // One query for every pinned repo, and one for which of them the
764 // viewer may still read: a pin outlives the access it was made with.
765 const repos = getReposByIds(ctx.app.db, ids);
766 const readable = readableRepoIds(ctx.app.db, user, ids);
767 return { pins, repos, readable };
768768 });
769769 return timePhase(ctx.request, "render", () => {
770770 const items = pins.flatMap((pin) => {
771771 const repo = repos.get(pin.repoId);
772 if (!repo) return [];
772 if (!repo || !readable.has(repo.id)) return [];
773773 const path = `${encodeURIComponent(repo.ownerName)}/${encodeURIComponent(repo.name)}`;
774774 return [
775775 {
@@ -849,7 +849,10 @@ export function userRoutes(router: Router<Handler>): void {
849849 router.add("DELETE", "/api/v1/user/pins/:owner/:name", (ctx) => {
850850 const denied = requireScope(ctx, "rw");
851851 if (denied) return denied;
852 const repo = loadRepo(ctx);
852 // Not `loadRepo`: a pin on a repository the caller can no longer read
853 // must still come off. Only the caller's own pin is dropped, and a repo
854 // they never pinned answers 404 whether or not it exists.
855 const repo = getRepo(ctx.app.db, ctx.params.owner!, ctx.params.name!);
853856 if (!repo) return notFound();
854857 const removed = unpinRepo(ctx.app, ctx.auth.user, repo);
855858 if (!removed.ok) return respondAccess(removed.error, 404);
src/http/mcp/tools/pins.ts +16 −3
@@ -1,11 +1,12 @@
11 import { pageLimit } from "../../../core/issues.ts";
22 import { listPinned, pinRepo, unpinRepo } from "../../../actions/origins.ts";
3 import { canRead, getReposByIds } from "../../../core/repos.ts";
3 import { isPinned } from "../../../core/pins.ts";
4 import { canRead, getRepo, getReposByIds } from "../../../core/repos.ts";
45 import { good, bad, badLimit, type Tool, REPO_ARG, repoArg, isAnswer } from "../shared.ts";
56
67 export const tool: Tool = {
78 name: "pins",
8 doc: "`{ action?, repo?, limit? (1 to 200), cursor? }`: `list` (the default) the caller's pinned repositories, paged by `owner/name` as `GET /api/v1/user/pins` is (`next_cursor`), leaving out a pin whose repository the caller can no longer read (the API's list still names it); `pin` or `unpin` `repo`, as `PUT`/`DELETE /api/v1/user/pins/:owner/:name` do. A repository the caller cannot see is not found",
9 doc: "`{ action?, repo?, limit? (1 to 200), cursor? }`: `list` (the default) the caller's pinned repositories, paged by `owner/name` as `GET /api/v1/user/pins` is (`next_cursor`), leaving out a pin whose repository the caller can no longer read; `pin` or `unpin` `repo`, as `PUT`/`DELETE /api/v1/user/pins/:owner/:name` do. A repository the caller cannot see is not found, but their own pin on one still unpins",
910 description: "Your pinned repos: list, pin or unpin `repo`.",
1011 inputSchema: {
1112 type: "object",
@@ -45,7 +46,11 @@ export const tool: Tool = {
4546 next_cursor: after.length > size ? page[page.length - 1]!.repo : null,
4647 });
4748 }
48 const repo = repoArg(ctx, user, args);
49 // A pin outlives the access it was made with (#14967): the caller's own
50 // pin comes off even when they can no longer read the repository. One
51 // they never pinned still answers like a repository that does not exist.
52 const stale = action === "unpin" && user !== undefined ? ownPin(ctx, user.id, args) : undefined;
53 const repo = stale ?? repoArg(ctx, user, args);
4954 if (isAnswer(repo)) return repo;
5055 const done = action === "pin" ? pinRepo(ctx.app, user, repo) : unpinRepo(ctx.app, user, repo);
5156 return done.ok
@@ -53,3 +58,11 @@ export const tool: Tool = {
5358 : bad(done.error, action === "pin" ? "that could not be pinned" : "that repository is not pinned");
5459 },
5560 };
61
62 /** The repository `repo` names, only when this user has it pinned. */
63 function ownPin(ctx: Parameters<Tool["run"]>[0], userId: string, args: Record<string, unknown>) {
64 const [owner, name, ...rest] = String(args["repo"] ?? "").split("/");
65 if (!owner || !name || rest.length > 0) return undefined;
66 const repo = getRepo(ctx.app.db, owner, name);
67 return repo !== undefined && isPinned(ctx.app.db, userId, repo.id) ? repo : undefined;
68 }
src/tui/screens/dashboard.ts +89 −35
@@ -78,6 +78,7 @@ import { listOrgsForUser } from "../../core/orgs.ts";
7878 import {
7979 canAdmin,
8080 canRead,
81 readableRepoIds,
8182 getRepo,
8283 getReposByIds,
8384 listReposVisibleTo,
@@ -197,6 +198,12 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
197198 /** What a typed filter found past `all`, for the query it was read for. */
198199 let found: { query: string; repos: Repo[] } | undefined;
199200 let pins: Pin[] = [];
201 /**
202 * Pins on repositories this account can no longer read (#14967): kept by
203 * id only, drawn as one nameless row that clears them, so the terminal can
204 * remove what it will not name.
205 */
206 let stalePins: string[] = [];
200207 let pinned = new Set<string>();
201208 let onYou: OnYouItem[] = [];
202209 /** Where each pull on you stands on the path (check, review, land, live), by issue id. */
@@ -444,7 +451,12 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
444451 const reload = (): void => {
445452 // The server remembers the *choice* and nothing about the laptop, so
outdated

Filtering here leaves no way to unpin the stale row in the terminal. Keep an unlisted-but-removable path (for example a count with a 'clear stale pins' action) without exposing names.

446453 // this is a list of decisions — never a status that would be stale.
447 pins = f.user ? listPins(f.db, f.user.id) : [];
454 // A pin outlives the access it was made with (#14967): list only what
455 // this account may still read, in one query for every pin.
456 const mine = f.user ? listPins(f.db, f.user.id) : [];
457 const readable = readableRepoIds(f.db, f.user, mine.map((p) => p.repoId));
458 pins = mine.filter((p) => readable.has(p.repoId));
459 stalePins = mine.filter((p) => !readable.has(p.repoId)).map((p) => p.repoId);
448460 startedFrom = f.user === undefined ? null : startedFromText(f.app.config.dataDir);
449461 firstWeek = firstWeekText(f.db, f.user);
450462 pinned = f.user ? pinnedRepoIds(f.db, f.user.id) : new Set<string>();
@@ -1036,6 +1048,8 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
10361048 const panes = (): PaneId[] => ORDER.filter((pane) => drawn.has(pane));
10371049
10381050 const at = (pane: PaneId): ListState => cursors[pane];
1051 /** The machine pane's rows: each readable pin, then one for every stale pin. */
1052 const machineRows = (): number => pins.length + (stalePins.length > 0 ? 1 : 0);
10391053 const size = (pane: PaneId): number =>
10401054 pane === "repos"
10411055 ? exploring()
@@ -1043,7 +1057,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
10431057 : shown().length
10441058 : pane === "onyou"
10451059 ? onYou.length + waves.length
1046 : pins.length;
1060 : machineRows();
10471061
10481062 const cycle = (step: number): void => {
10491063 const list = panes();
@@ -1068,6 +1082,51 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
10681082 ctx.toast(`${row.name} has no terminal page; the web has it at ${row.url}`, "attn");
10691083 };
10701084
1085 /** The one confirm both unpins ask: Keep (default) or Unpin, then reload and say so. */
1086 const confirmUnpin = (title: string, body: string[], keep: string, act: (user: NonNullable<typeof f.user>) => void): void => {
1087 if (f.user === undefined) return;
1088 const user = f.user;
1089 ctx.push(
1090 confirmScreen(ctx, screen, {
1091 title,
1092 body,
1093 actions: [
1094 { label: keep, variant: "ghost" },
1095 { label: "Unpin", variant: "danger" },
1096 ],
1097 selected: 0,
1098 onChoose: (index) => {
1099 if (index !== 1) return;
1100 act(user);
1101 reload();
1102 ctx.toast("unpinned", "success");
1103 },
1104 }),
1105 );
1106 };
1107
1108 const clearStale = (): void => {
1109 if (stalePins.length === 0) return;
1110 const ids = stalePins;
1111 confirmUnpin(
1112 "Clear pins",
1113 [
1114 `Unpin ${plural(ids.length, "repository", "repositories")} you can no longer read?`,
1115 "They stay hidden either way; this only takes them off your list.",
1116 ],
1117 "Keep them",
1118 (user) => {
1119 for (const repo of getReposByIds(f.db, ids).values()) unpinRepo(f.app, user, repo);
1120 },
1121 );
1122 };
1123
1124 /** `enter` or `d` on the machine pane: a named pin, or the nameless stale row after them. */
1125 const actOnPin = (index: number, named: (pin: Pin | undefined) => void): void => {
1126 if (index >= pins.length && stalePins.length > 0) return clearStale();
1127 named(pins[index]);
1128 };
1129
10711130 const openPin = (pin: Pin | undefined): void => {
10721131 if (pin === undefined) return;
10731132 const repo = getRepo(f.db, pin.ownerName, pin.name);
@@ -1082,28 +1141,18 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
10821141 };
10831142
10841143 const unpin = (pin: Pin | undefined): void => {
1085 if (pin === undefined || f.user === undefined) return;
1086 const user = f.user;
1087 ctx.push(
1088 confirmScreen(ctx, screen, {
1089 title: "Unpin",
1090 body: [
1091 `Stop keeping ${pin.ownerName}/${pin.name} on your machine?`,
1092 "Nothing here is deleted; forge sync simply stops fetching it.",
1093 ],
1094 actions: [
1095 { label: "Keep it", variant: "ghost" },
1096 { label: "Unpin", variant: "danger" },
1097 ],
1098 selected: 0,
1099 onChoose: (index) => {
1100 if (index !== 1) return;
1101 const repo = getRepo(f.db, pin.ownerName, pin.name);
1102 if (repo !== undefined) unpinRepo(f.app, user, repo);
1103 reload();
1104 ctx.toast("unpinned", "success");
1105 },
1106 }),
1144 if (pin === undefined) return;
1145 confirmUnpin(
1146 "Unpin",
1147 [
1148 `Stop keeping ${pin.ownerName}/${pin.name} on your machine?`,
1149 "Nothing here is deleted; forge sync simply stops fetching it.",
1150 ],
1151 "Keep it",
1152 (user) => {
1153 const repo = getRepo(f.db, pin.ownerName, pin.name);
1154 if (repo !== undefined) unpinRepo(f.app, user, repo);
1155 },
11071156 );
11081157 };
11091158
@@ -1123,7 +1172,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
11231172 if (exploring()) openExplored(exploredRows()[at("repos").index]);
11241173 else openRepo(shown()[at("repos").index]);
11251174 } else if (focus === "onyou") openAssigned(onYou[at("onyou").index]);
1126 else openPin(pins[at("machine").index]);
1175 else actOnPin(at("machine").index, openPin);
11271176 };
11281177
11291178 const screen: Screen = {
@@ -1161,7 +1210,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
11611210 ...(silenced.size > 0 ? [binding(["L"], "listen again")] : []),
11621211 ...(hidden !== undefined ? [binding(["F"], SHOW_ALL_WORDS.toLowerCase())] : []),
11631212 binding(["d"], "unpin", {
1164 disabled: focus !== "machine" || pins.length === 0,
1213 disabled: focus !== "machine" || machineRows() === 0,
11651214 }),
11661215 binding(["C"], "decider", { disabled: !f.user }),
11671216 ...(firstTell
@@ -1410,7 +1459,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
14101459 if (f.user && e.key >= "1" && e.key <= String(KIND_CHIPS.length))
14111460 return toggleChip(Number(e.key) - 1), true;
14121461 if (e.key === "d" && focus === "machine") {
1413 unpin(pins[at("machine").index]);
1462 actOnPin(at("machine").index, unpin);
14141463 return true;
14151464 }
14161465 if (e.key === "p" && f.user) {
@@ -1730,7 +1779,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
17301779 footer: "forge sync",
17311780 focused: on,
17321781 });
1733 if (pins.length === 0) {
1782 if (machineRows() === 0) {
17341783 note(s, inner, c, [
17351784 "Nothing pinned yet.",
17361785 "p pins the repository under the cursor;",
@@ -1743,20 +1792,25 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
17431792 inner,
17441793 c,
17451794 at("machine"),
1746 pins.map(
1747 (pin): ListRow => ({
1748 title: `${repoMark(true, set)}${pin.ownerName}/${pin.name}`,
1749 }),
1750 ),
1795 [
1796 ...pins.map(
1797 (pin): ListRow => ({
1798 title: `${repoMark(true, set)}${pin.ownerName}/${pin.name}`,
1799 }),
1800 ),
1801 ...(stalePins.length > 0
1802 ? [{ title: `${plural(stalePins.length, "pin")} no longer available · d clears` }]
1803 : []),
1804 ],
17511805 on,
17521806 );
1753 hitList(ctx, inner, at("machine"), pins.length, {
1807 hitList(ctx, inner, at("machine"), machineRows(), {
17541808 select: () => {
17551809 focus = "machine";
17561810 },
17571811 open: (index) => {
17581812 focus = "machine";
1759 openPin(pins[index]);
1813 actOnPin(index, openPin);
17601814 },
17611815 });
17621816 }
test/api-pins-revoked.test.ts added +130
@@ -0,0 +1,130 @@
1 /**
2 * A pin outlives the access it was made with (#14967): the list shows only
3 * what the viewer may still read, and the stale pin can still come off —
4 * through the API and on the terminal's first screen alike.
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { createApp, type App } from "../src/app.ts";
11 import { createRepo } from "../src/actions/repos.ts";
12 import { getRepo, updateRepoSettings } from "../src/core/repos.ts";
13 import { listPins } from "../src/core/pins.ts";
14 import { createSession } from "../src/core/sessions.ts";
15 import { createUser, type User } from "../src/core/users.ts";
16 import { seedAdmin } from "./helpers/admin.ts";
17 import { driveTerminal } from "./helpers/tui-drive.ts";
18 import { serve, type Servers } from "../src/http/server.ts";
19 import { quietLogs } from "./helpers/globals.ts";
20
21 quietLogs();
22
23 let dataDir: string;
24 let app: App;
25 let servers: Servers;
26 let bobCookie = "";
27 let bobId = "";
28 let bob: User;
29
30 const cells = process.env["FORGE_CELLS"];
31
32 beforeAll(async () => {
33 process.env["FORGE_CELLS"] = "off";
34 dataDir = await mkdtemp(join(tmpdir(), "forge-api-pins-revoked-"));
35 app = createApp({ dataDir, port: 0 });
36 servers = await serve(app);
37 const a = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-good-passphrase" });
38 if (!a.ok) throw new Error("signup failed");
39 const alice = a.value;
40 const b = await createUser(app.db, {
41 origin: "seed",
42 trusted: true,
43 username: "bob",
44 email: "[email protected]",
45 password: "a-good-passphrase",
46 });
47 if (!b.ok) throw new Error(String(b.error));
48 bob = b.value;
49 bobId = bob.id;
50 bobCookie = `forge_session=${createSession(app.db, bob.id).token}`;
51 for (const name of ["kept", "closed"]) {
52 const repo = await createRepo(app, alice, { name, visibility: "public" });
53 if (!repo.ok) throw new Error(String(repo.error));
54 }
55 });
56 afterAll(async () => {
57 await servers.stop();
58 app.close();
59 if (cells === undefined) delete process.env["FORGE_CELLS"];
60 else process.env["FORGE_CELLS"] = cells;
61 await rm(dataDir, { recursive: true, force: true });
62 });
63
64 function asBob(path: string, method = "GET"): Promise<Response> {
65 return fetch(`${servers.url}${path}`, {
66 method,
67 headers: { cookie: bobCookie, origin: servers.url },
68 });
69 }
70
71 async function listed(): Promise<string[]> {
72 const res = await asBob("/api/v1/user/pins");
73 expect(res.status).toBe(200);
74 const body = (await res.json()) as { items: { owner: string; name: string }[] };
75 return body.items.map((p) => `${p.owner}/${p.name}`).sort();
76 }
77
78 test("a pinned repo made private drops out of the list and can still be unpinned", async () => {
79 expect((await asBob("/api/v1/user/pins/alice/kept", "PUT")).status).toBe(200);
80 expect((await asBob("/api/v1/user/pins/alice/closed", "PUT")).status).toBe(200);
81 expect(await listed()).toEqual(["alice/closed", "alice/kept"]);
82
83 // Alice takes the repository private: bob's access is revoked.
84 const closed = getRepo(app.db, "alice", "closed")!;
85 updateRepoSettings(app.db, closed, { visibility: "private" });
86
87 expect(await listed()).toEqual(["alice/kept"]);
88 const terminal = await firstScreen();
89 expect(terminal).toContain("alice/kept");
90 expect(terminal).not.toContain("alice/closed");
91 expect(terminal).toContain("1 pin no longer available");
92
93 // The stale pin still comes off, and only once.
94 expect((await asBob("/api/v1/user/pins/alice/closed", "DELETE")).status).toBe(204);
95 expect(listPins(app.db, bobId).map((p) => p.repoId)).toEqual([
96 getRepo(app.db, "alice", "kept")!.id,
97 ]);
98 expect((await asBob("/api/v1/user/pins/alice/closed", "DELETE")).status).toBe(404);
99 });
100
101 // A regression guard, not proof of #14967: main answered this way too.
102 test("unpinning a private repo never pinned answers like one that does not exist", async () => {
103 const hidden = getRepo(app.db, "alice", "closed")!;
104 expect(hidden.visibility).toBe("private");
105 const there = await asBob("/api/v1/user/pins/alice/closed", "DELETE");
106 const absent = await asBob("/api/v1/user/pins/alice/nothing", "DELETE");
107 expect(there.status).toBe(404);
108 expect(absent.status).toBe(404);
109 expect(await there.text()).toBe(await absent.text());
110 });
111
112 test("the terminal clears a stale pin without naming it", async () => {
113 const closed = getRepo(app.db, "alice", "closed")!;
114 updateRepoSettings(app.db, closed, { visibility: "public" });
115 expect((await asBob("/api/v1/user/pins/alice/closed", "PUT")).status).toBe(200);
116 updateRepoSettings(app.db, closed, { visibility: "private" });
117 const before = await firstScreen();
118 expect(before).toContain("1 pin no longer available");
119 expect(before).not.toContain("alice/closed");
120
121 // Into the machine pane, past the readable pin, `d`, and choose Unpin.
122 const after = await firstScreen(["\t", "\t", "j", "d", "\x1b[C", "\r"]);
123 expect(listPins(app.db, bobId).map((p) => p.repoId)).toEqual([getRepo(app.db, "alice", "kept")!.id]);
124 expect(after).toContain("alice/kept");
125 expect(after).not.toContain("no longer available");
126 });
127
128 function firstScreen(keys: string[] = []): Promise<string> {
129 return driveTerminal(app, bob, keys, { cols: 200, rows: 48 });
130 }
test/helpers/tui-drive.ts added +32
@@ -0,0 +1,32 @@
1 /**
2 * Sign in to the terminal as a user, feed it keys one settle at a time, and
3 * read the screen they leave behind: the shape several terminal tests share.
4 */
5 import type { App } from "../../src/app.ts";
6 import type { User } from "../../src/core/users.ts";
7 import { createForgeApp } from "../../src/tui/forge.ts";
8 import { headlessTerminal } from "../../src/tui/term/terminal.ts";
9 import { settleApp } from "./tui.ts";
10
11 export async function driveTerminal(
12 app: App,
13 user: User,
14 keys: string[],
15 size: { cols: number; rows: number } = { cols: 120, rows: 30 },
16 ): Promise<string> {
17 const terminal = headlessTerminal(size.cols, size.rows);
18 const { app: tui } = createForgeApp(
19 app,
20 { sshUsername: user.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user },
21 { terminal, exitHooks: false },
22 );
23 tui.start();
24 await settleApp(tui);
25 for (const key of keys) {
26 terminal.feed(key);
27 await settleApp(tui);
28 }
29 const text = tui.screen.toText();
30 tui.stop();
31 return text;
32 }
test/mcp-pins.test.ts +11
@@ -106,6 +106,17 @@ describe("MCP pins", () => {
106106 expect(await listed(aliceRw)).toContain("alice/later");
107107 });
108108
109 test("the caller's own pin on a repository they can no longer read still unpins (#14967)", async () => {
110 expect((await tool(bobRw, { action: "unpin", repo: "alice/later" })).value).toEqual({
111 repo: "alice/later",
112 pinned: false,
113 });
114 // Once it is off, it answers like a repository that does not exist.
115 const gone = (await tool(bobRw, { action: "unpin", repo: "alice/later" })).error;
116 expect(gone).toBe((await tool(bobRw, { action: "unpin", repo: "alice/nope" })).error);
117 expect(gone).toContain("not_found");
118 });
119
109120 test("list pages by owner/name with limit and cursor", async () => {
110121 for (const n of ["pa", "pb", "pc"]) {
111122 app.db.run(
test/tui-talk-receipts.test.ts +3 −19
@@ -13,9 +13,7 @@ import { openConversation } from "../src/core/conversations.ts";
1313 import { hold } from "../src/core/fence.ts";
1414 import { createIssue, getIssue } from "../src/core/issues.ts";
1515 import { createUser, type User } from "../src/core/users.ts";
16 import { createForgeApp } from "../src/tui/forge.ts";
17 import { headlessTerminal } from "../src/tui/term/terminal.ts";
18 import { settleApp } from "./helpers/tui.ts";
16 import { driveTerminal } from "./helpers/tui-drive.ts";
1917 import { proveAll } from "./helpers/verified.ts";
2018
2119 let dir: string;
@@ -26,22 +24,8 @@ let repoId: string;
2624 let number: number;
2725 const open = [":", "Receipts", "\r"];
2826
29 async function drive(user: User, keys: string[]): Promise<string> {
30 const terminal = headlessTerminal(120, 30);
31 const { app: tui } = createForgeApp(
32 app,
33 { sshUsername: user.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:test", user },
34 { terminal, exitHooks: false },
35 );
36 tui.start();
37 await settleApp(tui);
38 for (const k of keys) {
39 terminal.feed(k);
40 await settleApp(tui);
41 }
42 const text = tui.screen.toText();
43 tui.stop?.();
44 return text;
27 function drive(user: User, keys: string[]): Promise<string> {
28 return driveTerminal(app, user, keys);
4529 }
4630
4731 beforeAll(async () => {

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs