@devries-cameron20 / t3code-1 / commits / 6343c28d95
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(usage): show even-pace marks on Limits bars (#14477)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

oliver committed Oct 19, 2026 at 10:29 UTC 6343c28d950789e7ab1b1462ad18814744229dd5
7 files changed +84 -32
apps/mobile/src/features/usage/UsageLimitsPooled.tsx
+32 -9
@@ -9,6 +9,7 @@ import {
9 cursorUsageWindowDetails,
10 displayLimitWindows,
11 formatResetsIn,
12 + paceRemainingPercent,
13 remainingPercent,
14 type LimitAccount,
15 type LimitPoolWindow,
@@ -146,22 +147,38 @@ function PoolWindowCard({
147 if (!member.window)
148 return <View key={member.account.key} className="h-7 min-w-0 flex-1" />;
149 const { account, window } = member;
150 + const timeLeft = paceRemainingPercent(window, now);
151 return (
152 <Pressable
153 key={account.key}
154 accessibilityRole="button"
153 - accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left`}
155 + accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left${timeLeft === null ? "" : `, ${timeLeft}% of the window left`}`}
156 accessibilityHint="Show account details"
157 onPress={() => openAccount(account)}
156 - className="h-7 min-w-0 flex-1 overflow-hidden rounded-md bg-subtle"
158 + className="h-7 min-w-0 flex-1 rounded-md bg-subtle"
159 >
158 - <AccountSegment
159 - remaining={remainingPercent(window)}
160 - color={color}
161 - refillPercent={window.resetsAt ? member.refillPercent : 0}
162 - />
163 - <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
164 - <Text className="text-xs font-t3-medium tabular-nums text-foreground">
160 + <View className="absolute inset-0 overflow-hidden rounded-md">
161 + <AccountSegment
162 + remaining={remainingPercent(window)}
163 + color={color}
164 + refillPercent={window.resetsAt ? member.refillPercent : 0}
165 + />
166 + </View>
167 + {timeLeft !== null ? (
168 + <View
169 + pointerEvents="none"
170 + className="absolute -top-1 -bottom-1 w-0.5 -translate-x-px rounded-full bg-foreground-muted"
171 + style={{ left: `${timeLeft}%` }}
172 + />
173 + ) : null}
174 + <View
175 + pointerEvents="none"
176 + className="absolute inset-0 items-center justify-center overflow-hidden rounded-md"
177 + >
178 + <Text
179 + numberOfLines={1}
180 + className="max-w-full shrink text-xs font-t3-medium tabular-nums text-foreground"
181 + >
182 {index + 1}
183 </Text>
184 </View>
@@ -370,6 +387,7 @@ export function UsageLimitAccountScreen({ route }: AccountScreenProps) {
387 .find((candidate) => candidate.driver === account?.driver)
388 ?.windows.find((candidate) => candidate.id === windowId && candidate.kind === windowKind);
389 const window = pool?.members.find((member) => member.account.key === accountKey)?.window;
390 + const evenPace = window ? paceRemainingPercent(window, now) : null;
391 const reset = pool?.resets.find((candidate) => candidate.member.account.key === accountKey);
392 const [revealed, setRevealed] = useState(false);
393 return (
@@ -424,6 +442,11 @@ export function UsageLimitAccountScreen({ route }: AccountScreenProps) {
442 })}
443 </Text>
444 ) : null}
445 + {evenPace !== null ? (
446 + <Text className="text-sm text-foreground-muted">
447 + Even pace: {evenPace}% left by now
448 + </Text>
449 + ) : null}
450 {reset && reset.restoresPercent > 0 ? (
451 <Text className="text-sm text-foreground-muted">
452 Restores {reset.restoresPercent}% of the pool
apps/mobile/src/features/usage/UsageLimitsSection.tsx
+2 -3
@@ -10,11 +10,11 @@ import {
10 type ServerProviderUsageWindow,
11 } from "@t3tools/contracts";
12 import {
13 - elapsedShare,
13 formatDuration,
14 formatResetsIn,
15 limitsNotice,
16 paceOf,
17 + paceRemainingPercent,
18 remainingPercent,
19 } from "@t3tools/shared/usageLimits";
20 import { type ReactNode, useEffect, useEffectEvent, useRef, useState } from "react";
@@ -46,8 +46,7 @@ function WindowRow(props: {
46 }) {
47 const { window, now } = props;
48 const remaining = remainingPercent(window);
49 - const elapsed = elapsedShare(window, now);
50 - const timeLeft = elapsed === null ? null : Math.round((1 - elapsed) * 100);
49 + const timeLeft = paceRemainingPercent(window, now);
50 const pace = paceOf(window, now);
51 const resetsIn = formatResetsIn(window, now);
52 return (
apps/web/src/components/usage/UsageLimits.tsx
+2 -3
@@ -10,11 +10,11 @@ import {
10 } from "@t3tools/contracts";
11 import { useAtomValue } from "@effect/atom-react";
12 import {
13 - elapsedShare,
13 formatDuration,
14 formatResetsIn,
15 type LimitPace,
16 paceOf,
17 + paceRemainingPercent,
18 remainingPercent,
19 } from "@t3tools/shared/usageLimits";
20 import { GaugeIcon, TrendingDownIcon, TrendingUpIcon } from "lucide-react";
@@ -84,8 +84,7 @@ function WindowBar({
84 }) {
85 const timestampFormat = usePrimarySettings((settings) => settings.timestampFormat);
86 const remaining = remainingPercent(window);
87 - const elapsed = elapsedShare(window, now);
88 - const timeLeft = elapsed === null ? null : Math.round((1 - elapsed) * 100);
87 + const timeLeft = paceRemainingPercent(window, now);
88 const resetsIn = formatResetsIn(window, now);
89 const resetsAt = window.resetsAt
90 ? formatUpcomingTimestamp(window.resetsAt, timestampFormat, now)
apps/web/src/components/usage/UsageLimitsPooled.tsx
+29 -16
@@ -11,6 +11,7 @@ import {
11 type LimitPool,
12 type LimitPoolMember,
13 type LimitPoolWindow,
14 + paceRemainingPercent,
15 remainingPercent,
16 } from "@t3tools/shared/usageLimits";
17 import { AlertTriangleIcon, ExternalLinkIcon, TicketIcon } from "lucide-react";
@@ -137,6 +138,7 @@ function SegmentPopover({
138 }) {
139 const timestampFormat = usePrimarySettings((settings) => settings.timestampFormat);
140 const remaining = remainingPercent(window);
141 + const timeLeft = paceRemainingPercent(window, now);
142 const resetsIn = formatResetsIn(window, now);
143 const where =
144 account.environments.length > 0
@@ -177,6 +179,7 @@ function SegmentPopover({
179 {resetsIn ? ` · ${resetsIn.replace("resets in ", "in ")}` : ""}
180 </Row>
181 ) : null}
182 + {timeLeft !== null ? <Row label="Even pace">{timeLeft}% left by now</Row> : null}
183 {reset && reset.restoresPercent > 0 ? (
184 <Row label="Restores">+{reset.restoresPercent}% of pool</Row>
185 ) : null}
@@ -226,6 +229,7 @@ function PoolSegment({
229 }) {
230 const [open, setOpen] = useState(false);
231 const remaining = remainingPercent(window);
232 + const timeLeft = paceRemainingPercent(window, now);
233 const resetsIn = formatResetsIn(window, now);
234 const credits = account.limits.resetCredits?.availableCount ?? 0;
235 return (
@@ -236,33 +240,42 @@ function PoolSegment({
240 <button
241 type="button"
242 style={{ gridColumn: index, gridRow: 1 }}
239 - aria-label={`${account.displayName ?? (account.email ? accountInitials(account.email) : account.driver)}: ${remaining}% left${resetsIn ? `, ${resetsIn}` : ""}${credits ? `, ${credits} reset ${credits === 1 ? "credit" : "credits"} banked` : ""}`}
240 - className="relative h-5 min-w-0 cursor-pointer overflow-hidden rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border @2xl/pool:h-8"
243 + aria-label={`${account.displayName ?? (account.email ? accountInitials(account.email) : account.driver)}: ${remaining}% left${resetsIn ? `, ${resetsIn}` : ""}${timeLeft === null ? "" : `, ${timeLeft}% of the window left`}${credits ? `, ${credits} reset ${credits === 1 ? "credit" : "credits"} banked` : ""}`}
244 + className="relative h-5 min-w-0 cursor-pointer rounded-md bg-muted text-start outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background data-[popup-open]:ring-1 data-[popup-open]:ring-inset data-[popup-open]:ring-border @2xl/pool:h-8"
245 />
246 }
247 >
244 - <div
245 - aria-hidden
246 - className="absolute inset-y-0 left-0 rounded-md opacity-35"
247 - style={{ width: `${remaining}%`, backgroundColor: color }}
248 - />
249 - {remaining < 100 && reset && refillPercent > 0 ? (
248 + <div aria-hidden className="absolute inset-0 overflow-hidden rounded-md">
249 <div
250 aria-hidden
252 - className="absolute inset-y-0 right-0 opacity-20"
253 - style={{
254 - width: `${Math.min(100 - remaining, refillPercent)}%`,
255 - backgroundImage: `repeating-linear-gradient(135deg, ${color} 0 1px, transparent 1px 5px)`,
256 - }}
251 + className="absolute inset-y-0 left-0 rounded-md opacity-35"
252 + style={{ width: `${remaining}%`, backgroundColor: color }}
253 + />
254 + {remaining < 100 && reset && refillPercent > 0 ? (
255 + <div
256 + aria-hidden
257 + className="absolute inset-y-0 right-0 opacity-20"
258 + style={{
259 + width: `${Math.min(100 - remaining, refillPercent)}%`,
260 + backgroundImage: `repeating-linear-gradient(135deg, ${color} 0 1px, transparent 1px 5px)`,
261 + }}
262 + />
263 + ) : null}
264 + </div>
265 + {timeLeft !== null ? (
266 + <span
267 + aria-hidden
268 + className="absolute -inset-y-1 w-0.5 -translate-x-1/2 rounded-full bg-muted-foreground"
269 + style={{ left: `${timeLeft}%` }}
270 />
271 ) : null}
272 <span
273 aria-hidden
261 - className="absolute inset-0 flex items-center justify-center text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
274 + className="absolute inset-0 flex items-center justify-center overflow-hidden rounded-md text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
275 >
276 {index}
277 </span>
265 - <div className="relative hidden h-full min-w-0 items-center gap-1.5 px-2 text-xs @2xl/pool:flex">
278 + <div className="relative hidden h-full min-w-0 items-center gap-1.5 overflow-hidden rounded-md px-2 text-xs @2xl/pool:flex">
279 {showAccountName ? (
280 <AccountName
281 account={account}
@@ -271,7 +284,7 @@ function PoolSegment({
284 ) : null}
285 <span className="shrink-0 font-semibold text-foreground tabular-nums">{remaining}%</span>
286 {resetsIn || credits ? (
274 - <span className="ms-auto flex shrink-0 items-center gap-1.5 rounded-sm bg-background/85 px-1.5 py-0.5 text-2xs text-foreground tabular-nums">
287 + <span className="ms-auto flex min-w-0 items-center gap-1.5 overflow-hidden rounded-sm bg-background/85 px-1.5 py-0.5 text-2xs whitespace-nowrap text-foreground tabular-nums">
288 {resetsIn?.replace("resets in ", "↻ ") ?? ""}
289 {credits ? (
290 <>
apps/web/src/components/usage/UsagePage.refresh.browser.test.tsx
+1 -1
@@ -124,7 +124,7 @@ const setPresentations = (entries: ReadonlyArray<readonly [EnvironmentId, object
124 act(async () => appAtomRegistry.set(state.presentations, new Map(entries) as Presentations));
125 const setNow = (iso: string) => vi.mocked(Date.now).mockReturnValue(Date.parse(iso));
126 const resetsIn = (countdown: string) =>
127 - page.getByRole("button", { name: `codex: 60% left, resets in ${countdown}` });
127 + page.getByRole("button", { name: `codex: 60% left, resets in ${countdown}`, exact: false });
128 const refreshButton = () => page.getByRole("button", { name: "Refresh limits" });
129 const selectMetric = (label: string) => userEvent.click(page.getByRole("button", { name: label }));
130
packages/shared/src/usageLimits.test.ts
+9
@@ -22,6 +22,7 @@ import {
22 formatResetsIn,
23 limitsNotice,
24 paceOf,
25 + paceRemainingPercent,
26 providersWithLimits,
27 remainingPercent,
28 usesChatGptSharing,
@@ -72,6 +73,7 @@ describe("pace", () => {
73
74 it("places the clock three fifths through a five-hour window with two hours left", () => {
75 expect(elapsedShare(window, now)).toBeCloseTo(0.6);
76 + expect(paceRemainingPercent(window, now)).toBe(40);
77 expect(paceOf(window, now)).toBe("under");
78 expect(paceOf({ ...window, usedPercent: 62 }, now)).toBe("on");
79 expect(paceOf({ ...window, usedPercent: 80 }, now)).toBe("ahead");
@@ -80,9 +82,16 @@ describe("pace", () => {
82 it("has no pace without a reset or a duration", () => {
83 expect(paceOf({ ...window, resetsAt: undefined }, now)).toBeNull();
84 expect(paceOf({ ...window, windowDurationMins: undefined }, now)).toBeNull();
85 + expect(paceRemainingPercent({ ...window, resetsAt: undefined }, now)).toBeNull();
86 + expect(paceRemainingPercent({ ...window, windowDurationMins: undefined }, now)).toBeNull();
87 expect(formatResetsIn({ ...window, resetsAt: undefined }, now)).toBeNull();
88 });
89
90 + it("keeps pace marks within the bar before a window starts and after it expires", () => {
91 + expect(paceRemainingPercent(window, Date.parse("2026-09-03T08:00:00.000Z"))).toBe(100);
92 + expect(paceRemainingPercent(window, Date.parse("2026-09-03T15:00:00.000Z"))).toBe(0);
93 + });
94 +
95 it("phrases the reset as a countdown", () => {
96 expect(formatResetsIn(window, now)).toBe("resets in 2h 0m");
97 expect(formatResetsIn({ ...window, resetsAt: "2026-09-06T15:30:00.000Z" }, now)).toBe(
packages/shared/src/usageLimits.ts
+9
@@ -546,6 +546,15 @@ export function elapsedShare(window: ServerProviderUsageWindow, now: number): nu
546 return Math.max(0, Math.min(1, (length - (resetsAt - now)) / length));
547 }
548
549 +// Bars show quota remaining, so even pace tracks time remaining.
550 +export function paceRemainingPercent(
551 + window: ServerProviderUsageWindow,
552 + now: number,
553 +): number | null {
554 + const elapsed = elapsedShare(window, now);
555 + return elapsed === null ? null : Math.round((1 - elapsed) * 100);
556 +}
557 +
558 export type LimitPace = "ahead" | "on" | "under";
559
560 export function paceOf(window: ServerProviderUsageWindow, now: number): LimitPace | null {