The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
feat(web): usage limit rows show your pace and open the usage page (#38789)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Theo Browne committed
Nov 18, 2026 at 20:22 UTC
669e2ea8e776410aff941897359e3c314aad231c
1 file changed
+34
-12
apps/web/src/components/chat/ThreadDetailsUsage.tsx
+34
-12
@@ -8,9 +8,11 @@ import {
8
collectProviderUsageLimits,
9
type LimitPace,
10
paceOf,
11
+ paceRemainingPercent,
12
remainingPercent,
13
} from "@t3tools/shared/usageLimits";
14
import { formatDuration, limitsNotice } from "@t3tools/shared/usageLimitsCopy";
15
+import { Link } from "@tanstack/react-router";
16
import { msg, useGT, useLocale, useMessages } from "gt-react";
17
import type { ReactNode } from "react";
18
@@ -39,7 +41,7 @@ export interface ThreadDetailsUsageInput {
41
42
type UsageTone = "error" | "warning" | null;
43
42
-/** The selected provider's limit windows. Each row reads as room left. */
44
+/** The selected provider's limit windows. Each row reads as room left and opens the usage page. */
45
export function ThreadDetailsUsage({
46
providerInstanceId,
47
providers,
@@ -75,6 +77,7 @@ export function ThreadDetailsUsage({
77
tone={null}
78
value={gt("Unavailable")}
79
tooltip={<span className="text-foreground">{notice}</span>}
80
+ opensUsage
81
/>
82
) : (
83
limits.windows.map((window) => <LimitRow key={window.id} window={window} now={now} />)
@@ -163,19 +166,27 @@ function LimitRow({
166
const timestampFormat = usePrimarySettings((settings) => settings.timestampFormat);
167
const left = remainingPercent(window);
168
const pace = paceOf(window, now);
169
+ const timeLeft = paceRemainingPercent(window, now);
170
const resetsAt = window.resetsAt ? Date.parse(window.resetsAt) : Number.NaN;
171
return (
172
<UsageRow
173
label={window.label}
174
fill={left}
175
tone={left <= 10 ? "error" : left <= 20 ? "warning" : null}
176
+ tick={timeLeft}
177
value={`${left}%`}
178
ariaValue={gt("{left}% left", { left })}
179
+ opensUsage
180
tooltip={
181
<>
182
<span className="text-foreground">
183
{gt("{label}: {left}% left", { label: window.label, left })}
184
</span>
185
+ {pace && timeLeft !== null ? (
186
+ <span className="text-muted-foreground">
187
+ {m(PACE_LABEL[pace])} · {gt("{timeLeft}% of the window left", { timeLeft })}
188
+ </span>
189
+ ) : null}
190
{window.resetsAt && resetsAt > now ? (
191
<span className="text-muted-foreground">
192
{gt("Resets in {duration} · {time}", {
@@ -184,14 +195,13 @@ function LimitRow({
195
})}
196
</span>
197
) : null}
187
- {pace ? <span className="text-muted-foreground">{m(PACE_LABEL[pace])}</span> : null}
198
</>
199
}
200
/>
201
);
202
}
203
194
-/** One label, hairline, and value row; the whole row opens the details tooltip. */
204
+/** One label, hairline, and value row; the whole row opens the details tooltip. With `opensUsage` it links to the usage page. */
205
function UsageRow({
206
label,
207
fill,
@@ -201,6 +211,7 @@ function UsageRow({
211
ariaValue = value,
212
tooltip,
213
muted = false,
214
+ opensUsage = false,
215
}: {
216
readonly label: string;
217
/** Bar fill from 0 to 100. Null hides the bar. */
@@ -212,20 +223,28 @@ function UsageRow({
223
readonly ariaValue?: string;
224
readonly tooltip: ReactNode;
225
readonly muted?: boolean;
226
+ readonly opensUsage?: boolean;
227
}) {
228
const gt = useGT();
229
+ const rowProps = {
230
+ "aria-label": gt("{label}: {value}", { label, value: ariaValue }),
231
+ className: cn(
232
+ "col-span-3 grid h-6 grid-cols-subgrid items-center rounded-lg px-2.5 outline-none hover:bg-black/[0.035] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-black/[0.035] dark:hover:bg-white/[0.08] dark:data-popup-open:bg-white/[0.08]",
233
+ opensUsage
234
+ ? "group cursor-pointer active:bg-black/[0.06] dark:active:bg-white/[0.12]"
235
+ : "cursor-default",
236
+ ),
237
+ };
238
return (
239
<Tooltip>
240
<TooltipTrigger
241
render={
221
- <div
222
- tabIndex={0}
223
- aria-label={gt("{label}: {value}", { label, value: ariaValue })}
224
- className="col-span-3 grid h-6 cursor-default grid-cols-subgrid items-center rounded-lg px-2.5 outline-none hover:bg-black/[0.035] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring data-popup-open:bg-black/[0.035] dark:hover:bg-white/[0.08] dark:data-popup-open:bg-white/[0.08]"
225
- />
242
+ opensUsage ? <Link to="/usage" {...rowProps} /> : <div tabIndex={0} {...rowProps} />
243
}
244
>
228
- <span className="max-w-28 truncate text-muted-foreground">{label}</span>
245
+ <span className="max-w-28 truncate text-muted-foreground group-hover:text-foreground">
246
+ {label}
247
+ </span>
248
{fill !== null ? (
249
<span className="relative h-[3px] rounded-full bg-muted-foreground/30 dark:bg-muted-foreground/20">
250
{fill > 0 ? (
@@ -246,8 +265,8 @@ function UsageRow({
265
{tick !== null ? (
266
<span
267
aria-hidden
249
- className="absolute -top-[3px] h-[9px] w-px -translate-x-1/2 bg-foreground/60"
250
- style={{ left: `${tick}%` }}
268
+ className="absolute -top-[3px] h-[9px] w-px -translate-x-1/2 bg-foreground/75"
269
+ style={{ left: `clamp(0.5px, ${tick}%, calc(100% - 0.5px))` }}
270
/>
271
) : null}
272
</span>
@@ -271,7 +290,10 @@ function UsageRow({
290
</TooltipTrigger>
291
{/* Rows sit 8px inside the card; clear its edge instead of overlapping it. */}
292
<TooltipPopup side="left" sideOffset={16}>
274
- <div className="flex flex-col gap-0.5">{tooltip}</div>
293
+ <div className="flex flex-col gap-0.5">
294
+ {tooltip}
295
+ {opensUsage ? <span className="text-muted-foreground">{gt("Open usage")}</span> : null}
296
+ </div>
297
</TooltipPopup>
298
</Tooltip>
299
);