Skip to content

Commit 7a1be25

Browse files
author
bcode
committed
fix(retry): promote free-tier action message to shared const
Cubic flagged that the inline literal change in retry.ts:87 ("Subscribe to OpenCode Go ... $5/month" -> "Free usage limit reached on this provider.") broke retry.test.ts:257 which asserted on the upstream literal byte-for-byte. Right fix: shared const, so test and impl reference one symbol and future BrowserCode-side neutral edits don't need synchronized test updates. Mirrors the existing GO_UPSELL_MESSAGE / GO_UPSELL_URL pattern. Added FREE_TIER_ACTION_MESSAGE; test now uses SessionRetry.FREE_TIER_ACTION_MESSAGE. The schema-decoding.test.ts inline literal stays — that's a schema-shape decode/encode round-trip with arbitrary string values, not an assertion on retry.ts behavior. Verified: bun typecheck 6/6 clean; retry.test.ts 31/31 pass; schema-decoding.test.ts 25/25 pass.
1 parent 3453ef1 commit 7a1be25

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

packages/opencode/src/session/retry.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export type Err = ReturnType<NamedError["toObject"]>
1111
// literal equality; leaving these as neutral values keeps the upsell UI dark.
1212
export const GO_UPSELL_MESSAGE = "Free usage exceeded"
1313
export const GO_UPSELL_URL = ""
14+
// Body shown if the TUI ever rendered the action card. Never visible in
15+
// practice because GO_UPSELL_URL is empty -> DialogRetryAction skips the
16+
// GO-treatment branch. Kept as an exported const so tests and downstream
17+
// consumers reference one symbol and don't drift on future BrowserCode-side
18+
// neutralization edits.
19+
export const FREE_TIER_ACTION_MESSAGE = "Free usage limit reached on this provider."
1420
export type RetryReason = "free_tier_limit" | "account_rate_limit" | (string & {})
1521

1622
export type Retryable = {
@@ -82,9 +88,7 @@ export function retryable(error: Err, provider: string) {
8288
reason: "free_tier_limit",
8389
provider,
8490
title: "Free limit reached",
85-
// Sentinel message; never surfaces because GO_UPSELL_URL is empty so the
86-
// TUI retry-action dialog skips the OpenCode-Go upsell treatment.
87-
message: "Free usage limit reached on this provider.",
91+
message: FREE_TIER_ACTION_MESSAGE,
8892
label: "subscribe",
8993
link: GO_UPSELL_URL,
9094
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ describe("session.retry.retryable", () => {
254254
reason: "free_tier_limit",
255255
provider: "opencode",
256256
title: "Free limit reached",
257-
message: "Subscribe to OpenCode Go for reliable access to the best open-source models, starting at $5/month.",
257+
message: SessionRetry.FREE_TIER_ACTION_MESSAGE,
258258
label: "subscribe",
259259
link: SessionRetry.GO_UPSELL_URL,
260260
},

0 commit comments

Comments
 (0)