fix(usage): dedup provider-wide notes and add report-level notes field

Provider-wide disclaimers (e.g. OpenCode Go's "OMP-observed spend
only") were duplicated onto every UsageLimit, then repeated N times
in the TUI aggregate renderer (once per account × window). With
2 accounts × 3 windows, the same disclaimer appeared 6 times
bullet-joined.

Structural fix:
- Add notes?: string[] to UsageReport (interface + both schema
  copies: usage.ts and auth-broker/wire-schemas.ts) so the field
  survives the broker client's "+": "reject" deserialization gate.
- Move opencode-go's disclaimer from per-limit notes to
  provider-level notes.

Defensive fix:
- Dedup identical per-limit notes in the TUI aggregate renderer
  (command-controller.ts) via [...new Set(...)].
- Render provider-level notes once above per-account sections in
  all three rendering paths: TUI (command-controller), CLI
  (usage-cli), and ACP (usage-report helper).

Regression tests:
- usage-cli.test.ts: provider-level notes render once, not
  duplicated per account or limit; positioned above per-account rows.
- usage-report-notes-schema.test.ts: wire-schema round-trip proving
  notes survives usageResponseSchema validation.

Fixes #3268
This commit is contained in:
oldschoola
2026-06-23 06:07:24 -07:00
parent 93d730c01d
commit 6c3f35dfef
10 changed files with 140 additions and 4 deletions
@@ -450,6 +450,9 @@ export function formatUsageBreakdown(
lines.push(
`${chalk.bold.cyan(formatProviderName(provider))} ${chalk.dim(`— ${accountCount} ${accountCount === 1 ? "account" : "accounts"}`)}`,
);
// Provider-wide disclaimers render once per provider, not per limit.
const providerNotes = [...new Set(providerReports.flatMap(report => report.notes ?? []))];
for (const note of providerNotes) lines.push(` ${chalk.dim(note)}`);
const labelWidth = providerReports
.flatMap(report => report.limits)