Files
FinalToken/src/FinalToken.App/ResetTooltip.cs
T
Florian Schmidt 058c2b5324
agent-review agent review: pass
app: list every model in the reset tooltip
The tooltip showed five models and folded the rest into a count, and no
other view shows a past instance's models. D12 asks for tokens and API value
by model for every instance, so the tooltip now lists all of them.

Refs #14
2026-10-18 11:04:57 +02:00

54 lines
3.5 KiB
C#

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))
};
if (row.Models.Count > 0) rows.Add(new("Models", row.Models.Count.ToString()));
foreach (var model in row.Models)
rows.Add(new(model.Model ?? "Unknown model", Count(model.Tokens.Total) + " · " + Display.Money(model.ApiValue)));
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)));
}
}