File tree Expand file tree Collapse file tree
apps/server/src/provider/Layers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -564,7 +564,10 @@ describe("Grok usage limits", () => {
564564 for ( const response of [ { } , { config : { } } , { config : { creditUsagePercent : NaN } } ] ) {
565565 const limits = grokUsageResponseToLimits ( response , checkedAt ) ;
566566 expect ( limits . windows ) . toEqual ( [ ] ) ;
567- expect ( limits . unavailable ?. reason ) . toBe ( "unsupported" ) ;
567+ // Nothing metered yet, which xAI reports by omitting the field until
568+ // usage registers. Marking it `unsupported` would drop the account from
569+ // the Limits view for good; leaving the marker off keeps it listed.
570+ expect ( limits . unavailable ) . toBeUndefined ( ) ;
568571 }
569572 expect (
570573 grokUsageResponseToLimits ( { config : { creditUsagePercent : 0 } } , checkedAt ) . windows ,
Original file line number Diff line number Diff line change @@ -41,7 +41,15 @@ export function grokUsageResponseToLimits(
4141) {
4242 const usedPercent = response . config ?. creditUsagePercent ;
4343 if ( usedPercent === undefined || ! Number . isFinite ( usedPercent ) ) {
44- return makeUnavailableUsageLimits ( { checkedAt, reason : "unsupported" } ) ;
44+ // A billing read that succeeded but carries no percentage is an account
45+ // with nothing metered yet, not one that can never report: xAI omits the
46+ // field entirely (rather than sending 0) until usage registers, then fills
47+ // it in. Calling that `unsupported` would strand the account — the Limits
48+ // view drops unsupported entries and deliberately mutes their notice, so a
49+ // freshly signed-in Grok account would vanish with no explanation until it
50+ // happened to be used, and `applyUsageLimitsUpdate` would refuse the
51+ // mid-turn windows that could have recovered it.
52+ return makeUsageLimits ( { checkedAt, windows : [ ] } ) ;
4553 }
4654 const period = response . config ?. currentPeriod ;
4755 const periodType = period ?. type ?. replace ( / ^ U S A G E _ P E R I O D _ T Y P E _ / , "" ) ;
You can’t perform that action at this time.
0 commit comments