From 2625327090115a630d97ff61257758c577589de7 Mon Sep 17 00:00:00 2001
From: Exotic <118054752+extoci@users.noreply.github.com>
Date: Sun, 11 Oct 2026 19:28:09 +0300
Subject: [PATCH] fix(usage): say resets momentarily in the final minute
(#17869)
---
.../src/features/usage/UsageLimitsPooled.tsx | 5 +++--
packages/shared/src/usageLimits.test.ts | 14 ++++++++++++++
packages/shared/src/usageLimits.ts | 4 +++-
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/apps/mobile/src/features/usage/UsageLimitsPooled.tsx b/apps/mobile/src/features/usage/UsageLimitsPooled.tsx
index 1dc9fc7043365eecfcea915aeafe1f6496e3be17..be9adb283488a5977e8ac5392d3d9e7587d12acc 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,
@@ -123,7 +122,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 3b74ffa3aa121416edc217a96d2b186f87a03592..657b84fd73141e997fdfc0c11707a0c8cbd34fc8 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 4a2f07f1df6caa83e8a35f442b9c6a3f3e336904..dd24b20c7e76958ec5bc48cde0e646f5ce018483 100644
--- a/packages/shared/src/usageLimits.ts
+++ b/packages/shared/src/usageLimits.ts
@@ -607,7 +607,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. */
--
2.54.0