app: show the reset history of each long limit window

A Resets section after the window charts gives, per provider, totals for
the listed instances, a timeline with each burn-up and the skipped time,
early resets by local hour and weekday, and a sortable instance table with
a detailed tooltip per row (D8, D12). The breakdown and reset tables share
their sorting, header and expander code.

Refs #14
This commit is contained in:
Florian Schmidt
2026-10-18 10:07:40 +02:00
parent 1c3f857a2c
commit e39a244751
13 changed files with 612 additions and 25 deletions
+53
View File
@@ -0,0 +1,53 @@
using FinalToken.Core;
namespace FinalToken.App;
public sealed partial class DataTooltip
{
public static DataTooltip Reset(ResetInstance row, TimeProvider clock)
{
var rows = new List<TooltipRow>
{
new("Start", Display.Projection(row.Start, clock)),
new(row.Running ? "As of" : "End", Display.Projection(row.End, clock)),
new("Nominal reset", Display.Projection(row.Reset, clock)),
new("Lasted", Display.ResetDuration(row.Duration)),
new("Final use", Display.ResetPercent(row.Final.Used, row.Final.Origin)),
new("Peak", row.Peak is { } peak ? Display.ResetPercent(peak, row.PeakOrigin) : "Collecting history"),
new("100 % reached", row.ReachedLimit is { } reached ?
(row.BurnUp.ReachedOrigin == UseOrigin.Estimated ? "≈ " : "") + Display.Projection(reached, clock) : "Not reached"),
new("Time at 100 %", Display.ResetDuration(row.TimeAtLimit)),
new("Total tokens", Count(row.Tokens.Total)), new("Input", Count(row.Tokens.Input)),
new("Cache read", Count(row.Tokens.CacheRead)), new("Cache write", Count(row.Tokens.CacheWrite)),
new("Output", Count(row.Tokens.Output)), new("Reasoning (in output)", Count(row.Tokens.ReasoningOutput)),
new("API list value", Display.Money(row.ApiValue)), new("Unpriced tokens", Count(row.UnpricedTokens))
};
foreach (var model in row.Models.Take(5))
rows.Add(new(model.Model ?? "Unknown model", Count(model.Tokens.Total) + " · " + Display.Money(model.ApiValue)));
if (row.Models.Count > 5) rows.Add(new("Other models", (row.Models.Count - 5).ToString()));
rows.Add(new("Tokens per percent", row.ValuePerPercent is { } rate ? "≈ " + Display.Compact(rate.Tokens) +
" · " + rate.Tokens.ToString("N2") : "No qualifying instance"));
rows.Add(new("API value per percent", Display.Money(row.ValuePerPercent?.ApiValue)));
rows.Add(new("Value basis", row.ValuePerPercent?.Basis switch
{
PercentBasis.OwnInstance => "Own instance (final ≥ 5 %)",
PercentBasis.SeriesMedian => "Median of qualifying listed instances",
_ => "No instance with final ≥ 5 %"
}));
if (row.Unused is { } unused) AddValue("Unused", unused);
if (row.Gift is { } gift) { AddValue("Gift", gift); rows.Add(new("Skipped", Display.ResetDuration(row.Skipped))); }
var estimates = new List<string>();
if (row.Final.Origin == UseOrigin.Estimated) estimates.Add("final");
if (row.PeakOrigin == UseOrigin.Estimated) estimates.Add("peak");
if (row.BurnUp.ReachedOrigin == UseOrigin.Estimated) estimates.Add("100 % time");
if (row.Unused is not null) estimates.Add("unused value");
if (row.Gift is not null) estimates.Add("gift value");
rows.Add(new("Estimated figures", estimates.Count == 0 ? "API list value" : string.Join(", ", estimates) + ", API list value"));
rows.Add(new("Prices checked", ApiPrices.CheckedOn.ToString("yyyy-MM-dd") + " · hourly boundary tokens"));
return new(row.Running ? "Running instance" : row.Early ? "Early reset" : "On-time reset", rows.ToArray());
void AddValue(string label, ResetValue value) => rows.Add(new(label,
Display.ResetPercent(value.Percent, UseOrigin.Estimated) + " · " +
(value.Tokens is { } count ? "≈ " + Display.Compact(count) + " tokens · " : "") + Display.Money(value.ApiValue)));
}
}