Skip to content

formatDuration emits invalid strings at rounding boundaries ("60.0s", "1m 60s", "59m 60s") #521

Description

@chhhee10

Description

formatDuration (lib/format-duration.ts:17) rounds the seconds component after it has
already committed to a minute/hour bucket, so when the rounded value lands on 60 it is never
carried up. This produces strings that are never supposed to exist.

This function is reused for tool-call durations across lib/codex-sessions.ts,
lib/cursor-sessions.ts, lib/goose-sessions.ts, and session duration in lib/log-stats.ts,
so these malformed strings surface on real transcripts in the dashboard/CLI.

Steps to Reproduce

import { formatDuration } from "./lib/format-duration";

formatDuration(59999);   // => "60.0s"   (expected "1m 0s")
formatDuration(119600);  // => "1m 60s"  (expected "2m 0s")
formatDuration(3599600); // => "59m 60s" (expected "1h 0m")

Expected Behavior

Durations should always be normalised: 60.0s1m 0s, 1m 60s2m 0s, 59m 60s1h 0m.

Failproof AI Version

0.0.14-beta.1

Node.js / Bun Version

Bun 1.3+

Operating System

macOS

Additional Context

Durations should always be normalised: 60.0s1m 0s, 1m 60s2m 0s, 59m 60s1h 0m.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions