feat: add opencode go upsell modal when limits are hit (#21583)

Co-authored-by: Frank <frank@anoma.ly>
This commit is contained in:
Aiden Cline
2026-04-09 01:16:29 -05:00
committed by GitHub
parent 3fc3974cbc
commit 489f57974d
3 changed files with 127 additions and 2 deletions

View File

@@ -6,6 +6,10 @@ import { iife } from "@/util/iife"
export namespace SessionRetry {
export type Err = ReturnType<NamedError["toObject"]>
// This exported message is shared with the TUI upsell detector. Matching on a
// literal error string kind of sucks, but it is the simplest for now.
export const GO_UPSELL_MESSAGE = "Free usage exceeded, subscribe to Go https://opencode.ai/go"
export const RETRY_INITIAL_DELAY = 2000
export const RETRY_BACKOFF_FACTOR = 2
export const RETRY_MAX_DELAY_NO_HEADERS = 30_000 // 30 seconds
@@ -53,8 +57,7 @@ export namespace SessionRetry {
if (MessageV2.ContextOverflowError.isInstance(error)) return undefined
if (MessageV2.APIError.isInstance(error)) {
if (!error.data.isRetryable) return undefined
if (error.data.responseBody?.includes("FreeUsageLimitError"))
return `Free usage exceeded, subscribe to Go https://opencode.ai/go`
if (error.data.responseBody?.includes("FreeUsageLimitError")) return GO_UPSELL_MESSAGE
return error.data.message.includes("Overloaded") ? "Provider is overloaded" : error.data.message
}