Repository navigation
Traffic: a session's duration rounds before it picks its unit - #382
Merged
fylorn merged 1 commit intoOct 30, 2026
Merged
Conversation
A session of 59.6 s read "60 s" and one of 59.5 min read "60 min": span() picked the unit from the raw value and rounded afterwards. Round first, then pick, as msShort already does.
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md for the branch contract. |
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 this changes
The duration in the session panel picks seconds, minutes or hours after rounding. A 59.6-second session now reads "1 min" instead of "60 s", and a 59.5-minute session reads "1.0 h" instead of "60 min".
Why
span()chose the unit from the raw value and rounded within it, so values just under a boundary rounded up to 60 of the smaller unit.msShort()already rounds first for the same reason.How it was verified
src/format.test.ts(span(59_600)is "1 分",span(3_570_000)is "1.0 小时"). Without the fix it fails withReceived: "60 秒"; with the fixpnpm exec vitest run src/format.test.tspasses 53 of 53.pnpm test: 120 files, 1322 tests pass.pnpm typecheckis clean.Fixes #381