From 823d368bf62d03d2b2dc3b2585217b54ea91f06d Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sat, 17 Oct 2026 18:30:45 -0400 Subject: [PATCH 1/2] fix(cli): carry rounded-up seconds and kilobytes into the next unit Co-Authored-By: Claude Sonnet 5.5 --- packages/cli/src/ui/format.test.ts | 29 +++++++++++++++++++++++++++++ packages/cli/src/ui/format.ts | 14 ++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/ui/format.test.ts b/packages/cli/src/ui/format.test.ts index f1d13fe2496..938d3a4a92a 100644 --- a/packages/cli/src/ui/format.test.ts +++ b/packages/cli/src/ui/format.test.ts @@ -1,6 +1,8 @@ import { describe, expect, it } from "vitest"; import { + formatBytes, + formatDuration, formatRenderPipelineDetail, formatRenderSummaryDetail, formatScreenshotFallbackHint, @@ -168,3 +170,30 @@ describe("formatRenderSummaryDetail", () => { ); }); }); + +describe("formatDuration", () => { + it("shows seconds with one decimal under a minute", () => { + expect(formatDuration(0)).toBe("0.0s"); + expect(formatDuration(1234)).toBe("1.2s"); + expect(formatDuration(59_940)).toBe("59.9s"); + }); + + it("carries a rounded-up 60.0 seconds into the next minute", () => { + expect(formatDuration(59_960)).toBe("1m 0.0s"); + expect(formatDuration(119_970)).toBe("2m 0.0s"); + }); + + it("splits minutes and seconds past one minute", () => { + expect(formatDuration(60_000)).toBe("1m 0.0s"); + expect(formatDuration(83_400)).toBe("1m 23.4s"); + }); +}); + +describe("formatBytes", () => { + it("steps up a unit when rounding reaches the next one", () => { + expect(formatBytes(1023)).toBe("1023 B"); + expect(formatBytes(1536)).toBe("1.5 KB"); + expect(formatBytes(1_048_575)).toBe("1.0 MB"); + expect(formatBytes(1_048_576)).toBe("1.0 MB"); + }); +}); diff --git a/packages/cli/src/ui/format.ts b/packages/cli/src/ui/format.ts index df3d2683d20..55f1b40772f 100644 --- a/packages/cli/src/ui/format.ts +++ b/packages/cli/src/ui/format.ts @@ -3,16 +3,18 @@ import { c } from "./colors.js"; export function formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B`; - if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + // Round first so 1048575 B reads "1.0 MB", never "1024.0 KB". + const kb = Math.round((bytes / 1024) * 10) / 10; + if (kb < 1024) return `${kb.toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; } export function formatDuration(ms: number): string { - const seconds = ms / 1000; - if (seconds < 60) return `${seconds.toFixed(1)}s`; - const minutes = Math.floor(seconds / 60); - const remaining = seconds - minutes * 60; - return `${minutes}m ${remaining.toFixed(1)}s`; + // Work in rounded tenths so 59.96s reads "1m 0.0s", never "60.0s" or "1m 60.0s". + const tenths = Math.round(ms / 100); + if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`; + const minutes = Math.floor(tenths / 600); + return `${minutes}m ${((tenths - minutes * 600) / 10).toFixed(1)}s`; } /** From 2bd496485abc30198d4e135c325c974d869af0d5 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sun, 18 Oct 2026 12:18:43 -0400 Subject: [PATCH 2/2] chore(cli): drop added comments to satisfy comment ratchet Co-Authored-By: Claude Sonnet 5.5 --- packages/cli/src/ui/format.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/cli/src/ui/format.ts b/packages/cli/src/ui/format.ts index 55f1b40772f..c908beb375f 100644 --- a/packages/cli/src/ui/format.ts +++ b/packages/cli/src/ui/format.ts @@ -3,14 +3,12 @@ import { c } from "./colors.js"; export function formatBytes(bytes: number): string { if (bytes < 1024) return `${bytes} B`; - // Round first so 1048575 B reads "1.0 MB", never "1024.0 KB". const kb = Math.round((bytes / 1024) * 10) / 10; if (kb < 1024) return `${kb.toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; } export function formatDuration(ms: number): string { - // Work in rounded tenths so 59.96s reads "1m 0.0s", never "60.0s" or "1m 60.0s". const tenths = Math.round(ms / 100); if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`; const minutes = Math.floor(tenths / 600);