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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 59903fa

opened this

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 ago next to the ISO datetime and the UTC title.
  • The age follows the clock: just now, then 3h ago, then 1d ago as 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.

Closes #13539

commented

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 ago next to the ISO datetime and the UTC title.
  • The age follows the clock: just now, then 3h ago, then 1d ago as 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.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs