feat(windows): Pulse says what an edit costs on each model

Pulse had the mac's three tiles and not its caption, which is the line
that turns them into a decision: what one accepted edit costs on the
cheapest model of the period, and on the dearest when that is a different
model. The figures come from `current.modelEfficiency`, which the CLI has
emitted all along and the Windows payload type simply did not name.

Three decimals under a cent, as on the mac: a model that costs a tenth of
a cent an edit and one that costs nine of them both read as $0.00
otherwise, and telling those apart is the whole point of the line.
This commit is contained in:
iamtoruk 2026-09-02 01:33:27 -07:00
parent 929bca8019
commit ff97aa7b8f
4 changed files with 90 additions and 12 deletions

View file

@ -245,6 +245,16 @@ export function EllipsisIcon(p: IconProps) {
)
}
/// pencil.line, for the Pulse cost-per-edit caption.
export function PencilLineIcon(p: IconProps) {
return (
<Svg {...p}>
<path d="M10.5 2.8 13.2 5.5 6.4 12.3 3.2 13l.7-3.2z" />
<path d="M2.5 14.5h11" />
</Svg>
)
}
export function CheckIcon(p: IconProps) {
return <Svg {...p}><path d="M3.5 8.5 6.5 11.5 12.5 5" /></Svg>
}

View file

@ -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 (
<div className="pulse-tiles">
<div className="pulse-tile">
<div className="pulse-label">Cache hit</div>
<div className="pulse-value pulse-value-accent">{cacheText}</div>
</div>
<div className="pulse-tile">
<div className="pulse-label">1-shot</div>
<div className={`pulse-value ${oneShotRate == null ? '' : 'pulse-value-accent'}`}>{oneShotText}</div>
</div>
<div className="pulse-tile">
<div className="pulse-label">Cost / session</div>
<div className="pulse-value">{costPerSession}</div>
<div className="pulse">
<div className="pulse-tiles">
<div className="pulse-tile">
<div className="pulse-label">Cache hit</div>
<div className="pulse-value pulse-value-accent">{cacheText}</div>
</div>
<div className="pulse-tile">
<div className="pulse-label">1-shot</div>
<div className={`pulse-value ${oneShotRate == null ? '' : 'pulse-value-accent'}`}>{oneShotText}</div>
</div>
<div className="pulse-tile">
<div className="pulse-label">Cost / session</div>
<div className="pulse-value">{costPerSession}</div>
</div>
</div>
<CostPerEdit payload={payload} currency={currency} />
</div>
)
}
/// 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 (
<div className="pulse-cpe">
<PencilLineIcon size={9} />
<span className="pulse-cpe-label">Cost/edit</span>
<span className="pulse-cpe-figure pulse-cpe-best">{perEdit(best.costPerEdit, currency)}</span>
<span className="pulse-cpe-model">{best.name}</span>
{worst && worst.name !== best.name && (
<>
<span className="pulse-cpe-dash">-</span>
<span className="pulse-cpe-figure">{perEdit(worst.costPerEdit, currency)}</span>
<span className="pulse-cpe-model">{worst.name}</span>
</>
)}
</div>
)
}
/// 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)}`
}

View file

@ -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 }>

View file

@ -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; }