diff --git a/src/FinalToken.App/AGENTS.md b/src/FinalToken.App/AGENTS.md index fcb9e41..d540550 100644 --- a/src/FinalToken.App/AGENTS.md +++ b/src/FinalToken.App/AGENTS.md @@ -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. diff --git a/src/FinalToken.App/ResetTooltip.cs b/src/FinalToken.App/ResetTooltip.cs index 471a5d2..cf37056 100644 --- a/src/FinalToken.App/ResetTooltip.cs +++ b/src/FinalToken.App/ResetTooltip.cs @@ -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))); diff --git a/tests/FinalToken.App.Tests/ResetTests.cs b/tests/FinalToken.App.Tests/ResetTests.cs index bb05f73..753a184 100644 --- a/tests/FinalToken.App.Tests/ResetTests.cs +++ b/tests/FinalToken.App.Tests/ResetTests.cs @@ -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); diff --git a/tests/FinalToken.App.Tests/ResetViews.cs b/tests/FinalToken.App.Tests/ResetViews.cs index 6e080f5..477963e 100644 --- a/tests/FinalToken.App.Tests/ResetViews.cs +++ b/tests/FinalToken.App.Tests/ResetViews.cs @@ -14,6 +14,7 @@ internal static class ResetViews { public static void Verify(Action 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 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().Single(g => g.Name == "ResetRows") + .Children.OfType().Single(t => Grid.GetRow(t) == 2 && Grid.GetColumn(t) == 0); + var tip = Assert.IsType(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 save) { foreach (var (name, fixture) in new[] { ("running-only", ResetFixture.RunningOnly()),