Skip to content

fix: normalize rounded duration units#552

Open
Dodothereal wants to merge 1 commit into
FailproofAI:mainfrom
Dodothereal:fix/521-formatduration-emits-invalid-strings-at-
Open

fix: normalize rounded duration units#552
Dodothereal wants to merge 1 commit into
FailproofAI:mainfrom
Dodothereal:fix/521-formatduration-emits-invalid-strings-at-

Conversation

@Dodothereal

@Dodothereal Dodothereal commented Jul 16, 2026

Copy link
Copy Markdown

fix: normalize rounded duration units

Summary

formatDuration rounded values at unit boundaries without carrying the overflow, producing invalid values such as 60.0s and 1m 60s. This change normalizes rounded seconds before formatting minutes and hours.

Fixes #521

Changes

  • Carry rounded seconds into minutes and hours before rendering a duration.
  • Add regression coverage for the reported second and minute rounding boundaries.
  • Document the bug fix in the changelog.

Testing

  • sandbox-run "npm install --ignore-scripts && npx vitest run __tests__/lib/format-duration.test.ts" — passed (14 tests).
  • sandbox-run "npm install --ignore-scripts && npx eslint lib/format-duration.ts __tests__/lib/format-duration.test.ts" — passed.
  • sandbox-run "npm install --ignore-scripts && npx tsc --noEmit" — passed.
  • sandbox-run "npm install --ignore-scripts && npx vitest run" — attempted; existing unrelated failures in hook integration/config tests prevented a clean full-suite result. The focused regression suite passed.

AI assistance disclosure

This contribution was produced by an autonomous AI coding agent (Claude Code) that @Dodothereal operates and monitors. @Dodothereal is accountable for it, will address review feedback promptly, and will close this PR immediately if this kind of contribution is unwelcome in this project. Commits carry an Assisted-by: Claude Code trailer.

Summary by CodeRabbit

  • Bug Fixes

    • Improved duration formatting to prevent invalid values such as 60.0s, 1m 60s, and 59m 60s.
    • Durations now round cleanly into the next minute or hour when appropriate.
  • Documentation

    • Updated the changelog with the corrected release date and duration-formatting fix.

Assisted-by: Claude Code
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c6287d85-84d0-4550-8a5a-7b815eb40caa

📥 Commits

Reviewing files that changed from the base of the PR and between 87793b9 and b0ed1fa.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • __tests__/lib/format-duration.test.ts
  • lib/format-duration.ts

📝 Walkthrough

Walkthrough

formatDuration now normalizes rounded duration units across seconds, minutes, and hours. Tests cover boundary carryover cases, and the changelog records the fix.

Changes

Duration formatting normalization

Layer / File(s) Summary
Normalize rounded duration output
lib/format-duration.ts, __tests__/lib/format-duration.test.ts, CHANGELOG.md
Rounded seconds now carry into minutes and hours, with tests covering 1m 0s, 2m 0s, and 1h 0m; the changelog records the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: niveditjain

Poem

I’m a rabbit who rounds time neat,
No sixty seconds in the heap.
Minutes hop, then hours bloom,
Clean formats make a tidy room.
Thump thump! The boundaries zoom.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: normalizing rounded duration units.
Description check ✅ Passed The description covers the bug, changes, and testing, but it does not fully follow the template's Type of Change and checklist sections.
Linked Issues check ✅ Passed The code and tests address #521 by carrying rounded seconds into minutes and hours at the specified boundaries.
Out of Scope Changes check ✅ Passed The changes stay focused on duration normalization, regression tests, and the changelog update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatDuration emits invalid strings at rounding boundaries ("60.0s", "1m 60s", "59m 60s")

1 participant