Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(usage): show reserved resources by pool (#7162)

r33drichardsa9b7a8a21124
diff --git a/libs/fleet/src/pages/BillingUsage.css b/libs/fleet/src/pages/BillingUsage.css
index f2056a59e2..0fb98078be 100644
--- a/libs/fleet/src/pages/BillingUsage.css
+++ b/libs/fleet/src/pages/BillingUsage.css
@@ -11,13 +11,16 @@
.usage-summary__metric {
display: grid;
- grid-column: 3;
gap: 5px;
min-width: 0;
- padding: 22px 0 22px 24px;
+ padding: 22px 24px;
border-inline-start: 1px solid var(--cua-color-border-subtle, rgba(255, 255, 255, 0.14));
}
+.usage-summary__metric:first-child {
+ border-inline-start: 0;
+}
+
.usage-summary__label,
.usage-panel__eyebrow,
.usage-breakdown__header {
@@ -87,7 +90,7 @@
.usage-breakdown__header,
.usage-breakdown__row {
display: grid;
- grid-template-columns: minmax(220px, 1fr) minmax(120px, auto);
+ grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 0.42fr)) minmax(110px, 0.32fr);
gap: 24px;
align-items: center;
}
@@ -103,8 +106,8 @@
text-align: start;
}
-.usage-breakdown__header th:last-child,
-.usage-breakdown__row > :last-child {
+.usage-breakdown__header th:not(:first-child),
+.usage-breakdown__row > :not(:first-child) {
text-align: end;
}
@@ -151,7 +154,6 @@
}
.usage-skeleton__block {
- grid-column: 3;
height: 112px;
}
@@ -178,28 +180,59 @@
}
.usage-summary__metric {
- grid-column: 1;
padding: 18px 0;
+ border-block-start: 1px solid var(--cua-color-border-subtle, rgba(255, 255, 255, 0.14));
border-inline-start: 0;
}
+ .usage-summary__metric:first-child {
+ border-block-start: 0;
+ }
+
.usage-panel {
padding: 18px 14px 12px;
}
- .usage-breakdown__header,
+ .usage-breakdown__header {
+ display: none;
+ }
+
.usage-breakdown__row {
- grid-template-columns: minmax(0, 1fr) auto;
- padding-inline: 0;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: 14px 10px;
+ padding: 16px 0;
+ }
+
+ .usage-breakdown__row > :first-child {
+ grid-column: 1 / -1;
+ font-size: 15px;
+ }
+
+ .usage-breakdown__row > :not(:first-child) {
+ display: grid;
+ gap: 4px;
+ min-width: 0;
+ text-align: start;
+ }
+
+ .usage-breakdown__row > :not(:first-child)::before {
+ content: attr(data-label);
+ color: var(--cua-color-text-muted, rgba(224, 230, 238, 0.68));
+ font-family: var(--cua-dashboard-font-mono, monospace);
+ font-size: 9px;
+ font-weight: 600;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ }
+
+ .usage-breakdown__row strong {
+ overflow-wrap: anywhere;
}
.usage-skeleton__summary {
grid-template-columns: 1fr;
}
- .usage-skeleton__block {
- grid-column: 1;
- }
}
@media (prefers-reduced-motion: reduce) {
diff --git a/libs/fleet/src/pages/BillingUsage.tsx b/libs/fleet/src/pages/BillingUsage.tsx
index bf26c92650..6fff67ecab 100644
--- a/libs/fleet/src/pages/BillingUsage.tsx
+++ b/libs/fleet/src/pages/BillingUsage.tsx
@@ -22,11 +22,20 @@ const moneyFormatter = new Intl.NumberFormat(undefined, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
+const resourceFormatter = new Intl.NumberFormat(undefined, {
+ maximumFractionDigits: 2,
+})
+
+function resourceHours(value: number, unit: "core-h" | "GiB-h") {
+ return `${resourceFormatter.format(value)} ${unit}`
+}
function UsageSkeleton() {
return (
<div className="usage-skeleton" role="status" aria-label="Loading usage">
<div className="usage-skeleton__summary" aria-hidden="true">
- <div className="usage-skeleton__block" />
+ {Array.from({ length: 3 }, (_, index) => (
+ <div className="usage-skeleton__block" key={index} />
+ ))}
</div>
<div className="usage-skeleton__rows" aria-hidden="true">
{Array.from({ length: 4 }, (_, index) => (
@@ -76,11 +85,22 @@ export function BillingUsagePage() {
}, [load])
const pools = useMemo(
- () => [...(overview?.pools ?? [])].sort((left, right) => right.cost_usd - left.cost_usd),
+ () => [...(overview?.pools ?? [])].sort((left, right) =>
+ right.cpu.provisioned - left.cpu.provisioned ||
+ right.memory.provisioned - left.memory.provisioned ||
+ right.cost_usd - left.cost_usd
+ ),
[overview],
)
- const totalCost = useMemo(
- () => pools.reduce((total, pool) => total + pool.cost_usd, 0),
+ const totals = useMemo(
+ () => pools.reduce(
+ (total, pool) => ({
+ cpuProvisioned: total.cpuProvisioned + pool.cpu.provisioned,
+ memoryProvisioned: total.memoryProvisioned + pool.memory.provisioned,
+ cost: total.cost + pool.cost_usd,
+ }),
+ { cpuProvisioned: 0, memoryProvisioned: 0, cost: 0 },
+ ),
[pools],
)
@@ -104,15 +124,25 @@ export function BillingUsagePage() {
) : !overview || pools.length === 0 ? (
<div className="usage-empty">
<PageEmpty title="No resource usage yet">
- Costs appear here after pools begin reporting resource activity.
+ Reserved resource hours appear here after pools begin reporting activity.
</PageEmpty>
</div>
) : (
<div className="usage-layout">
<section className="usage-summary" aria-label="Usage summary">
<div className="usage-summary__metric">
- <span className="usage-summary__label">Cost incurred</span>
- <strong>{moneyFormatter.format(totalCost)}</strong>
+ <span className="usage-summary__label">Reserved CPU</span>
+ <strong>{resourceFormatter.format(totals.cpuProvisioned)}</strong>
+ <span>Core-hours across the selected range</span>
+ </div>
+ <div className="usage-summary__metric">
+ <span className="usage-summary__label">Reserved memory</span>
+ <strong>{resourceFormatter.format(totals.memoryProvisioned)}</strong>
+ <span>GiB-hours across the selected range</span>
+ </div>
+ <div className="usage-summary__metric">
+ <span className="usage-summary__label">OpenCost incurred</span>
+ <strong>{moneyFormatter.format(totals.cost)}</strong>
<span>Across {pools.length} {pools.length === 1 ? "pool" : "pools"}</span>
</div>
</section>
@@ -121,22 +151,26 @@ export function BillingUsagePage() {
<div className="usage-panel__heading">
<div>
<p className="usage-panel__eyebrow">Breakdown</p>
- <h2 id="usage-breakdown-title">Cost by pool</h2>
+ <h2 id="usage-breakdown-title">Reserved resources by pool</h2>
</div>
</div>
<table className="usage-breakdown">
- <caption className="cua-visually-hidden">Resource cost by pool</caption>
+ <caption className="cua-visually-hidden">Reserved resource hours and OpenCost by pool</caption>
<thead>
<tr className="usage-breakdown__header">
<th scope="col">Pool name</th>
- <th scope="col">Cost incurred</th>
+ <th scope="col">Reserved CPU</th>
+ <th scope="col">Reserved memory</th>
+ <th scope="col">OpenCost</th>
</tr>
</thead>
<tbody>
{pools.map(pool => (
<tr className="usage-breakdown__row" key={pool.id}>
<td>{pool.name}</td>
- <td><strong>{moneyFormatter.format(pool.cost_usd)}</strong></td>
+ <td data-label="Reserved CPU"><strong>{resourceHours(pool.cpu.provisioned, "core-h")}</strong></td>
+ <td data-label="Reserved memory"><strong>{resourceHours(pool.memory.provisioned, "GiB-h")}</strong></td>
+ <td data-label="OpenCost"><strong>{moneyFormatter.format(pool.cost_usd)}</strong></td>
</tr>
))}
</tbody>