app: redesign the panel and add limit forecasts and daily week use (#6)

Redesign the stats panel after the developer's feedback on v1 and add
limit forecasts, daily week use and token-based estimates (D7, D8).

- Panel: a fixed header with range and provider controls, limit tiles
  with pace chips, meters and forecasts, week use per day, token KPIs
  and charts, one burn-up chart per limit window with past instances,
  and a sortable breakdown whose "Other" row expands. One tooltip
  component for every chart, tile and table.
- Core (D7): average and recent-rate forecasts, the reach date whenever
  use is over pace, days of a long window with even pace and daily
  budget, window instances derived from resets with a 15-minute
  tolerance, and estimates from price-weighted tokens where samples are
  missing. Forecasts start at 10 % of a window, or as soon as it is
  ahead, so a Codex week far ahead right after its reset warns too.
- Settings, popups and the version (1.1.0) follow the new design.

Closes #5
Closes #7
This commit was merged in pull request #6.
This commit is contained in:
2026-10-15 19:06:04 +02:00
parent f8afd11679
commit adb8f5b88d
31 changed files with 2461 additions and 246 deletions
+55 -1
View File
@@ -5,13 +5,67 @@ namespace FinalToken.App.Tests;
public sealed class FormattingTests
{
[Theory]
[InlineData(6000000000, "6 B")]
[InlineData(2000000000, "2 B")]
[InlineData(1500000000, "1,5 B")]
[InlineData(600000000, "600 M")]
[InlineData(82500, "82,5 K")]
[InlineData(0, "0")]
public void AxisNumbersDropTrailingZerosWithoutChangingCompactValues(double value, string expected)
{
var previous = CultureInfo.CurrentCulture;
try
{
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");
Assert.Equal(expected, Display.Axis(value));
Assert.Equal("2,00 B", Display.Compact(2000000000));
}
finally { CultureInfo.CurrentCulture = previous; }
}
[Theory]
[InlineData(292950000, "293 M")]
[InlineData(2300000000, "2,30 B")]
[InlineData(966690000, "967 M")]
[InlineData(82500, "82,5 K")]
[InlineData(999950, "1,00 M")]
[InlineData(0, "0")]
public void CompactNumbersUseThreeSignificantDigits(double value, string expected)
{
var previous = CultureInfo.CurrentCulture;
try { CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("de-DE"); Assert.Equal(expected, Display.Compact(value)); }
finally { CultureInfo.CurrentCulture = previous; }
}
[Theory]
[InlineData(FinalToken.Core.PaceState.Ahead, true)]
[InlineData(FinalToken.Core.PaceState.OnTrack, false)]
[InlineData(FinalToken.Core.PaceState.Behind, false)]
[InlineData(FinalToken.Core.PaceState.Unknown, false)]
public void ForecastWarningFollowsState(FinalToken.Core.PaceState state, bool warning)
{
var text = Display.Forecast(new(2026, 10, 18, 14, 43, 0, TimeSpan.Zero), state);
Assert.Equal(warning, text.Contains('⚠'));
Assert.StartsWith(warning ? "⚠ 100 % on " : "At this pace 100 % on ", text);
}
[Theory]
[InlineData(1)]
[InlineData(1.25)]
[InlineData(2)]
public void DenseBarEdgesMeetOnPhysicalPixelsWithoutGaps(double scaling)
{
var first = UsageChart.BarBounds(50.13, 100, 3.17, 40, scaling);
var next = UsageChart.BarBounds(53.30, 100, 3.17, 40, scaling);
Assert.Equal(first.Right, next.Left, 6);
Assert.Equal(Math.Round(first.Left * scaling), first.Left * scaling, 6);
Assert.Equal(Math.Round(first.Right * scaling), first.Right * scaling, 6);
}
[Fact]
public void DailyChartLabelAndTooltipUseTheBucketsLocalDate()
{
var zone = TimeZoneInfo.CreateCustomTimeZone("Fixture+02", TimeSpan.FromHours(2), "Fixture", "Fixture");
var day = FinalToken.Core.CalendarDays.Start(new DateTimeOffset(2026, 10, 14, 12, 0, 0, TimeSpan.Zero), zone);
Assert.Equal("10-14", Display.ChartDateLabel(day, TimeSpan.FromDays(1)));
Assert.Equal(day.DateTime.ToString("g"), Display.ChartTimestamp(day, TimeSpan.FromDays(1)));
Assert.Equal(day.DateTime.ToString("d"), Display.ChartTimestamp(day, TimeSpan.FromDays(1)));
}
[Theory]
[InlineData(null)]