Skip to content

Traffic: a session's duration rounds before it picks its unit - #382

Merged
fylorn merged 1 commit into
ThinkWatchProject:devfrom
RaphaelFakhri:fix/span-round-before-unit
Oct 30, 2026
Merged

fylorn merged 1 commit into
ThinkWatchProject:devfrom
RaphaelFakhri:fix/span-round-before-unit

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

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

  • Added a case to src/format.test.ts (span(59_600) is "1 分", span(3_570_000) is "1.0 小时"). Without the fix it fails with Received: "60 秒"; with the fix pnpm exec vitest run src/format.test.ts passes 53 of 53.
  • pnpm test: 120 files, 1322 tests pass.
  • pnpm typecheck is clean.

Fixes #381

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

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md for the branch contract.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@RaphaelFakhri

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 29, 2026
@fylorn
fylorn merged commit 6acc47c into ThinkWatchProject:dev Oct 30, 2026
7 of 8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session duration reads "60 s" or "60 min" near a unit boundary

2 participants