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(usage): offer separate Fable resets in the composer usage popup · ttv20/t3code@1e86d3a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • PATCH.md
  • apps
    • mobile/src/features/usage
      • UsageLimitsSection.tsx
    • server/src
      • provider
        • Drivers
          • ClaudeDriver.ts
        • ProviderInstanceRegistry.test.ts
        • claudeResetCredits.test.ts
        • claudeResetCredits.ts
        • model-manifest.json
      • ws.ts
    • web/src/components
      • chat
        • ComposerWeeklyUsageIndicator.browser.test.tsx
        • ComposerWeeklyUsageIndicator.tsx
      • usage
        • UsageLimits.tsx
        • UsageLimitsPooled.tsx
  • packages
    • client-runtime/src
      • locales
        • ar.json
        • fa.json
        • he.json
      • usageLocalization.test.ts
      • usageLocalization.ts
    • contracts/src
      • providerUsageLimits.ts
    • provider-core/src/server
      • driver.ts
    • shared/src
      • usageLimits.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎PATCH.md‎

Copy file name to clipboardExpand all lines: PATCH.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Each release also attaches `t3-<version>-linux-x64.tgz` for direct npm or Bun in
3232
- The web and desktop composer shows the selected account's reported five-hour and seven-day limits as two miniature meters in its original bottom spacing. Each meter includes a progress bar, used percentage, and minute-updated reset countdown. Usage above 80% is red.
3333
- The indicator reads upstream's provider usage-limit snapshot and adds no separate polling or persistence. Upstream refreshes provider status on its configured interval and from live turn events.
3434
- Clicking the meters opens the account email, every reported usage window, exact reset times, last-check time, and a manual refresh action. Available reset credits can be redeemed through the existing permission checks and confirmation dialog. Manual refresh uses upstream's targeted provider refresh.
35+
- Claude reset choices remain separate in the footer popup and usage views on web, desktop, and mobile. Each choice keeps its own credit ID, available count, expiry, and translated confirmation. A Fable reset restores Fable's allowance and returns its weekly usage; it does not reset the whole weekly allowance. Older servers without typed choices retain the existing reset action.
3536
- Upstream's `/usage-limits` feature remains available for full quota details and account/environment aggregation.
3637

3738
## Android local completion notifications
Collapse file

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

Copy file name to clipboardExpand all lines: apps/mobile/src/features/usage/UsageLimitsSection.tsx
+40-51Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { formatUiResetCreditChoices } from "@t3tools/client-runtime/usage-localization";
12
import { RegistryContext, useAtomMount, useAtomValue } from "@effect/atom-react";
23
import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display";
34
import {
@@ -14,7 +15,7 @@ import {
1415
type ServerProviderUsageWindow,
1516
} from "@t3tools/contracts";
1617
import {
17-
formatDuration,
18+
type ResetCreditChoice,
1819
limitsNotice,
1920
paceOf,
2021
paceRemainingPercent,
@@ -248,7 +249,7 @@ export function ResetCredits(props: {
248249
readonly now: number;
249250
readonly dense?: boolean;
250251
}) {
251-
const { t: uiT } = useUiLanguage();
252+
const { t: uiT, locale } = useUiLanguage();
252253

253254
const { environmentId, input, credits, now, dense = false } = props;
254255
const canManageProviders = useEnvironmentScope(environmentId, AuthProvidersManageScope);
@@ -259,21 +260,11 @@ export function ResetCredits(props: {
259260
const [status, setStatus] = useState<string | null>(null);
260261
if (dense && credits.availableCount === 0 && status === null) return null;
261262

262-
const expiresIn = credits.nextExpiresAt
263-
? formatDuration(Date.parse(credits.nextExpiresAt) - now)
264-
: null;
265-
const summary =
266-
credits.availableCount === 0
267-
? "No reset credits banked"
268-
: `${credits.availableCount} ${credits.availableCount === 1 ? "reset credit" : "reset credits"} banked${
269-
expiresIn ? ` · next expires in ${expiresIn}` : ""
270-
}`;
271-
272-
const redeem = async () => {
263+
const redeem = async (choice: ResetCreditChoice) => {
273264
if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
274265
setBusy(true);
275266
setStatus(null);
276-
const result = await consume({ environmentId, input });
267+
const result = await consume({ environmentId, input: choice.input });
277268
setBusy(false);
278269
if (result._tag === "Success") {
279270
setStatus(result.value.warning ?? OUTCOME_TEXT[result.value.outcome]);
@@ -286,52 +277,50 @@ export function ResetCredits(props: {
286277
);
287278
};
288279

289-
const confirm = () => {
280+
const confirm = (choice: ResetCreditChoice) => {
290281
if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return;
291-
Dialog.alert(
292-
uiT("Use a reset credit?"),
293-
uiT(
294-
"This redeems one credit on your account and clears the current rate-limit windows. It cannot be undone.",
295-
),
296-
[
297-
{ text: "Cancel", style: "cancel" },
298-
{ text: "Use credit", onPress: () => void redeem() },
299-
],
300-
);
282+
Dialog.alert(uiT("Use a reset credit?"), choice.confirmDescription, [
283+
{ text: uiT("Cancel"), style: "cancel" },
284+
{ text: uiT("Use credit"), onPress: () => void redeem(choice) },
285+
]);
301286
};
302287

303288
return (
304-
<View className="flex-row flex-wrap items-center gap-x-3 gap-y-1">
305-
<Text className="text-xs tabular-nums text-foreground-tertiary">{summary}</Text>
306-
{credits.availableCount > 0 ? (
307-
<Pressable
308-
accessibilityRole="button"
309-
accessibilityState={{ disabled: busy || !canManageProviders }}
310-
disabled={busy || !canManageProviders}
311-
onPress={confirm}
312-
className={
313-
dense
314-
? "rounded-full bg-subtle-strong px-2.5 py-1 disabled:opacity-[0.45]"
315-
: "min-h-[44px] justify-center rounded-full bg-subtle-strong px-3 py-1.5 disabled:opacity-[0.45]"
316-
}
317-
>
318-
<Text
319-
className={
320-
dense
321-
? "text-xs font-t3-medium text-foreground"
322-
: "text-sm font-t3-medium text-foreground"
323-
}
324-
>
325-
{busy ? uiT("Using…") : uiT("Use reset")}
326-
</Text>
327-
</Pressable>
328-
) : null}
289+
<View className="gap-1">
290+
{formatUiResetCreditChoices(credits, input, now, locale).map((choice) => (
291+
<View key={choice.key} className="flex-row flex-wrap items-center gap-x-3 gap-y-1">
292+
<Text className="text-xs tabular-nums text-foreground-tertiary">{choice.summary}</Text>
293+
{choice.availableCount > 0 ? (
294+
<Pressable
295+
accessibilityRole="button"
296+
accessibilityState={{ disabled: busy || !canManageProviders }}
297+
disabled={busy || !canManageProviders}
298+
onPress={() => confirm(choice)}
299+
className={
300+
dense
301+
? "rounded-full bg-subtle-strong px-2.5 py-1 disabled:opacity-[0.45]"
302+
: "min-h-[44px] justify-center rounded-full bg-subtle-strong px-3 py-1.5 disabled:opacity-[0.45]"
303+
}
304+
>
305+
<Text
306+
className={
307+
dense
308+
? "text-xs font-t3-medium text-foreground"
309+
: "text-sm font-t3-medium text-foreground"
310+
}
311+
>
312+
{busy ? uiT("Using…") : choice.actionLabel}
313+
</Text>
314+
</Pressable>
315+
) : null}
316+
</View>
317+
))}
329318
{!canManageProviders ? (
330319
<Text className="text-xs text-foreground-tertiary">
331320
{uiT("This connection cannot manage provider accounts.")}
332321
</Text>
333322
) : null}
334-
{status ? <Text className="text-sm text-foreground">{status}</Text> : null}
323+
{status ? <Text className="text-sm text-foreground">{uiT(status)}</Text> : null}
335324
</View>
336325
);
337326
}
Collapse file

‎apps/server/src/provider/Drivers/ClaudeDriver.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeDriver.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,15 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
309309
const consumeResetCredit: NonNullable<ProviderInstance["consumeResetCredit"]> = Effect.fn(
310310
"ClaudeDriver.consumeResetCredit",
311311
)(
312-
function* () {
312+
function* (creditId) {
313313
const current = yield* snapshot.getSnapshot;
314-
const grantId = current.usageLimits?.resetCredits?.nextCreditId;
314+
const credits = current.usageLimits?.resetCredits;
315+
const grantId =
316+
creditId === undefined
317+
? credits?.nextCreditId
318+
: credits?.options?.some((option) => option.creditId === creditId)
319+
? creditId
320+
: undefined;
315321
if (!grantId || !current.version) return "noCredit" as const;
316322
const version = current.version;
317323
return yield* resetCreditCoordinator.redeem(
Collapse file

‎apps/server/src/provider/ProviderInstanceRegistry.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/ProviderInstanceRegistry.test.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ describe("ProviderInstanceRegistry — multi-instance codex slice", () => {
664664
const before = yield* instance!.snapshot.refresh;
665665
expect(before.usageLimits?.windows[0]?.usedPercent).toBe(100);
666666
expect(before.usageLimits?.resetCredits?.nextCreditId).toBe("grant_a");
667-
const outcome = yield* instance!.consumeResetCredit!().pipe(Effect.result);
667+
const outcome = yield* instance!.consumeResetCredit!(undefined).pipe(Effect.result);
668668
return { outcome, after: yield* instance!.snapshot.getSnapshot };
669669
}).pipe(
670670
// macOS logins live in the Keychain, where resets are never read.
Collapse file

‎apps/server/src/provider/claudeResetCredits.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/claudeResetCredits.test.ts
+43-1Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,51 @@ describe("claudeResetCreditsToContract", () => {
6262
availableCount: 2,
6363
nextCreditId: "grant_a",
6464
nextExpiresAt: "2026-10-01T00:00:00.000Z",
65+
options: [
66+
expect.objectContaining({
67+
creditId: "grant_a",
68+
label: "Full reset",
69+
availableCount: 2,
70+
expiresAt: "2026-10-01T00:00:00.000Z",
71+
}),
72+
],
6573
});
6674
});
6775

76+
it("offers each kind of reset by its own grant", () => {
77+
const credits = ClaudeResetCredits.claudeResetCreditsToContract(
78+
{
79+
eligible: true,
80+
next_grant_id: "weekly_a",
81+
grants: [
82+
grant({ id: "weekly_a", clears: ["seven_day"], ends_at: "2026-12-10T22:00:00Z" }),
83+
grant({
84+
id: "fable_a",
85+
clears: ["seven_day_overage_included"],
86+
gives_back_weekly: true,
87+
ends_at: "2027-03-09T07:59:00Z",
88+
}),
89+
grant({ id: "fable_b", gives_back_weekly: true, type: "weekly" }),
90+
grant({ id: "session_a", type: "session" }),
91+
grant({ id: "spent", clears: ["seven_day"], resets_left: 0 }),
92+
],
93+
},
94+
NOW,
95+
);
96+
expect(
97+
credits?.options?.map(({ creditId, label, availableCount }) => [
98+
creditId,
99+
label,
100+
availableCount,
101+
]),
102+
).toEqual([
103+
["session_a", "5-hour reset", 1],
104+
["weekly_a", "Weekly reset", 1],
105+
["fable_a", "Fable reset", 2],
106+
]);
107+
expect(credits).toMatchObject({ availableCount: 4, nextCreditId: "weekly_a" });
108+
});
109+
68110
it("offers nothing to redeem without a usable next grant or an eligible account", () => {
69111
expect(
70112
ClaudeResetCredits.claudeResetCreditsToContract(
@@ -111,7 +153,7 @@ effectIt.layer(NodeServices.layer)("readClaudeResetCredits", (it) => {
111153
Effect.provideService(HostProcess.Platform, "linux"),
112154
Effect.provideService(HttpClient.HttpClient, client),
113155
);
114-
expect(credits).toEqual({ availableCount: 1, nextCreditId: "grant_a" });
156+
expect(credits).toMatchObject({ availableCount: 1, nextCreditId: "grant_a" });
115157
}),
116158
);
117159

Collapse file

‎apps/server/src/provider/claudeResetCredits.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/claudeResetCredits.ts
+58-4Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
ProviderConsumeResetCreditOutcome,
3+
ServerProviderResetCreditOption,
34
ServerProviderResetCredits,
45
} from "@t3tools/contracts";
56
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -31,6 +32,9 @@ const Grant = Schema.Struct({
3132
ends_at: Schema.optional(Schema.NullOr(Schema.String)),
3233
paused: Schema.optional(Schema.Boolean),
3334
usable_now: Schema.optional(Schema.Boolean),
35+
clears: Schema.optional(Schema.Array(Schema.Unknown)),
36+
type: Schema.optional(Schema.Unknown),
37+
gives_back_weekly: Schema.optional(Schema.Boolean),
3438
});
3539
const decodeGrant = Schema.decodeUnknownOption(Grant);
3640
const CedarEmber = Schema.Struct({
@@ -95,6 +99,31 @@ const isFutureTimestamp = (value: string, nowMs: number) => {
9599
);
96100
};
97101

102+
// Claude Code's own grouping: a grant that gives back weekly usage is a Fable reset, else its
103+
// declared type, else what it clears.
104+
const RESET_KINDS = {
105+
session: { label: "5-hour reset", description: "Refills your 5-hour limit." },
106+
weekly: { label: "Weekly reset", description: "Refills your weekly limit." },
107+
fable: {
108+
label: "Fable reset",
109+
description:
110+
"Refills your Fable allowance and gives back what Fable used on your weekly limit. It doesn't reset your whole week.",
111+
},
112+
full: { label: "Full reset", description: "Refills your 5-hour and weekly limits." },
113+
} as const;
114+
type ResetKind = keyof typeof RESET_KINDS;
115+
116+
const grantKind = (grant: typeof Grant.Type): ResetKind => {
117+
if (grant.gives_back_weekly) return "fable";
118+
if (grant.type === "session" || grant.type === "weekly" || grant.type === "full") {
119+
return grant.type;
120+
}
121+
const clears = grant.clears ?? [];
122+
const session = clears.includes("five_hour");
123+
const other = clears.some((limit) => limit !== "five_hour");
124+
return session && !other ? "session" : other && !session ? "weekly" : "full";
125+
};
126+
98127
export function claudeResetCreditsToContract(
99128
block: unknown,
100129
nowMs: number,
@@ -110,13 +139,38 @@ export function claudeResetCreditsToContract(
110139
(grant.ends_at == null || isFutureTimestamp(grant.ends_at, nowMs)),
111140
);
112141
const next = live.find((grant) => grant.id === parsed.value.next_grant_id);
113-
const nextExpiresAt = next?.ends_at ? DateTime.make(next.ends_at) : Option.none();
142+
const expiresAt = (grant: typeof Grant.Type | undefined) => {
143+
const at = grant?.ends_at ? DateTime.make(grant.ends_at) : Option.none();
144+
return Option.isSome(at) ? DateTime.formatIso(at.value) : undefined;
145+
};
146+
const byKind = new Map<ResetKind, Array<typeof Grant.Type>>();
147+
for (const grant of live) {
148+
if (grant.resets_left === 0) continue;
149+
const kind = grantKind(grant);
150+
byKind.set(kind, [...(byKind.get(kind) ?? []), grant]);
151+
}
152+
const options = (Object.keys(RESET_KINDS) as Array<ResetKind>).flatMap(
153+
(kind): Array<ServerProviderResetCreditOption> => {
154+
const grants = byKind.get(kind);
155+
const target = grants?.[0];
156+
if (!grants || !target) return [];
157+
const optionExpiresAt = expiresAt(target);
158+
return [
159+
{
160+
creditId: target.id,
161+
...RESET_KINDS[kind],
162+
availableCount: grants.reduce((sum, grant) => sum + grant.resets_left, 0),
163+
...(optionExpiresAt ? { expiresAt: optionExpiresAt } : {}),
164+
},
165+
];
166+
},
167+
);
168+
const nextExpiresAt = expiresAt(next);
114169
return {
115170
availableCount: next ? live.reduce((sum, grant) => sum + grant.resets_left, 0) : 0,
116-
...(Option.isSome(nextExpiresAt)
117-
? { nextExpiresAt: DateTime.formatIso(nextExpiresAt.value) }
118-
: {}),
171+
...(nextExpiresAt ? { nextExpiresAt } : {}),
119172
...(next ? { nextCreditId: next.id } : {}),
173+
...(next ? { options } : {}),
120174
};
121175
}
122176

Collapse file

‎apps/server/src/provider/model-manifest.json‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/model-manifest.json
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"updatedAt": "2026-11-05T22:38:29Z",
3+
"updatedAt": "2026-11-09T19:07:56Z",
44
"compatibility": [
55
{
66
"driver": "codex",
@@ -125,7 +125,7 @@
125125
"gpt-daybreak-blue-latest",
126126
"gpt-daybreak-red-latest"
127127
],
128-
"claudeAgent": ["claude-fable-5-1", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"],
128+
"claudeAgent": ["claude-fable-5-2", "claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"],
129129
"antigravity": ["gemini-3.8-flash-high", "gemini-3.8-flash-medium", "gemini-3.8-flash-low"]
130130
},
131131
"providers": {
@@ -757,11 +757,19 @@
757757
"profile": "sonnet-5-5",
758758
"adapter": { "claudeCode": { "minVersion": "2.1.284" } }
759759
},
760+
{
761+
"slug": "claude-fable-5-2",
762+
"name": "Claude Fable 5.2",
763+
"aliases": ["fable", "fable-5.2", "claude-fable-5.2"],
764+
"status": "current",
765+
"profile": "fable-5",
766+
"adapter": { "claudeCode": { "minVersion": "2.1.290" } }
767+
},
760768
{
761769
"slug": "claude-fable-5-1",
762770
"name": "Claude Fable 5.1",
763-
"aliases": ["fable", "fable-5.1", "claude-fable-5.1"],
764-
"status": "current",
771+
"aliases": ["fable-5.1", "claude-fable-5.1"],
772+
"status": "legacy",
765773
"profile": "fable-5",
766774
"adapter": {
767775
"claudeCode": {
Collapse file

‎apps/server/src/ws.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/ws.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ export const layerWsRpc = (
26442644
detail: "This provider does not bank reset credits.",
26452645
});
26462646
}
2647-
const outcome = yield* instance.consumeResetCredit().pipe(
2647+
const outcome = yield* instance.consumeResetCredit(input.creditId).pipe(
26482648
Effect.mapError(
26492649
(error) =>
26502650
new ProviderSetupError({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — 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.