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

Merged opened this

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

Merged

scout/forge:scout/13193-settings-has-looks-of-a-changed-and-an-u → main 6 commits fork 3 threads · 3 unresolved

  • Merged. scout/13193-settings-has-looks-of-a-changed-and-an-u was merged into main as 82e562b.

Review

Sign in to review this change.
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
2828 `settingLine()` and `toggleLine()` in `src/web/setting_line.ts`; styled in `src/web/style/components.ts`.
2929
3030 - `.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`).
outdated

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.

34 The seed changes one setting so a changed row shows beside untouched ones.
3335 - `.why` — the `<details>` holding a setting's reason. Its summary is the help mark drawn as a small bordered round
3436 button (28px, 44px on touch), named "Why" for a screen reader and a tooltip; open, the reason takes the full width
3537 under the row.
src/spawn/preview-looks.ts +11
@@ -72,6 +72,16 @@ export const PREVIEW_TEMPLATE_PAGE = `/${PREVIEW_ADMIN}/${PREVIEW_TEMPLATE}`;
7272 export const PREVIEW_MOVE_PAGE = `${PREVIEW_REPO_HOME}/settings`;
7373 export const PREVIEW_MOVE_LOOK = `${PREVIEW_MOVE_PAGE}#move`;
7474
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
7585 /** The Iterations page of the seeded fork family (#9182). */
7686 export const PREVIEW_ITERATIONS_PAGE = `${PREVIEW_REPO_HOME}/iterations`;
7787 /**
@@ -240,6 +250,7 @@ export const PREVIEW_OWNER_LOOKS: readonly OwnerLook[] = [
240250 PREVIEW_MOVED_PAGE,
241251 PREVIEW_TEMPLATE_PAGE,
242252 PREVIEW_MOVE_LOOK,
253 PREVIEW_GATES_LOOK,
243254 PREVIEW_PULL_PAGE,
244255 PREVIEW_PULL_FILES,
245256 PREVIEW_ITERATIONS_PAGE,
src/spawn/preview-seed.ts +35
@@ -46,6 +46,7 @@ import { reviewGate } from "../actions/gate_review.ts";
4646 import { forgeHttp } from "../http/server.ts";
4747 import { transferRepository } from "../actions/transfer.ts";
4848 import { linkIssue } from "../actions/dependencies.ts";
49 import { lastChanges } from "../settings/last_change.ts";
4950 import { createApp as createAppRecord } from "../core/apps.ts";
5051 import { studioApp } from "../web/studio/app.ts";
5152 import { THEMES_AT_REST } from "../web/pages/gate.ts";
@@ -91,6 +92,7 @@ import {
9192 PREVIEW_MOVED,
9293 PREVIEW_MOVED_OWNER,
9394 PREVIEW_MOVED_PAGE,
95 PREVIEW_CHANGED_SETTING,
9496 PREVIEW_MOVE_PAGE,
9597 PREVIEW_EVERYDAY,
9698 PREVIEW_EVERYDAY_ADMIN,
@@ -200,6 +202,35 @@ export async function checkMoveSection(
200202 return ok();
201203 }
202204
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
203234 async function seedMoveSection(app: App, admin: User): Promise<Result<void, string>> {
204235 const http = forgeHttp(app);
205236 const session = createSession(app.db, admin.id);
@@ -424,6 +455,8 @@ export async function seedPreview(
424455 if (!settings.ok) return settings;
425456 const moveSection = await seedMoveSection(app, admin);
426457 if (!moveSection.ok) return moveSection;
458 const changedSetting = await seedChangedSetting(app, admin);
459 if (!changedSetting.ok) return changedSetting;
427460 const disks = await seedDisks(app, admin);
428461 if (!disks.ok) return disks;
429462 const files = await seedConfigFiles(app, admin);
@@ -448,6 +481,8 @@ export async function seedPreview(
448481 if (!settings.ok) return settings;
449482 const moveSection = await seedMoveSection(app, admin);
450483 if (!moveSection.ok) return moveSection;
484 const changedSetting = await seedChangedSetting(app, admin);
485 if (!changedSetting.ok) return changedSetting;
451486 const disks = await seedDisks(app, admin);
452487 if (!disks.ok) return disks;
453488 const files = await seedConfigFiles(app, admin);
src/web/pages/settings.ts +1 −1
@@ -281,7 +281,7 @@ export async function settingsPage(
281281
282282 // The lead's About card owns the description and visibility; this form
283283 // 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.

285285 <h2>Branch and gates</h2>
286286 <form method="post" action="${base}/settings">
287287 <input type="hidden" name="card" value="gates" />
src/web/setting_line.ts +2 −2
@@ -16,12 +16,12 @@ export interface ChangedBy {
1616 }
1717
1818 /**
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".
2020 * Nothing for one never changed.
2121 */
2222 export function changedNote(last: ChangedBy | undefined, now: number = Date.now()): Html | null {
2323 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>`;
2525 }
2626
2727 /** 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 {
144144 .setting-line > details.why { margin: 0; }
145145 .setting-line > details.why[open] { flex-basis: 100%; }
146146 .setting-line > .setting-changed { margin-left: auto; }
147 @media (max-width: 600px) { .setting-line > .setting-changed { flex-basis: 100%; margin-left: 0; } }
148147 .why > summary {
149148 list-style: none; cursor: pointer; display: inline-grid; place-items: center;
150149 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
5757 });
5858 expect(res.status).toBeLessThan(400);
5959 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>/);
6161 expect(row(after, "polishShare")).not.toContain("data-changed");
6262 expect(row(after, "requireReview")).not.toContain("data-changed");
6363 });
@@ -65,7 +65,7 @@ test("a changed setting shows who and when; an untouched one shows nothing", asy
6565 test("the phrase reads from the instant, and is empty without a change", () => {
6666 const now = Date.parse("2026-01-01T12:00:00Z");
6767 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, ");
6969 expect(out).toContain(agoWords("2026-01-01T10:00:00Z", now));
7070 expect(out).toContain("2 hours ago");
7171 expect(changedNote(undefined)).toBeNull();

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs