Skip to content

fix: round durations and sizes before picking the unit - #2096

Merged
okwasniewski merged 10 commits into
e2e-inc:mainfrom
Wali05:fix/markdown-duration-rounding
Nov 23, 2026
Merged

okwasniewski merged 10 commits into
e2e-inc:mainfrom
Wali05:fix/markdown-duration-rounding

Conversation

@Wali05

@Wali05 Wali05 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What and why

  • formatDuration in markdown-text.ts picked the unit before rounding, so 999.6ms showed as 1000ms and 59.96s as 60.0s in the markdown report (and the GitHub PR comment built from it), trace pages, and failure details.
  • It now rounds first, as fix(html-reporter): round durations before choosing the unit #1829 did for the HTML report. Anything that rounds to a minute or more still goes through formatMinutes, which already rounds first, so 119.6s stays 2m 0s.
  • I checked the other unit formatters in the repo. Four more had the same bug and are fixed here too: formatMs (--debug timings), formatBytes (e2e cache stats), formatSize (the HTML reporter's embedded page note), and duration in scripts/bench-ab/markdown.ts. The two size helpers moved into their own small modules so their tests use the production code.
  • Apart from formatTime in report/format.ts, none are left. It prints 1000ms for 999.6ms, but it copies vitest's format, which prints 1000ms for exactly 1000 too, so I left it.

Issue

Fixes #2090

Verified

Ran it locally: yes

formatter input main this branch
formatDuration 999.6ms 1000ms 1.0s
formatDuration 59_949ms (unchanged) 59.9s 59.9s
formatDuration 59_960ms 60.0s 1m 0s
formatDuration 119_600ms (unchanged) 2m 0s 2m 0s
formatMs 9_999.6ms 10000ms 10.0s
formatBytes 1_048_575 B 1024.0 KiB 1.0 MiB
formatSize 1_047_553 B 1024 KB 1.0 MB
bench-ab duration 999.6ms 1000 ms 1.00 s

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

View guided diff

@Wali05
Wali05 requested a review from okwasniewski as a code owner November 23, 2026 09:57
@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 23, 2026

@cubic-dev-ai cubic-dev-ai 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.

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 okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[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)

  • e2e gets 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, e2e markdown-duration.test.ts + cli-cache-bytes.test.ts, html-reporter format-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 (1000ms vs 1.0s, 1024.0 KiB vs 1.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 check is green.
  • Changesets are all patch. No any, no dashes, files are small.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 23, 2026

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

@okwasniewski
okwasniewski merged commit 634d060 into e2e-inc:main Nov 23, 2026
31 checks passed
kblok added a commit to hardkoded/e2e-dotnet that referenced this pull request Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown report shows 1000ms and 60.0s for durations just under a unit

2 participants