Public: anyone can read this; the crew can change it.
The home's duplicate "What you asked for" link leaves, and the Asked tab shows how many asks are still in flight #6315
scout/forge:scout/5822-the-home-s-duplicate-what-you-asked-for → main 5 commits fork
7 files
changed +48
−18
docs/design/areas/feed.md +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Feed |
| 2 | 2 | |
| 3 | - `.feed-head` — the head of the home's feed: a §5 `.bar` above the timeline holding the "What you asked for" link, pushed to the end by a spacer. Drawn by `studioHome` in `src/web/studio/home.ts`, styled in `src/web/studio/feed_style.ts`. Under 900px it is hidden, since that link is a tab on a phone and the first post should come next; a bare `.bar` cannot carry this, as it has no reason to vanish on a narrow screen. | |
| 3 | The home has no head above the timeline: the Feed / Your apps / Asked tabs are the one way to `/asked`, and the Asked tab carries the count of asks not yet landed (§5's tab count pill). `.feed-head` is gone. | |
| 4 | 4 | - `.look[data-slot="feed"]` — a look post's thumbnail, drawn by `feedCard` in `src/web/studio/feed.ts`: the §5 `.look` frame fixed at 160×100 (the img carries the same width and height, so nothing shifts), cropped from the top like the other thumbs. A bare `.look` is fluid and would resize the post. |
| 5 | 5 | - `.feed` — the home's timeline list: a one-column grid with no gap that holds the feed's cards, each focusable with a visible outline and removed from layout while `hidden`. Drawn by `drawRegion` in `src/web/studio/feed.ts` (the `#live-feed` section), styled in `src/web/studio/feed_style.ts`. |
| 6 | 6 | - Day divider — no new class: a §5 `.muted.small` line with `data-day-divider="<label>"`, drawn by `drawRegion` in `src/web/studio/feed.ts` before the first post of each UTC day (labels from `day_divider.ts`). It marks a change of day between neighbours in the order the feed already has; it never reorders. It is `role="separator"`, and hiding a card (dismiss, mute) moves it to the next card showing that day or hides it (`keepDay`). The "Older posts" link and `data-live-src` carry `day=` so a later page does not repeat the divider. |
src/web/pages/apps.ts +2 −2
| @@ -64,7 +64,7 @@ import { html, when, type Html } from "../html.ts"; | ||
| 64 | 64 | import { flashTo, page, redirect } from "../layout.ts"; |
| 65 | 65 | import { writableAppsOf } from "../studio/asks.ts"; |
| 66 | 66 | import { costLine } from "../studio/cost_line.ts"; |
| 67 | import { homeTabs } from "../studio/home_tabs.ts"; | |
| 67 | import { askedTabCount, homeTabs } from "../studio/home_tabs.ts"; | |
| 68 | 68 | import { shelfRows } from "../studio/shelf.ts"; |
| 69 | 69 | import { |
| 70 | 70 | badge, |
| @@ -214,7 +214,7 @@ export async function appsList(ctx: Ctx): Promise<Response> { | ||
| 214 | 214 | costLine(ctx.app.db, writableAppsOf(ctx, ctx.auth.user).repos), |
| 215 | 215 | ); |
| 216 | 216 | const rendering = performance.now(); |
| 217 | const body = html`${when(ctx.auth.user, () => homeTabs("apps"))} | |
| 217 | const body = html`${when(ctx.auth.user, () => homeTabs("apps", askedTabCount(ctx)))} | |
| 218 | 218 | ${pageHead("Apps", { actions: create })} |
| 219 | 219 | ${cost} |
| 220 | 220 | ${filters} |
src/web/studio/asked_page.ts +2 −2
| @@ -41,7 +41,7 @@ import { | ||
| 41 | 41 | timeAgo, |
| 42 | 42 | type Tone, |
| 43 | 43 | } from "../ui.ts"; |
| 44 | import { homeTabs } from "./home_tabs.ts"; | |
| 44 | import { askedTabCount, homeTabs } from "./home_tabs.ts"; | |
| 45 | 45 | |
| 46 | 46 | const WORD: Record<AskedState, { text: string; tone: Tone }> = { |
| 47 | 47 | waiting: { text: "Waiting", tone: "default" }, |
| @@ -204,7 +204,7 @@ export function askedPage(ctx: Ctx): Response { | ||
| 204 | 204 | ? "Nothing asked yet" |
| 205 | 205 | : `${asked} asked · ${shipped} shipped${flagged > 0 ? ` · ${flagged} with nothing built` : ""}`; |
| 206 | 206 | |
| 207 | const body = html`${homeTabs("asked")} | |
| 207 | const body = html`${homeTabs("asked", repoSpec ? askedTabCount(ctx) : counts.unshipped)} | |
| 208 | 208 | <h1 id="asked-sentence">What you asked for</h1> |
| 209 | 209 | <p class="muted">${sentence}</p> |
| 210 | 210 | ${thoughts} |
src/web/studio/feed_style.ts −3
| @@ -10,9 +10,6 @@ export const feedCss = /* css */ ` | ||
| 10 | 10 | /* An admin's tick boxes are always shown (no Select toggle); 24 px to tap. */ |
| 11 | 11 | #live-apps input[type="checkbox"] { width: 24px; height: 24px; } |
| 12 | 12 | @media (max-width: 899px) { |
| 13 | /* "What you asked for" is a tab on a phone: the first post comes next. | |
| 14 | !important, as [hidden] is: .bar sits in a later cascade layer. */ | |
| 15 | .feed-head { display: none !important; } | |
| 16 | 13 | #live-apps { display: none; } |
| 17 | 14 | } |
| 18 | 15 | @media (max-width: 600px) { |
src/web/studio/home.ts +2 −6
| @@ -61,7 +61,7 @@ import { archivedAppCount } from "../pages/apps.ts"; | ||
| 61 | 61 | import { pinnedPanels } from "./pinned.ts"; |
| 62 | 62 | import { isNavigation, lastVisit, noteVisit } from "../../core/home_visit.ts"; |
| 63 | 63 | import { sinceYouWere } from "./since.ts"; |
| 64 | import { homeTabs } from "./home_tabs.ts"; | |
| 64 | import { askedTabCount, homeTabs } from "./home_tabs.ts"; | |
| 65 | 65 | import { crewKeyNote } from "./crew.ts"; |
| 66 | 66 | import { everydayCard } from "../pages/everyday.ts"; |
| 67 | 67 | import { nextStepsCard, nextStepsOf } from "../pages/next-steps.ts"; |
| @@ -301,14 +301,10 @@ export async function studioHome( | ||
| 301 | 301 | </p>`, |
| 302 | 302 | )} |
| 303 | 303 | ${since} |
| 304 | ${homeTabs("feed")} | |
| 304 | ${homeTabs("feed", askedTabCount(ctx))} | |
| 305 | 305 | <div class="split" data-rail="wide"> |
| 306 | 306 | <div class="stack"> |
| 307 | 307 | ${composer(ctx, user)} |
| 308 | <div class="bar feed-head"> | |
| 309 | <span class="spacer"></span> | |
| 310 | <a class="small muted" href="/asked">What you asked for</a> | |
| 311 | </div> | |
| 312 | 308 | ${flowCards(ctx, user)} |
| 313 | 309 | ${feedNote()} |
| 314 | 310 | ${timePhase(ctx.request, "feed", () => feedRegion(user, ctx), () => feedCandidateCache(ctx.app.db))} |
src/web/studio/home_tabs.ts +20 −4
| @@ -6,19 +6,35 @@ | ||
| 6 | 6 | |
| 7 | 7 | import { html, type Html } from "../html.ts"; |
| 8 | 8 | import { tabs } from "../ui.ts"; |
| 9 | import { askedCounts, askedRepos } from "../../core/asked.ts"; | |
| 10 | import { timePhase } from "../../core/route_timing.ts"; | |
| 11 | import type { Ctx } from "../../http/context.ts"; | |
| 9 | 12 | |
| 10 | 13 | export type HomeTab = "feed" | "apps" | "asked"; |
| 11 | 14 | |
| 12 | /** §5's `tabs()` in a `.mb` block: link tabs, so `aria-current`. */ | |
| 13 | export function homeTabs(current: HomeTab): Html { | |
| 14 | const item = (id: HomeTab, href: string, label: string) => ({ | |
| 15 | /** | |
| 16 | * How many asks have not landed yet — `/asked`'s default list, from the same | |
| 17 | * `askedCounts`; a named Server-Timing phase, `asked`. | |
| 18 | */ | |
| 19 | export function askedTabCount(ctx: Ctx): number { | |
| 20 | const user = ctx.auth.user; | |
| 21 | if (!user) return 0; | |
| 22 | return timePhase(ctx.request, "asked", () => | |
| 23 | askedCounts(ctx.app.db, askedRepos(ctx.app.db, user, null)).unshipped, | |
| 24 | ); | |
| 25 | } | |
| 26 | ||
| 27 | /** §5's `tabs()` in a `.mb` block: link tabs, so `aria-current`. `asked` is the count on the Asked tab; zero shows plain. */ | |
| 28 | export function homeTabs(current: HomeTab, asked = 0): Html { | |
| 29 | const item = (id: HomeTab, href: string, label: string, count?: number) => ({ | |
| 15 | 30 | label, |
| 16 | 31 | href, |
| 17 | 32 | current: current === id, |
| 33 | ...(count === undefined ? {} : { count }), | |
| 18 | 34 | }); |
| 19 | 35 | return html`<div class="mb"> |
| 20 | 36 | ${tabs( |
| 21 | [item("feed", "/", "Feed"), item("apps", "/apps", "Your apps"), item("asked", "/asked", "Asked")], | |
| 37 | [item("feed", "/", "Feed"), item("apps", "/apps", "Your apps"), item("asked", "/asked", "Asked", asked)], | |
| 22 | 38 | "Home", |
| 23 | 39 | )} |
| 24 | 40 | </div>`; |
test/home-feed.test.ts +21
| @@ -14,6 +14,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 14 | 14 | import { addComment, assignIssue, openIssue } from "../src/actions/issues.ts"; |
| 15 | 15 | import { createRepo } from "../src/actions/repos.ts"; |
| 16 | 16 | import { createApp as insertApp } from "../src/core/apps.ts"; |
| 17 | import { askedCounts, askedRepos } from "../src/core/asked.ts"; | |
| 17 | 18 | import { listIssues } from "../src/core/issues.ts"; |
| 18 | 19 | import type { Repo } from "../src/core/repos.ts"; |
| 19 | 20 | import { createSession } from "../src/core/sessions.ts"; |
| @@ -187,6 +188,26 @@ describe("home is the feed", () => { | ||
| 187 | 188 | } |
| 188 | 189 | }); |
| 189 | 190 | |
| 191 | test("the home has no second door to /asked, and the Asked tab counts asks not yet landed", async () => { | |
| 192 | const home = await get("/", aliceCookie); | |
| 193 | const text = await home.text(); | |
| 194 | expect(text).not.toContain("feed-head"); | |
| 195 | expect(text).not.toMatch(/<a[^>]*href="\/asked"[^>]*>\s*What you asked for/); | |
| 196 | const n = askedCounts(app.db, askedRepos(app.db, alice, null)).unshipped; | |
| 197 | expect(n).toBeGreaterThan(0); | |
| 198 | const tab = text.match(/<a\s+href="\/asked"[^>]*>([\s\S]*?)<\/a\s*>/); | |
| 199 | expect(tab?.[1]?.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim()).toBe(`Asked ${n}`); | |
| 200 | expect(home.headers.get("server-timing") ?? "").toContain("asked"); | |
| 201 | // /asked shows the same number it counts. | |
| 202 | const asked = await (await get("/asked", aliceCookie)).text(); | |
| 203 | expect(asked).toContain(`Asked`); | |
| 204 | expect(asked).toMatch(new RegExp(`href="/asked"[^>]*>[\\s\\S]*?${n}`)); | |
| 205 | // Nothing asked: plain Asked. | |
| 206 | const none = await (await get("/", bobCookie)).text(); | |
| 207 | const plain = none.match(/<a\s+href="\/asked"[^>]*>([\s\S]*?)<\/a\s*>/); | |
| 208 | expect(plain?.[1]?.replace(/<[^>]+>/g, "").trim()).toBe("Asked"); | |
| 209 | }); | |
| 210 | ||
| 190 | 211 | test("a reader's timeline has the public repository's posts and nothing private or configured", async () => { |
| 191 | 212 | const text = await (await get("/", bobCookie)).text(); |
| 192 | 213 | expect(text).toContain("Water the tomatoes at dawn"); |
new above
offline