Repository navigation
Use one relative time helper across the app - #373
Merged
abhishekgahlot2 merged 2 commits intoNov 6, 2026
Merged
abhishekgahlot2 merged 2 commits into
abhishekgahlot2 merged 2 commits into
Conversation
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.
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #295
One relative-time formatter instead of three.
utils/format.tskeeps the flooring buckets the library pagesalready 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.tsis deleted and the bots copy inroster-model.tskeeps onlyits 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
utils/format.tsutils/format.test.tswalks every bucket in one table. The six Settings and Secrets callers importrelativeTimefrom@/utils/format, andsettings/relative-time.tsis gone, so nothing else can drift.components/bots/roster-model.test.tsalready assertsnow/5m/2h/3dand""for an unknown clock, and it passes unchanged.relativeTime()inroster-model.tsis now a gate overrelativeTimeShort().bun run typecheckpassesutils/format.test.tshas 18 rows spanning those buckets plus the input-handling cases.bun run typecheckis green.Deltas from ticket
The buckets floor, they do not round. The issue says to keep
relativeTimeinutils/format.ts, and thatfunction 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 agois thelast relative label, then the local date. Note this is a behaviour change for dense rails:
relativeTimeShortolder than a month used to say
57w, and now returns the date, which has noagosuffix to drop and isreturned as it is.
frontend/package.jsonaddsutilsto the test script. The issue asks for the table inutils/format.test.ts, butbun run testwasbun test components app lib, so a file there would never run inCI.
utils/cx.test.tswas already in that position: written, passing, and skipped. Addingutilsruns 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.
settingsis the deletedrelTime,botsis the oldroster-model.relativeTime,libraryis the old shared helper:The new cases are not vacuous: with
utils/format.tsandroster-model.tsrestored tomain, three of themfail, 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 arethe new table plus the three
utils/cx.test.tscases the script change brings in. The one failure iscomponents/chat/terminal-surface.test.ts, which fails the same way on unmodifiedmainin this checkout.bun run typecheck,bun run lintandbun run buildare clean.Post-Merge Validation
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.
Need help on this PR? Tag
@codesmith-botwith what you need.