diff --git a/windows/src/components/Icons.tsx b/windows/src/components/Icons.tsx index 46f250c6..7ea96cc8 100644 --- a/windows/src/components/Icons.tsx +++ b/windows/src/components/Icons.tsx @@ -245,6 +245,16 @@ export function EllipsisIcon(p: IconProps) { ) } +/// pencil.line, for the Pulse cost-per-edit caption. +export function PencilLineIcon(p: IconProps) { + return ( + + + + + ) +} + export function CheckIcon(p: IconProps) { return } diff --git a/windows/src/components/PulseInsight.tsx b/windows/src/components/PulseInsight.tsx index 1668e8c8..4b0f5b87 100644 --- a/windows/src/components/PulseInsight.tsx +++ b/windows/src/components/PulseInsight.tsx @@ -1,6 +1,7 @@ import type { MenubarPayload } from '../lib/payload' import type { CurrencyState } from '../lib/currency' import { formatCompactCurrency } from '../lib/currency' +import { PencilLineIcon } from './Icons' type Props = { payload: MenubarPayload @@ -14,19 +15,59 @@ export function PulseInsight({ payload, currency }: Props) { const costPerSession = sessions > 0 ? formatCompactCurrency(cost / sessions, currency) : '-' return ( -
-
-
Cache hit
-
{cacheText}
-
-
-
1-shot
-
{oneShotText}
-
-
-
Cost / session
-
{costPerSession}
+
+
+
+
Cache hit
+
{cacheText}
+
+
+
1-shot
+
{oneShotText}
+
+
+
Cost / session
+
{costPerSession}
+
+
) } + +/// The mac's CostPerEditCaption: what an accepted edit costs on the cheapest model of the +/// period, and on the dearest when that is a different model. It is the line that turns the +/// three tiles above into a decision, which is why it sits with them. +function CostPerEdit({ payload, currency }: Props) { + const ranked = (payload.current.modelEfficiency ?? []) + .filter((m): m is { name: string; costPerEdit: number; oneShotRate: number | null } => + typeof m.costPerEdit === 'number' && m.costPerEdit > 0) + .sort((a, b) => a.costPerEdit - b.costPerEdit) + const best = ranked[0] + if (!best) return null + const worst = ranked.length > 1 ? ranked[ranked.length - 1] : null + + return ( +
+ + Cost/edit + {perEdit(best.costPerEdit, currency)} + {best.name} + {worst && worst.name !== best.name && ( + <> + - + {perEdit(worst.costPerEdit, currency)} + {worst.name} + + )} +
+ ) +} + +/// Three decimals under a cent, as on the mac: a model costing a tenth of a cent an edit and +/// one costing nine of them both read as $0.00 otherwise, which is the comparison this line +/// exists to make. +function perEdit(usd: number, currency: CurrencyState): string { + const converted = usd * currency.rate + return `${currency.symbol}${converted.toFixed(converted < 0.01 ? 3 : 2)}` +} diff --git a/windows/src/lib/payload.ts b/windows/src/lib/payload.ts index 60baa033..c3029ad4 100644 --- a/windows/src/lib/payload.ts +++ b/windows/src/lib/payload.ts @@ -24,6 +24,9 @@ export type MenubarPayload = { /// Where the money went, by repository and by session. Empty on older CLI payloads. topProjects?: ProjectEntry[] topSessions?: TopSessionEntry[] + /// Cost per accepted edit and one-shot rate per model, which is what the mac's Pulse + /// caption names its cheapest and dearest model from. Empty on older CLI payloads. + modelEfficiency?: Array<{ name: string; costPerEdit: number | null; oneShotRate: number | null }> /// What the agent reached for. Empty on older CLI payloads. tools?: Array<{ name: string; calls: number }> skills?: Array<{ name: string; turns: number; cost: number }> diff --git a/windows/src/styles.css b/windows/src/styles.css index 89bd3ec4..06114b0a 100644 --- a/windows/src/styles.css +++ b/windows/src/styles.css @@ -1192,6 +1192,30 @@ code { font-family: var(--font-mono); } color: var(--label-2); } .pulse-value-accent { color: var(--brand-accent); } +.pulse { display: flex; flex-direction: column; gap: 8px; } +.pulse-cpe { + display: flex; + align-items: center; + gap: 4px; + min-width: 0; + color: var(--label-3); +} +.pulse-cpe-label { font-size: 10px; font-weight: 500; } +.pulse-cpe-figure { + font-family: var(--font-mono); + font-size: 10.5px; + font-weight: 600; + color: var(--label); +} +.pulse-cpe-best { color: var(--brand-accent); } +.pulse-cpe-model { + font-size: 10px; + color: var(--label-2); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.pulse-cpe-dash { font-size: 9px; color: var(--label-3); } /* Stats */ .stats-grid { display: flex; gap: 14px; }