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

Every empty state on the signed-in home says the one next thing in a sentence, and a test finds none that is blank #12345

Merged opened this

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

Merged

mason/forge:mason/12328-every-empty-state-on-the-signed-in-home → main 12 commits fork 13 threads · 13 unresolved

  • Merged. mason/12328-every-empty-state-on-the-signed-in-home was merged into main as d6d8932.

Review

Sign in to review this change.
9 files changed +290 −4
docs/design/areas/home.md +3
@@ -8,3 +8,6 @@ The signed-in home's door line (Notes, Talk) is `.home-doors`: accent underlined
88
99 `/explore` (#9645) speaks the same language: the kinds (All, Apps, People, Forges) are `tabs()` as on home; sort and time stay one `seg` each in a small line (they stay boxed: they are two-to-three-way switches whose current choice must read at a glance, and a plain link row would blur it from the tabs above), with "Show archived" a link (`aria-pressed`) wearing `.home-doors`' 44px hit area, no box; the rows are a `.card.bare` list, rows and space on the page's one background, no box. Row words, ranking, "Make it yours" and the URL line are unchanged, so the terminal's explore search keeps the same words. No new class.
1010
11 ## Quiet feed (#12328)
12
13 The feed's quiet line is one `/talk` link wearing `.home-doors`, shown only when nothing is stuck, no milestone has open work and nothing landed since the last visit; no new class.
docs/features/quiet-feed.md added +7
@@ -0,0 +1,7 @@
1 # The quiet feed names its one next thing (#12328)
2
3 When the signed-in feed has nothing stuck (`flow/stalled.ts`), no milestone with open work in your apps and nothing landed since your last visit, it shows one link where those would be: "Tell the crew what to build next", to `/talk`. If any one of the three has something, the line is not shown. Milestones are only an input: the feed does not draw them.
4
5 The rule is `isQuiet` in `web/studio/home_empty.ts`; the terminal's dashboard reads the same three facts through `quietFor` and shows "Tell the crew what to build next → /talk" by the same rule.
6
7 Try it: sign in to a fresh forge and open `/feed`, or open the terminal's dashboard.
src/tui/screens/dashboard.ts +12
@@ -32,6 +32,7 @@ import { SAY_SOMETHING_WORDS } from "../../actions/tell_words.ts";
3232 import { crewCanRun, crewFirstText } from "../../web/studio/crew_key.ts";
3333 import { agentsLine } from "../../web/studio/client_home.ts";
3434 import { lastVisit } from "../../core/home_visit.ts";
35 import { quietFor, quietText } from "../../web/studio/home_empty.ts";
3536 import { sinceDigest } from "../../web/studio/since.ts";
3637 import { askForSomething } from "./tell.ts";
3738 import { movingLines } from "./moving.ts";
@@ -227,6 +228,11 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
227228 let clientLines: string[] = [];
228229 /** "Since you were here" and its lines: read from the web home's last-visit row, never written here. */
229230 let sinceLines: string[] = [];
231 /**
232 * The feed's quiet line (#12328), by the feed's own rule: nothing stalled, no milestone,
233 * nothing landed.
234 */
235 let quiet = false;
230236 /** The web home's living pipeline (#8015): Now for a site admin, then being built and just shipped. */
231237 let moving: string[] = [];
232238 /** The ids of those apps, so the key that asks for something stays on them. */
@@ -390,6 +396,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
390396 const loadSinceLines = (): void => {
391397 const d = f.user ? sinceDigest(f.app.db, f.user, lastVisit(f.app.db, f.user.id), Date.now()) : undefined;
outdated

Both doors must agree. The web's quiet check includes movingMilestones; this one reads only the digest and the stalled list. A terminal user whose milestone moved this week is told 'Nothing is stuck and nothing is new'. Share one isQuiet function in home_empty.ts and test the dashboard with something moved.

392398 sinceLines = d === undefined ? [] : [d.heading, ...d.lines.map((l) => ` ${l.says}`)];
399 quiet = f.user !== undefined && quietFor({ app: f.app }, f.user, d !== undefined);
393400 ctx.invalidate();
394401 };
395402
@@ -1192,6 +1199,11 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
11921199 );
11931200 body = rest!;
11941201 }
1202 if (quiet) {
1203 const [strip, rest] = split(body, "v", [len(1), fill(1)]);
1204 s.text(strip!.x, strip!.y, truncate(quietText(), strip!.w), style(c.mutedFg, c.bg), strip!.x + strip!.w);
1205 body = rest!;
1206 }
11951207 if (moving.length > 0) {
11961208 const [strip, rest] = split(body, "v", [len(moving.length), fill(1)]);
11971209 moving.forEach((line, i) =>
src/web/studio/home.ts +7 −2
@@ -41,7 +41,8 @@ import { START_REFUSALS, startRefusalIn } from "../start_refusal.ts";
4141 import { SITE_PATH, SITE_WHAT } from "../site_line.ts";
4242 import { siteStructuredData } from "../structured_data.ts";
4343 import { running } from "../../kernel/version.ts";
44 import { homeMilestones } from "./milestone_lines.ts";
44 import { biggestMilestones, homeMilestones } from "./milestone_lines.ts";
45 import { isQuiet, quietLine } from "./home_empty.ts";
4546 import { liveClientJs } from "../live.ts";
4647 import {
4748 btn,
@@ -335,6 +336,9 @@ export async function feedPage(ctx: Ctx): Promise<Response> {
335336 );
336337 const since = timePhase(ctx.request, "since", () => sinceYouWere(ctx.app.db, user, before, visitedAt));
337338 const draws = homeDraws(ctx, user);
339 const stalled = flowCards(ctx, user);
340 // Milestones are only an input here: the feed does not draw them (#12328).
341 const quiet = isQuiet({ stalled: stalled !== null, milestones: biggestMilestones(ctx, appRepos).length > 0, landed: since !== null });
outdated

String(since) === "" tests rendered HTML for emptiness, which breaks silently if sinceYouWere ever emits whitespace or a comment. Have it return null, as movingMilestones and flowCards do. Also, the quiet line is placed outside #live-milestones, so a live milestone update leaves 'Nothing is new' on screen beside the new row.

338342 const access = timePhase(ctx.request, "access", () => accessFingerprint(ctx.app.db, user));
339343 const regionOf = (name: HomeRegion): Promise<Html> =>
340344 homeRegion(ctx.app.db, ctx.request, user.id, name, homeVariant(ctx.url), access, draws[name]);
@@ -342,11 +346,12 @@ export async function feedPage(ctx: Ctx): Promise<Response> {
342346 ${await regionOf("waiting")}
343347 ${user.isAdmin ? await regionOf("panels") : null}
344348 ${since}
349 ${quiet ? quietLine() : null}
outdated

Scope: this puts the milestones panel on every signed-in /feed, which the issue did not ask for, and no test covers it. It grows the first view while the direction is pipeline first. Keep milestones as the quiet check's input only, or make it a separate pull.

345350 ${await regionOf("asked")}
346351 <div class="split" data-rail="wide">
347352 <div class="stack">
348353 ${composer(ctx, user)}
349 ${flowCards(ctx, user)}
354 ${stalled}
350355 ${feedNote()}
351356 ${await regionOf("feed")}
352357 </div>
src/web/studio/home_empty.ts added +54
@@ -0,0 +1,54 @@
1 /**
2 * The signed-in feed's quiet line (#12328): when nothing is stuck, no
3 * milestone has open work and nothing landed since the last visit, the feed
4 * names the one next action, once, instead of three blank panels. `isQuiet`
5 * is the one rule, and `quietFor` reads its facts the same way for the
6 * terminal's dashboard, so both doors call the same thing quiet.
7 */
8
9 import type { User } from "../../core/users.ts";
10 import type { Ctx } from "../../http/context.ts";
11 import { readStalled } from "../../flow/stalled.ts";
12 import { html, type Html } from "../html.ts";
13 import { writableAppsOf } from "./asks.ts";
14 import { biggestMilestones } from "./milestone_lines.ts";
15
outdated

Principle 1: 'Open an app to park work for later' sends to the /apps list, not to a gate setting; vague next step. Also no terminal counterpart exists for any of these four lines.

16 /** The line's words and where it goes (never the feed itself). */
outdated

Principle 1/8: href "/" links the home to itself; this is not a next action. Point to a real destination (e.g. the place the crew is told, /talk, or the app's flow page).

17 export const QUIET = {
18 label: "Tell the crew what to build next",
outdated

Same: "/" is the page the reader is on. Link somewhere that does the thing the label says.

19 href: "/talk",
20 } as const;
21
22 /**
outdated

Principles 1 and 8: with .panel-empty set to display:flex the sentence and the link become two flex items, and the space between them is dropped. It reads 'new.Tell the crew'. Wrap the whole line in one inline span inside the flex box, or use display:block with padding. The link's hit area is also about 20px; DESIGN.md gives home links the .home-doors 44px area, so reuse that. Also: 'nothing is new' says nothing the page does not already show; one sentence naming the next action is enough.

23 * What the feed would otherwise show: a stalled step, a milestone with open work, something
24 * landed.
25 */
26 export interface QuietFacts {
27 readonly stalled: boolean;
28 readonly milestones: boolean;
29 readonly landed: boolean;
30 }
31
32 /** Quiet is none of the three. */
33 export const isQuiet = (f: QuietFacts): boolean => !f.stalled && !f.milestones && !f.landed;
34
35 /**
36 * The facts read for `user`, `landed` being whether the caller's since-you-were-here digest
37 * has lines.
38 */
39 export function quietFor(ctx: Pick<Ctx, "app">, user: User, landed: boolean, now = new Date()): boolean {
40 if (landed) return false;
41 return isQuiet({
42 stalled: readStalled(ctx.app.db, user, now).length > 0,
43 milestones: biggestMilestones(ctx, writableAppsOf(ctx, user).repos).length > 0,
44 landed,
45 });
46 }
47
48 /** The terminal's line: the words, then the path to say it at. */
49 export const quietText = (): string => `${QUIET.label} → ${QUIET.href}`;
50
51 /** The one line: a single link with the home doors' 44px hit area. */
52 export function quietLine(): Html {
53 return html`<p class="home-doors" data-empty="quiet"><a href="${QUIET.href}">${QUIET.label}</a></p>`;
54 }
src/web/studio/since.ts +2 −2
@@ -110,9 +110,9 @@ export function feedDigest(db: Database, viewer: User, now: number): { heading:
110110 return sinceDigest(db, viewer, visitOf(db, viewer.id), now) ?? null;
111111 }
112112
113 export function sinceYouWere(db: Database, viewer: User | undefined, lastVisit: number | undefined, now: number): Html {
113 export function sinceYouWere(db: Database, viewer: User | undefined, lastVisit: number | undefined, now: number): Html | null {
114114 const d = sinceDigest(db, viewer, lastVisit, now);
115 if (d === undefined) return html``;
115 if (d === undefined) return null;
116116 return listCard(
outdated

Principle 3/6: a bare section with a differing aria-label and no heading; the empty line is an extra block on every first paint. Consider one combined empty line rather than four.

117117 d.lines.map((l) => row({ title: html`${l.says}`, href: l.href, nav: true })),
118118 { id: "since-you-were-here", head: html`<h2>${d.heading}</h2>` },
test/helpers/quiet-feed.ts added +72
@@ -0,0 +1,72 @@
1 /** #12328: a fresh forge with one person, and the three things that make the feed not quiet. */
2 import { mkdtemp, rm } from "node:fs/promises";
3 import { tmpdir } from "node:os";
4 import { join } from "node:path";
5 import { linkIssue } from "../../src/actions/dependencies.ts";
6 import { openIssue } from "../../src/actions/issues.ts";
7 import { openPull } from "../../src/actions/pulls.ts";
8 import { commitToBranch, createRepo } from "../../src/actions/repos.ts";
9 import { createApp, type App } from "../../src/app.ts";
10 import { createApp as createAppRecord } from "../../src/core/apps.ts";
11 import { getIssueById } from "../../src/core/issues.ts";
12 import { getRepoById, type Repo } from "../../src/core/repos.ts";
13 import { createUser, type User } from "../../src/core/users.ts";
14
15 const must = <T>(r: { ok: true; value: T } | { ok: false; error: unknown }): T => {
16 if (!r.ok) throw new Error(JSON.stringify(r.error));
17 return r.value;
18 };
19
20 export interface Fresh {
21 readonly app: App;
22 readonly user: User;
23 readonly repo: Repo;
24 close(): Promise<void>;
25 }
26
27 /** A forge with one admin and one app repository that has a first commit and nothing else. */
28 export async function freshForge(prefix: string): Promise<Fresh> {
29 const dir = await mkdtemp(join(tmpdir(), `forge-${prefix}-`));
30 const app = createApp({ dataDir: dir, port: 0 });
31 const user = must(
32 await createUser(app.db, { origin: "seed", trusted: true, username: "ann", allowReserved: true, email: "[email protected]", password: "a-good-passphrase", adminIfFirst: true }),
33 );
34 const repo = must(await createRepo(app, user, { name: "shop", visibility: "private" }));
35 must(await commitToBranch(app, user, repo, { message: "init", files: [{ path: "README.md", content: "hi\n" }] }));
36 must(createAppRecord(app.db, { repoId: repo.id, slug: "shop", access: "private" }));
37 return {
38 app,
39 user,
40 repo,
41 close: async () => {
42 app.close();
43 await rm(dir, { recursive: true, force: true });
44 },
45 };
46 }
47
48 async function pullFrom(f: Fresh, branch: string) {
49 const repo = getRepoById(f.app.db, f.repo.id)!;
50 must(await commitToBranch(f.app, f.user, repo, { branch, base: "main", message: branch, files: [{ path: `${branch}.md`, content: "x\n" }] }));
51 return must(await openPull(f.app, f.user, getRepoById(f.app.db, f.repo.id)!, { title: `Change ${branch}`, body: "", baseBranch: "main", headBranch: branch }));
52 }
53
54 /** An open pull five hours old whose check was never asked for: a stalled step. */
55 export async function seedStalled(f: Fresh): Promise<void> {
56 const p = await pullFrom(f, "stalled");
57 f.app.db.query("UPDATE issue SET created_at = ?2 WHERE id = ?1").run(p.id, new Date(Date.now() - 5 * 3_600_000).toISOString());
58 }
59
60 /** A milestone with open work beneath it. */
61 export function seedMilestone(f: Fresh): void {
62 const repo = () => getRepoById(f.app.db, f.repo.id)!;
63 const goal = must(openIssue(f.app, f.user, repo(), { title: "Ship the shop" }));
64 const part = must(openIssue(f.app, f.user, repo(), { title: "Part A" }));
65 must(linkIssue(f.app, f.user, repo(), getIssueById(f.app.db, goal.id)!, getIssueById(f.app.db, part.id)!));
66 }
67
68 /** A pull merged a minute ago. */
69 export async function seedLanded(f: Fresh): Promise<void> {
70 const p = await pullFrom(f, "landed");
71 f.app.db.query("UPDATE pull SET merged_at = ? WHERE issue_id = ?").run(new Date(Date.now() - 60_000).toISOString(), p.id);
72 }
test/home-empty-states.test.ts added +81
@@ -0,0 +1,81 @@
1 /**
2 * #12328: a quiet signed-in feed names one next action, once, as a link off
3 * the feed; a stalled step, a milestone with open work or a landed pull each
4 * take the line away, and the terminal's rule is the feed's.
5 */
6 import { afterAll, beforeAll, describe, expect, test } from "bun:test";
7 import { createSession } from "../src/core/sessions.ts";
8 import { serve, type Servers } from "../src/http/server.ts";
9 import { isQuiet, QUIET, quietFor, quietText } from "../src/web/studio/home_empty.ts";
10 import { freshForge, seedLanded, seedMilestone, seedStalled, type Fresh } from "./helpers/quiet-feed.ts";
11
12 const QUIET_LINE = /<p[^>]*data-empty="quiet"[^>]*>([\s\S]*?)<\/p>/g;
13
14 async function feedOf(f: Fresh): Promise<string> {
15 const servers: Servers = await serve(f.app);
16 try {
17 const cookie = `forge_session=${createSession(f.app.db, f.user.id).token}`;
18 return await (await fetch(`${servers.url}/feed`, { headers: { cookie } })).text();
19 } finally {
20 await servers.stop?.();
21 }
22 }
23
24 describe("a fresh forge's feed", () => {
25 let f: Fresh;
26 let body = "";
27 beforeAll(async () => {
28 f = await freshForge("empty");
29 body = await feedOf(f);
30 });
31 afterAll(() => f.close());
32
33 test("carries one quiet line, whose one link goes to /talk, not the feed", () => {
34 const lines = [...body.matchAll(QUIET_LINE)];
35 expect(lines.length).toBe(1);
36 const inner = lines[0]![1]!;
37 expect(inner.replace(/<[^>]*>/g, "").trim()).toBe(QUIET.label);
38 const hrefs = [...inner.matchAll(/href="([^"]*)"/g)].map((m) => m[1]);
39 expect(hrefs).toEqual(["/talk"]);
40 });
41
42 test("the line wears the home doors' 44px hit area and is one link, so no space can be dropped", () => {
43 expect(body).toMatch(/<p class="home-doors" data-empty="quiet"><a href="\/talk">/);
44 });
45
46 test("draws no milestones panel: milestones are only the quiet rule's input", () => {
47 expect(body).not.toContain('id="live-milestones"');
48 });
49
50 test("the terminal's rule agrees", () => {
51 expect(quietFor({ app: f.app }, f.user, false)).toBe(true);
52 expect(quietText()).toBe(`${QUIET.label} → /talk`);
53 });
outdated

This test claims to cover 'something is stuck or new' but only repeats the fresh-forge case, after setting home_visit to 0 (which changes nothing). Seed a stalled card, a moved milestone and a landed pull one at a time and assert the line is absent for each. Without that, deleting the 'never beside a filled panel' logic keeps every test green. The test also checks only /feed, so a missing href on the held panel (dropped) goes unnoticed.

54 });
outdated

Tautological: asserts the constants are non-empty and start with '/'. Replace with a check that each rendered href differs from the page it appears on.

55
56 describe("the line is absent when the feed has something", () => {
57 for (const [what, seed, shows] of [
58 ["a stalled step", seedStalled, "data-flow-card="],
59 ["a milestone with open work", seedMilestone, null],
60 ["a pull landed since the last visit", seedLanded, 'id="since-you-were-here"'],
61 ] as const) {
62 test(what, async () => {
63 const f = await freshForge("busy");
64 try {
65 await seed(f);
66 const body = await feedOf(f);
67 if (shows !== null) expect(body).toContain(shows);
68 expect(body).not.toContain('data-empty="quiet"');
69 if (seed !== seedLanded) expect(quietFor({ app: f.app }, f.user, false)).toBe(false);
70 } finally {
71 await f.close();
72 }
73 });
74 }
75
76 test("isQuiet is none of the three", () => {
77 expect(isQuiet({ stalled: false, milestones: false, landed: false })).toBe(true);
78 for (const k of ["stalled", "milestones", "landed"] as const)
79 expect(isQuiet({ stalled: false, milestones: false, landed: false, [k]: true })).toBe(false);
80 });
81 });
test/tui-quiet-line.test.ts added +52
@@ -0,0 +1,52 @@
1 /**
2 * #12328: the terminal's dashboard says the quiet feed's line by the feed's rule, with a path
3 * off the dashboard.
4 */
5 import { expect, test } from "bun:test";
6 import { createForgeApp } from "../src/tui/forge.ts";
7 import { headlessTerminal } from "../src/tui/term/terminal.ts";
8 import { QUIET, quietText } from "../src/web/studio/home_empty.ts";
9 import { quietLogs } from "./helpers/globals.ts";
10 import { freshForge, seedMilestone, seedStalled, type Fresh } from "./helpers/quiet-feed.ts";
11 import { settleApp } from "./helpers/tui.ts";
12
13 quietLogs();
14
15 async function dashboardOf(f: Fresh): Promise<string> {
16 const { app } = createForgeApp(
17 f.app,
18 { sshUsername: f.user.username, remoteAddress: "127.0.0.1", fingerprint: "SHA256:t", user: f.user },
19 { terminal: headlessTerminal(200, 32), exitHooks: false },
20 );
21 app.start();
22 try {
23 await settleApp(app);
24 return app.screen.toText();
25 } finally {
26 app.stop();
27 }
28 }
29
30 test("a fresh forge's dashboard says what to do next, at a path that is not the dashboard", async () => {
31 const f = await freshForge("tui-quiet");
32 try {
33 expect(await dashboardOf(f)).toContain(quietText());
34 expect(QUIET.href).toBe("/talk");
35 } finally {
36 await f.close();
37 }
38 });
39
40 for (const [what, seed] of [
41 ["a milestone with open work", seedMilestone],
42 ["a stalled step", seedStalled],
43 ] as const)
44 test(`${what} takes the line away, as on the feed`, async () => {
45 const f = await freshForge("tui-busy");
46 try {
47 await seed(f);
48 expect(await dashboardOf(f)).not.toContain(QUIET.label);
49 } finally {
50 await f.close();
51 }
52 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs