Public: anyone can read this; the crew can change it.
A person who opens a forge link for the first time sees three next steps, proven by a test with a link login #16010
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/15972-a-person-who-opens-a-forge-link-for-the → main 0 commits fork 3 threads · 3 unresolved
8 files
changed +138
−5
docs/features/first-steps.md added +11
| @@ -0,0 +1,11 @@ | ||
| 1 | --- | |
| 2 | topic: What a forge is | |
| 3 | row: The steps still undone on a forge link's first page | |
| 4 | --- | |
| 5 | # The steps still undone on a forge link's first page | |
| 6 | ||
| 7 | After someone opens a forge link and signs in, their first page is the one box ("What do you want built?"), then the crew at work, then **Next steps**: a plain list of links, one for each step they have not taken yet. The steps are *Make your everyday account* (`/settings/everyday`), *Open your apps* (`/apps`) and *Tell the crew something* (the box above). Each is read from what has happened, never ticked by hand, so a second visit lists only what is still undone. The list goes with the one box once the first tell exists. The heading is always "Next steps". | |
| 8 | ||
| 9 | In the terminal, the home screen of that person shows the same heading and the same undone steps, one per line, under the first-tell line. | |
| 10 | ||
| 11 | Code: `src/core/next-steps.ts` (the steps and their words), `src/web/pages/first_steps.ts` (the list), `src/tui/screens/dashboard.ts` (the terminal lines). Tests: `test/first-login.test.ts`, `test/next-steps-card.test.ts`. |
src/core/next-steps.ts +10
| @@ -36,6 +36,16 @@ export const STEP_TITLES: Record<StepKey, string> = { | ||
| 36 | 36 | tell: "Tell the crew something", |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | /** The one heading of the list of steps still undone, whatever their count. */ | |
| 40 | export const FIRST_STEPS_HEADING = "Next steps"; | |
| 41 | ||
| 42 | /** | |
| 43 | * The titles of the steps not yet taken, in order: the web list and the terminal's lines read this. | |
| 44 | */ | |
| 45 | export function undoneTitles(steps: readonly NextStep[]): string[] { | |
| 46 | return steps.filter((s) => !s.done).map((s) => STEP_TITLES[s.key]); | |
| 47 | } | |
| 48 | ||
| 39 | 49 | /** |
| 40 | 50 | * What the recipient of a sent forge sees first, in one line: the apps chosen, that the crew is |
| 41 | 51 | * working, the three steps. |
src/tui/screens/dashboard.ts +11 −2
| @@ -27,7 +27,16 @@ import { coveredByVerdict, forgeVerdict, verdictLine } from "../../kernel/guard_ | ||
| 27 | 27 | import { lastChangeLine } from "../../story/last_change.ts"; |
| 28 | 28 | import { clientAppRows, clientFinished } from "../../core/client-apps.ts"; |
| 29 | 29 | import { appCrew } from "../../core/app-crew.ts"; |
| 30 | import { nextStepsFor } from "../../core/next-steps.ts"; | |
| 30 | import { FIRST_STEPS_HEADING, nextStepsFor, undoneTitles, type NextStep } from "../../core/next-steps.ts"; | |
| 31 | ||
| 32 | /** | |
| 33 | * The steps still undone, as the page lists them (`web/pages/first_steps.ts`): a heading, then one | |
| 34 | * line each. | |
| 35 | */ | |
| 36 | const firstStepLines = (steps: readonly NextStep[]): string[] => { | |
| 37 | const todo = undoneTitles(steps); | |
| 38 | return todo.length === 0 ? [] : [FIRST_STEPS_HEADING, ...todo.map((t) => ` ${t}`)]; | |
| 39 | }; | |
| 31 | 40 | import { askRepos, askStatus, askStatusLine } from "../../core/ask-status.ts"; |
| 32 | 41 | import { AUTONOMY_FAILED_WORDS, firstAsk } from "../../actions/first_ask.ts"; |
| 33 | 42 | import { SAY_SOMETHING_WORDS } from "../../actions/tell_words.ts"; |
| @@ -427,7 +436,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen { | ||
| 427 | 436 | figures = []; |
| 428 | 437 | firstTell = steps.some((s) => s.key === "tell" && !s.done); |
| 429 | 438 | if (firstTell) { |
| 430 | clientLines = [FIRST_TELL_LINE, crewFirstText(f.app)]; | |
| 439 | clientLines = [FIRST_TELL_LINE, crewFirstText(f.app), ...firstStepLines(steps)]; | |
| 431 | 440 | ctx.invalidate(); |
| 432 | 441 | return; |
| 433 | 442 | } |
src/web/pages/first_steps.ts added +31
| @@ -0,0 +1,31 @@ | ||
| 1 | /** | |
| 2 | * The steps a person has not taken yet after a forge link's first login, under the one-box first | |
| 3 | * screen: the crew working right now, then a plain list of links, one per undone step (#15972). | |
| 4 | * Read from what has happened (`core/next-steps.ts`), so a later visit lists only what is still | |
| 5 | * undone, and it is part of the first-screen card, so it is gone once the first tell exists. The | |
| 6 | * terminal's home lists the same steps (`tui/screens/dashboard.ts`). | |
| 7 | */ | |
| 8 | ||
| 9 | import { crewNow } from "../../core/crew_now.ts"; | |
| 10 | import { FIRST_STEPS_HEADING, STEP_TITLES, type NextStep, type StepKey } from "../../core/next-steps.ts"; | |
| 11 | import type { Ctx } from "../../http/context.ts"; | |
| 12 | import { crewNowHtml } from "../crew_now.ts"; | |
| 13 | import { html, type Html } from "../html.ts"; | |
| 14 | import { listCard, row } from "../ui.ts"; | |
| 15 | ||
| 16 | /** Where each step leads: the composer on this page, the apps list, the everyday-account form. */ | |
| 17 | const STEP_HREF: Record<StepKey, string> = { | |
| 18 | everyday: "/settings/everyday", | |
| 19 | apps: "/apps", | |
| 20 | tell: "#composer", | |
| 21 | }; | |
| 22 | ||
| 23 | /** | |
| 24 | * The crew now, then the undone steps under one fixed heading; the crew block appears here only. | |
| 25 | */ | |
| 26 | export function firstSteps(ctx: Ctx, steps: readonly NextStep[]): Html { | |
| 27 | const todo = steps.filter((s) => !s.done); | |
| 28 | return html`${crewNowHtml(crewNow(ctx.app.db))} | |
outdated
Principles 7 and 8: a dl with only dt is misused markup; use a plain list of links, and a fixed heading rather than the count-dependent title. |
||
| 29 | <section id="first-steps" class="mt" aria-label="${FIRST_STEPS_HEADING}"><h2 class="small">${FIRST_STEPS_HEADING}</h2> | |
| 30 | ${listCard(todo.map((s) => row({ href: STEP_HREF[s.key], title: html`${STEP_TITLES[s.key]}`, data: { "first-step": s.key } })))}</section>`; | |
| 31 | } |
src/web/pages/next-steps.ts +2 −1
| @@ -22,6 +22,7 @@ import { hasPassword, type User } from "../../core/users.ts"; | ||
| 22 | 22 | import { passkeyIds } from "../../core/passkeys.ts"; |
| 23 | 23 | import type { Ctx } from "../../http/context.ts"; |
| 24 | 24 | import { html, type Html } from "../html.ts"; |
| 25 | import { firstSteps } from "./first_steps.ts"; | |
| 25 | 26 | import { btn, row } from "../ui.ts"; |
| 26 | 27 | import { askRepos, askStatus, type AskStatus } from "../../core/ask-status.ts"; |
| 27 | 28 | import { crewCanRun, crewFirstLine } from "../studio/crew_key.ts"; |
| @@ -90,7 +91,7 @@ export async function nextStepsCard( | ||
| 90 | 91 | ): Promise<Html | null> { |
| 91 | 92 | if (!steps || steps.every((s) => s.done)) return null; |
| 92 | 93 | const repos = await spawnedRepos(ctx.app, user); |
| 93 | if (steps.some((s) => s.key === "tell" && !s.done)) return firstTell(ctx, user); | |
| 94 | if (steps.some((s) => s.key === "tell" && !s.done)) return html`${firstTell(ctx, user)}${firstSteps(ctx, steps)}`; | |
| 94 | 95 | const ask = askStatus(ctx.app.db, await askRepos(ctx.app, user), user.id, crewCanRun(ctx.app), user.isAdmin === true); |
| 95 | 96 | // What the person made leads: the ask's state, then each app a crew member is on. An app nobody |
| 96 | 97 | // is on says nothing here; the apps list below carries it. |
test/first-login.test.ts +27 −1
| @@ -28,6 +28,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 28 | 28 | import { firstBoot } from "../src/spawn/first-boot.ts"; |
| 29 | 29 | import { hostedPlacement } from "../src/spawn/placement.ts"; |
| 30 | 30 | import { quietLogs } from "./helpers/globals.ts"; |
| 31 | import { jargonIn } from "./helpers/jargon.ts"; | |
| 31 | 32 | import { passkeyFields } from "./helpers/passkey.ts"; |
| 32 | 33 | |
| 33 | 34 | quietLogs(); |
| @@ -211,7 +212,9 @@ describe("the first login to a spawned forge", () => { | ||
| 211 | 212 | expect(mainForms[0]).toContain('action="/tell"'); |
| 212 | 213 | expect(forms.some((f) => f.includes("/settings/everyday"))).toBe(false); |
| 213 | 214 | expect(main).not.toContain("There is no password"); |
| 214 | expect(main).not.toContain("Make your everyday account"); | |
| 215 | // The step is a link; the everyday form itself is not on the first screen. | |
| 216 | expect(main).not.toContain("/settings/everyday/options"); | |
| 217 | expect(main).not.toContain('name="username"'); | |
| 215 | 218 | expect(steps(home)).toEqual({ everyday: undefined, apps: undefined, tell: undefined }); |
| 216 | 219 | // Before the first ask: the sentence and the box, no crew rows (#13012). |
| 217 | 220 | const card = home.slice(home.indexOf("data-first-tell"), home.indexOf("</section>", home.indexOf("data-first-tell"))); |
| @@ -220,12 +223,33 @@ describe("the first login to a spawned forge", () => { | ||
| 220 | 223 | expect(card).not.toContain("arrive here"); |
| 221 | 224 | }); |
| 222 | 225 | |
| 226 | test("the first page shows the crew and the three steps as working links; none of it is jargon", async () => { | |
| 227 | const home = await page(owner); | |
| 228 | const main = home.slice(home.indexOf("<main")); | |
| 229 | expect(main).toContain('id="crew-now"'); | |
| 230 | expect(main).toContain(">Next steps<"); | |
| 231 | expect(main.match(/id="crew-now"/g)?.length).toBe(1); | |
| 232 | expect(main.match(/id="first-steps"/g)?.length).toBe(1); | |
| 233 | const links = [...main.matchAll(/data-first-step="(\w+)"/g)].map((m) => m[1]); | |
| 234 | expect(links).toEqual(["everyday", "apps", "tell"]); | |
| 235 | expect(main).toContain(">Make your everyday account<"); | |
| 236 | expect(main).toContain(">Open your apps<"); | |
| 237 | expect(main).toContain(">Tell the crew something<"); | |
| 238 | expect(main).toContain('id="composer"'); // the "#composer" link has a target | |
| 239 | for (const href of ["/settings/everyday", "/apps"]) { | |
| 240 | expect(main).toContain(`href="${href}"`); | |
| 241 | expect((await fetch(url(href), { headers: { cookie: owner }, redirect: "manual" })).status).toBe(200); | |
| 242 | } | |
| 243 | expect(jargonIn(main)).toEqual([]); | |
| 244 | }); | |
| 245 | ||
| 223 | 246 | test("once a tell exists the home leads with the crew's work and the ask box; the everyday account is one quiet line", async () => { |
| 224 | 247 | const told = await post(owner, "/marias/bakery/tell", { text: "Add a weekly menu page." }); |
| 225 | 248 | expect(told.status).toBeLessThan(400); |
| 226 | 249 | const home = await page(owner); |
| 227 | 250 | expect(home).toContain(CARD); |
| 228 | 251 | expect(home).not.toContain("Your next steps"); |
| 252 | expect(home).not.toContain('id="first-steps"'); | |
| 229 | 253 | expect(home).not.toContain("Make your everyday account"); |
| 230 | 254 | expect(home).not.toContain("can break the forge"); |
| 231 | 255 | expect(home).not.toContain("nobody is on it yet"); |
| @@ -252,6 +276,8 @@ describe("the first login to a spawned forge", () => { | ||
| 252 | 276 | expect(getUserByName(child.db, "maria-me")).toBeDefined(); |
| 253 | 277 | const home = await page(daily); |
| 254 | 278 | expect(home).not.toContain('href="/settings/everyday"'); |
| 279 | // The first ask is made by now: the steps are gone, not repeated. | |
| 280 | expect([...home.matchAll(/data-first-step="(\w+)"/g)].map((m) => m[1])).toEqual([]); | |
| 255 | 281 | // It can read the client's own apps, and the crew line reads for it too. |
| 256 | 282 | expect(home).toContain('href="/marias/bakery"'); |
| 257 | 283 | expect(home).not.toContain("Your apps arrive here"); |
test/first-steps.test.ts added +44
| @@ -0,0 +1,44 @@ | ||
| 1 | /** | |
| 2 | * The list of steps still undone under the first-screen box (#15972): one fixed heading, a plain | |
| 3 | * list of links, only the steps not yet taken; the crew block once; the terminal's lines say the | |
| 4 | * same. | |
| 5 | */ | |
| 6 | import { expect, test } from "bun:test"; | |
| 7 | import { mkdtempSync } from "node:fs"; | |
| 8 | import { tmpdir } from "node:os"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { createApp } from "../src/app.ts"; | |
| 11 | import { FIRST_STEPS_HEADING, undoneTitles, type NextStep } from "../src/core/next-steps.ts"; | |
| 12 | import type { Ctx } from "../src/http/context.ts"; | |
| 13 | import { firstSteps } from "../src/web/pages/first_steps.ts"; | |
| 14 | import { quietLogs } from "./helpers/globals.ts"; | |
| 15 | ||
| 16 | quietLogs(); | |
| 17 | ||
| 18 | const step = (key: NextStep["key"], done: boolean): NextStep => ({ key, title: key, done }); | |
| 19 | const app = createApp({ dataDir: mkdtempSync(join(tmpdir(), "forge-steps-")), port: 0 }); | |
| 20 | const ctx = { app } as unknown as Ctx; | |
| 21 | const keys = (h: string) => [...h.matchAll(/data-first-step="(\w+)"/g)].map((m) => m[1]); | |
| 22 | ||
| 23 | test("a second login, the everyday account made and nothing asked, lists only apps and tell", () => { | |
| 24 | const out = String(firstSteps(ctx, [step("everyday", true), step("apps", false), step("tell", false)])); | |
| 25 | expect(keys(out)).toEqual(["apps", "tell"]); | |
| 26 | expect(out).not.toContain("Make your everyday account"); | |
| 27 | expect(out).not.toContain("/settings/everyday"); | |
| 28 | expect(undoneTitles([step("everyday", true), step("apps", false), step("tell", false)])).toEqual([ | |
| 29 | "Open your apps", | |
| 30 | "Tell the crew something", | |
| 31 | ]); | |
| 32 | }); | |
| 33 | ||
| 34 | test("the heading is fixed whatever the count, the list is plain links, the crew block is once", () => { | |
| 35 | for (const all of [[false, false, false], [true, false, false], [true, true, false]]) { | |
| 36 | const out = String(firstSteps(ctx, [step("everyday", all[0]!), step("apps", all[1]!), step("tell", all[2]!)])); | |
| 37 | expect(out).toContain(`<h2 class="small">${FIRST_STEPS_HEADING}</h2>`); | |
| 38 | expect(out).not.toContain("<dl"); | |
| 39 | expect(out).toContain("<ul"); | |
| 40 | expect(out).not.toContain("<dt"); | |
| 41 | expect(out.match(/<li data-first-step="\w+">\s*<a href=/g)?.length).toBe(keys(out).length); | |
| 42 | expect(out.match(/id="crew-now"/g)?.length).toBe(1); | |
| 43 | } | |
| 44 | }); |
test/next-steps-card.test.ts +2 −1
| @@ -54,7 +54,8 @@ describe("the next-steps card of a spawned forge", () => { | ||
| 54 | 54 | expect(forms[0]).toContain('id="composer"'); |
| 55 | 55 | expect(forms[0]).toContain('action="/tell"'); |
| 56 | 56 | expect(forms.filter((f) => f.includes('action="/tell"')).length).toBe(1); |
| 57 | expect(main).not.toContain("/settings/everyday"); | |
| 57 | expect(main).not.toContain("action=\"/settings/everyday\""); | |
| 58 | expect(main).not.toContain("/settings/everyday/options"); | |
| 58 | 59 | expect(main).not.toContain("There is no password"); |
| 59 | 60 | expect(main.match(/data-variant="primary"/g)?.length).toBe(1); |
| 60 | 61 | expect(keys(home)).toEqual([]); |
new above
offline
Principle 1: this repeats the steps the first-screen card already carries, and crewNowHtml may duplicate id=crew-now. Show it once.