From 4b1eca73eb64c62ebdf668eb18d587510066bd9d Mon Sep 17 00:00:00 2001 From: Jay V Date: Tue, 16 Sep 2025 16:16:30 -0400 Subject: ignore: zen --- .../app/src/component/workspace/usage-section.tsx | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 cloud/app/src/component/workspace/usage-section.tsx (limited to 'cloud/app/src/component/workspace/usage-section.tsx') diff --git a/cloud/app/src/component/workspace/usage-section.tsx b/cloud/app/src/component/workspace/usage-section.tsx new file mode 100644 index 000000000..a2ad507af --- /dev/null +++ b/cloud/app/src/component/workspace/usage-section.tsx @@ -0,0 +1,66 @@ +import { Billing } from "@opencode/cloud-core/billing.js" +import { query, useParams, createAsync } from "@solidjs/router" +import { createMemo, For, Show } from "solid-js" +import { formatDateUTC, formatDateForTable } from "./common" +import { withActor } from "~/context/auth.withActor" + +const getUsageInfo = query(async (workspaceID: string) => { + "use server" + return withActor(async () => { + return await Billing.usages() + }, workspaceID) +}, "usage.list") + +export function UsageSection() { + const params = useParams() + const usage = createAsync(() => getUsageInfo(params.id)) + + return ( +
+
+

Usage History

+

Recent API usage and costs.

+
+
+ 0} + fallback={ +
+

Make your first API call to get started.

+
+ } + > + + + + + + + + + + + + + {(usage) => { + const date = createMemo(() => new Date(usage.timeCreated)) + return ( + + + + + + + + ) + }} + + +
DateModelInputOutputCost
+ {formatDateForTable(date())} + {usage.model}{usage.inputTokens}{usage.outputTokens}${((usage.cost ?? 0) / 100000000).toFixed(4)}
+
+
+
+ ) +} -- cgit v1.2.3