Pick two ranges and see exactly what drove the change — projects, models, and the sessions behind them.
+ A spans {daysA} {daysA === 1 ? 'day' : 'days'} · B spans {daysB} {daysB === 1 ? 'day' : 'days'} + {delta !== 0 && <> · duration differs by {delta > 0 ? '+' : ''}{delta} {Math.abs(delta) === 1 ? 'day' : 'days'}>} + {overlap > 0 && <> · the ranges overlap on {overlap} {overlap === 1 ? 'day' : 'days'} — overlapping days count in BOTH sides>} + · all differences are B − A +
+ ) +} + +function TotalsCard({ report }: { report: PeriodDiffReport }) { + const rows: Array<{ label: string; get: (t: PeriodDiffReport['totals']['A']) => number }> = [ + { label: 'API-equivalent cost', get: t => t.cost }, + { label: 'API calls', get: t => t.calls }, + { label: 'Sessions', get: t => t.sessions }, + { label: 'Input tokens', get: t => t.inputTokens }, + { label: 'Output tokens', get: t => t.outputTokens }, + { label: 'Cache read tokens', get: t => t.cacheReadTokens }, + { label: 'Cache write tokens', get: t => t.cacheWriteTokens }, + { label: 'Local-model savings', get: t => t.savingsUSD }, + { label: 'Estimated-price cost', get: t => t.estimatedCostUSD }, + ] + const fmt = (label: string, value: number): string => { + if (label.includes('cost') || label.includes('savings')) return formatUsd(value) + if (label.includes('tokens')) return formatCompact(value) + return value.toLocaleString('en-US') + } + // A range whose sources aged off disk is explained by the durable daily + // history alone, which carries no session detail. That cost is real and it is + // NOT in these totals, so say so where the totals are read — not only in the + // Coverage card at the bottom of the page. + const carriedA = report.history?.aggregateOnly.A ?? 0 + const carriedB = report.history?.aggregateOnly.B ?? 0 + return ( ++ Session detail only. A further {formatUsd(carriedA)} (A) and {formatUsd(carriedB)} (B) of daily history + has no session detail behind it and is NOT in these totals — see Coverage & basis. +
+ )} ++ Denominators: {report.normalized.denominators.perDay}; {report.normalized.denominators.per100Calls}. +
+Each side's cost divided by its own calendar days (A: {report.rangeA.days}, B: {report.rangeB.days}) — differences and percentages compare these daily averages.
+ )} + {view === 'per100Calls' && ( +Each side's cost per 100 of its OWN API calls — efficiency, not scale. A side with zero calls has no cost per call: shown as —.
+ )} +Different range lengths — per-day rows compare daily averages, not totals.
+ )} + {drill && ( +Click a row to inspect the sessions behind it. The project and model lenses describe the SAME global difference from two perspectives — never add them together.
+A session active on both sides of the boundary appears once with its in-range cost on each side — attribution follows each call's own timestamp.
+