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

Inviting someone says what they can now do (#16439) #16441

Merged opened this

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

Merged

fix/invite-says-what-they-can-do → main 0 commits 3 threads · 3 unresolved

  • Merged. fix/invite-says-what-they-can-do was merged into main as 1ebf390.

Review

Sign in to review this change.
7 files changed +45 −14
src/crew/conversation_ask.ts +3 −2
@@ -14,6 +14,7 @@
1414 */
1515
1616 import { OVERLAP_PATHS_MAX, OVERLAP_WORD_MAX, upstreamWords } from "../origins/words.ts";
17 import { contributorMay, linkOpens } from "../text/contributor.ts";
outdated

This pure words module now depends on the actions layer, and through it on the db. Import the words from a dependency-free module instead.

1718
1819 type Args = Record<string, unknown>;
1920
@@ -301,14 +302,14 @@ export const ASKED_AS: Readonly<Record<string, Form>> = {
301302 pinned_forge: (a) => pinnedForge(a),
302303 invite: (a) =>
303304 a["link"] === true
304 ? `Make a one-use link to work on ${repo(a)}: whoever opens it can make an account, open the app and ask the crew for changes; they cannot merge or change settings`
305 ? `Make a one-use link to work on ${repo(a)}: ${linkOpens(repo(a))}; they cannot merge or change settings`
305306 : val(a, "revoke") !== ""
306307 ? `Take back the invite link ${val(a, "revoke")} to ${repo(a)}: it opens nothing after`
307308 : val(a, "who") === ""
308309 ? `List who works on ${repo(a)}`
309310 : a["remove"] === true
310311 ? `Take ${val(a, "who")} off ${repo(a)}: they can no longer open it, its app or ask its crew`
311 : `Make ${val(a, "who")} a contributor on ${repo(a)}: they can open the app and ask the crew for changes; they cannot merge or change settings`,
312 : `Make ${val(a, "who")} a contributor on ${repo(a)}: they can ${contributorMay("it")}; they cannot merge or change settings`,
312313 outsiders: (a) =>
313314 a["on"] === false
314315 ? `Stop people who cannot write to ${repo(a)} from directing its crew`
src/http/mcp/tools/invite.ts +3 −2
@@ -7,6 +7,7 @@ import {
77 revokeInviteLink,
88 type ContributorError,
99 } from "../../../actions/invites.ts";
10 import { contributorNow, linkOpens } from "../../../text/contributor.ts";
1011 import { type Answer, bad, good, isAnswer, REPO_ARG, repoArg, str, type Tool } from "../shared.ts";
1112
1213 /** A refusal in the words every door says. */
@@ -51,7 +52,7 @@ export const tool: Tool = {
5152 return good({
5253 link: made.value.link,
5354 expiresAt: made.value.invite.expiresAt,
54 says: `A one-use link to work on ${name}, shown this once: whoever opens it can make an account, then asks its crew for changes and lands nothing.`,
55 says: `A one-use link to work on ${name}, shown this once: ${linkOpens(name)}, and lands nothing.`,
5556 });
5657 }
5758 const revoke = str(args["revoke"]);
@@ -72,7 +73,7 @@ export const tool: Tool = {
7273 const v = made.value;
7374 return good({
7475 contributor: v.username,
75 says: v.added ? `${v.username} works on ${name} now: they hear it, and can ask Talk for changes there.` : `${v.username} already works on ${name}.`,
76 says: v.added ? `${contributorNow(v.username, name)} They hear it.` : `${v.username} already works on ${name}.`,
7677 });
7778 },
7879 };
src/text/contributor.ts added +19
@@ -0,0 +1,19 @@
1 /**
2 * What a contributor may do, in the words every door says (#16439): read, enter the app, ask the
3 * crew, and fork to propose (`forkRepo` lets a contributor's new account fork what it was invited
4 * to). Words only, so the ask words, the MCP tool and the terminal share them without the db.
5 */
6
7 /** What a contributor may do on `repo`: "it" in a sentence that already names it, or its name. */
8 export const contributorMay = (repo: string): string =>
9 `read ${repo}, enter its app, ask its crew for changes, and fork it to propose changes`;
10
11 /**
12 * What a one-use invite link to `repo` opens: an account where none is, then a contributor's
13 * rights.
14 */
15 export const linkOpens = (repo: string): string => `whoever opens it can make an account, then ${contributorMay(repo)}`;
16
17 /** The sentence an invite answers with: who can now do what, where. */
18 export const contributorNow = (who: string, repo: string): string =>
19 `${who} can now ${contributorMay(repo)}.`;
src/tui/screens/deploys.ts +7 −5
@@ -140,6 +140,7 @@ import { envTone } from "./runwords.ts";
140140 import { pullScreen } from "./pull.ts";
141141 import { local } from "./where.ts";
142142 import { appMembersScreen } from "./appmembers.ts";
143 import { contributorMay, contributorNow, linkOpens } from "../../text/contributor.ts";
143144 import { CONTRIBUTOR_WORDS, inviteContributor, inviteLinkTo, removeContributorFrom, repoPeople, type ContributorError } from "../../actions/invites.ts";
144145 import { publicOrigin } from "../../core/public_origin.ts";
145146 import { mayManagePrompts, promptsScreen } from "./prompts.ts";
@@ -1058,7 +1059,8 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
10581059 void later(ctx, () =>
10591060 confirmScreen(ctx, screen, {
10601061 title,
1061 body: [body],
1062 // Wrapped to the dialog's 54 columns, so the whole sentence shows, never cut at "…".
1063 body: wrap(body, 48),
10621064 actions: [{ label: "Cancel", variant: "ghost" }, { label: verb }],
10631065 selected: 1,
10641066 onChoose: (i) => {
@@ -1074,10 +1076,10 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
10741076 onSubmit: (raw) => {
10751077 const who = raw.trim();
10761078 if (who === "") return "Name a person.";
1077 confirm("Invite", `${who} works on ${name}: they read it and ask its crew for changes, and land nothing.`, "Invite", () => {
1079 confirm("Invite", `Make ${who} a contributor on ${name}: they can ${contributorMay("it")}, and land nothing.`, "Invite", () => {
10781080 const made = inviteContributor(f.app, f.user, repo, who);
10791081 if (!made.ok) return say(contributorRefusal(made.error));
1080 say(made.value.added ? `${made.value.username} works on ${name} now.` : `${made.value.username} already works on ${name}.`);
1082 say(made.value.added ? contributorNow(made.value.username, name) : `${made.value.username} already works on ${name}.`);
10811083 });
10821084 return undefined;
10831085 },
@@ -1098,7 +1100,7 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
10981100 ? note
10991101 : people.length === 0
11001102 ? `Nobody works on ${name} with you yet. Press a to invite someone.`
1101 : `${people.length} work on ${name} with you: they read it, enter the app and ask its crew for changes.`;
1103 : `${people.length} work on ${name} with you: they can ${contributorMay("it")}.`;
11021104 const links = open === 0 || note !== "" ? "" : ` ${open} invite ${open === 1 ? "link is" : "links are"} open.`;
11031105 const said = wrap(text + links, Math.max(1, area.w)).slice(0, 4);
11041106 const [head, list] = split(area, "v", [len(said.length), fill(1)]);
@@ -1113,7 +1115,7 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen {
11131115 return true;
11141116 }
11151117 if (e.key === "l") {
1116 confirm("Make a link", `A one-use link to work on ${name}: whoever opens it can make an account and ask its crew for changes, and lands nothing.`, "Make it", () => {
1118 confirm("Make a link", `A one-use link to work on ${name}: ${linkOpens(name)}, and lands nothing.`, "Make it", () => {
11171119 const made = inviteLinkTo(f.app, f.user, repo, publicOrigin(f.app.config.url, `http://localhost:${f.app.config.port}`));
11181120 say(made.ok ? `Send this link; it is shown once and works for one person until ${made.value.invite.expiresAt.slice(0, 10)}: ${made.value.link}` : contributorRefusal(made.error));
11191121 });
src/web/pages/site.ts +2 −1
@@ -8,6 +8,7 @@
88 * typed still in it. A dead end that loses input is a bug, not a message.
99 */
1010
11 import { contributorMay } from "../../text/contributor.ts";
1112 import { closeState, closingSays } from "../../actions/account_close.ts";
1213 import { USERNAME_PATTERN } from "../username_pattern.ts";
1314 import { expireCookie, setCookie } from "../../auth/cookies.ts";
@@ -686,7 +687,7 @@ export function joinPage(ctx: Ctx): Response {
686687 const name = `${opened.repo.ownerName}/${opened.repo.name}`;
687688 if (opened.joined) return redirect(`/talk?about=${encodeURIComponent(name)}`);
688689 const here = `/join/${encodeURIComponent(token)}`;
689 const said = html`You are invited to work on <strong>${name}</strong>: read it, open the app and ask its crew for changes from your own Talk. Whoever owns it lands what you ask.`;
690 const said = html`You are invited to work on <strong>${name}</strong>: you can ${contributorMay("it")}, from your own Talk. Whoever owns it lands what you ask.`;
690691 return page({
691692 ctx,
692693 title: `Work on ${name}`,
test/conversation-ask.test.ts +1 −1
@@ -488,7 +488,7 @@ const SAID: readonly (readonly [string, Record<string, unknown>, string])[] = [
488488 { verb: "rename", provider: "hetzner", name: "eu", to: "eu2" },
489489 "Rename the hetzner account eu to eu2.",
490490 ],
491 ["invite", { repo: "marin/cakes", who: "ben" }, "Make ben a contributor on marin/cakes: they can open the app and ask the crew for changes; they cannot merge or change settings."],
491 ["invite", { repo: "marin/cakes", who: "ben" }, "Make ben a contributor on marin/cakes: they can read it, enter its app, ask its crew for changes, and fork it to propose changes; they cannot merge or change settings."],
492492 ["invite", { repo: "marin/cakes", who: "ben", remove: true }, "Take ben off marin/cakes: they can no longer open it, its app or ask its crew."],
493493 ["wall", { repo: "marin/cakes", number: 2, answer: "allow" }, "Allow pull #2 in marin/cakes at the access wall and merge it."],
494494 ["wall", { repo: "marin/cakes", number: 2, answer: "send_back" }, "Send pull #2 in marin/cakes back at the access wall."],
test/invite-contributors.test.ts +10 −3
@@ -206,7 +206,8 @@ describe("a contributor: reads, enters, directs; nothing outside the repository"
206206 mayDirectCrew(app.db, fresh(), ben),
207207 ]).toEqual([false, false]);
208208 // The repository's admin lets him in through Talk's `invite`.
209 expect(await letIn(ben)).toContain("ben works on alice/garden now");
209 // The answer says what ben can now do there, the fork included (#16439).
210 expect(await letIn(ben)).toContain("ben can now read alice/garden, enter its app, ask its crew for changes, and fork it to propose changes.");
210211 const record = { id: "", access: "private" as const };
211212 record.id = app.db
212213 .query<{ id: string }, [string]>("SELECT id FROM app WHERE repo_id = ?1")
@@ -336,7 +337,13 @@ describe("the doors: Talk's invite and the terminal", () => {
336337 return shown;
337338 };
338339 expect(await drive(alice, [])).toContain("ben");
339 await drive(alice, ["a", "dave", "\r", "\x1b[C", "\r"]);
340 // The confirm says what dave may do, the fork included; the answer, what dave can now do there.
341 const flat = (shown: string) => shown.replace(/[│╭╮╰╯─]/g, " ").replace(/\s+/g, " ");
342 expect(flat(await drive(alice, []))).toContain("1 work on alice/garden with you: they can read it, enter its app, ask its crew for changes, and fork it to propose changes.");
343 const asked = flat(await drive(alice, ["a", "dave", "\r"]));
344 expect(asked).toContain("Make dave a contributor on alice/garden: they can read it, enter its app, ask its crew for changes, and fork it to propose changes, and land nothing.");
345 const added = flat(await drive(alice, ["a", "dave", "\r", "\x1b[C", "\r"]));
346 expect(added).toContain("dave can now read alice/garden, enter its app, ask its crew for changes, and fork it to propose changes.");
340347 expect(canRead(standIn.app.db, fresh(), dave)).toBe(true);
341348 // dave is the second in the list: down once, take off, confirm.
342349 await drive(alice, ["j", "d", "\x1b[C", "\r"]);
@@ -458,7 +465,7 @@ describe("the one-use link: anyone, with or without an account", () => {
458465 describe("taking someone off is at once", () => {
459466 test("dave's next request after removal reads, enters and directs nothing", async () => {
460467 const { app } = standIn;
461 expect(await letIn(dave)).toContain("dave works on alice/garden now");
468 expect(await letIn(dave)).toContain("dave can now read alice/garden");
462469 expect((await page(dave, `/${name()}`)).status).toBe(200);
463470 expect(await takeOff(dave)).toContain("dave is no longer a contributor");
464471 expect((await page(dave, `/${name()}`)).status).toBe(404);

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs