tui: update go upsell copy

This commit is contained in:
Frank
2026-05-08 01:51:31 -04:00
parent 6f165e23de
commit bb3f14119b
2 changed files with 17 additions and 15 deletions

View File

@@ -6,7 +6,6 @@ import { iife } from "@/util/iife"
export type Err = ReturnType<NamedError["toObject"]>
export const GO_UPSELL_MESSAGE = "Free usage exceeded, subscribe to Go"
export const PAYG_UPSELL_MESSAGE = "Go usage exceeded, enable PAYG"
export const GO_UPSELL_URL = "https://opencode.ai/go"
export type Retryable = {
@@ -83,11 +82,11 @@ export function retryable(error: Err) {
if (error.data.responseBody?.includes("GoUsageLimitError")) {
const body = parseJSON(error.data.responseBody)
const workspace = str(body?.metadata?.workspace)
const limit = str(body?.metadata?.limit)
const resetAt = num(body?.metadata?.resetAt)
const limitName = str(body?.metadata?.limitName)
const retryAfter = num(error.data.responseHeaders?.["retry-after"])
const resetIn = iife(() => {
if (resetAt === undefined) return ""
const seconds = Math.max(0, Math.ceil(resetAt))
if (retryAfter === undefined) return ""
const seconds = Math.max(0, Math.ceil(retryAfter))
const days = Math.floor(seconds / 86_400)
const hours = Math.floor((seconds % 86_400) / 3_600)
const minutes = Math.ceil((seconds % 3_600) / 60)
@@ -97,16 +96,17 @@ export function retryable(error: Err) {
if (hours > 0) return minutes > 0 ? `${unit(hours, "hour")} ${unit(minutes, "minute")}` : unit(hours, "hour")
return minutes > 0 ? unit(minutes, "minute") : "less than a minute"
})
const message = `${limitName} usage limit reached. It will reset in ${resetIn}. To continue using this model now, enable usage from your available balance`
const link = `https://opencode.ai/workspace/${workspace}/go`
return {
message: PAYG_UPSELL_MESSAGE,
message: `${message} - ${link}`,
action: {
title: "Go limit reached",
message:
limit && resetIn
? `You hit your ${limit} limit. It will reset in ${resetIn}. You can also enable pay-as-you-go.`
: "Enable pay-as-you-go to keep using Go models after your subscription quota is used.",
label: "enable PAYG",
...(workspace ? { link: `https://opencode.ai/workspace/${workspace}/go` } : {}),
message,
label: "open settings",
link,
},
}
}

View File

@@ -279,11 +279,13 @@ describe("session.retry.retryable", () => {
)
expect(SessionRetry.retryable(error)).toEqual({
message: SessionRetry.PAYG_UPSELL_MESSAGE,
message:
"5 hour usage limit reached. It will reset in 5 hours 23 minutes. To continue using this model now, enable usage from your available balance - https://opencode.ai/workspace/wrk_01K6XGM22R6FM8JVABE9XDQXGH/go",
action: {
title: "Go limit reached",
message: "You hit your 5 hour limit. It will reset in 5 hours 23 minutes. You can also enable pay-as-you-go.",
label: "enable PAYG",
message:
"5 hour usage limit reached. It will reset in 5 hours 23 minutes. To continue using this model now, enable usage from your available balance",
label: "open settings",
link: "https://opencode.ai/workspace/wrk_01K6XGM22R6FM8JVABE9XDQXGH/go",
},
})