app: show the reset history of each long limit window #16

Merged
schmidt.florian merged 16 commits from 14-reset-history into master 2026-10-18 11:12:40 +02:00
4 changed files with 51 additions and 2 deletions
Showing only changes of commit 058c2b5324 - Show all commits
+1
View File
@@ -72,3 +72,4 @@ Run `dotnet test --project tests/FinalToken.App.Tests -c Release` from the root.
- Resets use the shared detail-table sorting, headers, row placement and expansion. Preserve
the selected window, sort and expansion on renders. Money is invariant USD at API list prices;
unknown models stay unpriced, and percent-derived values and token estimates carry `≈` (D13).
Reset tooltips list every model in Core's token order, with its tokens and API list value.
+2 -2
View File
@@ -22,9 +22,9 @@ public sealed partial class DataTooltip
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))
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)));
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)));
+12
View File
@@ -128,6 +128,18 @@ internal sealed record ResetFixture(HistoryStore Store, Snapshot Snapshot, DateT
public static ResetFixture RunningOnly() => Create([]);
public static ResetFixture OnTimeOnly() => Create([7, 7]);
public static ResetFixture Overlapping() => Create([1, 1, 1, 1, 1]);
public static ResetFixture ManyModels()
{
var fixture = OnTimeOnly();
var start = fixture.History.Resets[0].Instances[1].Start;
string[] models = ["gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna", "gpt-5.4-mini"];
for (var i = 0; i < models.Length; i++)
{
var count = 2_000_123 - i * 200_001;
fixture.Store.Add(new(Provider.Codex, start.AddHours(2), models[i], "Fixture", new(Input: count, Total: count), "extra" + i));
}
return fixture with { History = PanelViewModel.QueryHistory(fixture.Store, fixture.Snapshot, HistoryRange.All, null, fixture.Now) };
}
private static ResetFixture Create(int[] durations)
{
var start = new DateTimeOffset(2026, 9, 12, 6, 0, 0, TimeSpan.Zero);
+36
View File
@@ -14,6 +14,7 @@ internal static class ResetViews
{
public static void Verify(Action<Window, string> save)
{
VerifyEveryModelsTokensAndValue(save);
VerifyScenarios(save);
var fixture = ResetFixture.Create();
var clock = new FixedClock(fixture.Now);
@@ -106,6 +107,41 @@ internal static class ResetViews
}
}
private static void VerifyEveryModelsTokensAndValue(Action<Window, string> save)
{
var fixture = ResetFixture.ManyModels();
var history = fixture.History.Resets[0];
var row = history.Instances[1];
Assert.False(row.Running); Assert.Equal(9, row.Models.Count);
foreach (var theme in new[] { ThemeVariant.Dark, ThemeVariant.Light })
{
var card = new ResetCard(history, new(ResetColumn.Start), new FixedClock(fixture.Now));
var window = new Window { Width = 1280, Height = 1030, RequestedThemeVariant = theme,
Content = new Border { Padding = new Thickness(24), Child = Ui.Card(Ui.Stack(Ui.Text("Codex · Week", 15), card)) } };
Ui.Theme(window); window.Show(); Dispatcher.UIThread.RunJobs();
using (window.CaptureRenderedFrame()) { }
var cell = card.GetVisualDescendants().OfType<Grid>().Single(g => g.Name == "ResetRows")
.Children.OfType<TextBlock>().Single(t => Grid.GetRow(t) == 2 && Grid.GetColumn(t) == 0);
var tip = Assert.IsType<DataTooltip>(ToolTip.GetTip(cell));
foreach (var model in row.Models)
{
var detail = Assert.Single(tip.Rows, r => r.Label == model.Model);
Assert.Equal(DataTooltip.Count(model.Tokens.Total) + " · " + Display.Money(model.ApiValue), detail.Value);
}
Assert.Equal(row.Models.Select(m => m.Model), tip.Rows.Where(r => row.Models.Any(m => m.Model == r.Label)).Select(r => r.Label));
Assert.DoesNotContain(tip.Rows, r => r.Label == "Other models");
var pointer = cell.TranslatePoint(new Point(12, cell.Bounds.Height / 2), window)!.Value;
window.MouseMove(pointer); ToolTip.SetIsOpen(cell, true); Dispatcher.UIThread.RunJobs();
using (window.CaptureRenderedFrame()) { }
Assert.True(ToolTip.GetIsOpen(cell)); Assert.True(tip.Bounds.Width > 320);
var bounds = new PixelRect(tip.PointToScreen(default), PixelSize.FromSize(tip.Bounds.Size, 1));
Assert.False(bounds.Contains(window.PointToScreen(pointer)));
Assert.True(window.Screens.ScreenFromWindow(window)!.WorkingArea.Contains(bounds), $"tooltip {bounds}");
save(window, $"resets-many-models-hover-{theme}.png");
ToolTip.SetIsOpen(cell, false); window.Close();
}
}
private static void VerifyScenarios(Action<Window, string> save)
{
foreach (var (name, fixture) in new[] { ("running-only", ResetFixture.RunningOnly()),