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 stands on its own ink, and tests stop reading real usage

dee22e3f155ac3d
diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dart
index 24db58677..b357f14ba 100644
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import '../core/models.dart';
+import '../core/test_run.dart';
import '../state/app_state.dart';
import '../theme/app_theme.dart';
import '../usage/models_menu_controller.dart';
@@ -109,7 +110,10 @@ class _GridModelPickerState extends State<GridModelPicker> {
// row's provider name and percentage, and skipping it left that row falling back to the bare
// engine label with no status beside it.
_usage ??= ModelsMenuController(remote: widget.notifier.readRemoteUsage);
- unawaited(_usage!.refresh().catchError((_) {}));
+ // Not under `flutter test`: a refresh reads the Keychain and asks the vendors, the same reads the
+ // usage rail keeps out of tests (kUnderTest) — here every test that drew a pane header left that
+ // work's timers pending after the tree was gone. Opening the menu still refreshes.
+ if (!kUnderTest) unawaited(_usage!.refresh().catchError((_) {}));
final answer = await widget.notifier.gridModels(widget.machineId);
if (mounted) _last = answer;
}
@@ -481,39 +485,44 @@ class _GridModelPickerState extends State<GridModelPicker> {
// person sees while hovering this was whatever the surface underneath asked for — so a
// control that opens a menu did not look like one until you clicked it.
cursor: SystemMouseCursors.click,
- child: InkWell(
- onTap: _open,
- // Stated on the InkWell as well as on the MouseRegion above it. The cursor a person sees is
- // the INNERMOST annotation under the pointer, and InkWell installs one of its own — so an
- // ancestor asking for a hand is not, by itself, the thing that decides.
- mouseCursor: SystemMouseCursors.click,
- borderRadius: BorderRadius.circular(4),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- // No leading glyph: the word carries the control, and a header this dense reads
- // better with one fewer mark in it. The spinner takes that space only while a read
- // is in flight, so the label does not shift when nothing is happening.
- if (_loading) ...[
- const SizedBox(
- width: 11,
- height: 11,
- child: CircularProgressIndicator(strokeWidth: 1.5),
+ // Its own ink surface: an InkWell needs a Material above it, and a pane header is not
+ // always inside one — every test that drew a header threw "No Material widget found".
+ child: Material(
+ type: MaterialType.transparency,
+ child: InkWell(
+ onTap: _open,
+ // Stated on the InkWell as well as on the MouseRegion above it. The cursor a person sees is
+ // the INNERMOST annotation under the pointer, and InkWell installs one of its own — so an
+ // ancestor asking for a hand is not, by itself, the thing that decides.
+ mouseCursor: SystemMouseCursors.click,
+ borderRadius: BorderRadius.circular(4),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // No leading glyph: the word carries the control, and a header this dense reads
+ // better with one fewer mark in it. The spinner takes that space only while a read
+ // is in flight, so the label does not shift when nothing is happening.
+ if (_loading) ...[
+ const SizedBox(
+ width: 11,
+ height: 11,
+ child: CircularProgressIndicator(strokeWidth: 1.5),
+ ),
+ const SizedBox(width: 5),
+ ],
+ Text(
+ 'Model',
+ style: TextStyle(fontSize: 11, color: AppColors.textSoft),
+ ),
+ Icon(
+ Icons.arrow_drop_down,
+ size: 14,
+ color: AppColors.mutedStrong,
),
- const SizedBox(width: 5),
],
- Text(
- 'Model',
- style: TextStyle(fontSize: 11, color: AppColors.textSoft),
- ),
- Icon(
- Icons.arrow_drop_down,
- size: 14,
- color: AppColors.mutedStrong,
- ),
- ],
+ ),
),
),
),
diff --git a/desktop/test/pane_restart_test.dart b/desktop/test/pane_restart_test.dart
index 913232d19..e8f9c4f43 100644
--- a/desktop/test/pane_restart_test.dart
+++ b/desktop/test/pane_restart_test.dart
@@ -66,9 +66,14 @@ void main() {
),
);
await tester.pump();
- expect(connection.calls, hasLength(1));
- expect(connection.calls.single.$1, 'agent_restart');
- expect(connection.calls.single.$2, {'agentId': 'a0'});
+ // Each pane header's model picker also asks for grid_models_list as it mounts; the restart is
+ // the one request that is not that.
+ final sent = connection.calls
+ .where((call) => call.$1 != 'grid_models_list')
+ .toList();
+ expect(sent, hasLength(1));
+ expect(sent.single.$1, 'agent_restart');
+ expect(sent.single.$2, {'agentId': 'a0'});
expect(app.panes, [first, second]);
expect(first.session, same(session));
expect(find.byType(AlertDialog), findsNothing);