In the Electron app / standalone server, session cost is never calculated. calculateMetrics (src/main/utils/jsonl.ts:349) declares const costUsd = 0 and returns costUsd: costUsd > 0 ? costUsd : undefined, so metrics.costUsd is always undefined and the export (src/renderer/utils/sessionExporter.ts:29, formatCost) always prints N/A. Upstream has the same code. Cost exists only in the CLI (roundCostUsd, src/cli/analyzeSession.ts:203).
Depends on #72 (correct price table first).
Что сделать
- Вынести таблицу цен и
roundCostUsd из src/cli/analyzeSession.ts в src/shared/ — единый источник для CLI и приложения.
- Считать
costUsd в calculateMetrics по уже дедуплицированным раундам (deduplicateByRequestId), с учётом модели каждого раунда.
- Для неизвестной модели — частичная стоимость с флагом (как
costPartial в CLI), а не молчаливый 0.
- Показать стоимость там, где показываются токены (экспорт уже готов; UI — по необходимости).
Acceptance
In the Electron app / standalone server, session cost is never calculated.
calculateMetrics(src/main/utils/jsonl.ts:349) declaresconst costUsd = 0and returnscostUsd: costUsd > 0 ? costUsd : undefined, sometrics.costUsdis alwaysundefinedand the export (src/renderer/utils/sessionExporter.ts:29,formatCost) always printsN/A. Upstream has the same code. Cost exists only in the CLI (roundCostUsd,src/cli/analyzeSession.ts:203).Depends on #72 (correct price table first).
Что сделать
roundCostUsdизsrc/cli/analyzeSession.tsвsrc/shared/— единый источник для CLI и приложения.costUsdвcalculateMetricsпо уже дедуплицированным раундам (deduplicateByRequestId), с учётом модели каждого раунда.costPartialв CLI), а не молчаливый 0.Acceptance
totalsFromRounds) иcalculateMetricsдают одинаковую стоимость на одной фикстуре — parity-тест по образцуtest/shared/turnAccounting.parity.test.tsN/Aдля известных моделейpnpm typecheck && pnpm testзелёные