Repository navigation
feat: show and redeem each gateway account's banked resets - #124
Merged
Merged
Conversation
… is safe The gateway spends the credit and re-probes the account before it answers, which can take up to a minute. The 30s request timeout gave up early, and the body read had no bound at all while the refresh lock was held. One 90s timeout now covers the request, the body and its decoding. A timeout or a dropped connection says the reset may have applied and that trying again will not spend a second credit. A redeem the gateway answers with an error carries its HTTP status.
…a redeem fails After a redemption the gateway branch published the raw re-read, skipping the settling that refresh applies. A failed read right after a reset then published no accounts and no routes, and routed models left the picker. The re-read after a redemption now goes through the same settling: a transient failure keeps the last good snapshot and any failure keeps the gateway's routes.
…malformed one The gateway can reject a token its expiry still vouches for. A 401 or 403 on a redeem now signs in again and sends the same request id once more, the way status reads already do. If the fresh token is rejected too, the existing message stands and the id is kept. A 400 from the gateway means Lathe sent something it does not accept, so it is logged at warn with the source, account and kind. The id is kept.
A dropped connection and an answer Lathe does not know (such as "constructor") keep the id. alreadyRedeemed, noCredit and nothingToReset each release it, so the next redemption gets a fresh one.
…e one The reset tooltip read "next expires in now" once an expiry had passed and "next expires in " when the timestamp could not be read. It now says "next expires now" and leaves the clause out. The weekly bucket no longer carries an explicit undefined Fable field.
A successful reset clears the spent window and usually the last credit, so the account moves to the other group and its weekly bucket disappears. Both remount the row and the redeem status went with it, so the answer was almost never seen. The card's ledger now keeps each redemption's progress and answer, keyed by account and kind, and the row shows a bucket while it holds one even after its count reaches zero. ResetCredits takes an optional store for this; elsewhere it keeps its own state as before. The hover peek still offers no redemption.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
The gateway panel now shows how many limit resets each pooled modelproxy account has banked. The docked card can redeem one.
↻1for one weekly reset, with· F3appended when Fable-only resets are banked too. The chip is muted when none of the weekly resets would act yet. Codex reports that state until a limit is reached. The tooltip lists the counts and the next expiry.How it works
ServerProviderResetCreditsgains optionalusableNowCountandfable.modelproxyApidecodes the gateway'saccounts[].resetCreditsintousageLimits.resetCredits. It decodes forward-compatibly, so a field this build cannot read is dropped rather than costing the whole status. ThecreditIdfor a gateway account isweeklyorfable, and the gateway resolves the real grant.UsageLimitSources.consumeResetCreditgains amodelproxybranch that calls the gateway'sPOST /api/accounts/{name}/reset-credits/redeem.Spending safety
Credits are real and non-refundable.
reset,nothingToReset,noCreditoralreadyRedeemed.unconfirmed,coolingDown,rateLimited,signedOut, a 5xx, a timeout and a dropped connection. The gateway binds an id to one credit, so a retry can never spend a second one.Notes
chromium_headless_shell-1223. This host has only 1234 and 1248, so the test was run against an aliased browser. CI or aplaywright installcovers it.Testing
src/usagetests (204), web unit tests (1740 undersrc/components, and 473 inchatafter the last commit) and the new browser render test.effect-tsgotypecheck exits 0 in contracts, server and web. Repo lint andfmt:checkare clean.Known follow-ups