Skip to content

fix(shared): redeem reset credits through the hub when it holds the account - #10462

Merged
juliusmarminge merged 2 commits into
mainfrom
fix/prefer-hub-reset-credit-redemption
Sep 7, 2026
Merged

fix(shared): redeem reset credits through the hub when it holds the account#10462
juliusmarminge merged 2 commits into
mainfrom
fix/prefer-hub-reset-credit-redemption

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 7, 2026

Copy link
Copy Markdown
Member

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, because cliproxyApi.consume clears 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 checkedAt race 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 nextCreditId was already spent by an earlier native redeem, we now send that spent id. The hub returns already_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

  • A focused test per builder, each covering the regressed case: native contributor with its own credits and a fresher checkedAt, hub duplicate on the same email with a staler one. Both fail on main — 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 --noEmit on @t3tools/shared clean; lint and fmt --check clean.
  • No further client changes needed: the composers' ?? { 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

…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>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 7, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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:

  • Monthly spending limit reached (workspace setting). Approvability relies on correctness review in order to determine eligibility

Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.6 KiB +11 B (+0.1%) 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.0 KiB −5 B (−0.1%) 7.3 KiB
Codex Live turn WebSocket wire 6.5 KiB 6.6 KiB +16 B (+0.2%) 7.8 KiB
Codex Live turn WebSocket decoded 57.1 KiB 57.1 KiB 0 B (0.0%) 66.4 KiB
Codex Live turn messages 10 10 0 (0.0%) 21
Claude Total thread wire 13.6 KiB 13.6 KiB −2 B (−0.0%) 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.0 KiB −1 B (−0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.6 KiB 6.6 KiB −1 B (−0.0%) 7.8 KiB
Claude Live turn WebSocket decoded 57.9 KiB 57.9 KiB 0 B (0.0%) 66.4 KiB
Claude Live turn messages 10 10 0 (0.0%) 21

Baseline: 7e03dcf · PR result: 9c2c644 · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

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>
@juliusmarminge juliusmarminge changed the title fix(server): redeem reset credits through the hub when it holds the account fix(shared): redeem reset credits through the hub when it holds the account Sep 7, 2026
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Sep 7, 2026
@juliusmarminge
juliusmarminge merged commit 6abdf37 into main Sep 7, 2026
25 checks passed
@juliusmarminge
juliusmarminge deleted the fix/prefer-hub-reset-credit-redemption branch September 7, 2026 03:39
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 7, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant