From e63f39ad40d1181b0aafb811fb8ae37eb160a22e Mon Sep 17 00:00:00 2001 From: Alex Southwell <4596216+saphid@users.noreply.github.com> Date: Tue, 3 Nov 2026 11:21:17 +1100 Subject: [PATCH] fix(mobile): scheduled tasks due within the hour no longer read "Next run in 60 minutes" Co-Authored-By: Claude Opus 5.5 --- .../settings/scheduledTaskPresentation.test.ts | 13 +++++++++++++ .../features/settings/scheduledTaskPresentation.ts | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 apps/mobile/src/features/settings/scheduledTaskPresentation.test.ts diff --git a/apps/mobile/src/features/settings/scheduledTaskPresentation.test.ts b/apps/mobile/src/features/settings/scheduledTaskPresentation.test.ts new file mode 100644 index 0000000000000..02ca0a2d11c78 --- /dev/null +++ b/apps/mobile/src/features/settings/scheduledTaskPresentation.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from "vite-plus/test"; + +import { formatNextScheduledTaskRun } from "./scheduledTaskPresentation"; + +describe("formatNextScheduledTaskRun", () => { + it("names the rounded unit for a run later today", () => { + const now = new Date(2026, 10, 3, 10, 0, 0).getTime(); + const at = (minutes: number) => new Date(now + minutes * 60_000).toISOString(); + expect(formatNextScheduledTaskRun(at(59), now)).toBe("Next run in 59 minutes"); + expect(formatNextScheduledTaskRun(at(59.5), now)).toBe("Next run in 1 hour"); + expect(formatNextScheduledTaskRun(at(150), now)).toBe("Next run in 3 hours"); + }); +}); diff --git a/apps/mobile/src/features/settings/scheduledTaskPresentation.ts b/apps/mobile/src/features/settings/scheduledTaskPresentation.ts index 0fbc2626f1fbb..04fad7b3d3453 100644 --- a/apps/mobile/src/features/settings/scheduledTaskPresentation.ts +++ b/apps/mobile/src/features/settings/scheduledTaskPresentation.ts @@ -38,8 +38,10 @@ export function formatNextScheduledTaskRun(nextRunAt: string, now: number): stri const days = localCalendarDay(next) - localCalendarDay(current); if (days === 0) { if (remaining < MINUTE) return "Next run in less than a minute"; - const unit = remaining < HOUR ? "minute" : "hour"; - const count = Math.round(remaining / (remaining < HOUR ? MINUTE : HOUR)); + // Choose the unit after rounding so 59.5 minutes never renders as "60 minutes". + const minutes = Math.round(remaining / MINUTE); + const unit = minutes < 60 ? "minute" : "hour"; + const count = minutes < 60 ? minutes : Math.round(remaining / HOUR); return `Next run in ${count} ${unit}${count === 1 ? "" : "s"}`; }