Public: anyone can read this; the crew can change it.
The home's "waiting on you" line wraps on a narrow screen and its action stays tappable #6253
scout/forge:scout/6068-the-home-s-waiting-on-you-line-wraps-on → main 1 commit fork
3 files
changed +22
−7
src/web/studio/home_cache.ts +2 −1
| @@ -21,10 +21,11 @@ const panelCaches = new WeakMap<Database, Stamped<Answer>>(); | ||
| 21 | 21 | const vitalsCaches = new WeakMap<Database, Stamped<Vitals>>(); |
| 22 | 22 | const waitingCaches = new WeakMap<Database, Stamped<Waiting>>(); |
| 23 | 23 | |
| 24 | /** What the waiting line keeps of the viewer's asks: how many, and the oldest's time. */ | |
| 24 | /** What the waiting line keeps of the viewer's asks: how many, and the oldest's time and title. */ | |
| 25 | 25 | export interface Waiting { |
| 26 | 26 | readonly count: number; |
| 27 | 27 | readonly oldest: string | null; |
| 28 | readonly oldestTitle: string | null; | |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | function cacheOf<V>(into: WeakMap<Database, Stamped<V>>, db: Database, maxEntries: number): Stamped<V> { |
src/web/studio/kpi_row.ts +8 −3
| @@ -173,16 +173,21 @@ export function kpiRow(db: Database, opts: { ceilingUsd?: number; dataDir?: stri | ||
| 173 | 173 | * (the very rows /review lists) and how long the oldest has. Empty at zero. |
| 174 | 174 | */ |
| 175 | 175 | export function waitingLine(db: Database, user: User, now: Date = new Date()): Html { |
| 176 | const { count, oldest } = cachedWaiting(db, user.id, () => { | |
| 176 | const { count, oldest, oldestTitle } = cachedWaiting(db, user.id, () => { | |
| 177 | 177 | const repos = listReposVisibleTo(db, user, { limit: 200, withoutArchived: true }); |
| 178 | 178 | const asks = waitingOn(db, user, repos); |
| 179 | const first = asks.reduce<(typeof asks)[number] | null>((o, a) => (o === null || Date.parse(a.since) < Date.parse(o.since) ? a : o), null); | |
| 179 | 180 | return { |
| 180 | 181 | count: asks.length, |
| 181 | oldest: asks.reduce<string | null>((o, a) => (o === null || Date.parse(a.since) < Date.parse(o) ? a.since : o), null), | |
| 182 | oldest: first?.since ?? null, | |
| 183 | oldestTitle: first === null ? null : (first.pull?.title ?? first.issue?.title ?? first.proposal?.title ?? null), | |
| 182 | 184 | }; |
| 183 | 185 | }); |
| 184 | 186 | const words = waitingWords(count, oldest, now); |
| 185 | return words === null ? html`` : html`<p class="small muted"><a href="/review">${words}</a></p>`; | |
| 187 | if (words === null) return html``; | |
| 188 | // The title is a person's text with no promise of spaces: `.break` lets it wrap; `.stack` puts the link on its own line. | |
| 189 | const title = oldestTitle === null ? html`` : html`: ${oldestTitle}`; | |
| 190 | return html`<p class="small muted break stack stack-tight"><span>${words}${title}</span><a href="/review">Review them</a></p>`; | |
| 186 | 191 | } |
| 187 | 192 | |
| 188 | 193 | /** Home's flow vitals for an admin (#5935): one muted line of counts; the open count links to the boards. */ |
test/home-kpi-row.test.ts +12 −3
| @@ -351,7 +351,7 @@ describe("home waiting line", () => { | ||
| 351 | 351 | expect(waitingWords(1, "2026-10-21T11:40:00.000Z", now)).toBe("1 waiting on you, oldest under 1 h"); |
| 352 | 352 | }); |
| 353 | 353 | |
| 354 | async function homeWith(stale: number[]): Promise<string> { | |
| 354 | async function homeWith(stale: number[], title?: string): Promise<string> { | |
| 355 | 355 | const root = mkdtempSync(join(tmpdir(), "forge-home-wait-")); |
| 356 | 356 | const app = createApp({ dataDir: root, port: 0 }); |
| 357 | 357 | const servers = await serve(app); |
| @@ -365,7 +365,7 @@ describe("home waiting line", () => { | ||
| 365 | 365 | const number = app.db.query<{ issue_seq: number }, [string]>("UPDATE repo SET issue_seq = issue_seq + 1 WHERE id = ?1 RETURNING issue_seq").get(repo.value.id)!.issue_seq; |
| 366 | 366 | app.db |
| 367 | 367 | .query(`INSERT INTO issue (id, repo_id, number, kind, title, body, author_id, state, created_at) VALUES (?1, ?2, ?3, 'pull', ?4, '', ?5, 'open', ?6)`) |
| 368 | .run(issueId, repo.value.id, number, `Stale ${i}`, made.value.id, new Date(Date.now() - h * 3_600_000).toISOString()); | |
| 368 | .run(issueId, repo.value.id, number, title ?? `Stale ${i}`, made.value.id, new Date(Date.now() - h * 3_600_000).toISOString()); | |
| 369 | 369 | app.db |
| 370 | 370 | .query(`INSERT INTO pull (issue_id, base_branch, head_branch, base_oid, head_oid, head_repo_id) VALUES (?1, 'main', ?2, ?3, ?3, ?4)`) |
| 371 | 371 | .run(issueId, `b/${i}`, "0".repeat(40), repo.value.id); |
| @@ -389,7 +389,16 @@ describe("home waiting line", () => { | ||
| 389 | 389 | |
| 390 | 390 | test("three asks show one line linking to /review", async () => { |
| 391 | 391 | const body = await homeWith([30, 40, 50]); |
| 392 | expect(body).toMatch(/<p class="small muted"><a href="\/review">3 waiting on you, oldest 5\d h<\/a><\/p>/); | |
| 392 | expect(body).toMatch(/<p class="small muted break stack stack-tight"><span>3 waiting on you, oldest 5\d h: Stale \d<\/span><a href="\/review">Review them<\/a><\/p>/); | |
| 393 | }, 30_000); | |
| 394 | ||
| 395 | test("a 120-character title with no spaces sits in a line that breaks, the link below it", async () => { | |
| 396 | const long = "x".repeat(120); | |
| 397 | const body = await homeWith([30], long); | |
| 398 | const line = body.slice(body.indexOf('<p class="small muted break'), body.indexOf("Review them</a></p>")); | |
| 399 | expect(line).toContain(long); | |
| 400 | expect(line).toMatch(/^<p class="[^"]*\bbreak\b[^"]*\bstack\b/); | |
| 401 | expect(line).toContain('</span><a href="/review">'); | |
| 393 | 402 | }, 30_000); |
| 394 | 403 | |
| 395 | 404 | test("with none, the line is absent", async () => { |
new above
offline