fix(shared): redeem reset credits through the hub when it holds the account - #10462
Conversation
…ccount When a Codex account is signed in natively and also pooled behind a CLIProxyAPI hub, "Use reset" could redeem through either path. Which one it picked came down to whichever usage snapshot happened to be fresher, because one flag decided both which credit balance to display and which path to redeem through. Redeeming natively resets the subscription upstream but never calls the hub's `reset-quota`, so the hub kept refusing to route to an account that had just been reset, until its own cooldown expired days later. Split the two decisions. The displayed balance still follows the fresher snapshot; the redemption path now always prefers the hub when it has a credit for that account, falling back to the native instance only when the hub has nothing to redeem. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ApprovabilityVerdict: Would Approve Macroscope's review found this PR approvable — This is a small, self-contained usage-limit bug fix that changes only the redemption route for accounts duplicated between a native provider and a hub, while preserving the freshest displayed balance and all unaffected paths. Both shared aggregation paths have focused regression tests, with no schema, default, deployment, or static-analysis changes. Not approved because:
Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
collectLimitAccounts, which backs the pooled usage panel on web and mobile, picked its redemption target the same way the composer report did: whichever contributor had credits and the freshest snapshot. When a native instance read more recently than the hub, the panel redeemed natively and left the hub's cooldown armed. Prefer a hub redemption target whenever one exists, independent of freshness. A hub contributor only carries a target when it actually has a credit id, so the native fallback still covers the case where the hub has nothing to redeem. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
## What's Changed * fix(web): show load balancing note for a single machine by @maria-rcks in pingdotgg/t3code#10433 * fix(server): follow placeholder branches after checkout updates by @Yash-Singh1 in pingdotgg/t3code#10441 * fix(mobile): expand single-line tool details in work logs by @Yash-Singh1 in pingdotgg/t3code#10442 * fix(server): import transcripts with oversized tool records by @Yash-Singh1 in pingdotgg/t3code#10430 * fix(marketing): deploy site with nightly releases by @t3dotgg in pingdotgg/t3code#10443 * fix(web): preserve multiline composer drafts during timeline scrolling by @Yash-Singh1 in pingdotgg/t3code#10444 * fix(server): handle JSON-wrapped titles and verbose Claude output by @Noojuno in pingdotgg/t3code#10446 * fix(marketing): restore continuous endorsement scrolling by @t3dotgg in pingdotgg/t3code#10450 * Revert "fix(marketing): restore continuous endorsement scrolling" by @t3dotgg in pingdotgg/t3code#10454 * fix(marketing): bring back the endorsement marquee by @t3dotgg in pingdotgg/t3code#10455 * chore: enable CodeRabbit automatic reviews by @t3dotgg in pingdotgg/t3code#10457 * fix(codex): keep Spark limits from replacing the main allowance by @Yash-Singh1 in pingdotgg/t3code#10458 * fix(marketing): send 95 nightly downloads to the downloads page by @t3dotgg in pingdotgg/t3code#10460 * fix(web): composer regains focus when you tab back into T3 Code by @t3dotgg in pingdotgg/t3code#10463 * fix(web): keep sidebar drag dividers clear and gestures smooth by @juliusmarminge in pingdotgg/t3code#10453 * fix(server): mark Cursor transport error answers as failed by @shivamhwp in pingdotgg/t3code#10337 * fix(web): clear stuck panel resize cursor by @t3dotgg in pingdotgg/t3code#10461 * fix(web): clarify sidebar drag dividers and empty targets by @juliusmarminge in pingdotgg/t3code#10464 * fix(web): make onboarding a shared multi-computer wizard by @juliusmarminge in pingdotgg/t3code#10465 * fix(shared): redeem reset credits through the hub when it holds the account by @juliusmarminge in pingdotgg/t3code#10462 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260907.1325...v0.0.39-nightly.20260907.1332 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260907.1332
Problem
When a Codex account is signed in natively and also pooled behind a CLIProxyAPI hub, the "Use reset" button could redeem down either path. Which one it took came down to whichever usage snapshot happened to be fresher, because a single flag decided both which credit balance to display and which path to redeem through.
Those are different questions. Redeeming natively goes through the local Codex app-server against the instance's own
CODEX_HOME, which resets the subscription upstream but never calls the hub's/v0/management/reset-quota. The hub therefore kept its routing cooldown for that account and went on refusing every request to it — in the case that prompted this, for another ~119h — even though the account had just been reset. Redeeming through the hub does both, becausecliproxyApi.consumeclears the cooldown after a successful redemption.The user has no way to choose: a hub account that duplicates a native provider is folded into the native entry, so there is exactly one button and a
checkedAtrace decides where it goes.This is client-side logic in
packages/shared, and it had the same defect in two independent builders, so both are fixed here:collectProviderUsageLimits— the chat view and composer banners (ChatView.tsx,ComposerUsageLimits.tsx).collectLimitAccounts— the pooled usage panel (UsageLimitsPooled.tsx).Both are imported by web and mobile, and desktop wraps web, so all three surfaces are covered.
Fix
Split the fused decision in each builder. Display still follows the fresher snapshot. The redemption path now prefers the hub whenever it has a credit for that account, and falls back to the native instance only when the hub genuinely has nothing to redeem — a hub contributor only carries a redemption target when it has a credit id, so that fallback keeps working.
One case worth naming: if the hub snapshot is stale and its
nextCreditIdwas already spent by an earlier native redeem, we now send that spent id. The hub returnsalready_redeemed, which is already treated as a success that still clears the cooldown, and the clients already have copy for it. That is strictly better than the old behavior, which left the hub cooling down a healthy account.Verification
checkedAt, hub duplicate on the same email with a staler one. Both fail onmain— the first with the exact production symptom,expected { instanceId: 'codex' } to deeply equal { sourceId: 'hub', … }— and pass here.packages/shared/src/usageLimits.test.ts: 41 passed. The existing tests that assert a native redemption target still pass, because in those the hub has no credit to redeem.tsgo --noEmiton@t3tools/sharedclean; lint andfmt --checkclean.?? { instanceId }fallback only fires when the field is absent, which never happens for native providers, and the contract union already carried both shapes.No UI change — nothing about the rendered output moves, only which backend path the existing button takes.
Written by Claude Opus 5 (1M context) in Claude Code.
🤖 Generated with Claude Code