Skip to content

[Bug]: duration formatters render 999.5–999.99ms as "1000ms" instead of "1s" #99978

Description

@devin-ai-integration

What happened

All three duration formatters check ms < 1000 before rounding, so inputs in [999.5, 1000) fall into the milliseconds branch and render as the out-of-scheme string "1000ms" instead of "1s".

Code:

Repro

formatDurationPrecise(999.6); // "1000ms" — expected "1s"
formatDurationCompact(999.6); // "1000ms" — expected "1s"
formatDurationHuman(999.6);   // "1000ms" — expected "1s"

Note the same file already guards the analogous rollover for token counts in formatTokenShort ("Rounding can reach 1000 … fall through to the million branch"), see src/shared/subagents-format.ts#L17-L24 — the duration helpers miss the same edge.

Expected

"1s" for any input that rounds to 1000ms (round first, or branch on the rounded value).

Impact

Cosmetic but user-visible: fractional millisecond timings (provider latency, tool timing) can display as 1000ms.

Environment

Current main (4287d26).

Found via source review (AI-assisted).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:current-main-reproClawSweeper found a high-confidence current-main issue reproduction.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦀 challenger crabExceptional issue quality: high-confidence current-main reproduction and actionable evidence.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions