Skip to content

Commit 1560c7a

Browse files
committed
fix(usage): retain reset history and unify accounting
Keep family selection within the recorded agent and assign each instance once. Carry discovered SQLite or JSONL sources into batched loading, including empty current sessions and history encountered before a current artifact. Share Gateway and Control UI aggregation and total arithmetic, use canonical pricing for detail logs, and invalidate both result caches on config changes. Split calendar, cache, selection, and loading owners out of the usage handler. Add failing-before regressions for reset history, overlapping families, mixed sources, config replacement, missing-price exports, and log pricing.
1 parent 4ec40f1 commit 1560c7a

23 files changed

Lines changed: 2282 additions & 1976 deletions

‎config/assertion-safety-baseline.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,7 +2990,6 @@ src/gateway/server-methods/terminal.ts 7
29902990
src/gateway/server-methods/tools-catalog.ts 2
29912991
src/gateway/server-methods/ui-command.ts 1
29922992
src/gateway/server-methods/update.ts 2
2993-
src/gateway/server-methods/usage.ts 3
29942993
src/gateway/server-methods/web.ts 3
29952994
src/gateway/server-methods/wizard.ts 1
29962995
src/gateway/server-methods/workspace-fs.ts 2
@@ -3239,7 +3238,7 @@ src/infra/session-cost-usage-cache-runtime.ts 1
32393238
src/infra/session-cost-usage-cache.sqlite.ts 1
32403239
src/infra/session-cost-usage-collection.ts 4
32413240
src/infra/session-cost-usage-pricing.ts 6
3242-
src/infra/session-cost-usage-reporting.ts 9
3241+
src/infra/session-cost-usage-reporting.ts 8
32433242
src/infra/session-delivery-queue-runtime.ts 1
32443243
src/infra/session-delivery-queue-storage.ts 6
32453244
src/infra/shell-env.ts 1

‎config/max-lines-baseline.txt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,6 @@ src/gateway/server-methods/sessions-files.ts
653653
src/gateway/server-methods/skills.ts
654654
src/gateway/server-methods/talk.test.ts
655655
src/gateway/server-methods/talk.ts
656-
src/gateway/server-methods/usage.ts
657656
src/gateway/server-node-events.test.ts
658657
src/gateway/server-node-events.ts
659658
src/gateway/server-plugins.test.ts
@@ -884,7 +883,6 @@ ui/src/pages/sessions/view.test.ts
884883
ui/src/pages/sessions/view.ts
885884
ui/src/pages/skill-workshop/view.ts
886885
ui/src/pages/skills/view.ts
887-
ui/src/pages/usage/metrics.ts
888886
ui/src/pages/usage/view-details.ts
889887
ui/src/pages/usage/view-overview.ts
890888
ui/src/pages/usage/view.ts

‎docs/reference/api-usage-costs.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Map of OpenClaw features that can call paid provider APIs, where each reads its
2828

2929
- Shows transcript-derived token and estimated-cost totals for the selected date range, with breakdowns by provider, model, agent, channel, and token type.
3030
- Named sessions use their stored agent owner. Identical session IDs under different agents remain separate, including when historical lineage is grouped.
31+
- Grouped history remains visible after a session reset, even before the new session has its first message. Filtering and JSON exports retain the breakdown of entries with missing model prices.
3132
- Compares shorter calendar windows ending on the selected range end date. Missing dates count as zero-usage calendar days; they are not skipped to create a denser window.
3233
- Labels the daily chart scale directly. A `√` badge means square-root compression is keeping low-usage days visible.
3334
- These totals describe the available local session history, not a provider invoice or lifetime billing ledger. The UI warns when pricing is missing for some entries.

‎scripts/check-session-accessor-boundary.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const readOnlyGatewaySessionAccessorFiles = new Set([
268268
"src/gateway/server-methods/sessions-subscriptions.ts",
269269
"src/gateway/server-methods/task-suggestions.ts",
270270
"src/gateway/server-methods/tools-effective.ts",
271-
"src/gateway/server-methods/usage.ts",
271+
"src/gateway/server-methods/usage-session-selection.ts",
272272
"src/gateway/server-session-events.ts",
273273
]);
274274

0 commit comments

Comments
 (0)