Skip to content

ui-react: run durations read "1m 60s" and "60.0s" because rounded seconds never carry #2605

Open

Description

@schlessera

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" and 60_000 → "1m 0s", to the formatDuration tests.

Out of scope

Acceptance criteria

  • formatDuration(119_500) === "2m 0s", formatDuration(59_950) === "1m 0s" and formatDuration(3_599_500) === "60m 0s".
  • No output of formatDuration contains 60s or 60.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 lint

Contract impact

  • This touches the integration contract, so it needs the contract label, a CONTRACT: 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

  1. added
    type: fix
    area: ui-react
    priority: p2
    agent-ready
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-reactpriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions