Skip to content

Use one relative time helper across the app - #373

Merged
abhishekgahlot2 merged 2 commits into
useagenthq:mainfrom
sunred-liu:fix/295-one-relative-time-helper
Nov 6, 2026
Merged

abhishekgahlot2 merged 2 commits into
useagenthq:mainfrom
sunred-liu:fix/295-one-relative-time-helper

Conversation

@sunred-liu

@sunred-liu sunred-liu commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #295

One relative-time formatter instead of three. utils/format.ts keeps the flooring buckets the library pages
already used and gains the date fallback Settings had, so every surface now agrees on the bucket and on what
happens past a month. settings/relative-time.ts is deleted and the bots copy in roster-model.ts keeps only
its empty-until-mounted gate.

Evidence: L1 (the helper is pure, so its whole surface is exercised by the unit table) -> L1 required (the
issue's "Done when" asks for a shared helper, the removal of the copies, and one test table). Residual: none.

AC Evidence

AC Evidence
Settings, Secrets, bots and library pages share the rounding buckets and the date fallback in utils/format.ts CI-covered: utils/format.test.ts walks every bucket in one table. The six Settings and Secrets callers import relativeTime from @/utils/format, and settings/relative-time.ts is gone, so nothing else can drift.
Compact labels and the bots' empty-until-mounted behaviour are preserved CI-covered: components/bots/roster-model.test.ts already asserts now / 5m / 2h / 3d and "" for an unknown clock, and it passes unchanged. relativeTime() in roster-model.ts is now a gate over relativeTimeShort().
The test table covers seconds, minutes, hours, days, weeks and the date fallback, and bun run typecheck passes CI-covered: utils/format.test.ts has 18 rows spanning those buckets plus the input-handling cases. bun run typecheck is green.

Deltas from ticket

The buckets floor, they do not round. The issue says to keep relativeTime in utils/format.ts, and that
function already floored. Only Settings and the bots rounded, and rounding overstates: 90 seconds is "2m ago",
100 minutes is "2h ago". Flooring is also the smaller change, because the library pages, the runs list, the
dashboard and the automations cards all already read the floored helper. If you would rather round everywhere,
that is a one-word change on two lines and the table says which rows move.

The date fallback starts at 30 days, as Settings had it. With the week bucket that means 4w ago is the
last relative label, then the local date. Note this is a behaviour change for dense rails: relativeTimeShort
older than a month used to say 57w, and now returns the date, which has no ago suffix to drop and is
returned as it is.

frontend/package.json adds utils to the test script. The issue asks for the table in
utils/format.test.ts, but bun run test was bun test components app lib, so a file there would never run in
CI. utils/cx.test.ts was already in that position: written, passing, and skipped. Adding utils runs it too,
and it passes.

Test Evidence

All coverage runs in CI. The receipts a green suite cannot show are the three old implementations and the new
one side by side, run against a pinned clock. settings is the deleted relTime, bots is the old
roster-model.relativeTime, library is the old shared helper:

age             settings (old)  bots (old)  library (old)  shared (new)  compact (new)
20 seconds      just now        now         just now       just now      now
90 seconds      2m ago          2m          1m ago         1m ago        1m
59 minutes      59m ago         59m         59m ago        59m ago       59m
100 minutes     2h ago          2h          1h ago         1h ago        1h
3 days          3d ago          3d          3d ago         3d ago        3d
29 days         29d ago         29d         4w ago         4w ago        4w
400 days        2025/8/26       400d        57w ago        2025/8/26     2025/8/26

The new cases are not vacuous: with utils/format.ts and roster-model.ts restored to main, three of them
fail, all on the date fallback (Received: "57w ago"), and they pass with the change.

cd frontend && bun run test: 1693 passed / 1 failed before, 1735 passed / 1 failed after. The extra 42 are
the new table plus the three utils/cx.test.ts cases the script change brings in. The one failure is
components/chat/terminal-surface.test.ts, which fails the same way on unmodified main in this checkout.
bun run typecheck, bun run lint and bun run build are clean.

Post-Merge Validation

  • Nothing beyond a bump in what the next person reads: the summary line in Settings, the secrets table, the
    bots roster and the library lists all show the same bucket now, and the table above is the record of what
    moved.

Authored by Sunred Liu (DeepSeek-V4.1-Flash, WorkBuddy). Session 420178fc-d00d-4e07-90a7-e5508930f10b.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Settings, Secrets and the bots roster each kept their own copy of the relative-time formatter, and the
copies disagreed. At 90 seconds Settings said "2m ago" while the library pages said "1m ago"; past a month
the bots roster said "400d" while the library pages said "57w ago".

`utils/format.ts` is now the only implementation. It keeps the flooring buckets the library pages already
used, so no bucket overstates an age, and it gains the date fallback Settings had: past 30 days the label is
the local date rather than an ever-growing week count.

- `settings/relative-time.ts` is deleted, and its six callers import `relativeTime` instead.
- `components/bots/roster-model.ts` keeps only the empty-until-mounted gate, so a server render and the first
  client render still agree, and hands the rest to `relativeTimeShort`.
- `utils/format.test.ts` walks every bucket in one table, including the 90-second and 119-second cases that
  pin flooring, and the 29/30-day boundary where the date takes over.
- `frontend/package.json` adds `utils` to the test script: the table lives next to the helper, and without it
  `bun test components app lib` would never run it.
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sunred-liu

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 20, 2026
@abhishekgahlot2
abhishekgahlot2 merged commit 27f9947 into useagenthq:main Nov 6, 2026
21 checks passed
@abhishekgahlot2

Copy link
Copy Markdown
Contributor

Merged, thanks @sunred-liu. One relative time helper across the app is a nice cleanup, and the date fallback after 30 days reads much better.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use one relative time helper across the app

2 participants