Public: anyone can read this; the crew can change it.
/settings has looks of a changed and an untouched setting line at 390 and 1280 px, light and dark #13202
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13193-settings-has-looks-of-a-changed-and-an-u → main 6 commits fork 3 threads · 3 unresolved
8 files
changed +113
−8
docs/design/areas/settings.md +4 −2
| @@ -28,8 +28,10 @@ its name, its control (the checkbox, select or number is the value) and a mark t | ||
| 28 | 28 | `settingLine()` and `toggleLine()` in `src/web/setting_line.ts`; styled in `src/web/style/components.ts`. |
| 29 | 29 | |
| 30 | 30 | - `.setting-line` — the `.field` row: a wrapping flex line of label, control and mark, at desktop and 390 px alike. |
| 31 | - `.setting-changed` — the muted "changed by <name>, <time>" phrase at the end of a `.setting-line`; present only once the | |
| 32 | setting has changed (read from `repo.settings_updated`), so an untouched row is unchanged. Under 600 px it takes its own full line, so a long label never squeezes it. | |
| 31 | - `.setting-changed` — the muted "by <name>, <time>" phrase at the end of a `.setting-line`; present only once the | |
| 32 | setting has changed (read from `repo.settings_updated`), so an untouched row is unchanged. It stays beside the control and wraps only when the line is full. | |
| 33 | - Looks: Settings at `#gates`, 390 and 1280 px, light and dark (`PREVIEW_GATES_LOOK`, `src/spawn/preview-looks.ts`). | |
| 34 | The seed changes one setting so a changed row shows beside untouched ones. | |
| 33 | 35 | - `.why` — the `<details>` holding a setting's reason. Its summary is the help mark drawn as a small bordered round |
| 34 | 36 | button (28px, 44px on touch), named "Why" for a screen reader and a tooltip; open, the reason takes the full width |
| 35 | 37 | under the row. |
src/spawn/preview-looks.ts +11
| @@ -72,6 +72,16 @@ export const PREVIEW_TEMPLATE_PAGE = `/${PREVIEW_ADMIN}/${PREVIEW_TEMPLATE}`; | ||
| 72 | 72 | export const PREVIEW_MOVE_PAGE = `${PREVIEW_REPO_HOME}/settings`; |
| 73 | 73 | export const PREVIEW_MOVE_LOOK = `${PREVIEW_MOVE_PAGE}#move`; |
| 74 | 74 | |
| 75 | /** | |
| 76 | * The sample's Settings scrolled to "Branch and gates" (#13193): one setting | |
| 77 | * the seed changed (Polish share, "changed by <admin>, <time>") beside the | |
| 78 | * untouched rows, so the muted phrase is seen at phone and desk width. The | |
| 79 | * looks service takes each light and dark. The path is the page's own. | |
| 80 | */ | |
| 81 | export const PREVIEW_GATES_LOOK = `${PREVIEW_REPO_HOME}/settings#gates`; | |
| 82 | /** The setting the seed changes so the gates look has a changed row beside untouched ones. */ | |
| 83 | export const PREVIEW_CHANGED_SETTING = "polishShare"; | |
| 84 | ||
| 75 | 85 | /** The Iterations page of the seeded fork family (#9182). */ |
| 76 | 86 | export const PREVIEW_ITERATIONS_PAGE = `${PREVIEW_REPO_HOME}/iterations`; |
| 77 | 87 | /** |
| @@ -240,6 +250,7 @@ export const PREVIEW_OWNER_LOOKS: readonly OwnerLook[] = [ | ||
| 240 | 250 | PREVIEW_MOVED_PAGE, |
| 241 | 251 | PREVIEW_TEMPLATE_PAGE, |
| 242 | 252 | PREVIEW_MOVE_LOOK, |
| 253 | PREVIEW_GATES_LOOK, | |
| 243 | 254 | PREVIEW_PULL_PAGE, |
| 244 | 255 | PREVIEW_PULL_FILES, |
| 245 | 256 | PREVIEW_ITERATIONS_PAGE, |
src/spawn/preview-seed.ts +35
| @@ -46,6 +46,7 @@ import { reviewGate } from "../actions/gate_review.ts"; | ||
| 46 | 46 | import { forgeHttp } from "../http/server.ts"; |
| 47 | 47 | import { transferRepository } from "../actions/transfer.ts"; |
| 48 | 48 | import { linkIssue } from "../actions/dependencies.ts"; |
| 49 | import { lastChanges } from "../settings/last_change.ts"; | |
| 49 | 50 | import { createApp as createAppRecord } from "../core/apps.ts"; |
| 50 | 51 | import { studioApp } from "../web/studio/app.ts"; |
| 51 | 52 | import { THEMES_AT_REST } from "../web/pages/gate.ts"; |
| @@ -91,6 +92,7 @@ import { | ||
| 91 | 92 | PREVIEW_MOVED, |
| 92 | 93 | PREVIEW_MOVED_OWNER, |
| 93 | 94 | PREVIEW_MOVED_PAGE, |
| 95 | PREVIEW_CHANGED_SETTING, | |
| 94 | 96 | PREVIEW_MOVE_PAGE, |
| 95 | 97 | PREVIEW_EVERYDAY, |
| 96 | 98 | PREVIEW_EVERYDAY_ADMIN, |
| @@ -200,6 +202,35 @@ export async function checkMoveSection( | ||
| 200 | 202 | return ok(); |
| 201 | 203 | } |
| 202 | 204 | |
| 205 | /** | |
| 206 | * One setting of the sample changed through the action a person uses (#13193), | |
| 207 | * once, so the owner's look of Settings › Branch and gates draws "changed by | |
| 208 | * <admin>, <time>" on one row and nothing on the rest. Refused unless the | |
| 209 | * page draws the phrase. | |
| 210 | */ | |
| 211 | async function seedChangedSetting(app: App, admin: User): Promise<Result<void, string>> { | |
| 212 | const repo = getRepo(app.db, PREVIEW_ADMIN, PREVIEW_REPO); | |
| 213 | if (repo === undefined) return err("the sample repository is missing"); | |
| 214 | if (!lastChanges(app.db, repo.id).has(PREVIEW_CHANGED_SETTING)) { | |
| 215 | const changed = await updateRepoSettings(app, admin, repo, { polishShare: repo.polishShare === 15 ? 20 : 15 }); | |
| 216 | if (!changed.ok) return err(`the sample's changed setting: ${String(changed.error)}`); | |
| 217 | } | |
| 218 | const http = forgeHttp(app); | |
| 219 | const session = createSession(app.db, admin.id); | |
| 220 | try { | |
| 221 | const res = await http.handle( | |
| 222 | new Request(`http://localhost${PREVIEW_MOVE_PAGE}`, { headers: { cookie: `forge_session=${session.token}` } }), | |
| 223 | ); | |
| 224 | if (res.status !== 200) return err(`${PREVIEW_MOVE_PAGE} answers ${String(res.status)}, not 200`); | |
| 225 | const page = await res.text(); | |
| 226 | if (!page.includes('id="gates"') || !page.includes("data-changed")) return err(`${PREVIEW_MOVE_PAGE} draws no changed setting`); | |
| 227 | } finally { | |
| 228 | destroySession(app.db, session.token); | |
| 229 | http.close(); | |
| 230 | } | |
| 231 | return ok(); | |
| 232 | } | |
| 233 | ||
| 203 | 234 | async function seedMoveSection(app: App, admin: User): Promise<Result<void, string>> { |
| 204 | 235 | const http = forgeHttp(app); |
| 205 | 236 | const session = createSession(app.db, admin.id); |
| @@ -424,6 +455,8 @@ export async function seedPreview( | ||
| 424 | 455 | if (!settings.ok) return settings; |
| 425 | 456 | const moveSection = await seedMoveSection(app, admin); |
| 426 | 457 | if (!moveSection.ok) return moveSection; |
| 458 | const changedSetting = await seedChangedSetting(app, admin); | |
| 459 | if (!changedSetting.ok) return changedSetting; | |
| 427 | 460 | const disks = await seedDisks(app, admin); |
| 428 | 461 | if (!disks.ok) return disks; |
| 429 | 462 | const files = await seedConfigFiles(app, admin); |
| @@ -448,6 +481,8 @@ export async function seedPreview( | ||
| 448 | 481 | if (!settings.ok) return settings; |
| 449 | 482 | const moveSection = await seedMoveSection(app, admin); |
| 450 | 483 | if (!moveSection.ok) return moveSection; |
| 484 | const changedSetting = await seedChangedSetting(app, admin); | |
| 485 | if (!changedSetting.ok) return changedSetting; | |
| 451 | 486 | const disks = await seedDisks(app, admin); |
| 452 | 487 | if (!disks.ok) return disks; |
| 453 | 488 | const files = await seedConfigFiles(app, admin); |
src/web/pages/settings.ts +1 −1
| @@ -281,7 +281,7 @@ export async function settingsPage( | ||
| 281 | 281 | |
| 282 | 282 | // The lead's About card owns the description and visibility; this form |
| 283 | 283 | // sends them back unchanged, as that one does the gates below. |
| 284 | const body = html`<section class="settings-block"> | |
| 284 | const body = html`<section class="settings-block" id="gates"> | |
The anchor is fine. Box 2 is still open: the changed phrase wraps to its own line at 390 px. Fix it in setting_line.ts/CSS, or shorten the phrase. |
||
| 285 | 285 | <h2>Branch and gates</h2> |
| 286 | 286 | <form method="post" action="${base}/settings"> |
| 287 | 287 | <input type="hidden" name="card" value="gates" /> |
src/web/setting_line.ts +2 −2
| @@ -16,12 +16,12 @@ export interface ChangedBy { | ||
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | * The muted phrase after a changed setting: "changed by olive, 2 hours ago". | |
| 19 | * The muted phrase after a changed setting: "by olive, 2 hours ago". | |
| 20 | 20 | * Nothing for one never changed. |
| 21 | 21 | */ |
| 22 | 22 | export function changedNote(last: ChangedBy | undefined, now: number = Date.now()): Html | null { |
| 23 | 23 | if (last === undefined) return null; |
| 24 | return html`<span class="muted small setting-changed" data-changed>changed by ${last.by}, <time datetime="${last.at}">${agoWords(last.at, now)}</time></span>`; | |
| 24 | return html`<span class="muted small setting-changed" data-changed>by ${last.by}, <time datetime="${last.at}">${agoWords(last.at, now)}</time></span>`; | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** The reason behind a setting, behind its mark. `id` ties it to the control via aria-describedby. */ |
src/web/style/components.ts −1
| @@ -144,7 +144,6 @@ select.input { | ||
| 144 | 144 | .setting-line > details.why { margin: 0; } |
| 145 | 145 | .setting-line > details.why[open] { flex-basis: 100%; } |
| 146 | 146 | .setting-line > .setting-changed { margin-left: auto; } |
| 147 | @media (max-width: 600px) { .setting-line > .setting-changed { flex-basis: 100%; margin-left: 0; } } | |
| 148 | 147 | .why > summary { |
| 149 | 148 | list-style: none; cursor: pointer; display: inline-grid; place-items: center; |
| 150 | 149 | width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 999px; |
test/preview-gates-look.test.ts added +58
| @@ -0,0 +1,58 @@ | ||
| 1 | /** | |
| 2 | * A forge preview seeds one changed setting and looks at Branch and gates as the owner at desk and | |
| 3 | * phone (#13193). | |
| 4 | */ | |
| 5 | import { afterAll, beforeAll, expect, test } from "bun:test"; | |
| 6 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 7 | import { tmpdir } from "node:os"; | |
| 8 | import { join } from "node:path"; | |
| 9 | import { createApp, type App } from "../src/app.ts"; | |
| 10 | import { listEvents } from "../src/core/events.ts"; | |
| 11 | import { createSession } from "../src/core/sessions.ts"; | |
| 12 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 13 | import { PREVIEW_CHANGED_SETTING, PREVIEW_GATES_LOOK, PREVIEW_OWNER_LOOKS } from "../src/spawn/preview-looks.ts"; | |
| 14 | import { previewAdmin, seedPreview } from "../src/spawn/preview-seed.ts"; | |
| 15 | import { quietLogs } from "./helpers/globals.ts"; | |
| 16 | ||
| 17 | quietLogs(); | |
| 18 | ||
| 19 | let dir: string; | |
| 20 | let app: App; | |
| 21 | let servers: Servers; | |
| 22 | beforeAll(async () => { | |
| 23 | dir = await mkdtemp(join(tmpdir(), "forge-preview-gates-")); | |
| 24 | app = createApp({ dataDir: dir, port: 0 }); | |
| 25 | const seeded = await seedPreview(app, { FORGE_APP_ENV: "preview" }); | |
| 26 | if (!seeded.ok) throw new Error(seeded.error); | |
| 27 | servers = await serve(app); | |
| 28 | }, 30_000); | |
| 29 | afterAll(async () => { | |
| 30 | servers.stop(); | |
| 31 | app.close(); | |
| 32 | await rm(dir, { recursive: true, force: true }); | |
| 33 | }); | |
| 34 | ||
| 35 | test("the gates section is an owner look at desk and phone", () => { | |
| 36 | expect(PREVIEW_OWNER_LOOKS.filter((l) => l.page === PREVIEW_GATES_LOOK).map((l) => l.kind).sort()).toEqual(["desktop", "phone"]); | |
| 37 | }); | |
| 38 | ||
| 39 | test("one row says who changed it, the untouched rows say nothing, and the fragment is on the section", async () => { | |
| 40 | const cookie = `forge_session=${createSession(app.db, previewAdmin(app)!.id).token}`; | |
| 41 | const [path, fragment] = PREVIEW_GATES_LOOK.split("#") as [string, string]; | |
| 42 | const html = await (await fetch(`${servers.url}${path}`, { headers: { cookie } })).text(); | |
| 43 | expect(html).toContain(`id="${fragment}"`); | |
| 44 | const lines = html.split('class="field setting-line"').slice(1).map((l) => l.split("</form>")[0]!); | |
| 45 | const changed = lines.filter((l) => l.includes("data-changed")); | |
| 46 | expect(changed.length).toBe(1); | |
| 47 | expect(changed[0]).toContain(`data-setting="${PREVIEW_CHANGED_SETTING}"`); | |
| 48 | expect(changed[0]).toContain("by preview-"); | |
| 49 | expect(lines.length).toBeGreaterThan(1); | |
| 50 | }); | |
| 51 | ||
| 52 | test("a second seed changes nothing again", async () => { | |
| 53 | const count = () => listEvents(app.db, { kind: "repo.settings_updated", limit: 1000 }).length; | |
| 54 | const before = count(); | |
| 55 | const again = await seedPreview(app, { FORGE_APP_ENV: "preview" }); | |
| 56 | expect(again.ok).toBe(true); | |
| 57 | expect(count()).toBe(before); | |
| 58 | }); |
test/settings-last-change.test.ts +2 −2
| @@ -57,7 +57,7 @@ test("a changed setting shows who and when; an untouched one shows nothing", asy | ||
| 57 | 57 | }); |
| 58 | 58 | expect(res.status).toBeLessThan(400); |
| 59 | 59 | const after = await get(); |
| 60 | expect(row(after, "landing")).toMatch(/changed by olive, <time datetime="[^"]+">just now<\/time>/); | |
| 60 | expect(row(after, "landing")).toMatch(/by olive, <time datetime="[^"]+">just now<\/time>/); | |
| 61 | 61 | expect(row(after, "polishShare")).not.toContain("data-changed"); |
| 62 | 62 | expect(row(after, "requireReview")).not.toContain("data-changed"); |
| 63 | 63 | }); |
| @@ -65,7 +65,7 @@ test("a changed setting shows who and when; an untouched one shows nothing", asy | ||
| 65 | 65 | test("the phrase reads from the instant, and is empty without a change", () => { |
| 66 | 66 | const now = Date.parse("2026-01-01T12:00:00Z"); |
| 67 | 67 | const out = String(changedNote({ by: "ana", at: "2026-01-01T10:00:00Z" }, now)); |
| 68 | expect(out).toContain("changed by ana, "); | |
| 68 | expect(out).toContain("by ana, "); | |
| 69 | 69 | expect(out).toContain(agoWords("2026-01-01T10:00:00Z", now)); |
| 70 | 70 | expect(out).toContain("2 hours ago"); |
| 71 | 71 | expect(changedNote(undefined)).toBeNull(); |
new above
offline
Principle 1: nothing explains itself twice. Cut this bullet to what is kept and where. It also changes the rule box 1 refers to, which should be met as written.