Repository navigation
fix: round durations and sizes before picking the unit - #2096
Conversation
…h-ab durations through renderMarkdown
There was a problem hiding this comment.
No issues found across 16 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Reviewed at 7bd7ddf (no conflict with main b6e65ae, mergeable_state clean, all CI checks green).
Clean root-cause fix: every formatter now rounds to the precision it prints, then picks the unit. That matches what #1829 did in the HTML report. formatDuration in markdown-text.ts now matches app/data.ts line for line and still hands minutes to formatMinutes. Pulling formatBytes and formatSize into their own modules is the right size of change, and the tests import the production code, not copies. I also checked the formatters this PR does not touch: formatBytes in core/src/agent/tool-output.ts prints only B/KB, so it has no carry-over boundary. duration in scripts/examples-nightly/format.ts already rounds to whole seconds first. So "none left apart from formatTime" holds.
Must fix
- None.
Should fix
- None.
Nits (optional)
e2egets two changesets (cache-size-rounding.md,markdown-duration-rounding.md). Folding them into one patch entry would keep the 0.25.0 changelog shorter. Fine as is.
Verified
- New tests pass: core
debug.test.ts, e2emarkdown-duration.test.ts+cli-cache-bytes.test.ts, html-reporterformat-size.test.ts,node --test scripts/bench-ab/markdown.test.ts. - Mutation check: I restored main's logic in each of the 5 formatters, one at a time, and the matching test failed each time (
1000msvs1.0s,1024.0 KiBvs1.0 MiB, and so on). - oxlint is clean on the touched files. Core typechecks. The e2e and html-reporter tsc errors locally come only from unbuilt sibling dists, and CI
checkis green. - Changesets are all patch. No
any, no dashes, files are small.
What and why
formatDurationinmarkdown-text.tspicked the unit before rounding, so 999.6ms showed as1000msand 59.96s as60.0sin the markdown report (and the GitHub PR comment built from it), trace pages, and failure details.formatMinutes, which already rounds first, so 119.6s stays2m 0s.formatMs(--debugtimings),formatBytes(e2e cache stats),formatSize(the HTML reporter's embedded page note), anddurationinscripts/bench-ab/markdown.ts. The two size helpers moved into their own small modules so their tests use the production code.formatTimeinreport/format.ts, none are left. It prints1000msfor 999.6ms, but it copies vitest's format, which prints1000msfor exactly 1000 too, so I left it.Issue
Fixes #2090
Verified
Ran it locally: yes
formatDuration1000ms1.0sformatDuration59.9s59.9sformatDuration60.0s1m 0sformatDuration2m 0s2m 0sformatMs10000ms10.0sformatBytes1024.0 KiB1.0 MiBformatSize1024 KB1.0 MBduration1000 ms1.00 s1000msand60.0sfor durations just under a unit #2090, run against this branch's build, prints1.0sand1m 0s.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.