Public: anyone can read this; the crew can change it.
A new forge's empty feed says what will appear here and offers the one tell box #14728
Check · Review · Land · Live — Its check is queued.
scout/forge:scout/14725-a-new-forge-s-empty-feed-says-what-will → main 4 commits fork
This pull asks to reach lab--forge-trevato-apps.open-platform.sh. Its preview and check reach what main reaches; the new host opens when the pull lands.
6 files
changed +23
−11
docs/design/areas/feed.md +4
| @@ -7,3 +7,7 @@ | ||
| 7 | 7 | - `.like` — the Like form under a post, drawn by `likeBar` in `src/web/studio/feed.ts`: an inline form around one §5 ghost `.btn` (`aria-pressed` is the only state signal; the label is always "Like"). Its count `[data-likes]` is `inline-block` at `min-width: 3ch`, right-aligned with tabular numerals, so going from 9 to 10 or pressing moves nothing. Styled in `src/web/studio/feed_style.ts`. |
| 8 | 8 | - `.new-posts` — the "N new posts" button's slot above the home timeline, drawn by `feedNote` in `src/web/studio/feed.ts`: a `role="status"` `aria-live="polite"` paragraph, sticky under the topbar, zero-high while its button is `hidden`, so nothing shifts when it appears. The button is a §5 primary small `.btn` at 44 px; its text is its accessible name and carries the count. Pressing it swaps the held feed, scrolls to the top instantly and moves focus to `#live-feed`. Styled in `src/web/studio/feed_style.ts`. |
| 9 | 9 | - `.feed-newer` — the "N newer posts" line in the feed head, drawn by `newerLine` in `src/web/studio/feed.ts`: a `role="status"` paragraph at a fixed 24 px that always exists, holding a plain `#live-feed` link that is `hidden` when nothing is newer, so showing it shifts nothing. Styled in `src/web/studio/feed_style.ts`. |
| 10 | ||
| 11 | ## Empty feed | |
| 12 | ||
| 13 | `.feed-empty` wraps the one empty block of a feed with no posts. It holds the height of a first post so the post arriving moves nothing below it. |
src/web/studio/feed.ts +4 −4
| @@ -277,7 +277,7 @@ export function replyUnder(placement: Placement): Html { | ||
| 277 | 277 | * /api/v1/feed/tells`, so it survives a dropped connection. Nothing to say |
| 278 | 278 | * it to, and it is the way to make an app instead. |
| 279 | 279 | */ |
| 280 | export function composer(ctx: Ctx, user: User): Html { | |
| 280 | export function composer(ctx: Ctx, user: User, focus = false): Html { | |
| 281 | 281 | const { repos } = writableAppsOf(ctx, user); |
| 282 | 282 | const slug = (r: { ownerName: string; name: string }) => `${r.ownerName}/${r.name}`; |
| 283 | 283 | const noApps = html`${empty({ |
| @@ -294,7 +294,7 @@ export function composer(ctx: Ctx, user: User): Html { | ||
| 294 | 294 | const form = html`<form id="composer" class="stack" method="post" action="/tell"> |
| 295 | 295 | <input type="hidden" name="${COMPOSER_FIELDS.back}" value="/feed" /> |
| 296 | 296 | ${shared === "" ? "" : html`<input type="hidden" name="${COMPOSER_FIELDS.once}" value="${shareToken(user.id, shared)}" />`} |
| 297 | <textarea class="input" name="${COMPOSER_FIELDS.text}" rows="2" maxlength="${String(TELL_MAX)}" required placeholder="Tell the crew what should change" aria-label="Tell the crew" aria-keyshortcuts="Control+Enter Meta+Enter" data-draft="${user.id}">${shared}</textarea> | |
| 297 | <textarea class="input" name="${COMPOSER_FIELDS.text}" rows="2" maxlength="${String(TELL_MAX)}" required${focus ? " autofocus" : ""} placeholder="Tell the crew what should change" aria-label="Tell the crew" aria-keyshortcuts="Control+Enter Meta+Enter" data-draft="${user.id}">${shared}</textarea> | |
| 298 | 298 | <span class="muted small">${TELL_LIMIT_WORDS}</span> |
| 299 | 299 | <div class="bar"> |
| 300 | 300 | ${repos.length === 0 |
| @@ -485,7 +485,7 @@ function readRegion(user: User, ctx: Ctx) { | ||
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** The one line an empty timeline says; the tell box above it is the action. */ |
| 488 | export const EMPTY_FEED = "Tell the crew; its work will show here."; | |
| 488 | export const EMPTY_FEED = "Tell the crew what you want in the box above. What they make and finish will appear here, one post at a time."; | |
| 489 | 489 | |
| 490 | 490 | /** The region: cards, or one line saying there is nothing to do. */ |
| 491 | 491 | export function feedRegion(user: User, ctx: Ctx): Html { |
| @@ -559,7 +559,7 @@ function drawRegion(user: User, ctx: Ctx, read: ReturnType<typeof readRegion>): | ||
| 559 | 559 | ${chipsBar(user, ctx, items)} |
| 560 | 560 | ${thoughts.map((t) => thoughtCard(t, user.username, placed.get(t.id)))} |
| 561 | 561 | ${items.length === 0 && thoughts.length === 0 |
| 562 | ? empty({ title: EMPTY_FEED }) | |
| 562 | ? html`<div class="feed-empty" data-feed-empty>${empty({ title: EMPTY_FEED })}</div>` | |
| 563 | 563 | : posts} |
| 564 | 564 | ${quiet === 0 |
| 565 | 565 | ? "" |
src/web/studio/home.ts +1 −1
| @@ -398,7 +398,7 @@ export async function feedPage(ctx: Ctx): Promise<Response> { | ||
| 398 | 398 | ${await regionOf("asked")} |
| 399 | 399 | <div class="split" data-rail="wide"> |
| 400 | 400 | <div class="stack"> |
| 401 | ${composer(ctx, user)} | |
| 401 | ${composer(ctx, user, feedRegion.text.includes("data-feed-empty"))} | |
| 402 | 402 | ${stalled} |
| 403 | 403 | ${feedNote(newer)} |
| 404 | 404 | ${feedRegion} |
src/web/style/components.ts +3
| @@ -1085,6 +1085,9 @@ html[data-overlay] { overflow: hidden; } | ||
| 1085 | 1085 | } |
| 1086 | 1086 | .empty p { font-size: 13px; max-width: 320px; text-wrap: pretty; margin: 0; } |
| 1087 | 1087 | .empty .btn { margin-top: 8px; } |
| 1088 | /* The empty feed holds the height of the first post, so it arriving moves nothing below. */ | |
| 1089 | .feed-empty { min-height: 140px; display: flex; flex-direction: column; justify-content: center; } | |
| 1090 | .feed-empty .empty { padding: 24px; } | |
| 1088 | 1091 | |
| 1089 | 1092 | /* ---- board panel grid: a board's panels, on /boards and pinned in the studio ---- */ |
| 1090 | 1093 | /* ---- the boards (pages/boards-view.ts, flow-panel.ts): the home's column, figures and tiles, and under them |
test/feed-empty.test.ts +10 −5
| @@ -11,6 +11,7 @@ import { createSession } from "../src/core/sessions.ts"; | ||
| 11 | 11 | import { openIssue } from "../src/actions/issues.ts"; |
| 12 | 12 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 13 | 13 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 14 | import { EMPTY_FEED } from "../src/web/studio/feed.ts"; | |
| 14 | 15 | import { serve, type Servers } from "../src/http/server.ts"; |
| 15 | 16 | |
| 16 | 17 | let dataDir: string; |
| @@ -39,17 +40,20 @@ test("an empty home says one sentence below the tell box, and the old line is go | ||
| 39 | 40 | const page = await res.text(); |
| 40 | 41 | emptyPage = page; |
| 41 | 42 | expect(res.status).toBe(200); |
| 42 | const sentence = page.indexOf("Tell the crew; its work will show here."); | |
| 43 | const sentence = page.indexOf(EMPTY_FEED); | |
| 43 | 44 | expect(sentence).toBeGreaterThan(-1); |
| 44 | 45 | const form = page.match(/<form id="composer"[\s\S]*?<\/form>/)!; |
| 45 | 46 | expect(form[0]).toContain('action="/tell"'); |
| 46 | 47 | expect(form[0]).not.toContain("Nothing yet"); |
| 47 | 48 | expect(sentence).toBeGreaterThan(page.indexOf(form[0]) + form[0].length); |
| 48 | 49 | expect(page).not.toContain("Nothing new"); |
| 49 | expect(page).not.toContain("autofocus"); | |
| 50 | expect(page).toMatch(/<textarea[^>]*autofocus/); | |
| 51 | expect(page).toContain("feed-empty"); | |
| 52 | expect(EMPTY_FEED).not.toMatch(/\b(run|pull|gate)s?\b/i); | |
| 53 | expect(EMPTY_FEED.split(". ")).toHaveLength(2); | |
| 50 | 54 | }); |
| 51 | 55 | |
| 52 | test("a feed with something in it keeps its cards: no sentence, no autofocus", async () => { | |
| 56 | test("a feed with something in it keeps its cards: no sentence, no autofocus, no empty block", async () => { | |
| 53 | 57 | const user = getUserByName(app.db, "newbie")!; |
| 54 | 58 | const made = await createRepo(app, user, { name: "game" }); |
| 55 | 59 | if (!made.ok) throw new Error(String(made.error)); |
| @@ -58,8 +62,9 @@ test("a feed with something in it keeps its cards: no sentence, no autofocus", a | ||
| 58 | 62 | if (!opened.ok) throw new Error(String(opened.error)); |
| 59 | 63 | const page = await (await fetch(`${servers.url}/feed`, { headers: { cookie } })).text(); |
| 60 | 64 | expect(page).toContain("make the jump higher"); |
| 61 | expect(page).not.toContain("Tell the crew; its work will show here."); | |
| 65 | expect(page).not.toContain(EMPTY_FEED); | |
| 62 | 66 | expect(page).not.toContain("autofocus"); |
| 67 | expect(page).not.toContain("feed-empty"); | |
| 63 | 68 | }); |
| 64 | 69 | |
| 65 | 70 | test("the first post arrives in the region below the tell box: nothing above the box changes", async () => { |
| @@ -70,7 +75,7 @@ test("the first post arrives in the region below the tell box: nothing above the | ||
| 70 | 75 | expect(form).toBeGreaterThan(-1); |
| 71 | 76 | expect(form).toBeLessThan(region); |
| 72 | 77 | const end = page.indexOf("</section>", region); |
| 73 | return { above: page.slice(form, region).replace(/data-rendered="\d+"/g, "").replace(/(<p id="feed-newer"[^>]*>)<a [^>]*>[^<]*<\/a>/, "$1").replace(/<script[\s\S]*?<\/script>/g, ""), inside: page.slice(region, end) }; | |
| 78 | return { above: page.slice(form, region).replace(/data-rendered="\d+"/g, "").replace(" autofocus", "").replace(/(<p id="feed-newer"[^>]*>)<a [^>]*>[^<]*<\/a>/, "$1").replace(/<script[\s\S]*?<\/script>/g, ""), inside: page.slice(region, end) }; | |
| 74 | 79 | }; |
| 75 | 80 | const before = split(emptyPage); |
| 76 | 81 | expect(before.inside).toContain('class="empty"'); |
test/tui-feed-empty.test.ts +1 −1
| @@ -44,7 +44,7 @@ test("an empty feed says the page's line", async () => { | ||
| 44 | 44 | await key("k", true); |
| 45 | 45 | for (const k of [..."Feed", "enter"]) await key(k); |
| 46 | 46 | const text = app.screen.toText(); |
| 47 | expect(text).toContain("Tell the crew; its work will show here."); | |
| 47 | expect(text).toContain("Tell the crew what you want in"); | |
| 48 | 48 | expect(text).not.toContain("Nothing in the feed yet"); |
| 49 | 49 | app.stop(); |
| 50 | 50 | }); |
new above
offline