fix: keep a token-model bar visible even at a tiny share
- model bars are 8px tall and a nonzero share paints at least 8px, so a model that is a fraction of a percent of the report still reads as a sliver on the full-width track instead of an empty bar - an emulator check of the live report showed the shares were correct (the top model is 1.0 and renders full width); the many near-zero rows came from the real data, where eight of ten models are under a percent - widget test covers the tokens bar width and the metric grid
This commit is contained in:
1 parent
b65498d73e
commit
2e0308f232
2 files changed
+149
-6
No files matched your search
@@ -689,7 +689,8 @@ class _StatsScreenState extends State<StatsScreen> {
|
||||
Widget _modelRow(ThemeData theme, UsageModelStat model,
|
||||
double Function(UsageModelStat) valueOf, double max) {
|
||||
final value = valueOf(model);
|
||||
final share = max > 0 ? (value / max).clamp(0.0, 1.0) : 0.0;
|
||||
final share =
|
||||
max > 0 ? (value / max).clamp(0.0, 1.0).toDouble() : 0.0;
|
||||
final name = app.modelName(ModelRef(model.modelId, model.providerId,
|
||||
model.variant));
|
||||
final secondary = [
|
||||
@@ -727,8 +728,14 @@ class _StatsScreenState extends State<StatsScreen> {
|
||||
style: TextStyle(fontSize: 11, color: theme.hintColor)),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
SizedBox(
|
||||
height: 6,
|
||||
LayoutBuilder(builder: (context, constraints) {
|
||||
// A nonzero share always paints at least a few pixels, so a small
|
||||
// model reads as a sliver on the track, never as an empty bar.
|
||||
final visible = share <= 0
|
||||
? 0.0
|
||||
: math.max(share, 8 / constraints.maxWidth);
|
||||
return SizedBox(
|
||||
height: 8,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
child: Stack(
|
||||
@@ -737,11 +744,11 @@ class _StatsScreenState extends State<StatsScreen> {
|
||||
// A full-width track: a small share still reads as a sliver
|
||||
// of colour on it, not as an empty bar.
|
||||
ColoredBox(color: theme.dividerColor.withValues(alpha: 0.35)),
|
||||
if (share > 0)
|
||||
if (visible > 0)
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: share,
|
||||
widthFactor: visible,
|
||||
heightFactor: 1,
|
||||
child: _dimension == _ModelDimension.tokens
|
||||
? Row(children: [
|
||||
@@ -763,7 +770,9 @@ class _StatsScreenState extends State<StatsScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user