Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

desktop: the model picker's figures and button end on the panel edge

bitcoinbuilder606318ef0ebf
diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dart
index 07f752b5b..a83706adf 100644
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@ -713,6 +713,9 @@ class _ModelPickerPanelState extends State<_ModelPickerPanel> {
children: [
Text(
percent is double ? '${percent.floor()}% left' : status,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.end,
style: AppType.body(
color: low ? AppColors.warning : AppColors.textSoft,
).copyWith(fontSize: 12.5, fontWeight: FontWeight.w600),
@@ -721,6 +724,9 @@ class _ModelPickerPanelState extends State<_ModelPickerPanel> {
const SizedBox(height: 2),
Text(
low ? 'Running low' : 'Healthy',
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ textAlign: TextAlign.end,
style: AppType.body(color: AppColors.muted)
.copyWith(fontSize: 11),
),
@@ -734,7 +740,12 @@ class _ModelPickerPanelState extends State<_ModelPickerPanel> {
}
Widget _panelSentence(String text) => Padding(
- padding: const EdgeInsets.fromLTRB(9, 4, 9, 8),
+ padding: const EdgeInsets.fromLTRB(
+ kModelPickerInset,
+ 4,
+ kModelPickerInset,
+ 8,
+ ),
child: Text(text, style: AppType.body(color: AppColors.textSoft)),
);
}
diff --git a/desktop/lib/widgets/model_picker_chrome.dart b/desktop/lib/widgets/model_picker_chrome.dart
index 67b33e5a1..5cf6ad9f7 100644
--- a/desktop/lib/widgets/model_picker_chrome.dart
+++ b/desktop/lib/widgets/model_picker_chrome.dart
@@ -24,6 +24,17 @@ const double kModelPickerWidth = 376;
/// The avatar's side, and the gutter its column occupies on every row.
const double kModelAvatarSize = 34;
+/// The one inset every row's CONTENT sits at, from the edge of the box it is in: the search icon,
+/// the section headings, the avatars and the footer's summary all start on this line, and the
+/// counts, the quota figures and the meter all end on it. They used to sit at 16, 21, 24 and 14,
+/// and a column of left edges that close together reads as a mistake rather than as a design.
+const double kModelPickerInset = 12;
+
+/// The widest a row's right-hand column may be. Stated rather than flexed: a Flexible beside the
+/// Expanded title split the row in half and parked the column in the middle of it, away from the
+/// edge the eye looks for a figure at.
+const double kModelPickerTrailingMax = 120;
+
/// The same model artwork used in Models, with a brain fallback for unknown names.
class ModelAvatar extends StatelessWidget {
const ModelAvatar({super.key, required this.label, this.child});
@@ -59,7 +70,7 @@ class ModelPickerSearch extends StatelessWidget {
@override
Widget build(BuildContext context) => Container(
height: 44,
- padding: const EdgeInsets.symmetric(horizontal: 12),
+ padding: const EdgeInsets.symmetric(horizontal: kModelPickerInset),
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(10),
@@ -149,7 +160,12 @@ class ModelPickerSectionHeader extends StatelessWidget {
@override
Widget build(BuildContext context) => Padding(
- padding: const EdgeInsets.fromLTRB(4, 14, 4, 8),
+ padding: const EdgeInsets.fromLTRB(
+ kModelPickerInset,
+ 14,
+ kModelPickerInset,
+ 8,
+ ),
child: Row(
children: [
Expanded(
@@ -253,66 +269,66 @@ class ModelPickerRow extends StatelessWidget {
),
),
if (trailing != null) ...[
- const SizedBox(width: 10),
- // Flexible: a quota column that insisted on its full width overflowed the row at a
- // large text size in a small window.
- Flexible(child: trailing!),
+ const SizedBox(width: 12),
+ // Capped, not flexed — see [kModelPickerTrailingMax]. The cap is also what keeps a quota
+ // column from overflowing the row at a large text size in a small window.
+ ConstrainedBox(
+ constraints: const BoxConstraints(
+ maxWidth: kModelPickerTrailingMax,
+ ),
+ child: trailing!,
+ ),
],
- // The tick's gutter, reserved on every row so a row becoming the chosen one does not
- // shuffle the column beside it.
- SizedBox(
- width: 20,
- child: selected
- ? Icon(
- Icons.check,
- size: 16,
- color: AppColors.accent,
- semanticLabel: 'Selected',
- )
- : null,
- ),
],
);
- return MouseRegion(
- cursor: SystemMouseCursors.click,
- child: InkWell(
- onTap: onTap,
- mouseCursor: SystemMouseCursors.click,
- borderRadius: BorderRadius.circular(11),
- hoverColor: AppColors.rowHover,
- // Focus is a keyboard position, not a decision, and the panel focuses something the moment
- // it opens; painting it would light a row the person never pointed at.
- focusColor: Colors.transparent,
- splashColor: Colors.transparent,
- highlightColor: Colors.transparent,
- child: Container(
- padding: const EdgeInsets.fromLTRB(9, 9, 9, 9),
- decoration: BoxDecoration(
- color: selected ? AppColors.selected : null,
- borderRadius: BorderRadius.circular(11),
- border: selected
- ? Border.all(color: AppColors.accent.withValues(alpha: 0.45))
- : null,
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- row,
- if (meter != null) ...[
- const SizedBox(height: 9),
- ClipRRect(
- borderRadius: BorderRadius.circular(3),
- child: LinearProgressIndicator(
- value: meter!.clamp(0, 1),
- minHeight: 5,
- backgroundColor: AppColors.border,
- valueColor: AlwaysStoppedAnimation(
- note ?? AppColors.accent,
+ // No tick. The fill and its border are the mark, and a tick beside a quota figure crowded the
+ // one thing on the row worth reading. A screen reader is told in words instead.
+ return Semantics(
+ selected: selected,
+ child: MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: InkWell(
+ onTap: onTap,
+ mouseCursor: SystemMouseCursors.click,
+ borderRadius: BorderRadius.circular(11),
+ hoverColor: AppColors.rowHover,
+ // Focus is a keyboard position, not a decision, and the panel focuses something the moment
+ // it opens; painting it would light a row the person never pointed at.
+ focusColor: Colors.transparent,
+ splashColor: Colors.transparent,
+ highlightColor: Colors.transparent,
+ child: Container(
+ padding: const EdgeInsets.symmetric(
+ horizontal: kModelPickerInset,
+ vertical: 9,
+ ),
+ decoration: BoxDecoration(
+ color: selected ? AppColors.selected : null,
+ borderRadius: BorderRadius.circular(11),
+ border: selected
+ ? Border.all(color: AppColors.accent.withValues(alpha: 0.45))
+ : null,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ row,
+ if (meter != null) ...[
+ const SizedBox(height: 9),
+ ClipRRect(
+ borderRadius: BorderRadius.circular(3),
+ child: LinearProgressIndicator(
+ value: meter!.clamp(0, 1),
+ minHeight: 5,
+ backgroundColor: AppColors.border,
+ valueColor: AlwaysStoppedAnimation(
+ note ?? AppColors.accent,
+ ),
),
),
- ),
+ ],
],
- ],
+ ),
),
),
),
@@ -336,13 +352,20 @@ class ModelPickerFooter extends StatelessWidget {
@override
Widget build(BuildContext context) => Container(
- padding: const EdgeInsets.fromLTRB(14, 10, 12, 12),
+ // The summary starts on the content line the rows above it use; the button's box ends on the
+ // line their boxes end on, and sits as far from the panel's bottom as from its side.
+ padding: const EdgeInsets.fromLTRB(12 + kModelPickerInset, 12, 12, 12),
decoration: BoxDecoration(
border: Border(top: BorderSide(color: AppColors.border)),
),
child: Row(
+ // ⚠️ Both halves Flexible and pushed apart, never Expanded + Flexible. That pair splits the
+ // row down the middle and leaves the button at the START of its half, stranded short of
+ // the right edge. Flexible still gives each half a fair share when a large text size means
+ // they cannot both have everything they want.
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Expanded(
+ Flexible(
child: Text(
summary,
maxLines: 1,
@@ -350,6 +373,7 @@ class ModelPickerFooter extends StatelessWidget {
style: AppType.body(color: AppColors.muted).copyWith(fontSize: 12),
),
),
+ const SizedBox(width: 12),
Flexible(
child: MouseRegion(
cursor: SystemMouseCursors.click,
diff --git a/desktop/test/grid_model_picker_test.dart b/desktop/test/grid_model_picker_test.dart
index 3a42f446f..c30b6c14f 100644
--- a/desktop/test/grid_model_picker_test.dart
+++ b/desktop/test/grid_model_picker_test.dart
@@ -1,5 +1,5 @@
-// The pane header's model picker: two sections, the way back always offered, and a tick that says
-// where the agent actually is.
+// The pane header's model picker: two sections, the way back always offered, and a marked row that
+// says where the agent actually is.
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:harness/widgets/box_chrome.dart';
@@ -211,25 +211,24 @@ void main() {
expect(manage, 0);
});
- testWidgets(
- 'rows can be reached and activated from the keyboard',
- (tester) async {
- // Start on a local model: choosing an already selected subscription intentionally does
- // nothing. Down must leave search and Enter must switch to the subscription row.
- var ownLogin = 0;
- build(
- models: const [
- {'id': 'Qwen-Test', 'node': 'macbook'},
- ],
- );
- await open(tester, currentModel: 'Qwen-Test', onOwnLogin: () => ownLogin++);
- await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
- await tester.pumpAndSettle();
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pumpAndSettle();
- expect(ownLogin, 1);
- },
- );
+ testWidgets('rows can be reached and activated from the keyboard', (
+ tester,
+ ) async {
+ // Start on a local model: choosing an already selected subscription intentionally does
+ // nothing. Down must leave search and Enter must switch to the subscription row.
+ var ownLogin = 0;
+ build(
+ models: const [
+ {'id': 'Qwen-Test', 'node': 'macbook'},
+ ],
+ );
+ await open(tester, currentModel: 'Qwen-Test', onOwnLogin: () => ownLogin++);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.pumpAndSettle();
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(ownLogin, 1);
+ });
// THREE situations, two sentences and one silence, one test each — a single test cannot cover
// them, because re-pumping the same widget reuses the State and the picker answers from the memo
@@ -730,13 +729,13 @@ void main() {
build(models: served);
await open(tester, currentModel: 'Qwen-Test');
- // It is not a ModelPickerRow at all, so it cannot wear the fill or the tick that says
- // where the agent is.
- final titles = tester
- .widgetList<ModelPickerRow>(find.byType(ModelPickerRow))
- .map((r) => r.title);
- expect(titles, isNot(contains('Local models')));
- expect(find.byIcon(Icons.check), findsOneWidget);
+ // It is not a ModelPickerRow at all, so it cannot wear the fill that says where the agent
+ // is.
+ final rows = tester.widgetList<ModelPickerRow>(
+ find.byType(ModelPickerRow),
+ );
+ expect(rows.map((r) => r.title), isNot(contains('Local models')));
+ expect(rows.where((r) => r.selected).map((r) => r.title), ['Qwen-Test']);
});
testWidgets('fires onRunLocalModel and nothing else', (tester) async {
@@ -914,15 +913,16 @@ void main() {
// ── which row is the current one ─────────────────────────────────────────────────────────────
//
- // The panel says it twice, deliberately: a fill on the row and a tick at its end. A fill alone
- // could not carry it — hover paints one too, and the pointer decides where that lands. The
- // row's own colours are `pane_menu_row_test`; what is asked here is which ROW gets them.
+ // The mark is the fill and its accent border, and nothing else: the tick it used to carry sat
+ // beside the quota figure and crowded it, and was taken out on request. Hover paints a fill too,
+ // but never the border, which is what keeps the two apart. What is asked here is which ROW gets
+ // the mark, and that a screen reader is told which one it is.
ModelPickerRow rowFor(WidgetTester tester, String title) => tester
.widgetList<ModelPickerRow>(find.byType(ModelPickerRow))
.firstWhere((r) => r.title == title);
- testWidgets('exactly one row is marked, and it carries the tick', (
+ testWidgets('exactly one row is marked, with no tick beside it', (
tester,
) async {
build(
@@ -936,7 +936,16 @@ void main() {
expect(rowFor(tester, 'Qwen-Test').selected, isTrue);
expect(rowFor(tester, 'DeepSeek-Test').selected, isFalse);
expect(rowFor(tester, 'Anthropic').selected, isFalse);
- expect(find.byIcon(Icons.check), findsOneWidget);
+ expect(find.byIcon(Icons.check), findsNothing);
+ expect(
+ // `.last`: the header control names the current model too.
+ tester.getSemantics(find.text('Qwen-Test').last),
+ containsSemantics(isSelected: true),
+ );
+ expect(
+ tester.getSemantics(find.text('DeepSeek-Test')),
+ isNot(containsSemantics(isSelected: true)),
+ );
});
testWidgets('the subscription row is the marked one when no model is set', (
@@ -951,7 +960,7 @@ void main() {
expect(rowFor(tester, 'Anthropic').selected, isTrue);
expect(rowFor(tester, 'Qwen-Test').selected, isFalse);
- expect(find.byIcon(Icons.check), findsOneWidget);
+ expect(find.byIcon(Icons.check), findsNothing);
});
// ── the selection has to land before the machine confirms it ──────────────────────────────────
diff --git a/desktop/test/model_picker_chrome_test.dart b/desktop/test/model_picker_chrome_test.dart
new file mode 100644
index 000000000..9f11c71de
--- /dev/null
+++ b/desktop/test/model_picker_chrome_test.dart
@@ -0,0 +1,78 @@
+// Where the model picker's furniture sits: the figures and the one button end on the edges the eye
+// looks for them at, rather than wherever a flex split happened to leave them.
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/widgets/model_picker_chrome.dart';
+
+Widget _frame(Widget child, {double width = kModelPickerWidth}) => MaterialApp(
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: SizedBox(width: width, child: child),
+ ),
+ ),
+);
+
+void main() {
+ testWidgets('the quota column ends where the meter under it ends', (
+ tester,
+ ) async {
+ // ⚠️ REGRESSION. The column was Flexible beside an Expanded title, which split the row in half
+ // and parked "43% left" in the middle of it, a tick's width and more short of the edge.
+ await tester.pumpWidget(
+ _frame(
+ ModelPickerRow(
+ title: 'Anthropic',
+ subtitle: 'key ···315df1',
+ selected: true,
+ onTap: () {},
+ trailing: const Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ mainAxisSize: MainAxisSize.min,
+ children: [Text('43% left'), Text('Healthy')],
+ ),
+ meter: 0.43,
+ ),
+ ),
+ );
+
+ final meter = tester.getRect(find.byType(LinearProgressIndicator));
+ expect(tester.getRect(find.text('43% left')).right, meter.right);
+ expect(tester.getRect(find.text('Healthy')).right, meter.right);
+ expect(find.byIcon(Icons.check), findsNothing);
+ });
+
+ testWidgets('the footer button ends on the panel edge, not mid-row', (
+ tester,
+ ) async {
+ // ⚠️ REGRESSION. Expanded summary + Flexible button split the row in half and left the button
+ // at the start of its half. Wider than the real panel on purpose: the test font draws every
+ // glyph a full em wide, so at the real width both halves are full and ANY split looks right.
+ const width = 600.0;
+ await tester.pumpWidget(
+ _frame(
+ width: width,
+ ModelPickerFooter(
+ summary: '5 models available',
+ actionLabel: 'Local models',
+ onAction: () {},
+ ),
+ ),
+ );
+
+ final button = tester.getRect(
+ find
+ .ancestor(
+ of: find.text('Local models'),
+ matching: find.byType(InkWell),
+ )
+ .first,
+ );
+ // The same 12 the search box and the rows' boxes keep from the panel's side.
+ expect(button.right, width - 12);
+ expect(
+ tester.getRect(find.text('5 models available')).left,
+ 12 + kModelPickerInset,
+ );
+ });
+}