@@ -627,7 +627,7 @@ export class ChatEntitlementRequests extends Disposable {
627627 if ( response . monthly_quotas ?. chat && typeof response . limited_user_quotas ?. chat === 'number' ) {
628628 quotas . chat = {
629629 total : response . monthly_quotas . chat ,
630- percentRemaining : ( response . limited_user_quotas . chat / response . monthly_quotas . chat ) * 100 ,
630+ percentRemaining : Math . min ( 100 , Math . max ( 0 , ( response . limited_user_quotas . chat / response . monthly_quotas . chat ) * 100 ) ) ,
631631 overageEnabled : false ,
632632 overageCount : 0 ,
633633 unlimited : false
@@ -637,7 +637,7 @@ export class ChatEntitlementRequests extends Disposable {
637637 if ( response . monthly_quotas ?. completions && typeof response . limited_user_quotas ?. completions === 'number' ) {
638638 quotas . completions = {
639639 total : response . monthly_quotas . completions ,
640- percentRemaining : ( response . limited_user_quotas . completions / response . monthly_quotas . completions ) * 100 ,
640+ percentRemaining : Math . min ( 100 , Math . max ( 0 , ( response . limited_user_quotas . completions / response . monthly_quotas . completions ) * 100 ) ) ,
641641 overageEnabled : false ,
642642 overageCount : 0 ,
643643 unlimited : false
@@ -653,7 +653,7 @@ export class ChatEntitlementRequests extends Disposable {
653653 }
654654 const quotaSnapshot : IQuotaSnapshot = {
655655 total : rawQuotaSnapshot . entitlement ,
656- percentRemaining : rawQuotaSnapshot . percent_remaining ,
656+ percentRemaining : Math . min ( 100 , Math . max ( 0 , rawQuotaSnapshot . percent_remaining ) ) ,
657657 overageEnabled : rawQuotaSnapshot . overage_permitted ,
658658 overageCount : rawQuotaSnapshot . overage_count ,
659659 unlimited : rawQuotaSnapshot . unlimited
0 commit comments