Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/mobile/src/features/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
collectLimitPools,
cursorUsageWindowDetails,
displayLimitWindows,
formatDuration,
formatResetsIn,
remainingPercent,
type LimitAccount,
Expand Down Expand Up @@ -119,7 +118,9 @@ function PoolWindowCard({
{nextRefill ? (
<Text className="text-xs tabular-nums text-foreground-muted">
↻ +{nextRefill.restoresPercent}%{" "}
{nextRefill.at <= now ? "now" : `in ${formatDuration(nextRefill.at - now)}`}
{formatResetsIn(nextRefill.member.window, now)
?.replace("resets in ", "in ")
.replace("resets now", "now")}
</Text>
) : null}
<View className="flex-row gap-1">
Expand Down
14 changes: 14 additions & 0 deletions packages/shared/src/usageLimits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ function provider(overrides: Partial<ServerProvider>): 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");
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/src/usageLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading