Repository navigation
fix(cli): history list never prints 60m ago or 24h ago - #5818
rudycelekli wants to merge 2 commits into
Conversation
miguel-heygen
left a comment
There was a problem hiding this comment.
Thank you for this, and for splitting it out from the formatting fix. The bug is real and your fix is the right one: on main an entry 3,570 seconds old prints 60m ago and one 86,000 seconds old prints 24h ago, and with flooring they print 59m and 23h. I also checked the boundary just below a minute, where rounding seconds to 60 now falls into the minutes branch and prints 1m ago rather than 60s ago, so no unit can show at the size of the next one. Passing now in as an argument is a nice touch and makes the test honest.
The one thing blocking a stamp is the branch state rather than the code. The PR conflicts with main, history.ts has moved since you branched, and because of the conflict none of the real checks ran at this head: only the mergeability check and the WIP marker. Your new test file has therefore never been executed by CI, and you mention the workspace typecheck did not run locally either. Could you rebase on main and push, so the CLI suites, typecheck and lint actually run? If they come back green I am happy to approve as is.
One thing worth knowing while you are in here, not a change request. The Studio UI has its own relative age helper in the render queue item, with different thresholds and no day unit. It already floors so it is not affected by this bug, but it means this extraction does not yet become the single owner of how an age is printed.
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at f09ff82c32. Adding to Miguel's review rather than repeating it: I agree with him that the code is right and the only blocker is the conflict.
I checked current main independently. ago() in commands/history.ts (now around line 160) still rounds minutes, hours and days, so 3,570 seconds still prints 60m ago and 86,000 seconds still prints 24h ago. Flooring the larger units while keeping seconds rounded is correct: 59.5 seconds rounds to 60 and drops into the minutes branch as 1m ago, so no unit can print at the size of the next one. The new test covers both boundary cases and the future-timestamp clamp.
When you rebase, the call site in line() has moved but is otherwise the same shape, so it should be a mechanical resolution: delete the local ago, import the new one, and pass historyDeps.now().
Need: yes, the off-by-one-unit output is still on main · Size: ok · Reuse: nothing shared yet (Studio's render-queue age helper is separate, as Miguel noted) · Simpler: already minimal
— Rames
|
This PR has had no activity for 14 days, so it is marked stale and will close in 7 days. Push a commit or leave a comment to keep it open. A maintainer can add |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
f09ff82 to
a2b03a6
Compare
|
Rebased onto current Conflict in |
The boundary is already asserted by the unit test. The file comment put a new source file over the package's comment share. Co-authored-by: Cursor <cursoragent@cursor.com>
What
hyperframes historyprints relative ages that read as the next unit's size:60m agoand24h ago.Why
ago()rounds each unit. An entry 3,570 s old (59.5 minutes) prints60m agoinstead of59m ago, and one 86,000 s old prints24h agoinstead of23h ago.Related work
No overlapping PR found. Related in spirit to #5817 (rounding rollover in
ui/format.ts), but touches a different file.How
Floor minutes, hours and days; seconds stay rounded. The function moves unchanged in shape into
utils/historyAgo.tsand takesnowas an argument, so it can be tested without the history command's workspace dependencies.Test plan
utils/historyAgo.test.ts. The boundary case fails with the old rounding and passes with the fix (vitest run src/utils/historyAgo.test.ts).oxfmt --checkandoxlintclean on changed files.Not run locally:
history.test.tsand workspace typecheck (workspace packages were not installed), comment citation/ratchet scripts.