Skip to content

Commit e415b3c

Browse files
committed
fix(mobile): preserve current widget limits beside failed accounts
1 parent 0ef1591 commit e415b3c

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,11 @@ export function UsageLimitsSection({
449449
key={account.key}
450450
className="flex-row items-center gap-3 rounded-[24px] border-continuous bg-grouped-card p-4"
451451
>
452-
{account.email ? <AccountChip email={account.email} /> : null}
452+
<View className="size-5 items-center justify-center rounded-md bg-subtle-strong">
453+
<Text className="text-xs font-t3-medium tabular-nums text-foreground">
454+
{pool.accounts.indexOf(account) + 1}
455+
</Text>
456+
</View>
453457
<Text className="min-w-0 flex-1 text-sm font-t3-medium text-foreground">
454458
{accountName(account)}
455459
</Text>

‎apps/mobile/src/widgets/subscriptionUsageSnapshot.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { describe, expect, it, vi } from "vite-plus/test";
99
import {
1010
buildSubscriptionUsageSnapshot,
11+
subscriptionUsageTimeline,
1112
createWidgetRefresher,
1213
WIDGET_REFRESH_INTERVAL,
1314
} from "./subscriptionUsageSnapshot";
@@ -118,7 +119,7 @@ describe("subscription widget snapshots", () => {
118119
id: "failed-account",
119120
120121
usageLimits: {
121-
checkedAt,
122+
checkedAt: windows.length > 0 ? checkedAt : "2026-09-05T11:00:00.000Z",
122123
windows,
123124
unavailable: { reason: "probeFailed" as const },
124125
},
@@ -143,6 +144,9 @@ describe("subscription widget snapshots", () => {
143144
const partial = buildSubscriptionUsageSnapshot(failedInput([], true), deepLink);
144145
expect(partial.providers[0]?.detail).toBe("Available subscription limits");
145146
expect(partial.providers[0]?.windows[0]?.remaining).toBe(60);
147+
expect(partial.checkedAt).toBe(now);
148+
expect(partial.providers[0]?.expiresAt).toBe(now + 10 * 60_000);
149+
expect(subscriptionUsageTimeline(partial, now)[0]?.props.providers[0]?.windows).toHaveLength(1);
146150
const retained = buildSubscriptionUsageSnapshot(failedInput(limits.windows), deepLink);
147151
expect(retained.providers[0]?.detail).toBe("Last known limits");
148152
expect(retained.providers[0]?.windows[0]).toMatchObject({

‎apps/mobile/src/widgets/subscriptionUsageSnapshot.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ function subscriptionUsageProps(
5252
): SubscriptionUsageSnapshot {
5353
const pools = collectLimitPools(accounts, now);
5454
const checked = accounts
55-
.filter((account) => account.driver === "codex" || account.driver === "claudeAgent")
55+
.filter(
56+
(account) =>
57+
account.limits.windows.length > 0 &&
58+
(account.driver === "codex" || account.driver === "claudeAgent"),
59+
)
5660
.map((account) => Date.parse(account.limits.checkedAt));
5761
return {
5862
checkedAt: checked.length > 0 && checked.every(Number.isFinite) ? Math.min(...checked) : 0,
@@ -72,7 +76,11 @@ function subscriptionUsageProps(
7276
expiresAt: 0,
7377
totalWindows: 0,
7478
};
75-
const checkedAt = Math.min(...pool.accounts.map((a) => Date.parse(a.limits.checkedAt)));
79+
const checkedAt = Math.min(
80+
...pool.accounts
81+
.filter((account) => account.limits.windows.length > 0)
82+
.map((account) => Date.parse(account.limits.checkedAt)),
83+
);
7684
const expiresAt = Math.min(
7785
checkedAt + SNAPSHOT_MAX_AGE,
7886
...pool.windows.flatMap((window) => window.resets.map((reset) => reset.at)),

‎apps/server/src/usage/cliproxyApi.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ export const makeCliproxyApi = Effect.gen(function* () {
608608
accountId: string,
609609
creditId: string,
610610
): Effect.fn.Return<ProviderConsumeResetCreditResult, UsageLimitSourceError> {
611+
// The enclosing CliproxyApi.consume span covers this inline helper.
611612
const redeem = Effect.fnUntraced(function* (account: AuthFile) {
612613
const body = yield* apiCall(
613614
hub,

0 commit comments

Comments
 (0)