diff --git a/apps/mobile/src/features/usage/UsageLimitsPooled.tsx b/apps/mobile/src/features/usage/UsageLimitsPooled.tsx index ae2938476559..7a2f4d8ad44a 100644 --- a/apps/mobile/src/features/usage/UsageLimitsPooled.tsx +++ b/apps/mobile/src/features/usage/UsageLimitsPooled.tsx @@ -8,7 +8,6 @@ import { collectLimitPools, cursorUsageWindowDetails, displayLimitWindows, - formatDuration, formatResetsIn, remainingPercent, type LimitAccount, @@ -119,7 +118,9 @@ function PoolWindowCard({ {nextRefill ? ( ↻ +{nextRefill.restoresPercent}%{" "} - {nextRefill.at <= now ? "now" : `in ${formatDuration(nextRefill.at - now)}`} + {formatResetsIn(nextRefill.member.window, now) + ?.replace("resets in ", "in ") + .replace("resets now", "now")} ) : null} diff --git a/packages/shared/src/usageLimits.test.ts b/packages/shared/src/usageLimits.test.ts index 668103302417..69e526871c83 100644 --- a/packages/shared/src/usageLimits.test.ts +++ b/packages/shared/src/usageLimits.test.ts @@ -56,6 +56,20 @@ function provider(overrides: Partial): ServerProvider { } describe("pace", () => { + it.each([ + ["2026-09-03T12:01:00.000Z", "resets in 1m"], + ["2026-09-03T12:00:59.999Z", "Resets momentarily"], + ["2026-09-03T12:00:00.001Z", "Resets momentarily"], + ["2026-09-03T12:00:00.000Z", "resets now"], + ["2026-09-03T11:59:59.999Z", "resets now"], + ])("formats the reset boundary at %s", (resetsAt, label) => { + expect(formatResetsIn({ ...window, resetsAt }, now)).toBe(label); + }); + + it("ignores invalid reset timestamps", () => { + expect(formatResetsIn({ ...window, resetsAt: "invalid" }, now)).toBeNull(); + }); + it("places the clock three fifths through a five-hour window with two hours left", () => { expect(elapsedShare(window, now)).toBeCloseTo(0.6); expect(paceOf(window, now)).toBe("under"); diff --git a/packages/shared/src/usageLimits.ts b/packages/shared/src/usageLimits.ts index 85c5e6e39f88..4e78c29be01d 100644 --- a/packages/shared/src/usageLimits.ts +++ b/packages/shared/src/usageLimits.ts @@ -596,7 +596,9 @@ export function formatDuration(ms: number): string { export function formatResetsIn(window: ServerProviderUsageWindow, now: number): string | null { const resetsAt = resetMillis(window); if (resetsAt === null) return null; - return resetsAt <= now ? "resets now" : `resets in ${formatDuration(resetsAt - now)}`; + if (resetsAt <= now) return "resets now"; + if (resetsAt - now < MINUTE) return "Resets momentarily"; + return `resets in ${formatDuration(resetsAt - now)}`; } /** Limit commands are served by T3 from the same snapshots as Usage → Limits. */