3.8 KiB
PR#22: the dashboard marks estimated costs and lists LLM and Jev apart
WARNING: This document describes only the change applied in this PR. It may already be outdated once the next PR is merged. Historic PR documentation is not maintained along with new PRs; treat it as a snapshot.
The Problem
The dashboard of werkrevisor 0.18.0 shows one cost per period: the LLM costs via OpenRouter plus the Jev costs. Some of these amounts are werkrevisor's own calculation from the token counts and the prices in the config:
- the Jev costs always, since TypeSafe reports no amount;
- the LLM costs, if OpenRouter reports no amount for a call.
If a price in the config is outdated, such an amount differs from the bill, but the dashboard shows it like a billed one. The dashboard also does not show how the two providers contribute to the costs.
Non-Goals
- No comparison with the bills of OpenRouter or TypeSafe.
- No change of the usage record: it already holds both parts and the cost status.
The Scenarios
Feature: estimated costs are marked as such
Scenario#22.01: a period with an estimated part shows its total as an estimate
So that nobody takes a calculated amount for a billed one.
- Given a period holds
<costs> - When someone opens the dashboard
- Then the total of the period
<shows>
| costs | shows |
|---|---|
| only LLM costs reported by OpenRouter | the mark "=" |
| a Jev cost | the mark "≈" |
| an LLM cost that werkrevisor estimated | the mark "≈" |
| a review whose LLM cost is unknown | the mark "≈" |
Verified by
- UsageApiIntegrationTest: estimated parts are counted apart
- manual check in a browser, see Measurement
Feature: the costs of the providers are listed apart
Scenario#22.02: the dashboard lists LLM and Jev below the total
So that the reader sees what each provider costs.
- Given the reviews of the last 24 hours cost 0.18 USD for the LLM and 0.0007 USD for Jev
- When someone opens the dashboard
- Then the card of the last 24 hours shows the total "≈ 0.1807 USD"
- and below it, in smaller print, "LLM via OpenRouter = 0.1800 USD" and "Jev via TypeSafe ≈ 0.0007 USD"
Verified by
- UsageApiIntegrationTest: estimated parts are counted apart
- manual check in a browser, see Measurement
The Solution
GET /api/statsreturns per sum alsollmCostUsd,jevCostUsd,estimatedLlmReviews,llmEstimatedandestimated; any Jev cost above 0 makes the total an estimate, and the Jev line always shows "≈", since TypeSafe reports no amounts; the LLM line shows "≈" if an LLM cost is estimated or unknown.- The Web Component marks every amount with "=" if a provider reported it or "≈" if werkrevisor calculated it, and lists LLM and Jev below each total, in smaller print; the tables per day, week and month mark estimated totals too.
- The Jev part of a review counts even if its LLM costs are unknown; before, the whole review was left out of the sum. The list of recent reviews shows such a review with its Jev part and "+ LLM unknown", so that it agrees with the sums.
- werkrevisor 0.18.1.
Measurement
On 2026-10-06, the dashboard ran locally with the 180 usage records of the earlier runs. Each card showed its total with "≈" and below it the LLM and Jev parts, each with "=" or "≈"; the tables per period marked estimated totals and caused no horizontal scrolling of the page, neither at 800 px nor at a phone width of 375 px, where a wide table scrolls inside its own section.
Prerequisite PRs
- PR#21: the statistics service and the dashboard Web Component.