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 #5832

Parked opened this
Closed without merging

scout/forge:scout/5822-the-home-s-duplicate-what-you-asked-for → main 5 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
7 files changed +48 −18
docs/design/areas/feed.md +1 −1
@@ -1,6 +1,6 @@
11 # Feed
22
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.
44 - `.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.
55 - `.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`.
66 - 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";
6464 import { flashTo, page, redirect } from "../layout.ts";
6565 import { writableAppsOf } from "../studio/asks.ts";
6666 import { costLine } from "../studio/cost_line.ts";
67 import { homeTabs } from "../studio/home_tabs.ts";
67 import { askedTabCount, homeTabs } from "../studio/home_tabs.ts";
6868 import { shelfRows } from "../studio/shelf.ts";
6969 import {
7070 badge,
@@ -214,7 +214,7 @@ export async function appsList(ctx: Ctx): Promise<Response> {
214214 costLine(ctx.app.db, writableAppsOf(ctx, ctx.auth.user).repos),
215215 );
216216 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)))}
218218 ${pageHead("Apps", { actions: create })}
219219 ${cost}
220220 ${filters}
src/web/studio/asked_page.ts +2 −2
@@ -41,7 +41,7 @@ import {
4141 timeAgo,
4242 type Tone,
4343 } from "../ui.ts";
44 import { homeTabs } from "./home_tabs.ts";
44 import { askedTabCount, homeTabs } from "./home_tabs.ts";
4545
4646 const WORD: Record<AskedState, { text: string; tone: Tone }> = {
4747 waiting: { text: "Waiting", tone: "default" },
@@ -204,7 +204,7 @@ export function askedPage(ctx: Ctx): Response {
204204 ? "Nothing asked yet"
205205 : `${asked} asked · ${shipped} shipped${flagged > 0 ? ` · ${flagged} with nothing built` : ""}`;
206206
207 const body = html`${homeTabs("asked")}
207 const body = html`${homeTabs("asked", repoSpec ? askedTabCount(ctx) : counts.unshipped)}
208208 <h1 id="asked-sentence">What you asked for</h1>
209209 <p class="muted">${sentence}</p>
210210 ${thoughts}
src/web/studio/feed_style.ts −3
@@ -10,9 +10,6 @@ export const feedCss = /* css */ `
1010 /* An admin's tick boxes are always shown (no Select toggle); 24 px to tap. */
1111 #live-apps input[type="checkbox"] { width: 24px; height: 24px; }
1212 @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; }
1613 #live-apps { display: none; }
1714 }
1815 @media (max-width: 600px) {
src/web/studio/home.ts +2 −6
@@ -61,7 +61,7 @@ import { archivedAppCount } from "../pages/apps.ts";
6161 import { pinnedPanels } from "./pinned.ts";
6262 import { isNavigation, lastVisit, noteVisit } from "../../core/home_visit.ts";
6363 import { sinceYouWere } from "./since.ts";
64 import { homeTabs } from "./home_tabs.ts";
64 import { askedTabCount, homeTabs } from "./home_tabs.ts";
6565 import { crewKeyNote } from "./crew.ts";
6666 import { everydayCard } from "../pages/everyday.ts";
6767 import { nextStepsCard, nextStepsOf } from "../pages/next-steps.ts";
@@ -301,14 +301,10 @@ export async function studioHome(
301301 </p>`,
302302 )}
303303 ${since}
304 ${homeTabs("feed")}
304 ${homeTabs("feed", askedTabCount(ctx))}
305305 <div class="split" data-rail="wide">
306306 <div class="stack">
307307 ${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>
312308 ${flowCards(ctx, user)}
313309 ${feedNote()}
314310 ${timePhase(ctx.request, "feed", () => feedRegion(user, ctx), () => feedCandidateCache(ctx.app.db))}
src/web/studio/home_tabs.ts +20 −4
@@ -6,19 +6,35 @@
66
77 import { html, type Html } from "../html.ts";
88 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";
912
1013 export type HomeTab = "feed" | "apps" | "asked";
1114
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) => ({
1530 label,
1631 href,
1732 current: current === id,
33 ...(count === undefined ? {} : { count }),
1834 });
1935 return html`<div class="mb">
2036 ${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)],
2238 "Home",
2339 )}
2440 </div>`;
test/home-feed.test.ts +21
@@ -14,6 +14,7 @@ import { createApp, type App } from "../src/app.ts";
1414 import { addComment, assignIssue, openIssue } from "../src/actions/issues.ts";
1515 import { createRepo } from "../src/actions/repos.ts";
1616 import { createApp as insertApp } from "../src/core/apps.ts";
17 import { askedCounts, askedRepos } from "../src/core/asked.ts";
1718 import { listIssues } from "../src/core/issues.ts";
1819 import type { Repo } from "../src/core/repos.ts";
1920 import { createSession } from "../src/core/sessions.ts";
@@ -187,6 +188,26 @@ describe("home is the feed", () => {
187188 }
188189 });
189190
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
190211 test("a reader's timeline has the public repository's posts and nothing private or configured", async () => {
191212 const text = await (await get("/", bobCookie)).text();
192213 expect(text).toContain("Water the tomatoes at dawn");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs