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

A new forge's first-login page uses plain words: a test fails on jargon #10719

Closed opened this
Closed without merging

scout/forge:scout/10712-a-new-forge-s-first-login-page-uses-plai → main 6 commits fork 10 threads · 10 unresolved

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
28 files changed +183 −83
src/apps/feature.ts +1 −1
@@ -32,7 +32,7 @@ export const SETTING_TYPES: readonly SettingType[] = ["bool", "int", "string", "
3232 /** The labels the forge's own menus use: a feature may not borrow one. */
3333 const BUILT_IN_MENU_LABELS = [
3434 "your profile", "repositories", "apps", "notes", "talk", "explore", "packs", "displays", "map", "features",
35 "new app", "new repository", "new issue", "new organization", "migrate", "settings", "access tokens", "ssh keys",
35 "new app", "new repository", "new issue", "new organization", "migrate", "settings", "access tokens", "access keys", "ssh keys", "terminal keys",
3636 "origins", "boards", "crew", "system memory", "help", "sign out", "log out", "sign in", "admin", "administration",
3737 "theme", "create", "new forge", "create new", "appearance and help", "features from apps", "keyboard shortcuts",
3838 ];
src/core/tokens.ts +1 −1
@@ -15,7 +15,7 @@ import { getUserById, isActive, type User } from "./users.ts";
1515 export type TokenScope = "ro" | "rw" | "admin";
1616
1717 /** What a non-admin is told when they ask for a token that acts as admin. */
18 export const ADMIN_TOKEN_WORDS = "Only an admin can make a token with admin scope; ro and rw are open to you.";
18 export const ADMIN_TOKEN_WORDS = "Only an admin can make an access key with admin scope; ro and rw are open to you.";
1919
2020 const rank: Record<TokenScope, number> = { ro: 0, rw: 1, admin: 2 };
2121
src/tui/forge.ts +1 −1
@@ -403,7 +403,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
403403 if (session.signedIn)
404404 commands.push({
405405 id: "ssh-keys",
406 title: "SSH keys",
406 title: "Terminal keys",
407407 hint: "list, add and remove the keys that sign in as you",
408408 run: () => ctx.push(sshKeysScreen(session, ctx)),
409409 });
src/tui/screens/signins.ts +13 −13
@@ -104,7 +104,7 @@ function hardWrap(text: string, width: number): string[] {
104104 function secretScreen(ctx: Ctx, secret: string, market: { add: string; install: string } | null): Screen {
105105 let copied = "";
106106 return {
107 title: "New token",
107 title: "New access key",
108108 keys: [
109109 binding(["y"], "copy it"),
110110 ...(market === null ? [] : [binding(["a"], "copy the marketplace line"), binding(["i"], "copy the install line")]),
@@ -166,21 +166,21 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
166166
167167 const end = (picked: SignIn): void => {
168168 if (picked.kind === "terminal") {
169 note = "This terminal cannot be ended from here: disconnect, or remove its key in Settings → SSH keys.";
169 note = "This terminal cannot be ended from here: disconnect, or remove its key in Settings → Terminal keys.";
170170 ctx.invalidate();
171171 return;
172172 }
173173 if (picked.kind === "token") {
174174 ctx.push(
175175 confirmScreen(ctx, screen, {
176 title: "Revoke a token",
176 title: "Revoke an access key",
177177 body: [`Revoke ${picked.name} (${picked.scope})? It stops working at once.`],
178178 actions: [{ label: "Keep", variant: "ghost" }, { label: "Revoke", variant: "danger" }],
179179 onChoose: (i) => {
180180 if (i < 1) return;
181181 const user = f.user;
182182 const done = user !== undefined && deleteToken(f.app, user, picked.id).ok;
183 note = done ? "Revoked that token." : "That token is already gone.";
183 note = done ? "Revoked that access key." : "That access key is already gone.";
184184 ctx.invalidate();
185185 },
186186 }),
@@ -208,7 +208,7 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
208208 const user = f.user;
209209 const made = createToken(f.app, user, name, scope);
210210 if (!made.ok) {
211 note = made.error === "forbidden" ? ADMIN_TOKEN_WORDS : "Sign in to make a token.";
211 note = made.error === "forbidden" ? ADMIN_TOKEN_WORDS : "Sign in to make an access key.";
212212 ctx.invalidate();
213213 return;
214214 }
@@ -222,7 +222,7 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
222222 const confirmAdmin = (name: string) =>
223223 later(ctx, () =>
224224 confirmScreen(ctx, screen, {
225 title: "Make an admin token",
225 title: "Make an admin access key",
226226 body: [`${name} will act as admin: y to make it, n to cancel.`],
227227 actions: [{ label: "Make it", variant: "danger" }, { label: "Cancel", variant: "ghost" }],
228228 yesNo: true,
@@ -237,7 +237,7 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
237237 const askScope = (name: string, isAdmin: boolean) =>
238238 later(ctx, () =>
239239 promptScreen(ctx, screen, {
240 title: "Make a token",
240 title: "Make an access key",
241241 label: isAdmin ? "Scope: ro, rw or admin" : "Scope: ro or rw",
242242 value: "ro",
243243 onSubmit: (word) => {
@@ -252,11 +252,11 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
252252
253253 const askName = (isAdmin: boolean) =>
254254 promptScreen(ctx, screen, {
255 title: "Make a token",
255 title: "Make an access key",
256256 label: "Name",
257257 value: "token",
258258 onSubmit: (name) => {
259 if (name === "") return "A token needs a name.";
259 if (name === "") return "An access key needs a name.";
260260 if ([...name].length > 64) return "Keep the name to 64 characters.";
261261 return askScope(name, isAdmin);
262262 },
@@ -322,8 +322,8 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
322322 title: "Signed in",
323323 keys: [
324324 binding(["j", "k"], "move cursor"),
325 binding(["d"], "sign a browser out or revoke a token"),
326 binding(["m"], "make a token"),
325 binding(["d"], "sign a browser out or revoke an access key"),
326 binding(["m"], "make an access key"),
327327 binding(["p"], "change your password"),
328328 ],
329329 render(area, s) {
@@ -336,8 +336,8 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
336336 : f.user === undefined
337337 ? "Sign in to see where you are signed in."
338338 : f.user.kind === "agent"
339 ? "Where you are signed in. d signs a browser out or revokes a token."
340 : "Where you are signed in. d signs a browser out or revokes a token, m makes a token, p changes your password.";
339 ? "Where you are signed in. d signs a browser out or revokes an access key."
340 : "Where you are signed in. d signs a browser out or revokes an access key, m makes an access key, p changes your password.";
341341 s.text(head!.x, head!.y, truncate(text, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w);
342342 drawList(s, body!, c, state, rows(all));
343343 },
src/tui/screens/sshkeys.ts +1 −1
@@ -30,7 +30,7 @@ export function sshKeysScreen(f: Session, ctx: Ctx): Screen {
3030 }));
3131
3232 const screen: Screen = {
33 title: "SSH keys",
33 title: "Terminal keys",
3434 keys: [binding(["j", "k"], "move cursor"), binding(["a"], "add"), binding(["e"], "rename"), binding(["d"], "remove")],
3535 render(area, s) {
3636 const c = ctx.theme.c;
src/web/client.ts +1 −1
@@ -1575,7 +1575,7 @@ const shellCore = /* js */ `
15751575 // ---- help overlay, generated from the shortcuts actually on the page ----
15761576 var STATIC_KEYS = [
15771577 ['j / k', 'Move between rows'], ['o or Enter', 'Open the focused row'],
1578 ['/', 'Focus search'], ['Cmd/Ctrl K', 'Command palette'], [':', 'Go to a page by name'], ['?', 'This help'],
1578 ['/', 'Focus search'], ['Cmd/Ctrl K', 'Quick jump'], [':', 'Go to a page by name'], ['?', 'This help'],
15791579 ['Esc', 'Leave a box, close a menu or dialog'],
15801580 ];
15811581 // The rows a page earns by what it carries: a box to type in, a form
src/web/layout.ts +7 −7
@@ -346,8 +346,8 @@ function userMenu(
346346 ...forgeDoor(ctx),
347347 { separator: true, label: "" },
348348 { label: "Settings", href: "/settings", icon: "settings" },
349 { label: "Access tokens", href: "/settings/tokens", icon: "key" },
350 { label: "SSH keys", href: "/settings/keys", icon: "lock" },
349 { label: "Access keys", href: "/settings/tokens", icon: "key" },

The menu was renamed, but the destination pages' bodies still say 'SSH' and 'token' (e.g. the keys page text). Rename the whole surface or keep the old label; a person who clicks should meet the same word.

350 { label: "Terminal keys", href: "/settings/keys", icon: "lock" },

Principle 8: 'Terminal keys' now disagrees with the target page's title 'SSH keys'. Rename the page too so the label and the page match, and then 'Access tokens' and 'Origins' still need plain words.

351351 { label: "Origins", href: "/settings/origins", icon: "globe" },
352352 ...(!user.isAdmin && administersAny(ctx.app.db, user)
353353 ? [{ label: "Boards", href: "/boards", icon: "activity" as const }]
@@ -409,8 +409,8 @@ const STATIC_PALETTE: PaletteItem[] = [
409409 { t: "Migrate a repository", h: "/migrate", c: "Create" },
410410 { t: "New organization", h: "/organizations/new", c: "Create" },
411411 { t: "Account settings", h: "/settings", c: "Settings" },
412 { t: "Access tokens", h: "/settings/tokens", c: "Settings" },
413 { t: "SSH keys", h: "/settings/keys", c: "Settings" },
412 { t: "Access keys", h: "/settings/tokens", c: "Settings" },
413 { t: "Terminal keys", h: "/settings/keys", c: "Settings" },
414414 { t: "Origins", h: "/settings/origins", c: "Settings" },
415415 { t: "Your shells", h: "/settings/shells", c: "Settings" },
416416 ];
@@ -580,7 +580,7 @@ function overlays(): Html {
580580 id="palette"
581581 role="dialog"
582582 aria-modal="true"
583 aria-label="Command palette"
583 aria-label="Quick jump"
584584 >
585585 <input
586586 class="input palette-input"
@@ -591,7 +591,7 @@ function overlays(): Html {
591591 aria-controls="palette-list"
592592 aria-autocomplete="list"
593593 placeholder="Jump to a repository, page or action…"
594 aria-label="Command palette"
594 aria-label="Quick jump"
595595 autocomplete="off"
596596 autocapitalize="off"
597597 spellcheck="false"
@@ -742,7 +742,7 @@ function footer(ctx: Ctx, own?: Html): Html {
742742 type="button"
743743 data-palette
744744 >
745 Command palette
745 Quick jump
746746 </button>
747747 </footer>`;
748748 }
src/web/pages/account.ts +17 −17
@@ -710,7 +710,7 @@ function tokensView(ctx: Ctx): Html {
710710 listSessions(ctx.app.db, ctx.auth.user!.id, cookieValue(ctx.request, "forge_session")),
711711 );
712712 const list = tokens.length === 0
713 ? html`<p class="muted">No tokens yet. Mint one when a script, a CI job, or another machine needs to act as you.</p>`
713 ? html`<p class="muted">No access keys yet. Make one when a script, a CI job, or another machine needs to act as you.</p>`
714714 : html`<ul class="list setting-list">
715715 ${tokens.map((t) =>
716716 row({
@@ -725,18 +725,18 @@ function tokensView(ctx: Ctx): Html {
725725 </ul>`;
726726 return html`${help([
727727 [
728 "Tokens",
729 "Use a token as the password when pushing over HTTPS, or as a Bearer token for the API. Your account password works for git too — tokens are for scoped or automated access.",
728 "Access keys",
729 "Use an access key as the password when pushing over HTTPS, or as the Bearer value for the API. Your account password works for git too — access keys are for scoped or automated access.",
730730 ],
731 ["Token name", "Name it after where it lives — laptop, CI, deploy box."],
732 ["Scope", "A token can never mint another token, whatever its scope."],
731 ["Key name", "Name it after where it lives — laptop, CI, deploy box."],
732 ["Scope", "An access key can never make another access key, whatever its scope."],
733733 ])}${connectCard(ctx, readFlash(ctx.request)?.code)}
734 ${block("Tokens", list)}
734 ${block("Access keys", list)}
735735 ${block(
736 "New token",
736 "New access key",
737737 html`<form method="post" action="/settings/tokens">
738738 ${uiField({
739 label: "Token name",
739 label: "Key name",
740740 name: "name",
741741 required: true,
742742 })}
@@ -756,14 +756,14 @@ function tokensView(ctx: Ctx): Html {
756756 <label class="check">
757757 <input type="checkbox" name="aiAdmin" required />
758758 <span
759 >I mean to give this token admin: you are the forge's admin,
759 >I mean to give this access key admin: you are the forge's admin,
760760 so whatever holds it — an AI included — acts as admin.</span
761761 >
762762 </label>
763763 </div>`
764764 : null}
765765 <div class="form-actions">
766 ${btn("Generate token", { variant: "primary" })}
766 ${btn("Make access key", { variant: "primary" })}
767767 </div>
768768 </form>`,
769769 )}
@@ -775,7 +775,7 @@ export function tokensPage(ctx: Ctx): Response {
775775 if (!ctx.auth.user) return signInFirst(ctx);
776776 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
777777 const body = tokensView(ctx);
778 return timePhase(ctx.request, "render", () => accountShell(ctx, "tokens", "Personal access tokens", body));
778 return timePhase(ctx.request, "render", () => accountShell(ctx, "tokens", "Access keys", body));
779779 }
780780
781781 // POST /settings/tokens
@@ -861,14 +861,14 @@ function keysView(
861861 ${terminalCommand(ssh, ctx.app.config.sshHostKey)}
862862 </div>`}
863863 <p class="muted small mb">
864 Keys that sign you in over SSH. Paste a public key (<span class="mono"
864 Keys that sign you in to the terminal and to git. Paste a public key (<span class="mono"
865865 >~/.ssh/id_ed25519.pub</span
866866 >) — ed25519, ecdsa, or rsa (2048 bits or more).
867867 </p>
868868 ${block(
869 "SSH keys",
869 "Terminal keys",
870870 keys.length === 0
871 ? html`<p class="muted">No keys yet. Add one and git over SSH stops asking for a password.</p>`
871 ? html`<p class="muted">No keys yet. Add one and git stops asking for a password.</p>`
872872 : html`<ul class="list setting-list">
873873 ${keys.map((k) =>
874874 row({
@@ -880,7 +880,7 @@ function keysView(
880880 </ul>`,
881881 )}
882882 ${block(
883 "New SSH key",
883 "New terminal key",
884884 html`<form method="post" action="/settings/keys">
885885 ${uiField({
886886 label: "Name",
@@ -911,7 +911,7 @@ export function keysPage(ctx: Ctx): Response {
911911 if (!ctx.auth.user) return signInFirst(ctx);
912912 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
913913 const body = keysView(ctx, { name: "", key: "" });
914 return timePhase(ctx.request, "render", () => accountShell(ctx, "keys", "SSH keys", body));
914 return timePhase(ctx.request, "render", () => accountShell(ctx, "keys", "Terminal keys", body));
915915 }
916916
917917 // POST /settings/keys
@@ -930,7 +930,7 @@ export async function keyCreate(ctx: Ctx): Promise<Response> {
930930 return accountShell(
931931 ctx,
932932 "keys",
933 "SSH keys",
933 "Terminal keys",
934934 keysView(ctx, {
935935 name,
936936 key,
src/web/pages/accounts.ts +4 −4
@@ -281,12 +281,12 @@ export function personSignInsPage(ctx: Ctx): Response {
281281 html`<section class="settings-block" id="tokens">
282282 <h2>${userLink(user.username)}: where they are signed in</h2>
283283 <p class="muted">
284 Revoking a token or signing out a browser ends it at once; the person
284 Revoking an access key or signing out a browser ends it at once; the person
285285 can sign in again. To stop them signing in, suspend the account.
286286 </p>
287 <h3>Access tokens</h3>
287 <h3>Access keys</h3>
288288 ${tokens.length === 0

The heading now says 'Access keys' but this line still says 'No access tokens.'. Same name on the whole page.

289 ? html`<p class="muted">No access tokens.</p>`
289 ? html`<p class="muted">No access keys.</p>`
290290 : html`<ul class="list setting-list">
291291 ${tokens.map((t) =>
292292 row({
@@ -322,7 +322,7 @@ export function signInAct(what: "token" | "session") {
322322 : endAccountSession(ctx.app, ctx.auth.user, username, id);
323323 if (!done.ok) return notFoundPage(ctx);
324324 return flashTo(ctx, `/settings/accounts/${encodeURIComponent(username)}`, {
325 message: what === "token" ? "Token revoked." : "Browser signed out.",
325 message: what === "token" ? "Access key revoked." : "Browser signed out.",
326326 });
327327 };
328328 }
src/web/pages/origins.ts +3 −3
@@ -144,8 +144,8 @@ const SECTION_ROWS: readonly (readonly [
144144 ["Account", "Profile", "/settings", "user", (c) => c === "profile", false],
145145 ["Account", "Password", "/settings/password", "lock", (c) => c === "password", false],
146146 ["Account", "Passkeys", "/settings/passkeys", "key", (c) => c === "passkeys", false],
147 ["Account", "SSH keys", "/settings/keys", "lock", (c) => c === "keys", false],
148 ["Account", "Access tokens", "/settings/tokens", "key", (c) => c === "tokens", false],
147 ["Account", "Terminal keys", "/settings/keys", "lock", (c) => c === "keys", false],
148 ["Account", "Access keys", "/settings/tokens", "key", (c) => c === "tokens", false],
149149 ["Account", "Confirms", "/settings/confirms", "check", (c) => c === "confirms", false],
150150 ["Crew and AI", "Model", "/settings/model", "key", (c) => c === "model", false],
151151 ["Crew and AI", "Crew", "/settings/crew", "bot", (c) => c === "crew", true],
@@ -689,7 +689,7 @@ function forgeSection(ctx: Ctx, values: ConnectValues): Html {
689689 hint: "Read is enough to bring an app; private repositories come with it.",
690690 })}
691691 ${readOnlyField()}
692 <p class="muted small">Make the token there: ${tokens} (Settings → Access tokens).</p>
692 <p class="muted small">Make an access key there: ${tokens} (Settings → Access keys).</p>
693693 <div class="form-actions">
694694 ${btn("Connect that forge", { variant: "primary", icon: "globe" })}
695695 </div>
src/web/pages/site.ts +1 −1
@@ -201,7 +201,7 @@ export function terminalCard(ctx: Ctx): Html {
201201 ${terminalCommand(
202202 ssh,
203203 ctx.app.config.sshHostKey,
204 html`<a class="small" href="/settings/keys">SSH keys</a>`,
204 html`<a class="small" href="/settings/keys">Terminal keys</a>`,
205205 )}
206206 </section>`;
207207 }
src/web/studio/crew.ts +1 −1
@@ -424,7 +424,7 @@ export function settingsLead(ctx: Ctx, repo: Repo): Html {
424424 export function crewKeyNote(ctx: Ctx): Html | null {
425425 if (crewHasCredential(ctx.app.db)) return null;
426426 return html`<p class="small muted" id="crew-key-note" role="status">
427 ${icon("alert")} The crew has no model key yet, so it cannot start work.
427 ${icon("alert")} The crew has no AI key yet, so it cannot start work.
428428 ${ctx.auth.user?.isAdmin
429429 ? html`<a href="/settings/subscriptions">Add one in Subscriptions</a>.`
430430 : "Ask this forge's admin to add one."}
test/account-help.test.ts +1 −1
@@ -59,7 +59,7 @@ test("the password and token explanations live inside the help toggle, before th
5959 expect(pw.replace(helpOf(pw), "")).not.toContain("A passphrase beats a puzzle");
6060 expect(pw.indexOf("data-page-help")).toBeLessThan(pw.indexOf("Change password</h2>"));
6161 const tk = await get("/settings/tokens");
62 expect(helpOf(tk)).toContain("can never mint another token");
62 expect(helpOf(tk)).toContain("can never make another access key");
6363 expect(helpOf(tk)).toContain("laptop, CI, deploy box");
6464 expect(tk.replace(helpOf(tk), "")).not.toContain("laptop, CI, deploy box");
6565 });
test/account-rows.test.ts +7 −7
@@ -60,21 +60,21 @@ test("no account page is a card or holds a table", async () => {
6060 }
6161 });
6262
63 test("tokens are rows under a Tokens heading, each with Revoke", async () => {
63 test("tokens are rows under an Access keys heading, each with Revoke", async () => {
6464 const m = await main("/settings/tokens");
6565 expect(m).toContain('<section class="settings-block">');
66 const list = m.slice(m.indexOf("<h2>Tokens</h2>"));
67 expect(list).toMatch(/^<h2>Tokens<\/h2>\s*<ul class="list setting-list">/);
66 const list = m.slice(m.indexOf("<h2>Access keys</h2>"));
67 expect(list).toMatch(/^<h2>Access keys<\/h2>\s*<ul class="list setting-list">/);
6868 const item = list.slice(0, list.indexOf("</ul>"));
6969 expect(item).toContain("<strong>laptop</strong>");
7070 expect(item).toMatch(/settings%2Ftokens%2F[^"]+%2Fdelete/);
7171 expect(m).toContain('action="/settings/tokens"');
7272 });
7373
74 test("keys are rows under an SSH keys heading, each with its Remove link", async () => {
74 test("keys are rows under a Terminal keys heading, each with its Remove link", async () => {
outdated

Grammar: 'an Terminal keys'. Reword the test name.

7575 const m = await main("/settings/keys");
76 const list = m.slice(m.indexOf("<h2>SSH keys</h2>"));
77 expect(list).toMatch(/^<h2>SSH keys<\/h2>\s*<ul class="list setting-list">/);
76 const list = m.slice(m.indexOf("<h2>Terminal keys</h2>"));
77 expect(list).toMatch(/^<h2>Terminal keys<\/h2>\s*<ul class="list setting-list">/);
7878 const item = list.slice(0, list.indexOf("</ul>"));
7979 expect(item).toContain("<strong>work</strong>");
8080 expect(item).toMatch(/settings%2Fkeys%2F[^"]+%2Fdelete/);
@@ -90,7 +90,7 @@ test("empty lists are one muted sentence, not a panel", async () => {
9090 const c = (other.headers.get("set-cookie") ?? "").split(";")[0]!;
9191 const get = async (path: string) => (await (await fetch(`${base}${path}`, { headers: { cookie: c } })).text());
9292 const tokens = await get("/settings/tokens");
93 expect(tokens).toContain('<p class="muted">No tokens yet.');
93 expect(tokens).toContain('<p class="muted">No access keys yet.');
9494 expect(tokens).not.toContain("empty-title");
9595 const keys = await get("/settings/keys");
9696 expect(keys).toContain('<p class="muted">No keys yet.');
test/accounts-language.test.ts +1 −1
@@ -36,7 +36,7 @@ test("a person's sign-ins page is blocks all the way down, no card", async () =>
3636 const m = main(await (await fetch(`${servers.url}/settings/accounts/bobby`, { headers: { cookie: admin } })).text());
3737 expect(m).not.toContain('class="card');
3838 expect(m).toContain('<section class="settings-block" id="tokens">');
39 expect(m).toContain("No access tokens.");
39 expect(m).toContain("No access keys.");
4040 // the grant, ceiling and browsers sections are still there, forms intact
4141 expect(m).toContain("Model budget");
4242 expect(m).toContain('action="/settings/accounts/bobby/model"');
test/everyday.test.ts +2 −2
@@ -223,7 +223,7 @@ describe("the everyday account", () => {
223223 test("an admin's token from the page is minted only when they tick that they mean it", async () => {
224224 const root = await signIn("ada");
225225 const form = await page(root, "/settings/tokens");
226 expect(form).toContain("I mean to give this token admin");
226 expect(form).toContain("I mean to give this access key admin");
227227 const count = () =>
228228 (
229229 app.db
@@ -241,7 +241,7 @@ describe("the everyday account", () => {
241241 expect(count()).toBe(before + 1);
242242 // Someone who is not an admin is not asked.
243243 expect(await page(await signIn("kim"), "/settings/tokens")).not.toContain(
244 "I mean to give this token admin",
244 "I mean to give this access key admin",
245245 );
246246 });
247247
test/first-login.test.ts +11 −1
@@ -27,6 +27,7 @@ import { serve, type Servers } from "../src/http/server.ts";
2727 import { firstBoot } from "../src/spawn/first-boot.ts";
2828 import { hostedPlacement } from "../src/spawn/placement.ts";
2929 import { quietLogs } from "./helpers/globals.ts";
30 import { jargonIn, visibleText } from "./helpers/jargon.ts";
3031 import { passkeyFields } from "./helpers/passkey.ts";
3132
3233 quietLogs();
@@ -186,6 +187,12 @@ describe("the first login to a spawned forge", () => {
186187 expect(getUserSetting(parent.db, alice.id, "first_step_opened_app")).toBeUndefined();
187188 });
188189
190 test("the page a new forge's first login lands on has no jargon", async () => {
191 const text = visibleText(await page(owner));

Only the owner view is checked, and only visible text. Cover attributes and the other roles that land here.

192 expect(text).toContain("Your next steps");
193 expect(jargonIn(text)).toEqual([]);
194 });
195
189196 test("a plain reader of the child sees no next-steps card", async () => {
190197 const reader = await createUser(child.db, {
191198 origin: "seed",
@@ -196,7 +203,9 @@ describe("the first login to a spawned forge", () => {
196203 });
197204 if (!reader.ok) throw new Error("reader");
198205 const session = createSession(child.db, reader.value.id);
199 expect(await page(`forge_session=${session.token}`)).not.toContain(CARD);
206 const home = await page(`forge_session=${session.token}`);
207 expect(home).not.toContain(CARD);
208 expect(jargonIn(visibleText(home))).toEqual([]);
200209 });
201210
202211 test("after the claim, the home shows the crew and its direction, and one card with three steps, none done", async () => {
@@ -240,6 +249,7 @@ describe("the first login to a spawned forge", () => {
240249 expect(home).toContain('href="/marias/bakery"');
241250 expect(home).not.toContain("Your apps arrive here");
242251 expect(home).toContain("Your crew has its direction:");
252 expect(jargonIn(visibleText(home))).toEqual([]);
243253 // The admin's card moves along with it.
244254 expect(steps(await page(owner)).everyday).toBe("yes");
245255 });
test/helpers/jargon.ts added +68
@@ -0,0 +1,68 @@
1 /**
2 * Words a person who is not technical should not meet on the page a new
3 * forge's first login lands on (#10712). A test guard, so it lives with the tests. One list, one finder: a test renders
4 * that page and fails on any hit. Whole words only, case-insensitive, so
5 * "cellar" never trips "cell".
6 */
7
8 export const JARGON: readonly string[] = [
9 "egress",
10 "sentinel",
11 "shard",
12 "shards",
13 "cell",
14 "cells",
15 "gate",
16 "gates",
17 "rebase",
18 "rebased",
19 "tbw",
20 "sandbox",
21 "ledger",
22 "daemon",
23 "webhook",
24 "mcp",
25 "oauth",
26 "ssh",
27 "cron",
28 "worktree",
29 "upstream",
30 "downstream",
31 "quorum",
32 "heartbeat",
33 "preview",
34 "migration",
35 "namespace",
36 "tarball",
37 "token",
38 "tokens",
39 "palette",
40 "model key",
41 ];
42
43 const escape = (w: string) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
44 const PATTERN = new RegExp(`(?<![\\p{L}\\p{N}_-])(${JARGON.map(escape).join("|")})(?![\\p{L}\\p{N}_-])`, "giu");
45
46 const SPOKEN = /\b(?:aria-label|aria-description|title|alt|placeholder)\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;
47
48 /** What a reader sees or a screen reader speaks: the text, then the aria-label, title, alt and placeholder values. */
49 export function visibleText(html: string): string {
50 const spoken = [...html.replace(/<(script|style|template)\b[\s\S]*?<\/\1>/gi, " ").matchAll(SPOKEN)].map((m) => m[1] ?? m[2] ?? "");
51 return `${bodyText(html)} ${spoken.join(" ")}`.replace(/\s+/g, " ");
52 }
53
54 function bodyText(html: string): string {
55 return html
56 .replace(/<(script|style|template)\b[\s\S]*?<\/\1>/gi, " ")
57 .replace(/<!--[\s\S]*?-->/g, " ")
58 .replace(/<[^>]*>/g, " ")
59 .replace(/&nbsp;/g, " ")
60 .replace(/\s+/g, " ");
61 }
62
63 /** Every jargon word found in `text`, lower-cased, once each, in order of first appearance. */
64 export function jargonIn(text: string): string[] {
65 const found = new Set<string>();
66 for (const m of text.matchAll(PATTERN)) found.add(m[1]!.toLowerCase());
67 return [...found];
68 }
test/jargon.test.ts added +22
@@ -0,0 +1,22 @@
1 import { describe, expect, test } from "bun:test";
2 import { jargonIn, visibleText } from "./helpers/jargon.ts";
3
4 describe("the jargon finder", () => {
5 test("matches whole words, case-insensitively", () => {
6 expect(jargonIn("Egress and a Gate, then TBW")).toEqual(["egress", "gate", "tbw"]);
7 });
8 test("does not match inside words", () => {
9 expect(jargonIn("cellar, gateway, sentinels-of-old, rebased_x, shardy")).toEqual([]);
10 });
11 test("reads only visible text", () => {
12 const html = '<script>egress()</script><style>.cell{}</style><!-- shard --><a href="/gate">Your apps</a>';
13 expect(jargonIn(visibleText(html))).toEqual([]);
14 });
15 });
16
17 describe("spoken text", () => {
18 test("aria-label, title, alt and placeholder are checked too", () => {
19 const html = '<button aria-label="Open the palette"></button><img alt="shard"><a title=\'sentinel\'>x</a><input placeholder="egress">';
20 expect(jargonIn(visibleText(html))).toEqual(["palette", "shard", "sentinel", "egress"]);
21 });
22 });
test/onboarding.test.ts +1 −1
@@ -123,7 +123,7 @@ describe("onboarding: a person with just a login", () => {
123123 const pageHtml = await (
124124 await fetch(`${base}/settings/tokens`, { headers: { cookie } })
125125 ).text();
126 expect(pageHtml).toContain("Personal access tokens");
126 expect(pageHtml).toContain("Access keys");
127127
128128 // Post-redirect-get: minting redirects, and the secret rides a one-shot
129129 // flash cookie so a refresh shows the list instead of minting again.
test/palette-repos.test.ts +1 −1
@@ -117,7 +117,7 @@ test("a visitor's palette holds places to go and Sign in; a signed-in one holds
117117 expect(out.map((i) => i.t)).toEqual(["Home", "Apps", "Explore", "Forge packs", "Front page", "Search", "Sign in"]);
118118 expect(out.find((i) => i.t === "Sign in")!.h).toBe("/signin");
119119 const inn = (await rows({ cookie }, "/explore")).map((i) => i.t);
120 for (const t of ["New app", "New repository", "Migrate a repository", "New organization", "What you asked for", "Account settings", "Access tokens", "SSH keys", "Origins", "Map"]) expect(inn).toContain(t);
120 for (const t of ["New app", "New repository", "Migrate a repository", "New organization", "What you asked for", "Account settings", "Access keys", "Terminal keys", "Origins", "Map"]) expect(inn).toContain(t);
121121 expect(inn).not.toContain("Sign in");
122122 });
123123
test/palette-roster.test.ts +3 −3
@@ -89,7 +89,7 @@ test("a site-admin person is offered the whole roster", () => {
8989 ["confirms", "Confirms", "what the forge's agent asked to do; y does it once"],
9090 ["trusted", "Trusted sources", "who folds in without review; a trusts, x removes, s stops all, v reverts"],
9191 ["conversations", "Conversations", "your talks with the forge's agent; n starts one, r renames, x archives"],
92 ["ssh-keys", "SSH keys", "list, add and remove the keys that sign in as you"],
92 ["ssh-keys", "Terminal keys", "list, add and remove the keys that sign in as you"],
9393 ["passkeys", "Passkeys", "the passkeys that sign in as you"],
9494 ["account", "Account settings", undefined],
9595 ["signins", "Signed in", "your browsers and tokens; d signs a browser out"],
@@ -206,7 +206,7 @@ test("a site-admin agent is offered the roster without the person-only entries",
206206 ["asked", "Asked", "your thoughts and what became of them"],
207207 ["thought-notes", "Notes", "write an idea and watch it become shipped work"],
208208 ["decider", "Decider", "what it closed, deferred and asked you about today"],
209 ["ssh-keys", "SSH keys", "list, add and remove the keys that sign in as you"],
209 ["ssh-keys", "Terminal keys", "list, add and remove the keys that sign in as you"],
210210 ["account", "Account settings", undefined],
211211 ["signins", "Signed in", "your browsers and tokens; d signs a browser out"],
212212 ["sentinel", "Sentinel", "the forge's open faults"],
@@ -291,7 +291,7 @@ test("a member person is offered the signed-in roster without the admin entries"
291291 ["notify", "Phone notifications", "where the crew reaches your phone; s sets, x turns off"],
292292 ["confirms", "Confirms", "what the forge's agent asked to do; y does it once"],
293293 ["conversations", "Conversations", "your talks with the forge's agent; n starts one, r renames, x archives"],
294 ["ssh-keys", "SSH keys", "list, add and remove the keys that sign in as you"],
294 ["ssh-keys", "Terminal keys", "list, add and remove the keys that sign in as you"],
295295 ["passkeys", "Passkeys", "the passkeys that sign in as you"],
296296 ["account", "Account settings", undefined],
297297 ["signins", "Signed in", "your browsers and tokens; d signs a browser out"],
test/spawn-child-apps.test.ts +6 −6
@@ -175,18 +175,18 @@ describe("a spawned child's apps", () => {
175175 ).replace(/\s+/g, " ");
176176 expect(home).toContain("bakery");
177177 expect(home).not.toContain("No apps yet");
178 expect(home).toContain("The crew has no model key yet");
178 expect(home).toContain("The crew has no AI key yet");
179179 expect(home).toContain('href="/settings/subscriptions"');
180180 const appPage = await (
181181 await fetch(`${servers.url}/marias/bakery`, { headers: { cookie } })
182182 ).text();
183 expect(appPage).toContain("The crew has no model key yet");
183 expect(appPage).toContain("The crew has no AI key yet");
184184 });
185185
186186 test("on the app page the key note is an owner fact: not for a stranger or a plain reader", async () => {
187187 const anonymous = await (await fetch(`${servers.url}/marias/bakery`)).text();
188188 expect(anonymous).toContain("bakery");
189 expect(anonymous).not.toContain("The crew has no model key yet");
189 expect(anonymous).not.toContain("The crew has no AI key yet");
190190 const reader = await createUser(child.db, { origin: "seed", trusted: true,
191191 username: "reader",
192192 email: "[email protected]",
@@ -201,14 +201,14 @@ describe("a spawned child's apps", () => {
201201 })
202202 ).text();
203203 expect(asReader).toContain("bakery");
204 expect(asReader).not.toContain("The crew has no model key yet");
204 expect(asReader).not.toContain("The crew has no AI key yet");
205205 // Nor on the home: there the note is for an admin or a writer of an app.
206206 const readerHome = await (
207207 await fetch(`${servers.url}/`, {
208208 headers: { cookie: `forge_session=${session.token}` },
209209 })
210210 ).text();
211 expect(readerHome).not.toContain("The crew has no model key yet");
211 expect(readerHome).not.toContain("The crew has no AI key yet");
212212 });
213213
214214 test("first boot registers apps as the founder, an account with no verified email", () => {
@@ -262,6 +262,6 @@ describe("a spawned child's apps", () => {
262262 const home = await (
263263 await fetch(`${servers.url}/`, { headers: { cookie } })
264264 ).text();
265 expect(home).not.toContain("The crew has no model key yet");
265 expect(home).not.toContain("The crew has no AI key yet");
266266 });
267267 });
test/ssh-site.test.ts +1 −1
@@ -95,7 +95,7 @@ describe("the terminal on the website", () => {
9595 r.text(),
9696 );
9797 expect(page).not.toContain("terminal-line");
98 expect(page).toContain('<a class="small" href="/settings/keys">SSH keys</a>');
98 expect(page).toContain('<a class="small" href="/settings/keys">Terminal keys</a>');
9999 expect(page).toContain("host key SHA256:");
100100 });
101101
test/tui-signins-token.test.ts +1 −1
@@ -108,7 +108,7 @@ describe("revoking a token from the sign-ins screen", () => {
108108 expect(seen.filter((e) => e.kind === "token.deleted")).toEqual([]);
109109 expect(h.text()).toContain("alice-ci · ro");
110110 await h.press("d", "right", "enter");
111 expect(h.text()).toContain("Revoked that token.");
111 expect(h.text()).toContain("Revoked that access key.");
112112 expect(verifyToken(forge.db, ci.token).ok).toBe(false);
113113 expect(seen.filter((e) => e.kind === "token.deleted").map((e) => e.payload)).toEqual([{ tokenId: ci.id }]);
114114 stop();
test/tui-sshkeys.test.ts +3 −3
@@ -1,5 +1,5 @@
11 /**
2 * SSH keys in the terminal (#7242): your own keys listed, one added, a bad
2 * Your terminal keys, managed from the terminal (#7242): your own keys listed, one added, a bad
33 * line refused in MCP's words, one removed after a confirm.
44 */
55 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
@@ -27,7 +27,7 @@ const line = (fill: number, comment = "") => {
2727 return `ssh-ed25519 ${blob.toString("base64")} ${comment}`.trim();
2828 };
2929
30 describe("SSH keys in the terminal", () => {
30 describe("terminal keys, managed from the terminal", () => {
3131 let dataDir: string;
3232 let app: App;
3333
@@ -62,7 +62,7 @@ describe("SSH keys in the terminal", () => {
6262 open: async function () {
6363 key("k", true);
6464 await settleApp(tui);
65 await this.type("SSH keys");
65 await this.type("Terminal keys");
6666 await this.press("enter");
6767 },
6868 stop: () => tui.stop(),
test/tui-token-make.test.ts +2 −2
@@ -115,7 +115,7 @@ describe("making a token in the terminal", () => {
115115 await h.press("backspace", "backspace");
116116 await h.type("admin");
117117 await h.press("enter");
118 expect(h.text()).toContain("Only an admin can make a token");
118 expect(h.text()).toContain("Only an admin can make an access key");
119119 expect(listTokens(forge.db, getUserByName(forge.db, "carol")!.id).length).toBe(before);
120120 h.stop();
121121 });
@@ -149,7 +149,7 @@ describe("making a token in the terminal", () => {
149149 await h.open();
150150 const before = count("carol");
151151 await h.press("m", "backspace", "backspace", "backspace", "backspace", "backspace", "enter");
152 expect(h.text()).toContain("A token needs a name.");
152 expect(h.text()).toContain("An access key needs a name.");
153153 await h.type("x".repeat(65));
154154 await h.press("enter");
155155 expect(h.text()).toContain("Keep the name to 64 characters.");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs