Repository navigation
Description
Context
formatDuration (packages/ui-react/src/lib/duration.ts:2-10) rounds the seconds part on its own, after it has already taken the minutes, so the seconds can round up to 60 without carrying. It also rounds sub-minute values to one decimal without carrying into minutes. Run against the current tree:
| Input (ms) | Output | Expected |
|---|---|---|
59_950 |
60.0s |
1m 0s |
59_999 |
60.0s |
1m 0s |
119_500 |
1m 60s |
2m 0s |
3_599_500 |
59m 60s |
60m 0s |
It labels every run duration, approval wait and timeline row in Activity. Callers include activity-run-list.tsx:42, :71; activity-run-detail.tsx:189, :267, :299, :353; run-lanes.tsx:43, :64; turn-timing.tsx:6-17; and tool-call-timeline.tsx:168, :426. There are 20 call sites in all. Its tests (packages/ui-react/tests/tool-views.test.ts:162-173) cover only exact boundaries.
Guide: js/format-human-readable-durations (the fix needs no Intl; consolidation is #2606).
Scope
- Round the whole value to the precision that will be displayed before splitting it into units: tenths of a second below one minute, whole seconds from one minute up. A value that rounds to 60.0s renders as
1m 0s. - Add the four rows above, plus
999.9 → "1.0s"and60_000 → "1m 0s", to theformatDurationtests.
Out of scope
- An hours unit.
3_600_000stays60m 0shere, and ui-react: one locale-pinned time formatter module on Intl.RelativeTimeFormat and Intl.DurationFormat #2606 owns the format. Intl.DurationFormat, and any other formatter.- Callers.
Acceptance criteria
-
formatDuration(119_500) === "2m 0s",formatDuration(59_950) === "1m 0s"andformatDuration(3_599_500) === "60m 0s". - No output of
formatDurationcontains60sor60.0s. A test sweeps 0–7_200_000 ms in 50 ms steps and asserts that the seconds part is below 60 everywhere. - The new tests fail on the tree before the change and pass after. Record both runs in the PR.
- Existing expectations (
0.5s,2.5s,1m 0s,1m 30s) are unchanged.
Verification
bun run test packages/ui-react/tests/tool-views.test.ts
bun run test
bun run typecheck
bun run lintContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
@schlessera/brain-ui-react: patch.
Activity