From 8f53b0e406e43360bed55613ecd8ec18d35a14e2 Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Mon, 26 Oct 2026 02:13:31 +0000 Subject: [PATCH 1/2] fix(chrome-extension): show hours in recording timers The recording timer on the page and in the popup, and recording durations on the options page, counted minutes past 59, so a recording 1 h 5 m 5 s long read 65:05. Print H:MM:SS from an hour on; shorter times print as before. --- .../src/shared/format-duration.test.ts | 19 ++++++++++++++ .../src/shared/format-duration.ts | 25 ++++++++++--------- 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 apps/chrome-extension/src/shared/format-duration.test.ts diff --git a/apps/chrome-extension/src/shared/format-duration.test.ts b/apps/chrome-extension/src/shared/format-duration.test.ts new file mode 100644 index 00000000000..c449375daa9 --- /dev/null +++ b/apps/chrome-extension/src/shared/format-duration.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest"; +import { formatDuration, formatRecordedDuration } from "./format-duration"; + +describe("recording durations", () => { + it("keeps M:SS under an hour", () => { + expect(formatDuration(0)).toBe("0:00"); + expect(formatDuration(95_700)).toBe("1:35"); + expect(formatDuration(3_599_999)).toBe("59:59"); + expect(formatRecordedDuration(400)).toBe("0:01"); + expect(formatRecordedDuration(95_500)).toBe("1:36"); + }); + + it("shows hours from an hour on instead of counting minutes past 59", () => { + expect(formatDuration(3_600_000)).toBe("1:00:00"); + expect(formatDuration(3_905_900)).toBe("1:05:05"); + expect(formatRecordedDuration(3_599_600)).toBe("1:00:00"); + expect(formatRecordedDuration(3_905_000)).toBe("1:05:05"); + }); +}); diff --git a/apps/chrome-extension/src/shared/format-duration.ts b/apps/chrome-extension/src/shared/format-duration.ts index 8ec62b3802b..07ed159c26a 100644 --- a/apps/chrome-extension/src/shared/format-duration.ts +++ b/apps/chrome-extension/src/shared/format-duration.ts @@ -1,17 +1,18 @@ +const formatClock = (totalSeconds: number) => { + const hours = Math.floor(totalSeconds / 3600); + const minutes = Math.floor(totalSeconds / 60) % 60; + const seconds = (totalSeconds % 60).toString().padStart(2, "0"); + return hours > 0 + ? `${hours}:${minutes.toString().padStart(2, "0")}:${seconds}` + : `${minutes}:${seconds}`; +}; + // Live timers (recording bars) count up from 0:00 and truncate so the // display never runs ahead of the actual elapsed time. -export const formatDuration = (durationMs: number) => { - const totalSeconds = Math.max(0, Math.floor(durationMs / 1000)); - const minutes = Math.floor(totalSeconds / 60); - const seconds = totalSeconds % 60; - return `${minutes}:${seconds.toString().padStart(2, "0")}`; -}; +export const formatDuration = (durationMs: number) => + formatClock(Math.max(0, Math.floor(durationMs / 1000))); // Finished recordings round to the nearest second and never show 0:00 — a // sub-second capture still represents real data. -export const formatRecordedDuration = (durationMs: number) => { - const totalSeconds = Math.max(1, Math.round(durationMs / 1000)); - const minutes = Math.floor(totalSeconds / 60); - const seconds = totalSeconds % 60; - return `${minutes}:${seconds.toString().padStart(2, "0")}`; -}; +export const formatRecordedDuration = (durationMs: number) => + formatClock(Math.max(1, Math.round(durationMs / 1000))); From 6b6b50c30c1c3d809f20a4f4d9bf0b816da328ac Mon Sep 17 00:00:00 2001 From: Paddy <89168564+patrickballard@users.noreply.github.com> Date: Mon, 26 Oct 2026 02:13:31 +0000 Subject: [PATCH 2/2] fix(mobile): show hours in chapter times A cap's chapter list counted minutes past 59, so a chapter 1 h 5 m in read 65:05. Move formatChapterTime into utils/format with hours from an hour on, and make the label's 44 pt width a minimum, since from two hours on some labels measure up to 46.3 pt. --- apps/mobile/app/caps/[id].tsx | 12 ++---------- apps/mobile/src/utils/format.test.ts | 15 ++++++++++++++- apps/mobile/src/utils/format.ts | 10 ++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/apps/mobile/app/caps/[id].tsx b/apps/mobile/app/caps/[id].tsx index 45c5d46cac1..86d933cb389 100644 --- a/apps/mobile/app/caps/[id].tsx +++ b/apps/mobile/app/caps/[id].tsx @@ -46,7 +46,7 @@ import { GlassSurface } from "@/components/GlassSurface"; import { ReactionBar, type ReactionCount } from "@/components/ReactionBar"; import { Screen } from "@/components/Screen"; import { colors, fonts, radius, squircle } from "@/theme"; -import { formatRelativeDate } from "@/utils/format"; +import { formatChapterTime, formatRelativeDate } from "@/utils/format"; const showPhotosSettingsAlert = () => { if (Platform.OS === "ios") { @@ -106,14 +106,6 @@ const sectionEntrance = (order: number) => .stiffness(220) .delay(order * 55); -const formatChapterTime = (start: number) => { - const minutes = Math.floor(start / 60); - const seconds = Math.floor(start % 60) - .toString() - .padStart(2, "0"); - return `${minutes}:${seconds}`; -}; - type CapDetailOperation = "comment" | "safety" | "save" | "visibility"; type AnalyticsMetricProps = { @@ -1691,7 +1683,7 @@ const styles = StyleSheet.create({ borderColor: colors.gray5, }, chapterTime: { - width: 44, + minWidth: 44, fontFamily: fonts.medium, fontSize: 13, color: colors.blue11, diff --git a/apps/mobile/src/utils/format.test.ts b/apps/mobile/src/utils/format.test.ts index 1ef39850004..82475a65e63 100644 --- a/apps/mobile/src/utils/format.test.ts +++ b/apps/mobile/src/utils/format.test.ts @@ -1,5 +1,10 @@ import { describe, expect, it } from "vitest"; -import { formatDuration, formatFileSize, formatRelativeDate } from "./format"; +import { + formatChapterTime, + formatDuration, + formatFileSize, + formatRelativeDate, +} from "./format"; describe("mobile formatters", () => { it("formats card dates like Cap web", () => { @@ -24,6 +29,14 @@ describe("mobile formatters", () => { expect(formatDuration(7200)).toBe("2 hrs"); }); + it("formats chapter times with hours from an hour on", () => { + expect(formatChapterTime(0)).toBe("0:00"); + expect(formatChapterTime(95.7)).toBe("1:35"); + expect(formatChapterTime(3599.9)).toBe("59:59"); + expect(formatChapterTime(3600)).toBe("1:00:00"); + expect(formatChapterTime(3905)).toBe("1:05:05"); + }); + it("formats native upload file sizes", () => { expect(formatFileSize(null)).toBeNull(); expect(formatFileSize(0)).toBeNull(); diff --git a/apps/mobile/src/utils/format.ts b/apps/mobile/src/utils/format.ts index a8b43469f65..1713e6ae439 100644 --- a/apps/mobile/src/utils/format.ts +++ b/apps/mobile/src/utils/format.ts @@ -39,6 +39,16 @@ export const formatDuration = (seconds: number | null) => { return "< 1 sec"; }; +export const formatChapterTime = (seconds: number) => { + const total = Math.max(0, Math.floor(seconds)); + const hours = Math.floor(total / 3600); + const minutes = Math.floor(total / 60) % 60; + const secs = (total % 60).toString().padStart(2, "0"); + return hours > 0 + ? `${hours}:${minutes.toString().padStart(2, "0")}:${secs}` + : `${minutes}:${secs}`; +}; + export const formatFileSize = (bytes: number | null | undefined) => { if (bytes === null || bytes === undefined || !Number.isFinite(bytes)) { return null;