Runs list carries per-run token usage; app shows tokens beside size, Most tokens sort, Summary and stage tokens

This commit is contained in:
2026-11-03 22:04:55 +00:00
parent fa6c0864db
commit aa948bdfe4
19 changed files with 620 additions and 30 deletions
+8 -4
View File
@@ -197,6 +197,14 @@ type RunSummary struct {
// session directories and an estimate of its database rows. It is cached
// server-side; 0 means not measured yet (a background backfill fills it).
SizeBytes int64 `json:"size_bytes"`
// Usage is the totalled reported usage of the run's model stages. The run
// list sums it with one SQL aggregate per batch over the stored per-stage
// usage rows; the run detail sums the same rows in one pass over its loaded
// steps (TotalUsage). It is absent for a run with no model usage recorded
// (including historical runs and servers predating the list aggregate), so
// a client shows nothing rather than zero. A total is partial when
// TokensKnownStages < Stages.
Usage *RunUsage `json:"usage,omitempty"`
}
// RunGraphVisit contains only routing and lifecycle facts, never private step
@@ -433,10 +441,6 @@ type RunDetail struct {
Input map[string]any `json:"input"`
Output map[string]any `json:"output"`
Steps []RunStep `json:"steps"`
// Usage is the totalled reported usage of the run's model stages, summed in
// one pass over Steps. It is absent for a run with no model usage recorded
// (including historical runs).
Usage *RunUsage `json:"usage,omitempty"`
// TitleSource is "model" when Title came from the shared summariser or
// "fallback" when it was derived from the prompt; TitleModel names the model
// that produced a model title. They are retained so a diagnosis can tell the