From 6a5148455986ef920e1819bc216eb2b88319c223 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Thu, 22 Oct 2026 06:25:27 -0500 Subject: [PATCH 1/3] test(web): cover compact diff count suffix overflow Co-Authored-By: GPT-6.1 Sol --- .../src/components/chat/DiffStatLabel.test.ts | 18 ++++++++++++++++++ apps/web/src/components/chat/DiffStatLabel.tsx | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 apps/web/src/components/chat/DiffStatLabel.test.ts diff --git a/apps/web/src/components/chat/DiffStatLabel.test.ts b/apps/web/src/components/chat/DiffStatLabel.test.ts new file mode 100644 index 0000000000000..d4af1408aee7b --- /dev/null +++ b/apps/web/src/components/chat/DiffStatLabel.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { formatCompactDiffCount } from "./DiffStatLabel"; + +describe("formatCompactDiffCount", () => { + it("promotes counts when rounding reaches the next suffix", () => { + expect([ + 999_499, + 999_500, + 999_999, + 1_000_000, + 999_499_999, + 999_500_000, + 999_999_999, + 1_000_000_000, + ].map(formatCompactDiffCount)).toEqual(["999k", "1m", "1m", "1m", "999m", "1b", "1b", "1b"]); + }); +}); diff --git a/apps/web/src/components/chat/DiffStatLabel.tsx b/apps/web/src/components/chat/DiffStatLabel.tsx index a4110afe8a235..043978d7bed35 100644 --- a/apps/web/src/components/chat/DiffStatLabel.tsx +++ b/apps/web/src/components/chat/DiffStatLabel.tsx @@ -5,7 +5,7 @@ export function hasNonZeroStat(stat: { additions: number; deletions: number }): return stat.additions > 0 || stat.deletions > 0; } -function formatCompactDiffCount(value: number): string { +export function formatCompactDiffCount(value: number): string { if (value < 1000) return String(value); if (value < 1_000_000) { const k = value / 1000; From f1817469a88034eea379996a10124aa0fd2a0d21 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Thu, 22 Oct 2026 06:29:33 -0500 Subject: [PATCH 2/3] fix(web): promote rounded diff counts to the next suffix Select the million and billion tiers at their rounding boundaries so compact labels never overflow to 1000k or 1000m. Co-Authored-By: GPT-6.1 Sol --- apps/web/src/components/chat/DiffStatLabel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/chat/DiffStatLabel.tsx b/apps/web/src/components/chat/DiffStatLabel.tsx index 043978d7bed35..423b1cafe0ffe 100644 --- a/apps/web/src/components/chat/DiffStatLabel.tsx +++ b/apps/web/src/components/chat/DiffStatLabel.tsx @@ -7,11 +7,11 @@ export function hasNonZeroStat(stat: { additions: number; deletions: number }): export function formatCompactDiffCount(value: number): string { if (value < 1000) return String(value); - if (value < 1_000_000) { + if (value < 999_500) { const k = value / 1000; return `${k < 10 ? k.toFixed(1).replace(/\.0$/, "") : Math.round(k)}k`; } - if (value < 1_000_000_000) { + if (value < 999_500_000) { const m = value / 1_000_000; return `${m < 10 ? m.toFixed(1).replace(/\.0$/, "") : Math.round(m)}m`; } From 8b29043505bda5f9d8eb52636483513f9b82c0e1 Mon Sep 17 00:00:00 2001 From: Victor Vogel Date: Thu, 22 Oct 2026 06:31:01 -0500 Subject: [PATCH 3/3] test(web): keep suffix regression checks focused Co-Authored-By: GPT-6.1 Sol --- apps/web/src/components/chat/DiffStatLabel.test.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/web/src/components/chat/DiffStatLabel.test.ts b/apps/web/src/components/chat/DiffStatLabel.test.ts index d4af1408aee7b..2ea8bcdb83559 100644 --- a/apps/web/src/components/chat/DiffStatLabel.test.ts +++ b/apps/web/src/components/chat/DiffStatLabel.test.ts @@ -4,15 +4,9 @@ import { formatCompactDiffCount } from "./DiffStatLabel"; describe("formatCompactDiffCount", () => { it("promotes counts when rounding reaches the next suffix", () => { - expect([ - 999_499, - 999_500, - 999_999, - 1_000_000, - 999_499_999, - 999_500_000, - 999_999_999, - 1_000_000_000, - ].map(formatCompactDiffCount)).toEqual(["999k", "1m", "1m", "1m", "999m", "1b", "1b", "1b"]); + expect(formatCompactDiffCount(999_499)).toBe("999k"); + expect(formatCompactDiffCount(999_500)).toBe("1m"); + expect(formatCompactDiffCount(999_499_999)).toBe("999m"); + expect(formatCompactDiffCount(999_500_000)).toBe("1b"); }); });