Repository navigation
Closed
Labels
Description
Description
"Last run" timestamps are rendered by four separate copies of the same helper, under three different names, and they have drifted apart:
| Where | Name | Under a minute | Rounding | Past 30 days |
|---|---|---|---|---|
| topics/page.tsx#L57 | formatRelative(iso, t) |
t('relative.justNow') |
Math.floor |
locale date |
| prompts/page.tsx#L274 | formatRelative(iso?) |
Just now |
Math.round |
locale date |
| insights/page.tsx#L1731 | formatTimeAgo(date: Date) |
just now |
Math.floor |
Xd ago |
| traffic/page.tsx#L203 | timeAgo(dateStr) |
just now |
Math.floor |
Xd ago |
Three of those differences are visible to the user:
- Rounding. A run 90 seconds ago reads
2m agoon Prompts and1m agoon Topics. At 45 minutes Prompts says1h agowhile the other three still say45m ago. - Casing.
Just nowon Prompts,just noweverywhere else. - The 30-day cliff. Topics and Prompts hand off to a locale date; Insights and Traffic keep counting days indefinitely, so a year-old timestamp reads
412d ago.
Only the Topics copy goes through i18n.
Steps to reproduce
- Note a brand's last-run time on the Topics page.
- Open the Prompts page and find the same brand's last run.
- Compare them at a point where the rounding differs — 90 seconds, or 45 minutes.
Expected behavior
One timestamp renders one way, wherever it appears.
Actual behavior
The same instant produces different strings depending on which page you are on.
Deployment mode
Cloud (ansvisor.com)
Environment
Not environment-specific — these are pure functions.
Notes for whoever picks this up
The Topics copy is the one to keep. It uses Math.floor, hands off to a locale date past 30 days, and reads its strings from topics.relative.* in web/messages/en.json.
- New home:
web/src/lib/format-relative.ts, withweb/src/lib/format-relative.test.tsbeside it.web/src/lib/csv.test.tsis the pattern to follow for both. - The
relative.*keys currently live under thetopicsnamespace. Moving them tocommon— which already exists — lets all four call sites share them. - The Insights copy takes a
Date; the other three take an ISO string. Pick one signature and adjust that call site rather than supporting both. - Prompts' copy returns
—for a missing value; keep that, the table depends on it. - Adopting the Topics behaviour changes what Insights and Traffic show past 30 days. That is the intent, but call it out in the PR so it doesn't read as an accident.
Tests worth having: the sub-minute boundary, floor vs round at 90 seconds, the hour and day boundaries, the 30-day cliff, and a null/undefined input.
Activity
Maqbool61 commentedon Aug 21, 2026
Working on this issue.
fix(#767): consolidate relative-time formatting into a single shared …
Maqbool61 commentedon Aug 23, 2026
Forgot to add "Closes" that's why issue is still open can you close it? @gkhngyk
gkhngyk commentedon Aug 25, 2026
Delivered by #772. Verified on
main: one implementation inweb/src/lib/format-relative.tswith tests beside it, all four call sites (topics, prompts, insights, traffic) importing it, no copies left behind, and the strings moved tocommon.relative.*so every page goes through i18n. Thanks @Maqbool61 — the missingClosesline was all that kept this open.