Fix duration rounding at unit boundaries#530
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
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
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. 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. Comment |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
|
Automated code review started - full review. Results will be posted here. |
|
⏳ [Hermes Review — Progress Update] Phase 0-2 complete. Findings so far:
Running full test suite and Docker smoke test now... |
|
✅ [Hermes Review - Build and Test Complete] Results:
Logic verification:
Full review summary posting now... |
🔍 Automated Code Review📋 Executive SummaryThis PR fixes a rounding bug in 📊 Change Architecturegraph TD
A["formatDuration(ms)"] -->|"ms / 1000"| B["seconds (raw)"]
B -->|"Math.round(s*10)/10"| C["roundedTenths"]
C -->|"< 60?"| D["SECONDS BUCKET: toFixed(1)"]
C -->|">= 60"| E["roundedSeconds = Math.round(s)"]
E -->|"floor(rs/60)"| F["totalMinutes"]
F -->|">= 60?"| G["HOURS BUCKET: h/m output"]
F -->|"< 60"| H["MINUTES BUCKET: m/s output"]
style C fill:#90EE90
style E fill:#90EE90
style D fill:#87CEEB
style H fill:#87CEEB
Legend: 🟢 New (or changed) | 🔵 Modified (existing path) 🔴 Breaking Changes✅ No breaking changes detected. The function signature is unchanged, the return type is unchanged, and all existing test assertions continue to pass without modification. The output changes ONLY for values near boundaries that previously produced invalid strings (e.g., "60.0s" → "1m 0s"), which is the intended fix.
|
hermes-exosphere
left a comment
There was a problem hiding this comment.
Automated review: Approved. ✅
All 13 tests pass (including new boundary cases). TypeScript and ESLint are clean. The fix correctly addresses all three bug patterns from #521. No regressions detected. Full review summary posted above.
hermes-exosphere
left a comment
There was a problem hiding this comment.
Automated review: Approved. ✅
|
Your PR is awaiting review by a moderator. Till then you can join the Discord for conversation: https://discord.gg/qaFM2uYFb |
|
Your PR is awaiting review by a moderator. Till then you can join the Discord for conversation: https://discord.befailproof.ai |
|
Your PR is awaiting review by a reviewer. Till then you can join the Discord for conversation: https://discord.befailproof.ai |
|
Thanks @zzbcode — logic's correct, I ran it across the boundary spread and it lines up with the others exactly. Snag is #529 is on the same issue and got there first with a wider boundary suite, so I'll probably go with that one rather than double-merge the same fix. Sorry for the duplicated effort — #534 is the meatier one of yours and I'm going through it properly now. |
What changed
60.0s,1m 60s, and59m 60svalues into the next unitWhy
formatDurationpreviously chose a unit bucket before rounding its remainder. Values near a boundary could therefore render impossible strings such as60.0s,1m 60s, or59m 60s.The updated implementation rounds at the precision used by each bucket, preserving normal values such as
59.6swhile carrying only values that cross a display boundary.Validation
git diff --checkFixes #521.
This is my first contribution to Failproof AI. If the project maintains a contributors list or recognition process beyond GitHub's merged-PR attribution, I would be grateful to be included once this is merged.
Summary by CodeRabbit
Bug Fixes
Tests