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 moves to the controls, and its one action gets a section

bitcoinbuilder14a5d25a85d2
diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dart
index 8871b6031..690b57867 100644
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@ -9,6 +9,23 @@ import '../usage/models_menu_controller.dart';
import 'engine_identity.dart';
import 'transient_menus.dart';
+/// The engines whose panes carry a model picker.
+///
+/// Named here rather than derived from the daemon's `localModelEngines`, because the two answer
+/// different questions. That list is which engines a Local model *can* be handed to — a launch
+/// contract exists for seven of them. This is the narrower question of which ones a person is
+/// OFFERED the switch on, and it is the three whose switching has been driven end to end: Claude
+/// Code and Codex move by environment, and OpenCode by a config file plus its own `/models` picker.
+///
+/// The rest keep the header they had. A picker on an engine whose move has never been watched work
+/// is a menu that looks like a choice and may not be one, and the cost of finding out is an agent
+/// answering on a model nobody asked for.
+const Set<String> kModelPickerEngines = {'claude', 'codex', 'opencode'};
+
+/// Whether [engine] gets a picker. Unknown or absent is NO — a header offers nothing it cannot back.
+bool modelPickerSupports(String? engine) =>
+ kModelPickerEngines.contains(engine?.trim().toLowerCase());
+
/// The pane header's model picker, in two sections: **Subscription** and **Local**.
///
/// The shape is the app's own Models menu, deliberately — that menu already answers "what could this
@@ -239,14 +256,16 @@ class _GridModelPickerState extends State<GridModelPicker> {
subtitle: _subtitleFor(model),
),
),
- // The last row under Local, drawn as one of the models: it is what a person picks when the
- // model they want is not there yet, so it belongs in the same list, not in a section of its
- // own. Never filled — the fill means "the agent is here", and this row starts something.
+ // The way to GET a Local model, under the ones there are and behind a rule of its own.
+ //
+ // Not a row among the models: those are places this agent can go, and this starts something
+ // instead. Not on the section's own line either — that put a button beside a heading, two
+ // different kinds of thing sharing a line and competing for the same glance. A captioned
+ // rule says plainly that what follows answers a different question, and the button spans
+ // the menu so it reads as the section's one action rather than as a wider row.
+ //
// Offered whatever THIS pane's engine can do: it opens a new pane, on an engine that can.
- _item(
- onTap: () => close(const _Choice.runLocalModel()),
- child: const _Row(selected: false, title: 'Talk to Local model manager'),
- ),
+ _ManagerInvitation(onPressed: () => close(const _Choice.runLocalModel())),
],
);
if (chosen == null) return;
@@ -588,6 +607,93 @@ class _Row extends StatelessWidget {
}
}
+/// The invitation that closes the Local section: a captioned rule, then the one ACTION in this menu.
+///
+/// Everything above is a destination — pick it and the agent moves. This starts something instead,
+/// and the rule is what says so before the button is read: a line that names a different question,
+/// so the button under it is not scanned as one more place to go.
+///
+/// The spacing is the point as much as the parts. A rule tight against the last model reads as a
+/// separator between two rows rather than the end of a list, and a button pressed against its own
+/// caption reads as one block of chrome; both were tried. The gaps here are deliberately larger
+/// than the row rhythm above, because this is where the menu stops listing and starts offering.
+class _ManagerInvitation extends StatefulWidget {
+ const _ManagerInvitation({required this.onPressed});
+
+ final VoidCallback onPressed;
+
+ @override
+ State<_ManagerInvitation> createState() => _ManagerInvitationState();
+}
+
+class _ManagerInvitationState extends State<_ManagerInvitation> {
+ bool _hovered = false;
+
+ @override
+ Widget build(BuildContext context) {
+ final rule = Expanded(child: Container(height: 1, color: AppColors.border));
+ return Padding(
+ // Wider than a row's inset on purpose: this block is not one of them.
+ padding: const EdgeInsets.fromLTRB(
+ _menuInset + _rowPadding,
+ 12,
+ _menuInset + _rowPadding,
+ 4,
+ ),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Row(
+ children: [
+ rule,
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ child: Text(
+ 'Want to manage local models?',
+ style: TextStyle(
+ fontSize: 10.5,
+ letterSpacing: .2,
+ color: AppColors.mutedStrong,
+ ),
+ ),
+ ),
+ rule,
+ ],
+ ),
+ const SizedBox(height: 9),
+ MouseRegion(
+ cursor: SystemMouseCursors.click,
+ onEnter: (_) => setState(() => _hovered = true),
+ onExit: (_) => setState(() => _hovered = false),
+ child: GestureDetector(
+ onTap: widget.onPressed,
+ child: Container(
+ // Full width, so it reads as the section's one action rather than as a wider row.
+ width: double.infinity,
+ alignment: Alignment.center,
+ padding: const EdgeInsets.symmetric(vertical: 8),
+ decoration: BoxDecoration(
+ color: _hovered ? AppColors.selected : Colors.transparent,
+ border: Border.all(color: AppColors.border),
+ borderRadius: BorderRadius.circular(6),
+ ),
+ child: Text(
+ 'Talk to model manager',
+ style: TextStyle(
+ fontSize: 12,
+ fontWeight: FontWeight.w500,
+ color: _hovered ? AppColors.text : AppColors.textSoft,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
/// The row's own inset from the menu edge, and the padding inside its highlight. A section header
/// carries their SUM as a left inset, so header text sits exactly above the row text it heads.
const double _menuInset = 6;
diff --git a/desktop/lib/widgets/pane_header_actions.dart b/desktop/lib/widgets/pane_header_actions.dart
index de4ccc2c7..25e80f425 100644
--- a/desktop/lib/widgets/pane_header_actions.dart
+++ b/desktop/lib/widgets/pane_header_actions.dart
@@ -19,6 +19,7 @@ class PaneHeaderActions extends StatelessWidget {
this.viewerVisible = false,
this.viewerColor,
this.details,
+ this.modelPicker,
});
final bool zoomed, composerVisible;
@@ -37,6 +38,14 @@ class PaneHeaderActions extends StatelessWidget {
/// layers keep their size so hovering never changes the title's width.
final Widget? details;
+ /// Where this agent runs, shown with the controls rather than beside the name.
+ ///
+ /// It belongs here for the same reason the icons do: a header this narrow has room for the agent's
+ /// NAME or for what you can do to it, not both, and what you can do to it is worth reading only
+ /// when you are reaching for it. Parked on the left of the cluster, so the four icons a person
+ /// aims at by muscle memory keep the right edge they have always had.
+ final Widget? modelPicker;
+
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
@@ -81,6 +90,10 @@ class PaneHeaderActions extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
+ if (modelPicker != null) ...[
+ modelPicker!,
+ const SizedBox(width: 4),
+ ],
if (onToggleViewer != null) ...[
_ViewerToggle(
key: const ValueKey('pane-viewer-toggle'),
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index a265dbfbe..bc8a7248c 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -1534,7 +1534,14 @@ class _TerminalHeader extends StatelessWidget {
final remoteComposer = machine != null && !machine.isLocalMachine
? onToggleComposer
: null;
- final actionsWidth = remoteComposer == null ? 118.0 : 148.0;
+ // The icon cluster, plus the model picker that now sits at its left — without the extra the
+ // constraint clips the picker rather than the details it was measured for. Zero on an engine
+ // that gets no picker, so those headers keep the width they always had.
+ final showModelPicker =
+ status == null && !readOnly && modelPickerSupports(session.engineId);
+ final pickerWidth = showModelPicker ? 72.0 : 0.0;
+ final actionsWidth =
+ (remoteComposer == null ? 118.0 : 148.0) + pickerWidth;
final folder =
project?.cwd
.split(RegExp(r'[/\\]'))
@@ -1658,33 +1665,6 @@ class _TerminalHeader extends StatelessWidget {
],
),
),
- // The model picker sits next to the NAME, because that is the pair a person reads
- // together: this agent, on that model. Hidden while a notice is showing — a header
- // asking to reconnect is not the moment to offer a menu.
- if (status == null && !readOnly) ...[
- const SizedBox(width: 8),
- GridModelPicker(
- notifier: notifier,
- machineId: session.machineId,
- currentModel: agent?.gridModel,
- webSearch: agent?.gridWebSearch,
- engineLabel: session.engineId,
- onSelected: (model) => unawaited(
- notifier.retargetAgentToGridModel(
- session.machineId,
- session.agentId,
- model.id,
- ),
- ),
- onUseOwnLogin: () => unawaited(
- notifier.clearAgentGrid(session.machineId, session.agentId),
- ),
- // The pane's own context, because the flow opens a dialog before it opens a
- // pane. Which machine it runs on is the notifier's call, not this pane's: a
- // local model is about the computer the app is on, whatever this agent is on.
- onRunLocalModel: () => unawaited(notifier.runLocalModel(context)),
- ),
- ],
const SizedBox(width: 8),
// Which of the three paths carries this pane's bytes. Absent for a local machine's own
// terminal, which has no such distinction and so gets no badge.
@@ -1706,6 +1686,38 @@ class _TerminalHeader extends StatelessWidget {
),
),
child: PaneHeaderActions(
+ // Where this agent runs, with the controls rather than beside the name — the
+ // header has room for one of the two, and this is the half you only read while
+ // reaching for it. Absent while a notice is showing: a header asking to
+ // reconnect is not the moment to offer a menu.
+ modelPicker: showModelPicker
+ ? GridModelPicker(
+ notifier: notifier,
+ machineId: session.machineId,
+ currentModel: agent?.gridModel,
+ webSearch: agent?.gridWebSearch,
+ engineLabel: session.engineId,
+ onSelected: (model) => unawaited(
+ notifier.retargetAgentToGridModel(
+ session.machineId,
+ session.agentId,
+ model.id,
+ ),
+ ),
+ onUseOwnLogin: () => unawaited(
+ notifier.clearAgentGrid(
+ session.machineId,
+ session.agentId,
+ ),
+ ),
+ // The pane's own context, because the flow opens a dialog before it
+ // opens a pane. Which machine it runs on is the notifier's call, not
+ // this pane's: a local model is about the computer the app is on,
+ // whatever this agent is on.
+ onRunLocalModel: () =>
+ unawaited(notifier.runLocalModel(context)),
+ )
+ : null,
zoomed: zoomed,
onZoom: onToggleZoom,
onRestart: onRestart,
diff --git a/desktop/test/grid_model_picker_test.dart b/desktop/test/grid_model_picker_test.dart
index cc2d54860..638dfda7e 100644
--- a/desktop/test/grid_model_picker_test.dart
+++ b/desktop/test/grid_model_picker_test.dart
@@ -141,7 +141,7 @@ void main() {
// it already has. Only the middle one is about the ACCOUNT, and folding the first two together is
// what told a signed-in user to "sign in again" when the real problem was a daemon that had not
// answered: advice that was wrong, and useless even if the diagnosis had been right. The third
- // says nothing: the "Talk to Local model manager" row under Local is what a person does about it.
+ // says nothing: the invitation that closes the Local section is what a person does about it.
testWidgets(
'a machine that did not answer says so, and does not blame the account',
(tester) async {
@@ -169,7 +169,7 @@ void main() {
await open(tester);
expect(find.text('Nothing is being served yet.'), findsNothing);
expect(find.text('Could not reach this machine.'), findsNothing);
- expect(find.text('Talk to Local model manager'), findsOneWidget);
+ expect(find.text('Talk to model manager'), findsOneWidget);
},
);
@@ -449,55 +449,143 @@ void main() {
},
);
- group('the last row under Local starts a local model', () {
+ group('which engines are offered a picker at all', () {
+ test('the three whose switching has been driven end to end', () {
+ // Not the daemon's `localModelEngines`, which is the wider "could a Local model be handed to
+ // this engine" — seven carry a launch contract. This is which ones a person is OFFERED the
+ // switch on, and it is the three that have been watched work: Claude Code and Codex move by
+ // environment, OpenCode by a config file plus its own `/models` picker.
+ expect(kModelPickerEngines, {'claude', 'codex', 'opencode'});
+ for (final engine in ['claude', 'codex', 'opencode']) {
+ expect(modelPickerSupports(engine), isTrue, reason: engine);
+ }
+ });
+
+ test('everything else keeps the header it had', () {
+ // A picker on an engine whose move has never been watched work is a menu that looks like a
+ // choice and may not be one — and the cost of finding out is an agent answering on a model
+ // nobody asked for.
+ for (final engine in ['cursor', 'hermes', 'grok', 'pi', 'kilo', 'amp', 'devin']) {
+ expect(modelPickerSupports(engine), isFalse, reason: engine);
+ }
+ // Unknown and absent are NO, not "probably fine".
+ expect(modelPickerSupports(null), isFalse);
+ expect(modelPickerSupports(''), isFalse);
+ expect(modelPickerSupports('something-new'), isFalse);
+ });
+
+ test('an engine id is matched however it is spelled', () {
+ expect(modelPickerSupports('Claude'), isTrue);
+ expect(modelPickerSupports(' OpenCode '), isTrue);
+ });
+ });
+
+ group('the invitation that closes the Local section', () {
const served = [
{'id': 'Qwen-Test', 'node': 'macbook-m1max'},
];
- testWidgets('is there after the served models', (tester) async {
+ testWidgets('a captioned rule, then the button, under the models', (
+ tester,
+ ) async {
+ build(models: served);
+ await open(tester);
+ final caption = tester.getTopLeft(
+ find.text('Want to manage local models?'),
+ );
+ final button = tester.getTopLeft(find.text('Talk to model manager'));
+ final model = tester.getBottomLeft(find.text('Qwen-Test'));
+
+ // Under the list, not among it: the models are places this agent can go and this starts
+ // something, so the rule is what says a different question begins here.
+ expect(caption.dy, greaterThan(model.dy));
+ expect(button.dy, greaterThan(caption.dy));
+ // And the rule is a rule — a line either side of the caption, not just a label.
+ expect(
+ find.descendant(
+ of: find.byType(Row),
+ matching: find.byType(Container),
+ ),
+ findsWidgets,
+ );
+ });
+
+ testWidgets('has room to breathe, above and below the caption', (
+ tester,
+ ) async {
+ // The gaps are the point as much as the parts: a rule tight against the last model reads as a
+ // separator between two rows rather than the end of a list, and a button pressed against its
+ // own caption reads as one block of chrome. Both were tried.
build(models: served);
await open(tester);
- expect(find.text('Talk to Local model manager'), findsOneWidget);
- // After the models, not among them: it is the way to get another one, and a row that
- // started something sitting between two places the agent could go would read as a third.
- final row = tester.getTopLeft(find.text('Talk to Local model manager'));
- final model = tester.getTopLeft(find.text('Qwen-Test'));
- expect(row.dy, greaterThan(model.dy));
+ final model = tester.getBottomLeft(find.text('Qwen-Test'));
+ final caption = tester.getTopLeft(
+ find.text('Want to manage local models?'),
+ );
+ final captionBottom = tester.getBottomLeft(
+ find.text('Want to manage local models?'),
+ );
+ final button = tester.getTopLeft(find.text('Talk to model manager'));
+ expect(caption.dy - model.dy, greaterThan(8));
+ expect(button.dy - captionBottom.dy, greaterThan(8));
+ });
+
+ testWidgets('spans the menu, so it reads as the section action', (
+ tester,
+ ) async {
+ build(models: served);
+ await open(tester);
+ final surface = tester.getSize(find.byType(Material).last).width;
+ final box = tester.getSize(
+ find
+ .ancestor(
+ of: find.text('Talk to model manager'),
+ matching: find.byType(Container),
+ )
+ .first,
+ );
+ // Full width less its own inset — a button the width of its label would read as a row.
+ expect(box.width, greaterThan(surface - 40));
});
testWidgets(
'is there when nothing is served, and when there is no grid at all',
(tester) async {
- // The empty-state sentence is the sentence this row answers, so the row is under it — and it
- // is there even with no grid, because a person with no Local models is exactly who needs it.
+ // A person with no Local models is exactly who needs it, so it does not wait for a list.
await open(tester);
- expect(find.text('Talk to Local model manager'), findsOneWidget);
- final row = tester.getTopLeft(find.text('Talk to Local model manager'));
- final sentence = tester.getTopLeft(
- find.text('No local models on this account yet.'),
- );
- expect(row.dy, greaterThan(sentence.dy));
- // Never the plumbing's name, in this row as in the rest of the menu.
+ expect(find.text('Talk to model manager'), findsOneWidget);
+ // Never the plumbing's name, in this block as in the rest of the menu.
expect(find.textContaining('grid'), findsNothing);
},
);
testWidgets(
- 'is never filled: an action is nowhere, so it cannot be the current row',
+ 'is a button, not a row: it can never wear the current-model fill',
(tester) async {
build(models: served);
await open(tester, currentModel: 'Qwen-Test');
expect(find.byIcon(Icons.check), findsNothing);
- Container rowFor(String text) => tester.widget<Container>(
+ final model = tester.widget<Container>(
find
- .ancestor(of: find.text(text), matching: find.byType(Container))
+ .ancestor(
+ of: find.text('Qwen-Test'),
+ matching: find.byType(Container),
+ )
.first,
);
- expect(
- (rowFor('Qwen-Test').decoration as BoxDecoration?)?.color,
- isNotNull,
+ expect((model.decoration as BoxDecoration?)?.color, isNotNull);
+ // Its own shape — a border, no fill — so the eye does not read it as the selected row.
+ final button = tester.widget<Container>(
+ find
+ .ancestor(
+ of: find.text('Talk to model manager'),
+ matching: find.byType(Container),
+ )
+ .first,
);
- expect(rowFor('Talk to Local model manager').decoration, isNull);
+ final decoration = button.decoration as BoxDecoration?;
+ expect(decoration?.border, isNotNull);
+ expect(decoration?.color, Colors.transparent);
},
);
@@ -513,15 +601,15 @@ void main() {
onOwnLogin: () => logins++,
onSelected: (m) => picked = m,
);
- await tester.tap(find.text('Talk to Local model manager'));
+ await tester.tap(find.text('Talk to model manager'));
await tester.pumpAndSettle();
expect(runs, 1);
// Not a move: the agent stays where it was. `currentModel` is set so a stray own-login call
// would have fired — the case where it is silent for its own reason is not the one tested.
expect(logins, 0);
expect(picked, isNull);
- // The menu closed on the choice, like any other row.
- expect(find.text('Talk to Local model manager'), findsNothing);
+ // The menu closed on the press, as it does on any choice.
+ expect(find.text('Talk to model manager'), findsNothing);
});
});