From bd8afeb6867b110e8ae8141021bb1c50be04371a Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Thu, 26 Nov 2026 20:54:03 +0800 Subject: [PATCH] fix: give token bars a height so their fills paint A Row lays a childless ColoredBox out at zero height (the cross axis is loose), so the token segments in the model bars, the token-composition bar and the tool success bars painted nothing, while the single-ColoredBox steps/cost bars worked. Stretching those rows makes the fills visible; the stats test now asserts a token segment's height, not only its width. --- lib/screens/stats_screen.dart | 8 +++++++- test/stats_screen_test.dart | 16 +++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/screens/stats_screen.dart b/lib/screens/stats_screen.dart index 575f7c0..77b3c3d 100644 --- a/lib/screens/stats_screen.dart +++ b/lib/screens/stats_screen.dart @@ -592,7 +592,10 @@ class _StatsScreenState extends State { borderRadius: BorderRadius.circular(5), child: SizedBox( height: 10, + // A Row lays a childless ColoredBox out at zero height unless + // the cross axis is stretched; without this the bar is invisible. child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ for (final segment in segments) if (segment.value > 0) @@ -751,7 +754,9 @@ class _StatsScreenState extends State { widthFactor: visible, heightFactor: 1, child: _dimension == _ModelDimension.tokens - ? Row(children: [ + ? Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ for (final (i, value) in [ model.tokens.input, model.tokens.produced, @@ -866,6 +871,7 @@ class _StatsScreenState extends State { child: SizedBox( height: 5, child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ if (tool.succeeded > 0) Expanded( diff --git a/test/stats_screen_test.dart b/test/stats_screen_test.dart index a369a03..efbc7cf 100644 --- a/test/stats_screen_test.dart +++ b/test/stats_screen_test.dart @@ -56,10 +56,10 @@ Map _report() => { 'model': {'providerID': 'axonhub', 'id': 'deepseek-flash'}, 'steps': 100, 'tokens': { - 'input': 100000, - 'output': 50000, - 'reasoning': 20000, - 'cache': {'read': 900000, 'write': 5000}, + 'input': 56900000, + 'output': 4000000, + 'reasoning': 1400000, + 'cache': {'read': 1266000000, 'write': 0}, }, 'cost': 0, }, @@ -92,8 +92,6 @@ void main() { app.client = Client(Uri.parse('http://test'), transport: _FakeTransport(_report())); await tester.pumpWidget(MaterialApp(home: StatsScreen(app: app))); await tester.pumpAndSettle(); - final texts = tester.widgetList(find.byType(Text)).map((t) => t.data).whereType().toList(); - debugPrint('TEXTS: ${texts.take(20).toList()}'); } testWidgets('the tokens model bar paints a share of the row', (tester) async { @@ -114,10 +112,14 @@ void main() { for (final box in tester .renderObjectList(find.byWidgetPredicate( (w) => w is ColoredBox && w.color == color))) { + // A Row of childless ColoredBoxes collapses to zero height unless the + // cross axis is stretched; that is what made the bars look empty. + expect(box.size.height, greaterThan(0), + reason: 'token segments must have height, got ${box.size}'); widest = box.size.width > widest ? box.size.width : widest; } } - // The top model has 92% of all tokens, so its fill is hundreds of px. + // The top model has most of all tokens, so its fill is hundreds of px. expect(widest, greaterThan(200), reason: 'token-segment fills must paint; widest was $widest'); });