* Get the upsell command text for warning messages based on subscription and limit type. * Returns null if no upsell should be shown. * Only used for warnings because actual rate limit hits will see an interactive menu of options.
( rateLimitType: ClaudeAILimits['rateLimitType'], )
| 259 | * Only used for warnings because actual rate limit hits will see an interactive menu of options. |
| 260 | */ |
| 261 | function getWarningUpsellText( |
| 262 | rateLimitType: ClaudeAILimits['rateLimitType'], |
| 263 | ): string | null { |
| 264 | const subscriptionType = getSubscriptionType() |
| 265 | const hasExtraUsageEnabled = |
| 266 | getOauthAccountInfo()?.hasExtraUsageEnabled === true |
| 267 | |
| 268 | // 5-hour session limit warning |
| 269 | if (rateLimitType === 'five_hour') { |
| 270 | // Teams/Enterprise with overages disabled: prompt to request extra usage |
| 271 | // Only show if overage provisioning is allowed for this org type (e.g., not AWS marketplace) |
| 272 | if (subscriptionType === 'team' || subscriptionType === 'enterprise') { |
| 273 | if (!hasExtraUsageEnabled && isOverageProvisioningAllowed()) { |
| 274 | return '/extra-usage to request more' |
| 275 | } |
| 276 | // Teams/Enterprise with overages enabled or unsupported billing type don't need upsell |
| 277 | return null |
| 278 | } |
| 279 | |
| 280 | // Pro/Max users: prompt to upgrade |
| 281 | if (subscriptionType === 'pro' || subscriptionType === 'max') { |
| 282 | return '/upgrade to keep using Claude Code' |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | // Overage warning (approaching spending limit) |
| 287 | if (rateLimitType === 'overage') { |
| 288 | if (subscriptionType === 'team' || subscriptionType === 'enterprise') { |
| 289 | if (!hasExtraUsageEnabled && isOverageProvisioningAllowed()) { |
| 290 | return '/extra-usage to request more' |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // Weekly limit warnings don't show upsell per spec |
| 296 | return null |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Get notification text for overage mode transitions |
no test coverage detected