GeezerVison is showing github.com — feat(usage): offer separate Fable resets in the composer usage popup · ttv20/t3code@1e86d3a
File treeExpand file treeCollapse file tree Open diff view settings mobile/src/features/usage
Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -32,6 +32,7 @@ Each release also attaches `t3-<version>-linux-x64.tgz` for direct npm or Bun in | 32 | 32 | - 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. | 33 | 33 | - 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. | 34 | 34 | - 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. | 35 | 36 | - Upstream's `/usage-limits` feature remains available for full quota details and account/environment aggregation. | 36 | 37 |
| 37 | 38 | ## Android local completion notifications | |
Collapse file Copy file name to clipboardExpand all lines: apps/mobile/src/features/usage/UsageLimitsSection.tsx +40-51Lines changed: 40 additions & 51 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { formatUiResetCreditChoices } from "@t3tools/client-runtime/usage-localization"; | 1 | 2 | import { RegistryContext, useAtomMount, useAtomValue } from "@effect/atom-react"; | 2 | 3 | import { normalizeProviderAccentColor } from "@t3tools/client-runtime/state/provider-instance-display"; | 3 | 4 | import { | @@ -14,7 +15,7 @@ import { | 14 | 15 | type ServerProviderUsageWindow, | 15 | 16 | } from "@t3tools/contracts"; | 16 | 17 | import { | 17 | | - formatDuration, | | 18 | + type ResetCreditChoice, | 18 | 19 | limitsNotice, | 19 | 20 | paceOf, | 20 | 21 | paceRemainingPercent, | @@ -248,7 +249,7 @@ export function ResetCredits(props: { | 248 | 249 | readonly now: number; | 249 | 250 | readonly dense?: boolean; | 250 | 251 | }) { | 251 | | - const { t: uiT } = useUiLanguage(); | | 252 | + const { t: uiT, locale } = useUiLanguage(); | 252 | 253 |
| 253 | 254 | const { environmentId, input, credits, now, dense = false } = props; | 254 | 255 | const canManageProviders = useEnvironmentScope(environmentId, AuthProvidersManageScope); | @@ -259,21 +260,11 @@ export function ResetCredits(props: { | 259 | 260 | const [status, setStatus] = useState<string | null>(null); | 260 | 261 | if (dense && credits.availableCount === 0 && status === null) return null; | 261 | 262 |
| 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) => { | 273 | 264 | if (!readEnvironmentScope(environmentId, AuthProvidersManageScope)) return; | 274 | 265 | setBusy(true); | 275 | 266 | setStatus(null); | 276 | | - const result = await consume({ environmentId, input }); | | 267 | + const result = await consume({ environmentId, input: choice.input }); | 277 | 268 | setBusy(false); | 278 | 269 | if (result._tag === "Success") { | 279 | 270 | setStatus(result.value.warning ?? OUTCOME_TEXT[result.value.outcome]); | @@ -286,52 +277,50 @@ export function ResetCredits(props: { | 286 | 277 | ); | 287 | 278 | }; | 288 | 279 |
| 289 | | - const confirm = () => { | | 280 | + const confirm = (choice: ResetCreditChoice) => { | 290 | 281 | 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 | + ]); | 301 | 286 | }; | 302 | 287 |
| 303 | 288 | 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 | + ))} | 329 | 318 | {!canManageProviders ? ( | 330 | 319 | <Text className="text-xs text-foreground-tertiary"> | 331 | 320 | {uiT("This connection cannot manage provider accounts.")} | 332 | 321 | </Text> | 333 | 322 | ) : null} | 334 | | - {status ? <Text className="text-sm text-foreground">{status}</Text> : null} | | 323 | + {status ? <Text className="text-sm text-foreground">{uiT(status)}</Text> : null} | 335 | 324 | </View> | 336 | 325 | ); | 337 | 326 | } | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeDriver.ts +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -309,9 +309,15 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path. | 309 | 309 | const consumeResetCredit: NonNullable<ProviderInstance["consumeResetCredit"]> = Effect.fn( | 310 | 310 | "ClaudeDriver.consumeResetCredit", | 311 | 311 | )( | 312 | | - function* () { | | 312 | + function* (creditId) { | 313 | 313 | 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; | 315 | 321 | if (!grantId || !current.version) return "noCredit" as const; | 316 | 322 | const version = current.version; | 317 | 323 | return yield* resetCreditCoordinator.redeem( | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/ProviderInstanceRegistry.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -664,7 +664,7 @@ describe("ProviderInstanceRegistry — multi-instance codex slice", () => { | 664 | 664 | const before = yield* instance!.snapshot.refresh; | 665 | 665 | expect(before.usageLimits?.windows[0]?.usedPercent).toBe(100); | 666 | 666 | 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); | 668 | 668 | return { outcome, after: yield* instance!.snapshot.getSnapshot }; | 669 | 669 | }).pipe( | 670 | 670 | // macOS logins live in the Keychain, where resets are never read. | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/claudeResetCredits.test.ts +43-1Lines changed: 43 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,9 +62,51 @@ describe("claudeResetCreditsToContract", () => { | 62 | 62 | availableCount: 2, | 63 | 63 | nextCreditId: "grant_a", | 64 | 64 | 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 | + ], | 65 | 73 | }); | 66 | 74 | }); | 67 | 75 |
| | 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 | + | 68 | 110 | it("offers nothing to redeem without a usable next grant or an eligible account", () => { | 69 | 111 | expect( | 70 | 112 | ClaudeResetCredits.claudeResetCreditsToContract( | @@ -111,7 +153,7 @@ effectIt.layer(NodeServices.layer)("readClaudeResetCredits", (it) => { | 111 | 153 | Effect.provideService(HostProcess.Platform, "linux"), | 112 | 154 | Effect.provideService(HttpClient.HttpClient, client), | 113 | 155 | ); | 114 | | - expect(credits).toEqual({ availableCount: 1, nextCreditId: "grant_a" }); | | 156 | + expect(credits).toMatchObject({ availableCount: 1, nextCreditId: "grant_a" }); | 115 | 157 | }), | 116 | 158 | ); | 117 | 159 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/claudeResetCredits.ts +58-4Lines changed: 58 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { | 2 | 2 | ProviderConsumeResetCreditOutcome, | | 3 | + ServerProviderResetCreditOption, | 3 | 4 | ServerProviderResetCredits, | 4 | 5 | } from "@t3tools/contracts"; | 5 | 6 | import * as HostProcess from "@t3tools/shared/HostProcess"; | @@ -31,6 +32,9 @@ const Grant = Schema.Struct({ | 31 | 32 | ends_at: Schema.optional(Schema.NullOr(Schema.String)), | 32 | 33 | paused: Schema.optional(Schema.Boolean), | 33 | 34 | 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), | 34 | 38 | }); | 35 | 39 | const decodeGrant = Schema.decodeUnknownOption(Grant); | 36 | 40 | const CedarEmber = Schema.Struct({ | @@ -95,6 +99,31 @@ const isFutureTimestamp = (value: string, nowMs: number) => { | 95 | 99 | ); | 96 | 100 | }; | 97 | 101 |
| | 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 | + | 98 | 127 | export function claudeResetCreditsToContract( | 99 | 128 | block: unknown, | 100 | 129 | nowMs: number, | @@ -110,13 +139,38 @@ export function claudeResetCreditsToContract( | 110 | 139 | (grant.ends_at == null || isFutureTimestamp(grant.ends_at, nowMs)), | 111 | 140 | ); | 112 | 141 | 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); | 114 | 169 | return { | 115 | 170 | 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 } : {}), | 119 | 172 | ...(next ? { nextCreditId: next.id } : {}), | | 173 | + ...(next ? { options } : {}), | 120 | 174 | }; | 121 | 175 | } | 122 | 176 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/model-manifest.json +12-4Lines changed: 12 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "version": 1, | 3 | | - "updatedAt": "2026-11-05T22:38:29Z", | | 3 | + "updatedAt": "2026-11-09T19:07:56Z", | 4 | 4 | "compatibility": [ | 5 | 5 | { | 6 | 6 | "driver": "codex", | | 125 | 125 | "gpt-daybreak-blue-latest", | 126 | 126 | "gpt-daybreak-red-latest" | 127 | 127 | ], | 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"], | 129 | 129 | "antigravity": ["gemini-3.8-flash-high", "gemini-3.8-flash-medium", "gemini-3.8-flash-low"] | 130 | 130 | }, | 131 | 131 | "providers": { | | 757 | 757 | "profile": "sonnet-5-5", | 758 | 758 | "adapter": { "claudeCode": { "minVersion": "2.1.284" } } | 759 | 759 | }, | | 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 | + }, | 760 | 768 | { | 761 | 769 | "slug": "claude-fable-5-1", | 762 | 770 | "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", | 765 | 773 | "profile": "fable-5", | 766 | 774 | "adapter": { | 767 | 775 | "claudeCode": { | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/ws.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2644,7 +2644,7 @@ export const layerWsRpc = ( | 2644 | 2644 | detail: "This provider does not bank reset credits.", | 2645 | 2645 | }); | 2646 | 2646 | } | 2647 | | - const outcome = yield* instance.consumeResetCredit().pipe( | | 2647 | + const outcome = yield* instance.consumeResetCredit(input.creditId).pipe( | 2648 | 2648 | Effect.mapError( | 2649 | 2649 | (error) => | 2650 | 2650 | new ProviderSetupError({ | |
|