tui: update go upsell copy

This commit is contained in:
Frank
2026-05-08 01:51:33 -04:00
parent 6f165e23de
commit bb3f14119b
2 changed files with 17 additions and 15 deletions
+12 -12
View File
@@ -6,7 +6,6 @@ import { iife } from "@/util/iife"
export type Err = ReturnType<NamedError["toObject"]> export type Err = ReturnType<NamedError["toObject"]>
export const GO_UPSELL_MESSAGE = "Free usage exceeded, subscribe to Go" 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 const GO_UPSELL_URL = "https://opencode.ai/go"
export type Retryable = { export type Retryable = {
@@ -83,11 +82,11 @@ export function retryable(error: Err) {
if (error.data.responseBody?.includes("GoUsageLimitError")) { if (error.data.responseBody?.includes("GoUsageLimitError")) {
const body = parseJSON(error.data.responseBody) const body = parseJSON(error.data.responseBody)
const workspace = str(body?.metadata?.workspace) const workspace = str(body?.metadata?.workspace)
const limit = str(body?.metadata?.limit) const limitName = str(body?.metadata?.limitName)
const resetAt = num(body?.metadata?.resetAt) const retryAfter = num(error.data.responseHeaders?.["retry-after"])
const resetIn = iife(() => { const resetIn = iife(() => {
if (resetAt === undefined) return "" if (retryAfter === undefined) return ""
const seconds = Math.max(0, Math.ceil(resetAt)) const seconds = Math.max(0, Math.ceil(retryAfter))
const days = Math.floor(seconds / 86_400) const days = Math.floor(seconds / 86_400)
const hours = Math.floor((seconds % 86_400) / 3_600) const hours = Math.floor((seconds % 86_400) / 3_600)
const minutes = Math.ceil((seconds % 3_600) / 60) 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") 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" 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 { return {
message: PAYG_UPSELL_MESSAGE, message: `${message} - ${link}`,
action: { action: {
title: "Go limit reached", title: "Go limit reached",
message: message,
limit && resetIn label: "open settings",
? `You hit your ${limit} limit. It will reset in ${resetIn}. You can also enable pay-as-you-go.` link,
: "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` } : {}),
}, },
} }
} }
+5 -3
View File
@@ -279,11 +279,13 @@ describe("session.retry.retryable", () => {
) )
expect(SessionRetry.retryable(error)).toEqual({ 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: { action: {
title: "Go limit reached", 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.", message:
label: "enable PAYG", "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", link: "https://opencode.ai/workspace/wrk_01K6XGM22R6FM8JVABE9XDQXGH/go",
}, },
}) })