Public: anyone can read this; the crew can change it.
Follow upstream's "last checked" speaks the UI's one clock: `time()`, not a hand-rolled HH:MM UTC #16902
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/4016-follow-upstream-s-last-checked-speaks-th → main 0 commits fork
4 files
changed +27
−19
docs/ORIGINS.md +1 −1
| @@ -873,7 +873,7 @@ environment — never in the URL, never in argv. Nothing is stored in the | ||
| 873 | 873 | repository. A check's failure message is the remote's stderr with secrets |
| 874 | 874 | redacted, shown to admins only. |
| 875 | 875 | |
| 876 | The About card says "Following <upstream> · last checked HH:MM · N behind", | |
| 876 | The About card says "Following <upstream> · last checked 5m ago · N behind", | |
| 877 | 877 | to admins only. API, all admin-only (anyone else gets 404): |
| 878 | 878 | `GET|PUT /api/v1/repos/:owner/:name/upstream` (PUT takes |
| 879 | 879 | `{url, branch, enabled}`) and `POST …/upstream/check`. |
src/actions/upstream_follow.ts −6
| @@ -1041,12 +1041,6 @@ export function behindFor( | ||
| 1041 | 1041 | return level ? { checkedAt, text: "up to date", conflict: false, admin } : null; |
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | /** HH:MM, UTC. */ | |
| 1045 | export const clockWords = (iso: string): string => { | |
| 1046 | const at = new Date(iso); | |
| 1047 | return Number.isNaN(at.getTime()) ? "" : at.toISOString().slice(11, 16); | |
| 1048 | }; | |
| 1049 | ||
| 1050 | 1044 | /** Where a following stands: what the last check read. */ |
| 1051 | 1045 | export function standing(f: UpstreamFollow): string { |
| 1052 | 1046 | if (!f.enabled) return f.severedAt === null ? "off" : "severed"; |
src/web/pages/upstream-follow.ts +3 −12
| @@ -10,7 +10,6 @@ import { | ||
| 10 | 10 | checkedWords, |
| 11 | 11 | checkLine, |
| 12 | 12 | checkUpstreamNow, |
| 13 | clockWords, | |
| 14 | 13 | conflictWaitingWords, |
| 15 | 14 | crewResolvesWords, |
| 16 | 15 | FOLLOW_REFUSALS, |
| @@ -54,14 +53,6 @@ function backTo(form: Awaited<ReturnType<typeof readForm>> & object, fallback: s | ||
| 54 | 53 | return typeof back === "string" && isLocalPath(back) ? back : fallback; |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | /** HH:MM in UTC, with the instant for machines and the title for people. */ | |
| 58 | function clock(iso: string): Html { | |
| 59 | const at = new Date(iso); | |
| 60 | if (Number.isNaN(at.getTime())) return html``; | |
| 61 | const exact = `${at.toISOString().slice(0, 16).replace("T", " ")} UTC`; | |
| 62 | return html`<time datetime="${at.toISOString()}" title="${exact}">${clockWords(iso)}</time>`; | |
| 63 | } | |
| 64 | ||
| 65 | 56 | /** The About card's line, for admins; null for everyone else. */ |
| 66 | 57 | export function followingLine(ctx: Ctx, repo: Repo): Html | null { |
| 67 | 58 | const follow = followShown(ctx.app, repo, ctx.auth.user); |
| @@ -89,7 +80,7 @@ export function followingLine(ctx: Ctx, repo: Repo): Html | null { | ||
| 89 | 80 | ${icon("sync")} Following |
| 90 | 81 | <a href="${follow.url}" rel="noreferrer noopener">${upstreamLabel(follow.url)}</a> |
| 91 | 82 | <span class="mono">${follow.branch}</span> |
| 92 | ${follow.checkedAt === null ? null : html`· last checked ${clock(follow.checkedAt)}`} | |
| 83 | ${follow.checkedAt === null ? null : html`· last checked ${time(follow.checkedAt)}`} | |
| 93 | 84 | · ${standing(follow)} |
| 94 | 85 | </p>`; |
| 95 | 86 | } |
| @@ -208,7 +199,7 @@ export function followUpstreamCard(ctx: Ctx, repo: Repo, choice: Html | null = n | ||
| 208 | 199 | ${when( |
| 209 | 200 | follow, |
| 210 | 201 | (f) => html`<p class="hint" data-following-standing>${standing(f)}${ |
| 211 | f.checkedAt === null ? "" : html` · last checked ${clock(f.checkedAt)}` | |
| 202 | f.checkedAt === null ? "" : html` · last checked ${time(f.checkedAt)}` | |
| 212 | 203 | }${f.error === "" ? "" : html` · ${f.error}`} · ${f.opened} proposed so far</p>`, |
| 213 | 204 | )} |
| 214 | 205 | ${historyList(ctx, repo)} |
| @@ -306,7 +297,7 @@ function sourceLine(base: string, s: FollowSource): Html { | ||
| 306 | 297 | lead: icon("sync"), |
| 307 | 298 | title: html`<a href="${s.url}" rel="noreferrer noopener">${upstreamShort(s.url)}</a> <span class="mono">${s.branch}</span>`, |
| 308 | 299 | meta: html`${stamp === undefined ? "" : `${stamp.account}@${stamp.host}`} · ${stand}${ |
| 309 | s.checkedAt === null ? "" : html` · checked ${clock(s.checkedAt)}` | |
| 300 | s.checkedAt === null ? "" : html` · checked ${time(s.checkedAt)}` | |
| 310 | 301 | }`, |
| 311 | 302 | trail: html`<form method="post" action="${base}/settings/sources/${s.id}/remove" class="row-fields"> |
| 312 | 303 | ${btn("Remove", { size: "sm", variant: "outline", label: `Stop following ${upstreamShort(s.url)}` })} |
test/upstream_follow.test.ts +23
| @@ -27,6 +27,8 @@ import { getPull, listPulls } from "../src/core/pulls.ts"; | ||
| 27 | 27 | import { getRepoById, type Repo } from "../src/core/repos.ts"; |
| 28 | 28 | import { createUser, type User } from "../src/core/users.ts"; |
| 29 | 29 | import { checkDue, checkUpstream, mayCarryCredential } from "../src/actions/upstream_follow.ts"; |
| 30 | import { followingLine } from "../src/web/pages/upstream-follow.ts"; | |
| 31 | import type { Ctx } from "../src/http/context.ts"; | |
| 30 | 32 | import { createOrigin } from "../src/core/origins.ts"; |
| 31 | 33 | import { runGit } from "../src/git/env.ts"; |
| 32 | 34 | import { REMOTE_PROTOCOLS } from "../src/git/remote-env.ts"; |
| @@ -148,6 +150,27 @@ describe("the follow row", () => { | ||
| 148 | 150 | }); |
| 149 | 151 | }); |
| 150 | 152 | |
| 153 | describe("the About line's clock", () => { | |
| 154 | test("last checked is the UI's relative time with the exact instant in datetime", () => { | |
| 155 | const at = new Date(Date.now() - 5 * 60_000).toISOString(); | |
| 156 | putFollow(app.db, { repoId: repo.id, url: "https://example.com/a/b.git", branch: "main", enabled: true, byId: alice.id, originId: "" }); | |
| 157 | noteCheck(app.db, repo.id, { at, tip: "abc", behind: 0, error: "", ahead: 0 }); | |
| 158 | const ctx: Ctx = { | |
| 159 | app, | |
| 160 | request: new Request("http://forge.test/"), | |
| 161 | url: new URL("http://forge.test/"), | |
| 162 | params: {}, | |
| 163 | auth: { user: alice, scope: undefined, via: "session" }, | |
| 164 | theme: undefined, | |
| 165 | }; | |
| 166 | const line = followingLine(ctx, repo)?.toString() ?? ""; | |
| 167 | expect(line).toContain("last checked"); | |
| 168 | expect(line).toContain(`datetime="${at}"`); | |
| 169 | expect(line).toMatch(/>\s*5m ago\s*</); | |
| 170 | expect(line).not.toMatch(/\d\d:\d\d<\/time>/); | |
| 171 | }); | |
| 172 | }); | |
| 173 | ||
| 151 | 174 | describe("who hears of it", () => { |
| 152 | 175 | test("a guest's events do not carry the URL; an admin's do", () => { |
| 153 | 176 | const secret = "https://private.example.com/secret/repo.git"; |
new above
offline