Skip to content

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

Closed

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.0s → 1m 0s, 1m 60s → 2m 0s, 59m 60s → 1h 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.0s → 1m 0s, 1m 60s → 2m 0s, 59m 60s → 1h 0m.

Activity

  1. added a commit that references this issue on Jul 20, 2026
    e1440e6
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

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions