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.

Merge origin/feat/harness-grid into feat/harness-grid

Timd30a753f8ac2
diff --cc desktop/lib/widgets/grid_model_picker.dart
index 39c236602,690b57867..b4dac3bd0
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@@ -7,8 -7,25 +7,25 @@@ import '../state/app_state.dart'
import '../theme/app_theme.dart';
import '../usage/models_menu_controller.dart';
import 'engine_identity.dart';
-import 'transient_menus.dart';
+import 'pane_menu.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,17 -256,16 +256,18 @@@ class _GridModelPickerState extends Sta
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.
- paneMenuItem(
- onTap: () => close(const _Choice.runLocalModel()),
- child: const PaneMenuRow(
- selected: false,
- title: 'Talk to Local model manager',
- ),
- _ManagerInvitation(onPressed: () => close(const _Choice.runLocalModel())),
++ _ManagerInvitation(
++ onPressed: () => close(const _Choice.runLocalModel()),
+ ),
],
);
if (chosen == null) return;
@@@ -380,6 -510,198 +398,93 @@@
}
}
-/// One menu row: optional engine mark, title, a quiet detail beside it, and a right-aligned
-/// status — filled when it is the current one. The same column order in both sections, so the eye
-/// can run straight down the menu. A [subtitle], when there is one, sits under the title inside
-/// the same fill.
-class _Row extends StatelessWidget {
- final bool selected;
- final String? engine;
- final String title;
- final String detail;
- final String? status;
- final String? subtitle;
-
- const _Row({
- required this.selected,
- required this.title,
- this.engine,
- this.detail = '',
- this.status,
- this.subtitle,
- });
-
- @override
- Widget build(BuildContext context) {
- final row = Row(
- children: [
- if (engine != null) ...[
- EngineMark(engine: engine, size: 14),
- const SizedBox(width: 7),
- ],
- // ⚠️ Expanded on the TITLE, not on the status. The status is a handful of characters and
- // wants only what it needs; giving it the flexible half truncated
- // `Qwen3.6-35B-A3B-UD-Q5_K_XL` to `Qwen3.6-35B-A3B-UD-Q5_K…` while empty space sat beside
- // it. The long string here is the model id, so the model id is what gets the room.
- Expanded(
- child: Text(
- title,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12.5,
- // Stated rather than inherited: a PopupMenuItem's default text style is heavier than
- // this menu wants, which read as every row being emphasised.
- fontWeight: FontWeight.w400,
- color: AppColors.text,
- ),
- ),
- ),
- if (detail.isNotEmpty) ...[
- const SizedBox(width: 6),
- Text(
- detail,
- style: TextStyle(fontSize: 11, color: AppColors.mutedStrong),
- ),
- ],
- if (status != null) ...[
- const SizedBox(width: 14),
- Text(
- status!,
- style: TextStyle(fontSize: 11, color: AppColors.mutedStrong),
- ),
- ],
- ],
- );
- return Container(
- // No margin of its own: the inset is the item's (see `_item`), so that the hover the item
- // paints and the fill this row paints are one and the same rectangle.
- padding: const EdgeInsets.symmetric(horizontal: _rowPadding, vertical: 5),
- decoration: selected
- // Subtle on purpose: one row in the menu is already the current one, and a mark loud
- // enough to announce that would compete with the thing a person opened the menu to read.
- ? BoxDecoration(
- color: AppColors.selected,
- borderRadius: BorderRadius.circular(_rowRadius),
- )
- : null,
- // The subtitle sits INSIDE the fill, under the title: it is about this row, and a sentence
- // hanging below the highlight would read as belonging to the next one.
- child: subtitle == null
- ? row
- : Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- row,
- Padding(
- padding: const EdgeInsets.only(top: 2),
- child: Text(
- subtitle!,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 10.5, color: AppColors.textSoft),
- ),
- ),
- ],
- ),
- );
- }
-}
-
+ /// 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,
++ kPaneMenuInset + kPaneMenuRowPadding,
+ 12,
- _menuInset + _rowPadding,
++ kPaneMenuInset + kPaneMenuRowPadding,
+ 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;
-const double _rowPadding = 8;
-
-/// One radius for the hover and the selected fill: they are the same shape.
-const double _rowRadius = 5;
-
/// One row's meaning: a grid model, the engine's own login, or the action that starts a local
/// model. A sealed set rather than a nullable `GridModel`, because `null` already means "the menu
/// was dismissed" in `showMenu`'s own result — and the action is neither a model nor a login, so
diff --cc desktop/lib/widgets/terminal_panel.dart
index 4063417ae,bc8a7248c..b241ce2dd
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@@ -1495,7 -1534,14 +1534,13 @@@ class _TerminalHeader extends Stateless
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 actionsWidth = (remoteComposer == null ? 118.0 : 148.0) + pickerWidth;
final folder =
project?.cwd
.split(RegExp(r'[/\\]'))
@@@ -1675,6 -1686,38 +1685,42 @@@
),
),
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)),
++ // opens a pane — and the pane's own MACHINE, because a picker on a
++ // remote agent's pane is asking about the models that computer can
++ // serve, not this one's.
++ onRunLocalModel: () => unawaited(
++ notifier.runLocalModel(
++ context,
++ machineId: session.machineId,
++ ),
++ ),
+ )
+ : null,
zoomed: zoomed,
onZoom: onToggleZoom,
onRestart: onRestart,
diff --cc desktop/test/new_agent_choices_layout_test.dart
index a27772284,907bb3e95..d4f5d19cb
--- a/desktop/test/new_agent_choices_layout_test.dart
+++ b/desktop/test/new_agent_choices_layout_test.dart
@@@ -48,6 -50,25 +50,28 @@@ class _ChoicesApp extends AppNotifier
}
}
+ int createCalls = 0;
+
+ @override
+ Future<String?> createAgent(
+ String machineId, {
+ required String engine,
+ required String folder,
+ ProjectFolderRequest? projectFolder,
+ bool bypassPermission = false,
+ String? codexHome,
+ String? swarmId,
+ PaneSplitRequest? split,
+ String? dsh,
++ String? prompt,
++ String? name,
++ String? agent,
+ AgentCreationAttempt? attempt,
+ }) async {
+ createCalls++;
+ return null;
+ }
+
@override
Future<Map<String, dynamic>> readProjectPreview(
String machineId,