@@ -1219,7 +1219,6 @@ const renderKimiItems = (
12191219 'div' ,
12201220 { className : styleMap . quotaMeta } ,
12211221 h ( 'span' , { className : styleMap . quotaPercent } , percentLabel ) ,
1222- limit > 0 ? h ( 'span' , { className : styleMap . quotaAmount } , `${ used } / ${ limit } ` ) : null ,
12231222 resetLabel ? h ( 'span' , { className : styleMap . quotaReset } , resetLabel ) : null
12241223 )
12251224 ) ,
@@ -1260,6 +1259,22 @@ const formatXaiCurrency = (value: number | null): string => {
12601259 return `$${ ( value / 100 ) . toFixed ( 2 ) } ` ;
12611260} ;
12621261
1262+ const formatXaiRemainingAmount = ( billing : XaiBillingSummary ) : string => {
1263+ const remainingCents =
1264+ billing . monthlyLimitCents !== null && billing . includedUsedCents !== null
1265+ ? Math . max ( 0 , billing . monthlyLimitCents - billing . includedUsedCents )
1266+ : null ;
1267+ return `${ formatXaiCurrency ( remainingCents ) } / ${ formatXaiCurrency ( billing . monthlyLimitCents ) } ` ;
1268+ } ;
1269+
1270+ const formatXaiOnDemandAmount = ( billing : XaiBillingSummary ) : string => {
1271+ const remainingCents =
1272+ billing . onDemandCapCents !== null && billing . onDemandUsedCents !== null
1273+ ? Math . max ( 0 , billing . onDemandCapCents - billing . onDemandUsedCents )
1274+ : null ;
1275+ return `${ formatXaiCurrency ( remainingCents ) } / ${ formatXaiCurrency ( billing . onDemandCapCents ) } ` ;
1276+ } ;
1277+
12631278const XAI_SUPERGROK_LIMIT_CENTS = 15_000 ;
12641279const XAI_SUPERGROK_HEAVY_LIMIT_CENTS = 150_000 ;
12651280
@@ -1288,21 +1303,24 @@ const renderXaiItems = (
12881303 return h ( 'div' , { className : styleMap . quotaMessage } , t ( 'xai_quota.empty_data' ) ) ;
12891304 }
12901305
1291- const usedPercent = billing . usedPercent ;
1292- const clampedUsed = usedPercent === null ? null : Math . max ( 0 , Math . min ( 100 , usedPercent ) ) ;
1306+ const clampedUsed =
1307+ billing . usedPercent === null ? null : Math . max ( 0 , Math . min ( 100 , billing . usedPercent ) ) ;
12931308 const remaining = clampedUsed === null ? null : Math . max ( 0 , Math . min ( 100 , 100 - clampedUsed ) ) ;
12941309 const percentLabel = remaining === null ? '--' : `${ Math . round ( remaining ) } %` ;
1295- const remainingCents =
1296- billing . monthlyLimitCents !== null && billing . usedCents !== null
1297- ? Math . max ( 0 , billing . monthlyLimitCents - billing . usedCents )
1298- : null ;
1299- const amountLabel = t ( 'xai_quota.usage_amount' , {
1300- remaining : formatXaiCurrency ( remainingCents ) ,
1301- limit : formatXaiCurrency ( billing . monthlyLimitCents ) ,
1302- } ) ;
1310+ const amountLabel = formatXaiRemainingAmount ( billing ) ;
13031311 const resetLabel = billing . billingPeriodEnd
13041312 ? formatQuotaResetTime ( billing . billingPeriodEnd )
13051313 : t ( 'xai_quota.reset_unknown' ) ;
1314+ const onDemandCap = billing . onDemandCapCents ?? 0 ;
1315+ const clampedOnDemandUsed =
1316+ billing . onDemandUsedPercent === null
1317+ ? null
1318+ : Math . max ( 0 , Math . min ( 100 , billing . onDemandUsedPercent ) ) ;
1319+ const onDemandRemaining =
1320+ clampedOnDemandUsed === null ? null : Math . max ( 0 , Math . min ( 100 , 100 - clampedOnDemandUsed ) ) ;
1321+ const onDemandPercentLabel =
1322+ onDemandRemaining === null ? '--' : `${ Math . round ( onDemandRemaining ) } %` ;
1323+ const onDemandAmountLabel = formatXaiOnDemandAmount ( billing ) ;
13061324 const plan = resolveXaiPlan ( billing . monthlyLimitCents ) ;
13071325
13081326 const nodes : ReactNode [ ] = [
@@ -1318,13 +1336,40 @@ const renderXaiItems = (
13181336 )
13191337 )
13201338 : null ,
1339+ onDemandCap > 0
1340+ ? h (
1341+ 'div' ,
1342+ { key : 'pay-as-you-go' , className : styleMap . quotaRow } ,
1343+ h (
1344+ 'div' ,
1345+ { className : styleMap . quotaRowHeader } ,
1346+ h ( 'span' , { className : styleMap . quotaModel } , t ( 'xai_quota.pay_as_you_go_label' ) ) ,
1347+ h (
1348+ 'div' ,
1349+ { className : styleMap . quotaMeta } ,
1350+ h ( 'span' , { className : styleMap . quotaPercent } , onDemandPercentLabel ) ,
1351+ h ( 'span' , { className : styleMap . quotaAmount } , onDemandAmountLabel )
1352+ )
1353+ ) ,
1354+ h ( QuotaProgressBar , {
1355+ percent : onDemandRemaining ,
1356+ highThreshold : QUOTA_PROGRESS_HIGH_THRESHOLD ,
1357+ mediumThreshold : QUOTA_PROGRESS_MEDIUM_THRESHOLD ,
1358+ } )
1359+ )
1360+ : h (
1361+ 'div' ,
1362+ { key : 'pay-as-you-go' , className : styleMap . codexPlan } ,
1363+ h ( 'span' , { className : styleMap . codexPlanLabel } , t ( 'xai_quota.pay_as_you_go_label' ) ) ,
1364+ h ( 'span' , { className : styleMap . codexPlanValue } , t ( 'xai_quota.pay_as_you_go_disabled' ) )
1365+ ) ,
13211366 h (
13221367 'div' ,
13231368 { key : 'billing' , className : styleMap . quotaRow } ,
13241369 h (
13251370 'div' ,
13261371 { className : styleMap . quotaRowHeader } ,
1327- h ( 'span' , { className : styleMap . quotaModel } , t ( 'xai_quota.monthly_limit ' ) ) ,
1372+ h ( 'span' , { className : styleMap . quotaModel } , t ( 'xai_quota.monthly_credits ' ) ) ,
13281373 h (
13291374 'div' ,
13301375 { className : styleMap . quotaMeta } ,
@@ -1341,21 +1386,6 @@ const renderXaiItems = (
13411386 ) ,
13421387 ] ;
13431388
1344- if ( billing . onDemandCapCents !== null ) {
1345- nodes . push (
1346- h (
1347- 'div' ,
1348- { key : 'on-demand-cap' , className : styleMap . codexPlan } ,
1349- h ( 'span' , { className : styleMap . codexPlanLabel } , t ( 'xai_quota.on_demand_cap' ) ) ,
1350- h (
1351- 'span' ,
1352- { className : styleMap . codexPlanValue } ,
1353- formatXaiCurrency ( billing . onDemandCapCents )
1354- )
1355- )
1356- ) ;
1357- }
1358-
13591389 return h ( React . Fragment , null , ...nodes ) ;
13601390} ;
13611391
0 commit comments