summaryrefslogtreecommitdiffhomepage
path: root/packages/console/app/src/routes
diff options
context:
space:
mode:
authorFrank <[email protected]>2026-02-23 18:18:45 -0500
committerFrank <[email protected]>2026-02-23 18:18:47 -0500
commit284251ad6615dd37d4f2c0c9b14e0a989dbf3f1e (patch)
treef0330901fa6b7509d1f257d17c1caf3123a32d7f /packages/console/app/src/routes
parent34495a70d5069355bbad95c95625818afa677eb1 (diff)
downloadopencode-284251ad6615dd37d4f2c0c9b14e0a989dbf3f1e.tar.gz
opencode-284251ad6615dd37d4f2c0c9b14e0a989dbf3f1e.zip
zen: display BYOK cost
Diffstat (limited to 'packages/console/app/src/routes')
-rw-r--r--packages/console/app/src/routes/workspace/[id]/usage-section.tsx11
-rw-r--r--packages/console/app/src/routes/zen/util/handler.ts13
2 files changed, 19 insertions, 5 deletions
diff --git a/packages/console/app/src/routes/workspace/[id]/usage-section.tsx b/packages/console/app/src/routes/workspace/[id]/usage-section.tsx
index 7b030f4af..3d6637610 100644
--- a/packages/console/app/src/routes/workspace/[id]/usage-section.tsx
+++ b/packages/console/app/src/routes/workspace/[id]/usage-section.tsx
@@ -177,7 +177,16 @@ export function UsageSection() {
<td data-slot="usage-cost">
<Show
when={usage.enrichment?.plan === "sub"}
- fallback={<>${((usage.cost ?? 0) / 100000000).toFixed(4)}</>}
+ fallback={
+ <Show
+ when={usage.enrichment?.plan === "byok"}
+ fallback={<>${((usage.cost ?? 0) / 100000000).toFixed(4)}</>}
+ >
+ {i18n.t("workspace.usage.byok", {
+ amount: ((usage.cost ?? 0) / 100000000).toFixed(4),
+ })}
+ </Show>
+ }
>
{i18n.t("workspace.usage.subscription", {
amount: ((usage.cost ?? 0) / 100000000).toFixed(4),
diff --git a/packages/console/app/src/routes/zen/util/handler.ts b/packages/console/app/src/routes/zen/util/handler.ts
index dc10e1bf9..6096d7378 100644
--- a/packages/console/app/src/routes/zen/util/handler.ts
+++ b/packages/console/app/src/routes/zen/util/handler.ts
@@ -740,7 +740,11 @@ export async function handler(
cost,
keyID: authInfo.apiKeyId,
sessionID: sessionId.substring(0, 30),
- enrichment: billingSource === "subscription" ? { plan: "sub" } : undefined,
+ enrichment: (() => {
+ if (billingSource === "subscription") return { plan: "sub" }
+ if (billingSource === "byok") return { plan: "byok" }
+ return undefined
+ })(),
}),
db
.update(KeyTable)
@@ -788,9 +792,10 @@ export async function handler(
db
.update(BillingTable)
.set({
- balance: authInfo.isFree
- ? sql`${BillingTable.balance} - ${0}`
- : sql`${BillingTable.balance} - ${cost}`,
+ balance:
+ billingSource === "free" || billingSource === "byok"
+ ? sql`${BillingTable.balance} - ${0}`
+ : sql`${BillingTable.balance} - ${cost}`,
monthlyUsage: sql`
CASE
WHEN MONTH(${BillingTable.timeMonthlyUsageUpdated}) = MONTH(now()) AND YEAR(${BillingTable.timeMonthlyUsageUpdated}) = YEAR(now()) THEN ${BillingTable.monthlyUsage} + ${cost}