mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-16 09:33:24 +00:00
tui: update go upsell copy
This commit is contained in:
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user