Public: anyone can read this; the crew can change it.
A feed item's age reads as '3h' and its exact time is in the title attribute and a machine-readable datetime #13551
Check · Review · Land · Live done — Landed and live in production.
This pull adds only a test, because the behaviour already holds on main. Each feed card's time comes from time() in src/web/ui.ts, which feedCard calls. It renders a server-side " title="2026-03-04 05:06 UTC">3h ago , with no client script.
shipped production is serving it deploy 59903fa
This pull adds only a test, because the behaviour already holds on main.
Each feed card's time comes from time() in src/web/ui.ts, which feedCard calls. It renders a server-side <time datetime="<ISO>" title="2026-03-04 05:06 UTC">3h ago</time>, with no client script. timeAgo reads Date.now() at render time, so the age is not frozen in the markup.
What I added is test/feed-age.test.ts, which pins the clock with setSystemTime and checks two things:
- A card shows
3h agonext to the ISOdatetimeand the UTCtitle. - The age follows the clock:
just now, then3h ago, then1d agoas time moves on. It would fail if the age were baked in at write time.
I changed no source. The age reads 3h ago rather than a bare 3h, which is the existing short form used across the UI. I did not touch src/feed/items.ts or src/feed/timeline.ts, since the feed card renders its own time. The server-side ago() in src/feed/rank.ts ("3 hours ago") is the older wording that feeds the reason text and the card summaries.
I did not check whether feed ETag/304 responses can serve a stale age. That is the one thing to look at if you want the cached-page risk closed.
To try it, run bun test test/feed-age.test.ts. The test file and tsc --noEmit pass, and bun scripts/gate.ts --fix changed nothing.
Test-only pull; the behaviour already holds on main (time() in src/web/ui.ts, covered for the exact title by test/feed-time-title.test.ts). The new test adds what was missing: the short age follows the render-time clock (just now, 3h ago, 1d ago) next to the ISO datetime and UTC title, server-rendered. Nothing unsafe, no dependency, no src change. Two things I would do next: (1) fold the shared regex/fixture with feed-time-title.test.ts instead of a second copy of the item and stamp pattern; (2) check that the feed ETag/304 path cannot serve a stale age on a cached page, as the author flagged, and pin it with a test.
This pull adds only a test, because the behaviour already holds on main.
Each feed card's time comes from
time()insrc/web/ui.ts, whichfeedCardcalls. It renders a server-side<time datetime="<ISO>" title="2026-03-04 05:06 UTC">3h ago</time>, with no client script.timeAgoreadsDate.now()at render time, so the age is not frozen in the markup.What I added is
test/feed-age.test.ts, which pins the clock withsetSystemTimeand checks two things:3h agonext to the ISOdatetimeand the UTCtitle.just now, then3h ago, then1d agoas time moves on. It would fail if the age were baked in at write time.I changed no source. The age reads
3h agorather than a bare3h, which is the existing short form used across the UI. I did not touchsrc/feed/items.tsorsrc/feed/timeline.ts, since the feed card renders its own time. The server-sideago()insrc/feed/rank.ts("3 hours ago") is the older wording that feeds the reason text and the card summaries.I did not check whether feed ETag/304 responses can serve a stale age. That is the one thing to look at if you want the cached-page risk closed.
To try it, run
bun test test/feed-age.test.ts. The test file andtsc --noEmitpass, andbun scripts/gate.ts --fixchanged nothing.Closes #13539