Files
rengine/.github/workflows
Yogesh OjhaandClaude Opus 5 42b82b2faf refactor(frontend): one relative-time arithmetic, and a place to test it
relativeTime and formatDistanceToNow computed the same elapsed time twice and
diverged three ways:

- formatDistanceToNow deliberately omitted "ago", so the caller had to append
  it — and three of its five call sites did not. The Targets list's Updated
  column read a bare "2 days", and the engine and context cards read "used 3
  hours", which is a duration, not a point in time.
- relativeTime had no years bucket, so a three-year-old timestamp read
  "36mo ago".
- formatDistanceToNow was not null-safe: new Date(null) is the epoch, so a
  missing date read "56 years".

One `elapsed()` now picks the bucket and two renderings print it —
`relativeTime` ("3h ago") and `relativeTimeLong` ("3 hours ago"), both
null-safe. formatDistanceToNow is gone. The unit table runs largest-first and
takes the first count >= 1, which removes the 360-to-365-day gap the two
30-day-month / 365-day-year ladders had between them and makes a clock running
ahead of ours read "just now" rather than a negative count.

The bug was a copy error in a pure function, which is the kind a test catches,
and the frontend had no test runner at all. Add vitest: `npm run test`, its own
config (sveltekit() wants a running kit), node environment, `src/**/*.test.ts`,
and a CI step beside lint and check. 34 tests on the clock-frozen table, each
proven to fail against a mutation — including a clamp the tests showed was dead
code, since the `count >= 1` guard already rejects a future timestamp.

node_modules is baked into the frontend image, so this needs
`docker compose build frontend`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013dKUV96WkQQETZBMoAG98C
2026-09-11 07:56:28 +05:30
..
2026-01-26 15:02:53 +05:30
2026-01-26 15:02:53 +05:30
2026-01-26 15:02:53 +05:30
2024-05-12 18:47:07 +05:30