Public: anyone can read this; the crew can change it.
Inviting someone says what they can now do (#16439) #16441
Check · Review · Land · Live done — Landed and live in production.
fix/invite-says-what-they-can-do → main 0 commits 3 threads · 3 unresolved
7 files
changed +45
−14
src/crew/conversation_ask.ts +3 −2
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | import { OVERLAP_PATHS_MAX, OVERLAP_WORD_MAX, upstreamWords } from "../origins/words.ts"; |
| 17 | import { contributorMay, linkOpens } from "../text/contributor.ts"; | |
| 17 | 18 | |
| 18 | 19 | type Args = Record<string, unknown>; |
| 19 | 20 | |
| @@ -301,14 +302,14 @@ export const ASKED_AS: Readonly<Record<string, Form>> = { | ||
| 301 | 302 | pinned_forge: (a) => pinnedForge(a), |
| 302 | 303 | invite: (a) => |
| 303 | 304 | 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` | |
| 305 | 306 | : val(a, "revoke") !== "" |
| 306 | 307 | ? `Take back the invite link ${val(a, "revoke")} to ${repo(a)}: it opens nothing after` |
| 307 | 308 | : val(a, "who") === "" |
| 308 | 309 | ? `List who works on ${repo(a)}` |
| 309 | 310 | : a["remove"] === true |
| 310 | 311 | ? `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`, | |
| 312 | 313 | outsiders: (a) => |
| 313 | 314 | a["on"] === false |
| 314 | 315 | ? `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 { | ||
| 7 | 7 | revokeInviteLink, |
| 8 | 8 | type ContributorError, |
| 9 | 9 | } from "../../../actions/invites.ts"; |
| 10 | import { contributorNow, linkOpens } from "../../../text/contributor.ts"; | |
| 10 | 11 | import { type Answer, bad, good, isAnswer, REPO_ARG, repoArg, str, type Tool } from "../shared.ts"; |
| 11 | 12 | |
| 12 | 13 | /** A refusal in the words every door says. */ |
| @@ -51,7 +52,7 @@ export const tool: Tool = { | ||
| 51 | 52 | return good({ |
| 52 | 53 | link: made.value.link, |
| 53 | 54 | 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.`, | |
| 55 | 56 | }); |
| 56 | 57 | } |
| 57 | 58 | const revoke = str(args["revoke"]); |
| @@ -72,7 +73,7 @@ export const tool: Tool = { | ||
| 72 | 73 | const v = made.value; |
| 73 | 74 | return good({ |
| 74 | 75 | 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}.`, | |
| 76 | 77 | }); |
| 77 | 78 | }, |
| 78 | 79 | }; |
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"; | ||
| 140 | 140 | import { pullScreen } from "./pull.ts"; |
| 141 | 141 | import { local } from "./where.ts"; |
| 142 | 142 | import { appMembersScreen } from "./appmembers.ts"; |
| 143 | import { contributorMay, contributorNow, linkOpens } from "../../text/contributor.ts"; | |
| 143 | 144 | import { CONTRIBUTOR_WORDS, inviteContributor, inviteLinkTo, removeContributorFrom, repoPeople, type ContributorError } from "../../actions/invites.ts"; |
| 144 | 145 | import { publicOrigin } from "../../core/public_origin.ts"; |
| 145 | 146 | import { mayManagePrompts, promptsScreen } from "./prompts.ts"; |
| @@ -1058,7 +1059,8 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 1058 | 1059 | void later(ctx, () => |
| 1059 | 1060 | confirmScreen(ctx, screen, { |
| 1060 | 1061 | 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), | |
| 1062 | 1064 | actions: [{ label: "Cancel", variant: "ghost" }, { label: verb }], |
| 1063 | 1065 | selected: 1, |
| 1064 | 1066 | onChoose: (i) => { |
| @@ -1074,10 +1076,10 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 1074 | 1076 | onSubmit: (raw) => { |
| 1075 | 1077 | const who = raw.trim(); |
| 1076 | 1078 | 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", () => { | |
| 1078 | 1080 | const made = inviteContributor(f.app, f.user, repo, who); |
| 1079 | 1081 | 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}.`); | |
| 1081 | 1083 | }); |
| 1082 | 1084 | return undefined; |
| 1083 | 1085 | }, |
| @@ -1098,7 +1100,7 @@ export function contributorsScreen(f: Session, ctx: Ctx, repo: Repo): Screen { | ||
| 1098 | 1100 | ? note |
| 1099 | 1101 | : people.length === 0 |
| 1100 | 1102 | ? `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")}.`; | |
| 1102 | 1104 | const links = open === 0 || note !== "" ? "" : ` ${open} invite ${open === 1 ? "link is" : "links are"} open.`; |
| 1103 | 1105 | const said = wrap(text + links, Math.max(1, area.w)).slice(0, 4); |
| 1104 | 1106 | 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 { | ||
| 1113 | 1115 | return true; |
| 1114 | 1116 | } |
| 1115 | 1117 | 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", () => { | |
| 1117 | 1119 | const made = inviteLinkTo(f.app, f.user, repo, publicOrigin(f.app.config.url, `http://localhost:${f.app.config.port}`)); |
| 1118 | 1120 | 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)); |
| 1119 | 1121 | }); |
src/web/pages/site.ts +2 −1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | * typed still in it. A dead end that loses input is a bug, not a message. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | import { contributorMay } from "../../text/contributor.ts"; | |
| 11 | 12 | import { closeState, closingSays } from "../../actions/account_close.ts"; |
| 12 | 13 | import { USERNAME_PATTERN } from "../username_pattern.ts"; |
| 13 | 14 | import { expireCookie, setCookie } from "../../auth/cookies.ts"; |
| @@ -686,7 +687,7 @@ export function joinPage(ctx: Ctx): Response { | ||
| 686 | 687 | const name = `${opened.repo.ownerName}/${opened.repo.name}`; |
| 687 | 688 | if (opened.joined) return redirect(`/talk?about=${encodeURIComponent(name)}`); |
| 688 | 689 | 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.`; | |
| 690 | 691 | return page({ |
| 691 | 692 | ctx, |
| 692 | 693 | title: `Work on ${name}`, |
test/conversation-ask.test.ts +1 −1
| @@ -488,7 +488,7 @@ const SAID: readonly (readonly [string, Record<string, unknown>, string])[] = [ | ||
| 488 | 488 | { verb: "rename", provider: "hetzner", name: "eu", to: "eu2" }, |
| 489 | 489 | "Rename the hetzner account eu to eu2.", |
| 490 | 490 | ], |
| 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."], | |
| 492 | 492 | ["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."], |
| 493 | 493 | ["wall", { repo: "marin/cakes", number: 2, answer: "allow" }, "Allow pull #2 in marin/cakes at the access wall and merge it."], |
| 494 | 494 | ["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" | ||
| 206 | 206 | mayDirectCrew(app.db, fresh(), ben), |
| 207 | 207 | ]).toEqual([false, false]); |
| 208 | 208 | // 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."); | |
| 210 | 211 | const record = { id: "", access: "private" as const }; |
| 211 | 212 | record.id = app.db |
| 212 | 213 | .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", () => { | ||
| 336 | 337 | return shown; |
| 337 | 338 | }; |
| 338 | 339 | 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."); | |
| 340 | 347 | expect(canRead(standIn.app.db, fresh(), dave)).toBe(true); |
| 341 | 348 | // dave is the second in the list: down once, take off, confirm. |
| 342 | 349 | await drive(alice, ["j", "d", "\x1b[C", "\r"]); |
| @@ -458,7 +465,7 @@ describe("the one-use link: anyone, with or without an account", () => { | ||
| 458 | 465 | describe("taking someone off is at once", () => { |
| 459 | 466 | test("dave's next request after removal reads, enters and directs nothing", async () => { |
| 460 | 467 | 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"); | |
| 462 | 469 | expect((await page(dave, `/${name()}`)).status).toBe(200); |
| 463 | 470 | expect(await takeOff(dave)).toContain("dave is no longer a contributor"); |
| 464 | 471 | expect((await page(dave, `/${name()}`)).status).toBe(404); |
new above
offline
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.