Skip to content

fix(cli): carry rounded-up seconds and kilobytes into the next unit - #7565

Merged
jrusso1020 merged 1 commit into
mainfrom
fix/cli-format-rounding-carry
Nov 11, 2026
Merged

jrusso1020 merged 1 commit into
mainfrom
fix/cli-format-rounding-carry

Conversation

@jrusso1020

@jrusso1020 jrusso1020 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

What

formatDuration and formatBytes in packages/cli/src/ui/format.ts no 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 because main requires signed commits. The code and tests are theirs, carried over unchanged, and they're credited as co-author.

Why

  • formatDuration(59_960) printed 60.0s, and formatDuration(119_970) printed 1m 60.0s, because the seconds were rounded after the minute split.
  • formatBytes(1_048_575) printed 1024.0 KB instead of 1.0 MB.

These feed hyperframes cloud render progress and upload lines, info size, 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 formatDuration now always round up (150 ms prints 0.2s instead of 0.1s, because the old toFixed rounded the binary float inconsistently), and tiny negative durations print 0.0s instead of -0.0s. Otherwise output is unchanged.

Test plan

  • Unit tests added: both rollover cases. vitest run src/ui/format.test.ts passes 26/26. With format.ts reverted to main, the two new tests fail and the other 24 pass.
  • lint, format, typecheck and fallow pre-commit hooks pass.
  • Manual testing performed (not applicable; pure formatting functions)
  • Documentation updated (not applicable)
  • Comments follow CONTRIBUTING.md "Comments".

— Rames Jusso

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 88 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.1s and now prints 0.2s, and 1150 ms went from 1.1s to 1.2s, because the old toFixed rounded the binary float. Small negative values print 0.0s instead 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-13 and packages/producer/src/services/distributed/plan.ts:691-692 have the same rollover bug (1,048,575 bytes prints 1024.0 KiB). Separately, the CLI formatBytes has no GB step, so anything at or above about 1 GiB prints 1024.0 MB or 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

@jrusso1020
jrusso1020 enabled auto-merge November 11, 2026 18:12
@jrusso1020
jrusso1020 added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 1826083 Nov 11, 2026
131 checks passed
@jrusso1020
jrusso1020 deleted the fix/cli-format-rounding-carry branch November 11, 2026 18:36
@terencecho terencecho mentioned this pull request Nov 11, 2026
3 of 4 tasks
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.

1 participant