GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(mobile): Usage uses the width on iPad and unfolded phones (#26061) · pingdotgg/t3code@9ff0597

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/mobile/src/features/usage
    • UsageLimitsPooled.tsx
    • UsageRouteScreen.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Copy file name to clipboardExpand all lines: apps/mobile/src/features/usage/UsageLimitsPooled.tsx
+202-85Lines changed: 202 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,43 @@ import { usageProviderKind, useProviderColors } from "./usageProviders";
3131
const DRIVER_LABEL: Partial<Record<string, string>> = {
3232
codex: "Codex",
3333
claudeAgent: "Claude",
34+
grok: "Grok",
3435
antigravity: "Antigravity",
3536
};
3637
const PACE_LABEL = { ahead: "Ahead of pace", on: "On pace", under: "Under pace" } as const;
3738

3839
function accountName(account: LimitAccount) {
3940
if (account.displayName) return account.displayName;
4041
if (!account.email) return DRIVER_LABEL[account.driver] ?? String(account.driver);
41-
const [local = "", domain = ""] = account.email.split("@");
42-
return `${local[0] ?? ""}${domain[0] ?? ""}`.toUpperCase() || "Account";
42+
return emailInitials(account.email) || "Account";
43+
}
44+
45+
function emailInitials(email: string) {
46+
const [local = "", domain = ""] = email.split("@");
47+
return `${local[0] ?? ""}${domain[0] ?? ""}`.toUpperCase();
48+
}
49+
50+
function accountHue(email: string) {
51+
let hash = 0;
52+
for (let index = 0; index < email.length; index += 1) {
53+
hash = (hash * 31 + email.charCodeAt(index)) | 0;
54+
}
55+
return Math.abs(hash) % 360;
56+
}
57+
58+
// Same hashed hue as the web account chip, so an account keeps its color across clients.
59+
function AccountChip({ email }: { readonly email: string }) {
60+
const hue = accountHue(email);
61+
return (
62+
<View
63+
className="size-5 items-center justify-center rounded-full"
64+
style={{ backgroundColor: `hsl(${hue}, 45%, 82%)` }}
65+
>
66+
<Text className="text-[9px] font-t3-bold" style={{ color: `hsl(${hue}, 45%, 28%)` }}>
67+
{emailInitials(email)}
68+
</Text>
69+
</View>
70+
);
4371
}
4472

4573
// Same gap-and-tick as the Limits rows: two clipped copies of the segment leave a see-through gap.
@@ -141,15 +169,23 @@ function PoolWindowCard({
141169
environmentIds,
142170
label,
143171
description,
172+
wide,
144173
}: {
145174
readonly pool: LimitPoolWindow;
146175
readonly color: string;
147176
readonly now: number;
148177
readonly environmentIds: readonly string[] | null;
149178
readonly label?: string;
150179
readonly description?: string;
180+
readonly wide: boolean;
151181
}) {
152182
const navigation = useNavigation();
183+
const [barWidth, setBarWidth] = useState(0);
184+
// Each segment needs room for its account, percent and reset to label itself.
185+
const segmentWidth = barWidth / Math.max(pool.columns.length, 1);
186+
const inlineLabels = wide && segmentWidth >= 96;
187+
const inlineReset = wide && segmentWidth >= 150;
188+
const inlineName = wide && segmentWidth >= 220;
153189
const nextRefill = pool.resets.find((reset) => reset.restoresPercent > 0);
154190
const openAccount = (account: LimitAccount) =>
155191
navigation.navigate("SettingsUsageAccount", {
@@ -159,9 +195,9 @@ function PoolWindowCard({
159195
environmentIds,
160196
now,
161197
});
162-
return (
163-
<View className="gap-3 rounded-[24px] border-continuous bg-grouped-card p-4">
164-
<View className="flex-row items-start justify-between gap-3">
198+
const summary = (
199+
<>
200+
<View className={wide ? "gap-1" : "flex-row items-start justify-between gap-3"}>
165201
<View className="gap-1">
166202
<Text className="text-sm font-t3-medium text-foreground">{label ?? pool.label}</Text>
167203
<View className="flex-row items-baseline gap-1.5">
@@ -184,31 +220,89 @@ function PoolWindowCard({
184220
.replace("resets now", "now")}
185221
</Text>
186222
) : null}
187-
<View className="flex-row gap-1">
188-
{pool.columns.map((member, index) => {
189-
if (!member.window)
190-
return <View key={member.account.key} className="h-7 min-w-0 flex-1" />;
191-
const { account, window } = member;
192-
const timeLeft = paceRemainingPercent(window, now);
223+
</>
224+
);
225+
const bar = (
226+
<View
227+
className="flex-row gap-1"
228+
onLayout={(event) => setBarWidth(event.nativeEvent.layout.width)}
229+
>
230+
{pool.columns.map((member, index) => {
231+
if (!member.window)
193232
return (
194-
<Pressable
195-
key={account.key}
196-
accessibilityRole="button"
197-
accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left${timeLeft === null ? "" : `, ${timeLeft}% of the window left`}`}
198-
accessibilityHint="Show account details"
199-
onPress={() => openAccount(account)}
200-
className="h-7 min-w-0 flex-1 rounded-md"
201-
>
202-
<PaceGap timeLeft={timeLeft}>
203-
<View className="absolute inset-0 rounded-md bg-subtle" />
204-
<View className="absolute inset-0 overflow-hidden rounded-md">
205-
<AccountSegment
206-
remaining={remainingPercent(window)}
207-
color={color}
208-
refillPercent={window.resetsAt ? member.refillPercent : 0}
209-
/>
233+
<View
234+
key={member.account.key}
235+
className={wide ? "h-9 min-w-0 flex-1" : "h-7 min-w-0 flex-1"}
236+
/>
237+
);
238+
const { account, window } = member;
239+
const timeLeft = paceRemainingPercent(window, now);
240+
const credits = account.limits.resetCredits?.availableCount ?? 0;
241+
const resetsIn = formatResetsIn(window, now)?.replace("resets in ", "");
242+
return (
243+
<Pressable
244+
key={account.key}
245+
accessibilityRole="button"
246+
accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left${timeLeft === null ? "" : `, ${timeLeft}% of the window left`}`}
247+
accessibilityHint="Show account details"
248+
onPress={() => openAccount(account)}
249+
className={wide ? "h-9 min-w-0 flex-1 rounded-md" : "h-7 min-w-0 flex-1 rounded-md"}
250+
>
251+
<PaceGap timeLeft={timeLeft}>
252+
<View className="absolute inset-0 rounded-md bg-subtle" />
253+
<View className="absolute inset-0 overflow-hidden rounded-md">
254+
<AccountSegment
255+
remaining={remainingPercent(window)}
256+
color={color}
257+
refillPercent={window.resetsAt ? member.refillPercent : 0}
258+
/>
259+
</View>
260+
</PaceGap>
261+
{inlineLabels ? (
262+
<View
263+
pointerEvents="none"
264+
className="absolute inset-0 flex-row items-center justify-between gap-2 overflow-hidden rounded-md px-2"
265+
>
266+
<View className="min-w-0 shrink flex-row items-center gap-1.5">
267+
{account.email ? <AccountChip email={account.email} /> : null}
268+
{account.email && !(account.displayName && inlineName) ? null : (
269+
<Text
270+
numberOfLines={1}
271+
className="min-w-0 shrink text-xs font-t3-medium text-foreground"
272+
>
273+
{accountName(account)}
274+
</Text>
275+
)}
276+
<Text className="text-sm font-t3-bold tabular-nums text-foreground">
277+
{remainingPercent(window)}%
278+
</Text>
210279
</View>
211-
</PaceGap>
280+
{inlineReset && (resetsIn || credits) ? (
281+
<View className="shrink-0 flex-row items-center gap-1 rounded bg-grouped-card/85 px-1.5 py-0.5">
282+
{resetsIn ? (
283+
<>
284+
<SymbolView
285+
name="arrow.clockwise"
286+
size={11}
287+
tintColorClassName="accent-foreground-muted"
288+
/>
289+
<Text className="text-xs tabular-nums text-foreground-muted">
290+
{resetsIn}
291+
</Text>
292+
</>
293+
) : null}
294+
{credits ? (
295+
<>
296+
<SymbolView name="ticket" size={12} tintColorClassName="accent-icon" />
297+
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
298+
{credits}
299+
</Text>
300+
</>
301+
) : null}
302+
</View>
303+
) : null}
304+
</View>
305+
) : (
212306
<View
213307
pointerEvents="none"
214308
className="absolute inset-0 items-center justify-center overflow-hidden rounded-md"
@@ -220,65 +314,85 @@ function PoolWindowCard({
220314
{index + 1}
221315
</Text>
222316
</View>
223-
</Pressable>
224-
);
225-
})}
226-
</View>
227-
<View>
228-
{pool.columns.map(({ account, window }, index) => {
229-
if (!window) return null;
230-
const credits = account.limits.resetCredits?.availableCount ?? 0;
231-
const resetsIn = formatResetsIn(window, now);
232-
return (
233-
<Pressable
234-
key={account.key}
235-
accessibilityRole="button"
236-
accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left${resetsIn ? `, ${resetsIn}` : ""}${credits ? `, ${credits} reset credits banked` : ""}`}
237-
accessibilityHint="Show account details"
238-
onPress={() => openAccount(account)}
239-
className="min-h-[44px] flex-row items-center gap-2 active:opacity-60"
240-
>
241-
<View className="size-5 items-center justify-center overflow-hidden rounded-md bg-subtle-strong">
242-
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
243-
{index + 1}
244-
</Text>
245-
</View>
246-
<Text
247-
numberOfLines={1}
248-
className="min-w-0 flex-1 text-sm font-t3-medium text-foreground"
249-
>
250-
{accountName(account)}
251-
</Text>
252-
<Text className="text-sm font-t3-medium tabular-nums text-foreground">
253-
{remainingPercent(window)}%
317+
)}
318+
</Pressable>
319+
);
320+
})}
321+
</View>
322+
);
323+
const legend = (
324+
<View>
325+
{pool.columns.map(({ account, window }, index) => {
326+
if (!window) return null;
327+
const credits = account.limits.resetCredits?.availableCount ?? 0;
328+
const resetsIn = formatResetsIn(window, now);
329+
return (
330+
<Pressable
331+
key={account.key}
332+
accessibilityRole="button"
333+
accessibilityLabel={`Segment ${index + 1}, ${accountName(account)}, ${remainingPercent(window)}% left${resetsIn ? `, ${resetsIn}` : ""}${credits ? `, ${credits} reset credits banked` : ""}`}
334+
accessibilityHint="Show account details"
335+
onPress={() => openAccount(account)}
336+
className="min-h-[44px] flex-row items-center gap-2 active:opacity-60"
337+
>
338+
<View className="size-5 items-center justify-center overflow-hidden rounded-md bg-subtle-strong">
339+
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
340+
{index + 1}
254341
</Text>
255-
<View className="flex-row items-center gap-1">
256-
{resetsIn ? (
257-
<>
258-
<SymbolView
259-
name="arrow.clockwise"
260-
size={12}
261-
tintColorClassName="accent-foreground-muted"
262-
/>
263-
<Text className="text-xs tabular-nums text-foreground-muted">
264-
{resetsIn.replace("resets in ", "")}
265-
</Text>
266-
</>
267-
) : null}
268-
{credits ? (
269-
<>
270-
{resetsIn ? <Text className="text-xs text-foreground-tertiary">·</Text> : null}
271-
<SymbolView name="ticket" size={13} tintColorClassName="accent-icon" />
272-
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
273-
{credits}
274-
</Text>
275-
</>
276-
) : null}
277-
</View>
278-
</Pressable>
279-
);
280-
})}
342+
</View>
343+
<Text
344+
numberOfLines={1}
345+
className="min-w-0 flex-1 text-sm font-t3-medium text-foreground"
346+
>
347+
{accountName(account)}
348+
</Text>
349+
<Text className="text-sm font-t3-medium tabular-nums text-foreground">
350+
{remainingPercent(window)}%
351+
</Text>
352+
<View className="flex-row items-center gap-1">
353+
{resetsIn ? (
354+
<>
355+
<SymbolView
356+
name="arrow.clockwise"
357+
size={12}
358+
tintColorClassName="accent-foreground-muted"
359+
/>
360+
<Text className="text-xs tabular-nums text-foreground-muted">
361+
{resetsIn.replace("resets in ", "")}
362+
</Text>
363+
</>
364+
) : null}
365+
{credits ? (
366+
<>
367+
{resetsIn ? <Text className="text-xs text-foreground-tertiary">·</Text> : null}
368+
<SymbolView name="ticket" size={13} tintColorClassName="accent-icon" />
369+
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
370+
{credits}
371+
</Text>
372+
</>
373+
) : null}
374+
</View>
375+
</Pressable>
376+
);
377+
})}
378+
</View>
379+
);
380+
if (wide) {
381+
return (
382+
<View className="flex-row items-center gap-6 rounded-[24px] border-continuous bg-grouped-card p-4">
383+
<View className="w-44 gap-1">{summary}</View>
384+
<View className="min-w-0 flex-1 gap-1">
385+
{bar}
386+
{inlineLabels ? null : legend}
387+
</View>
281388
</View>
389+
);
390+
}
391+
return (
392+
<View className="gap-3 rounded-[24px] border-continuous bg-grouped-card p-4">
393+
{summary}
394+
{bar}
395+
{legend}
282396
</View>
283397
);
284398
}
@@ -288,11 +402,13 @@ export function UsageLimitsSection({
288402
failedLabels,
289403
selectedEnvironmentIds,
290404
cursorPrompt,
405+
wide = false,
291406
}: {
292407
readonly now: number;
293408
readonly failedLabels: readonly string[];
294409
readonly selectedEnvironmentIds: ReadonlySet<EnvironmentId> | null;
295410
readonly cursorPrompt?: ReactNode;
411+
readonly wide?: boolean;
296412
}) {
297413
const presentations = useAtomValue(environmentPresentations.presentationsWithProvidersAtom);
298414
const selected =
@@ -347,6 +463,7 @@ export function UsageLimitsSection({
347463
}
348464
label={details?.label}
349465
description={details?.description}
466+
wide={wide}
350467
/>
351468
);
352469
})}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.