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.
This commit is contained in:
1 parent
2e0308f232
commit
bd8afeb686
2 files changed
+16
-8
No files matched your search
@@ -592,7 +592,10 @@ class _StatsScreenState extends State<StatsScreen> {
|
||||
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<StatsScreen> {
|
||||
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<StatsScreen> {
|
||||
child: SizedBox(
|
||||
height: 5,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (tool.succeeded > 0)
|
||||
Expanded(
|
||||
|
||||
@@ -56,10 +56,10 @@ Map<String, dynamic> _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<Text>(find.byType(Text)).map((t) => t.data).whereType<String>().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<RenderBox>(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');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user