(limits: ClaudeAILimits, model: string)
| 141 | } |
| 142 | |
| 143 | function getLimitReachedText(limits: ClaudeAILimits, model: string): string { |
| 144 | const resetsAt = limits.resetsAt |
| 145 | const resetTime = resetsAt ? formatResetTime(resetsAt, true) : undefined |
| 146 | const overageResetTime = limits.overageResetsAt |
| 147 | ? formatResetTime(limits.overageResetsAt, true) |
| 148 | : undefined |
| 149 | const resetMessage = resetTime ? ` · resets ${resetTime}` : '' |
| 150 | |
| 151 | // if BOTH subscription (checked before this method) and overage are exhausted |
| 152 | if (limits.overageStatus === 'rejected') { |
| 153 | // Show the earliest reset time to indicate when user can resume |
| 154 | let overageResetMessage = '' |
| 155 | if (resetsAt && limits.overageResetsAt) { |
| 156 | // Both timestamps present - use the earlier one |
| 157 | if (resetsAt < limits.overageResetsAt) { |
| 158 | overageResetMessage = ` · resets ${resetTime}` |
| 159 | } else { |
| 160 | overageResetMessage = ` · resets ${overageResetTime}` |
| 161 | } |
| 162 | } else if (resetTime) { |
| 163 | overageResetMessage = ` · resets ${resetTime}` |
| 164 | } else if (overageResetTime) { |
| 165 | overageResetMessage = ` · resets ${overageResetTime}` |
| 166 | } |
| 167 | |
| 168 | if (limits.overageDisabledReason === 'out_of_credits') { |
| 169 | return `You're out of extra usage${overageResetMessage}` |
| 170 | } |
| 171 | |
| 172 | return formatLimitReachedText('limit', overageResetMessage, model) |
| 173 | } |
| 174 | |
| 175 | if (limits.rateLimitType === 'seven_day_sonnet') { |
| 176 | const subscriptionType = getSubscriptionType() |
| 177 | const isProOrEnterprise = |
| 178 | subscriptionType === 'pro' || subscriptionType === 'enterprise' |
| 179 | // For pro and enterprise, Sonnet limit is the same as weekly |
| 180 | const limit = isProOrEnterprise ? 'weekly limit' : 'Sonnet limit' |
| 181 | return formatLimitReachedText(limit, resetMessage, model) |
| 182 | } |
| 183 | |
| 184 | if (limits.rateLimitType === 'seven_day_opus') { |
| 185 | return formatLimitReachedText('Opus limit', resetMessage, model) |
| 186 | } |
| 187 | |
| 188 | if (limits.rateLimitType === 'seven_day') { |
| 189 | return formatLimitReachedText('weekly limit', resetMessage, model) |
| 190 | } |
| 191 | |
| 192 | if (limits.rateLimitType === 'five_hour') { |
| 193 | return formatLimitReachedText('session limit', resetMessage, model) |
| 194 | } |
| 195 | |
| 196 | return formatLimitReachedText('usage limit', resetMessage, model) |
| 197 | } |
| 198 | |
| 199 | function getEarlyWarningText(limits: ClaudeAILimits): string | null { |
| 200 | let limitName: string | null = null |
no test coverage detected