Skip to content

Commit bb3f141

Browse files
committed
tui: update go upsell copy
1 parent 6f165e2 commit bb3f141

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

packages/opencode/src/session/retry.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { iife } from "@/util/iife"
66
export type Err = ReturnType<NamedError["toObject"]>
77

88
export const GO_UPSELL_MESSAGE = "Free usage exceeded, subscribe to Go"
9-
export const PAYG_UPSELL_MESSAGE = "Go usage exceeded, enable PAYG"
109
export const GO_UPSELL_URL = "https://opencode.ai/go"
1110

1211
export type Retryable = {
@@ -83,11 +82,11 @@ export function retryable(error: Err) {
8382
if (error.data.responseBody?.includes("GoUsageLimitError")) {
8483
const body = parseJSON(error.data.responseBody)
8584
const workspace = str(body?.metadata?.workspace)
86-
const limit = str(body?.metadata?.limit)
87-
const resetAt = num(body?.metadata?.resetAt)
85+
const limitName = str(body?.metadata?.limitName)
86+
const retryAfter = num(error.data.responseHeaders?.["retry-after"])
8887
const resetIn = iife(() => {
89-
if (resetAt === undefined) return ""
90-
const seconds = Math.max(0, Math.ceil(resetAt))
88+
if (retryAfter === undefined) return ""
89+
const seconds = Math.max(0, Math.ceil(retryAfter))
9190
const days = Math.floor(seconds / 86_400)
9291
const hours = Math.floor((seconds % 86_400) / 3_600)
9392
const minutes = Math.ceil((seconds % 3_600) / 60)
@@ -97,16 +96,17 @@ export function retryable(error: Err) {
9796
if (hours > 0) return minutes > 0 ? `${unit(hours, "hour")} ${unit(minutes, "minute")}` : unit(hours, "hour")
9897
return minutes > 0 ? unit(minutes, "minute") : "less than a minute"
9998
})
99+
100+
const message = `${limitName} usage limit reached. It will reset in ${resetIn}. To continue using this model now, enable usage from your available balance`
101+
102+
const link = `https://opencode.ai/workspace/${workspace}/go`
100103
return {
101-
message: PAYG_UPSELL_MESSAGE,
104+
message: `${message} - ${link}`,
102105
action: {
103106
title: "Go limit reached",
104-
message:
105-
limit && resetIn
106-
? `You hit your ${limit} limit. It will reset in ${resetIn}. You can also enable pay-as-you-go.`
107-
: "Enable pay-as-you-go to keep using Go models after your subscription quota is used.",
108-
label: "enable PAYG",
109-
...(workspace ? { link: `https://opencode.ai/workspace/${workspace}/go` } : {}),
107+
message,
108+
label: "open settings",
109+
link,
110110
},
111111
}
112112
}

packages/opencode/test/session/retry.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,13 @@ describe("session.retry.retryable", () => {
279279
)
280280

281281
expect(SessionRetry.retryable(error)).toEqual({
282-
message: SessionRetry.PAYG_UPSELL_MESSAGE,
282+
message:
283+
"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",
283284
action: {
284285
title: "Go limit reached",
285-
message: "You hit your 5 hour limit. It will reset in 5 hours 23 minutes. You can also enable pay-as-you-go.",
286-
label: "enable PAYG",
286+
message:
287+
"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",
288+
label: "open settings",
287289
link: "https://opencode.ai/workspace/wrk_01K6XGM22R6FM8JVABE9XDQXGH/go",
288290
},
289291
})

0 commit comments

Comments
 (0)