Repository navigation
fix(cli): carry rounded-up seconds and kilobytes into the next unit - #7565
Merged
Merged
Conversation
formatDuration rounded seconds after splitting off minutes, so 59.96s printed "60.0s" and 119.97s printed "1m 60.0s". formatBytes compared KB against the MB threshold before rounding, so 1,048,575 bytes printed "1024.0 KB". Round first, then split or compare. Takes over #5817 by @rudycelekli, whose commits could not be merged unsigned. Co-authored-by: Rudy Celekli <rudy@gradiahq.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 5 tasks
Contributor
Contributor
There was a problem hiding this comment.
Verdict: APPROVE · 0 blocker · 0 important · 2 nits · f21aacd
Changed lines match #5817's head (2bd4964) exactly; only the hunk header moved with main. Brute-forced 0–3 MiB and 0–4 h against main: no 60.0s or 1024.0 KB output remains.
- nit (PR body): the claim that every other input prints the same isn't quite true. Exact half-tenths now always round up: 150 ms used to print
0.1sand now prints0.2s, and 1150 ms went from1.1sto1.2s, because the oldtoFixedrounded the binary float. Small negative values print0.0sinstead of-0.0s. Both are improvements, but the body should say so. - nit (follow-up): the KiB/MiB copies in
packages/aws-lambda/scripts/_formatBytes.ts:12-13andpackages/producer/src/services/distributed/plan.ts:691-692have the same rollover bug (1,048,575 bytes prints1024.0 KiB). Separately, the CLIformatByteshas no GB step, so anything at or above about 1 GiB prints1024.0 MBor higher. That was already the case before this PR.
Scope
Read format.ts and format.test.ts in full and checked every caller of formatBytes/formatDuration in packages/. All CI on f21aacd is green (CI, Windows render verification, CodeQL, regression, preview-regression). The commit is signed, and Rudy is credited with Co-authored-by: rudy@gradiahq.com, the address on their #5817 commits.
— Genesis
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
formatDurationandformatBytesinpackages/cli/src/ui/format.tsno longer print an out-of-range value when rounding reaches the next unit. This takes over #5817 by @rudycelekli, whose change is approved but can't merge becausemainrequires signed commits. The code and tests are theirs, carried over unchanged, and they're credited as co-author.Why
formatDuration(59_960)printed60.0s, andformatDuration(119_970)printed1m 60.0s, because the seconds were rounded after the minute split.formatBytes(1_048_575)printed1024.0 KBinstead of1.0 MB.These feed
hyperframes cloud renderprogress and upload lines,infosize, and Chrome download progress.Related work
Supersedes #5817. No other overlapping PR.
How
Round the duration to tenths of a second before splitting it into minutes and seconds, and round the KB value before comparing it with the MB threshold. Two small side effects: exact half-tenths in
formatDurationnow always round up (150 ms prints0.2sinstead of0.1s, because the oldtoFixedrounded the binary float inconsistently), and tiny negative durations print0.0sinstead of-0.0s. Otherwise output is unchanged.Test plan
vitest run src/ui/format.test.tspasses 26/26. Withformat.tsreverted tomain, the two new tests fail and the other 24 pass.— Rames Jusso
🤖 Generated with Claude Code