Skip to content

App never computes session cost — costUsd is hardcoded to 0 #73

Description

@axisrow

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).

Что сделать

  1. Вынести таблицу цен и roundCostUsd из src/cli/analyzeSession.ts в src/shared/ — единый источник для CLI и приложения.
  2. Считать costUsd в calculateMetrics по уже дедуплицированным раундам (deduplicateByRequestId), с учётом модели каждого раунда.
  3. Для неизвестной модели — частичная стоимость с флагом (как costPartial в CLI), а не молчаливый 0.
  4. Показать стоимость там, где показываются токены (экспорт уже готов; UI — по необходимости).

Acceptance

  • CLI (totalsFromRounds) и calculateMetrics дают одинаковую стоимость на одной фикстуре — parity-тест по образцу test/shared/turnAccounting.parity.test.ts
  • Экспорт сессии показывает сумму вместо N/A для известных моделей
  • Сессия со смешанными known/unknown моделями помечается как частичная
  • pnpm typecheck && pnpm test зелёные
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions