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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
desktop: the local-model dialog becomes a flow, and its openers carry their message
bitcoinbuilder355f7248305e
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex b2b21df88..800efe646 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -3559,7 +3559,7 @@ class AppNotifier extends ChangeNotifier {if (decision == null) return;// The dialog may list the machines, and the person may have moved the choice.machineId = decision.machineId;- final error = await _startLocalModelAgent(machineId);+ final error = await _startLocalModelAgent(machineId, prompt: decision.prompt);if (error != null) {_lastError = error;_lastErrorRetryable = false;@@ -3579,12 +3579,19 @@ class AppNotifier extends ChangeNotifier {machineStates.values.firstOrNull;}- /// What Start stands for: opencode, in the user's home, opened as the- /// `harness-compute` agent and waiting for the person to type. Home rather than- /// a project because the model is not about any one repo; no first prompt,- /// because the person opens the conversation. Null on success, else the- /// sentence for the person.- Future<String?> _startLocalModelAgent(String machineId) async {+ /// What a start stands for: opencode, in the user's home, opened as the+ /// `harness-compute` agent. Home rather than a project because the model is+ /// not about any one repo.+ ///+ /// [prompt] is the opening move the dialog's button stood for, handed to+ /// opencode's own `--prompt`: the pane opens with that message already+ /// submitted, so the first thing in it is the manager's answer rather than an+ /// empty composer. Null is the third option — the plain door, for a person who+ /// would rather word it themselves — and then nothing is sent, exactly as+ /// before this dialog had buttons.+ ///+ /// Null on success, else the sentence for the person.+ Future<String?> _startLocalModelAgent(String machineId, {String? prompt}) async {final machine = machineStates[machineId];if (machine == null) return 'Machine not found';final home = await _homeFolderOf(machine);@@ -3597,6 +3604,7 @@ class AppNotifier extends ChangeNotifier {folder: home,agent: localModelAgent,name: localModelAgentName,+ prompt: prompt,);if (error != null) return error;// A daemon that predates `agent`/`name` does not refuse them — it ignoresdiff --git a/desktop/lib/widgets/run_local_model_dialog.dart b/desktop/lib/widgets/run_local_model_dialog.dartindex 7857dda4d..829a1bc11 100644--- a/desktop/lib/widgets/run_local_model_dialog.dart+++ b/desktop/lib/widgets/run_local_model_dialog.dart@@ -1,7 +1,6 @@import 'dart:async';import 'package:flutter/material.dart';-import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';import '../core/models.dart';@@ -19,8 +18,9 @@ import 'pane_menu.dart';/// person decided, and the notifier does the rest, so the two doors cannot/// drift into two definitions of what Start means.///-/// Null is Not now (or Escape, or a click outside). A record is Start: the-/// machine the manager opens on.+/// Null is Cancel (or Escape, or a click outside). A record is a start: the+/// machine the manager opens on, and the message it opens with — null for+/// "open it and let me talk", which is the third option and the plain door.////// [machineId] is the door's own answer to "which computer" — the pane's/// machine, or the one the menu named — and is what the dialog starts on. With@@ -29,12 +29,12 @@ import 'pane_menu.dart';/// and that is that. There is deliberately no "don't show this again": the/// dialog is where the machine is chosen, and a dialog that could be waved/// off would take the choice with it.-Future<({String machineId})?> showRunLocalModelDialog(+Future<({String machineId, String? prompt})?> showRunLocalModelDialog(BuildContext context,AppNotifier notifier,String machineId, {bool chooseMachine = true,-}) => showAppDialog<({String machineId})>(+}) => showAppDialog<({String machineId, String? prompt})>(context: context,// Lighter than the app's default veil: this is a two-second yes/no in front// of the swarm the person was just looking at, not a screen of its own, and@@ -199,7 +199,7 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {crossAxisAlignment: CrossAxisAlignment.start,mainAxisSize: MainAxisSize.min,children: [- _label('The model will run on'),+ _label('Runs on'),_machineRow(current, opens: false),],);@@ -212,7 +212,7 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {crossAxisAlignment: CrossAxisAlignment.start,mainAxisSize: MainAxisSize.min,children: [- _label('Select the machine to run the model'),+ _label('Runs on'),_chips(visible, machines),],);@@ -363,7 +363,7 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {};final machines = _machines;return AlertDialog(- title: const Text('Models that live on your machine'),+ title: const Text('Run a model on this machine'),content: SizedBox(// Wider than the app's small dialogs: the machine row below wants// three names across before it folds the rest behind "…".@@ -381,12 +381,10 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {),const TextSpan(text:- " is an agent that looks after the models on one "- "of your computers. Say what you need and it helps "- "you pick a model that fits that computer and the "- "work, then sets it up there. Once a model is up, "- "every agent on every machine can switch to it "- "from its model picker.",+ " is an agent that finds a model to fit this "+ "computer, downloads it, and keeps it running. "+ "Once it is up, any agent on any of your machines "+ "can switch to it.",),],),@@ -397,12 +395,11 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {color: grid.AppPalette.textPrimary,),),- const SizedBox(height: 14),- // Two things a person could say first, with a copy button each:- // an empty composer is where most people stall, and a prompt they- // can paste is a start they cannot get wrong. Copy rather than- // send, because the pane does not exist until Start.- _StarterPrompts(key: const Key('run-local-model-prompts')),+ const SizedBox(height: 16),+ // Which computer, first: the manager looks after ONE machine's+ // models, and with more than one linked the answer changes what+ // is worth asking it. Never a control unless there is a choice.+ _machineLine(machines),if (status != null) ...[const SizedBox(height: 16),Text(@@ -416,29 +413,32 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {),],const SizedBox(height: 18),- // Which computer, as one slim row at the foot of the message:- // the manager looks after ONE machine's models, so the machine- // is always named, and never as a control unless there is a- // choice. With one machine linked it is a mark and two lines;- // with more, the same row opens a list, this computer first —- // one row whatever the count, so a long list never spreads- // through the dialog.- _machineLine(machines),+ Divider(height: 1, thickness: 1, color: grid.AppPalette.divider),+ const SizedBox(height: 16),+ // The three ways to begin, and the dialog's only action: two+ // openers that start the conversation for you, and a plain door+ // for a person who would rather word it themselves. Pressing one+ // IS the start — there is no Start button left, because there is+ // nothing for it to do that these do not.+ _StartOptions(+ key: const Key('run-local-model-options'),+ enabled: missing == null,+ onChosen: (prompt) => Navigator.of(context).pop((+ machineId: _machineId,+ prompt: prompt,+ )),+ ),],),),+ // Cancel alone: the three options above are the action, and a Start+ // beside them would be a fourth way to begin that means the same as+ // one of them.actions: [TextButton(key: const Key('run-local-model-not-now'),onPressed: () => Navigator.of(context).pop(),- child: const Text('Not now'),- ),- FilledButton(- key: const Key('run-local-model-start'),- onPressed: missing == null- ? () => Navigator.of(context).pop((machineId: _machineId))- : null,- child: const Text('Start'),+ child: const Text('Cancel'),),],);@@ -492,106 +492,161 @@ class _MoreMachines extends StatelessWidget {),);}--/// Example first messages for the manager, each with a copy button.-class _StarterPrompts extends StatefulWidget {- const _StarterPrompts({super.key});-- static const prompts = [- 'Set up a model for my coding work, just for me on this machine',- 'I want a model for chat and writing. What fits this machine?',+/// The three ways to begin, and the dialog's only action.+///+/// Two openers and a plain door. Pressing one closes the dialog and starts the+/// manager with that message already submitted — opencode's own `--prompt`, so+/// the pane's first line is the manager's answer rather than an empty composer.+///+/// They used to be example sentences with a copy button each, which was the+/// best a dialog could do when the pane did not exist yet: copy, open, paste,+/// send. The pane is created from what this returns, so the button can carry+/// the message itself and the other three steps disappear.+///+/// The third sends nothing, and says why it is there in a second line —+/// "Open Model manager" alone does not explain why a person would take it over+/// the two above. It is in the same stack rather than off to one side, because+/// it is the same kind of choice: a way to begin.+class _StartOptions extends StatelessWidget {+ const _StartOptions({super.key, required this.enabled, required this.onChosen});++ /// False while a prerequisite is missing — the machine is offline, or has no+ /// opencode. Every option leads to the same pane, so they fail together.+ final bool enabled;++ /// The message to open with, or null for the plain door.+ final void Function(String? prompt) onChosen;++ static const openers = [+ (+ label: 'A model for coding',+ prompt: 'Set up a model for my coding work on this machine.',+ ),+ (+ label: 'A model for chat and writing',+ prompt:+ 'I want a model for chat and writing. What fits this machine, and '+ 'can you set it up?',+ ),];- @override- State<_StarterPrompts> createState() => _StarterPromptsState();-}--class _StarterPromptsState extends State<_StarterPrompts> {- int? _copied;- Timer? _reset;-- @override- void dispose() {- _reset?.cancel();- super.dispose();- }-- Future<void> _copy(int index) async {- try {- await Clipboard.setData(- ClipboardData(text: _StarterPrompts.prompts[index]),- );- } catch (_) {- // No clipboard (a headless test, a locked-down session): the text is- // on screen to type out, so nothing is said.- return;- }- if (!mounted) return;- setState(() => _copied = index);- _reset?.cancel();- _reset = Timer(const Duration(seconds: 2), () {- if (mounted) setState(() => _copied = null);- });- }-@overrideWidget build(BuildContext context) => Column(crossAxisAlignment: CrossAxisAlignment.start,mainAxisSize: MainAxisSize.min,children: [- Text(- 'Try saying',- style: TextStyle(- fontFamily: grid.AppFont.sans,- fontSize: 12.5,- color: grid.AppPalette.textSecondary,+ Padding(+ padding: const EdgeInsets.only(bottom: 8),+ child: Text(+ 'Start with',+ style: TextStyle(+ fontFamily: grid.AppFont.sans,+ fontSize: 12,+ color: grid.AppPalette.textSecondary,+ ),),),- const SizedBox(height: 6),- for (var i = 0; i < _StarterPrompts.prompts.length; i++) ...[- if (i > 0) const SizedBox(height: 6),- Container(- padding: const EdgeInsets.fromLTRB(10, 6, 6, 6),- decoration: BoxDecoration(- color: grid.AppSurface.recess,- borderRadius: BorderRadius.circular(6),- ),+ // One card with dividers rather than separate boxes: three ways to do the+ // same thing are a set, and three loose rectangles read as three features.+ DecoratedBox(+ decoration: BoxDecoration(+ border: Border.all(color: grid.AppPalette.divider),+ borderRadius: BorderRadius.circular(8),+ ),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (final opener in openers) ...[+ _Option(+ label: opener.label,+ enabled: enabled,+ onTap: () => onChosen(opener.prompt),+ ),+ Divider(height: 1, thickness: 1, color: grid.AppPalette.divider),+ ],+ _Option(+ label: 'Open Model manager',+ detail: 'Decide what you need in the conversation',+ enabled: enabled,+ onTap: () => onChosen(null),+ ),+ ],+ ),+ ),+ ],+ );+}++/// One row of the stack: a label, an optional second line, and an arrow that+/// says this leads somewhere rather than toggling something.+class _Option extends StatelessWidget {+ const _Option({+ required this.label,+ required this.enabled,+ required this.onTap,+ this.detail,+ });++ final String label;+ final String? detail;+ final bool enabled;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final ink = enabled+ ? grid.AppPalette.textPrimary+ : grid.AppPalette.textFaint;+ return MouseRegion(+ cursor: enabled ? SystemMouseCursors.click : SystemMouseCursors.basic,+ child: InkWell(+ onTap: enabled ? onTap : null,+ mouseCursor: enabled+ ? SystemMouseCursors.click+ : SystemMouseCursors.basic,+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),child: Row(children: [Expanded(- child: Text(- _StarterPrompts.prompts[i],- key: ValueKey('run-local-model-prompt-$i'),- style: TextStyle(- fontFamily: grid.AppFont.sans,- fontSize: 12.5,- color: grid.AppPalette.textPrimary,- ),- ),- ),- const SizedBox(width: 8),- Tooltip(- message: _copied == i ? 'Copied' : 'Copy',- child: InkWell(- key: ValueKey('run-local-model-prompt-copy-$i'),- onTap: () => _copy(i),- borderRadius: BorderRadius.circular(4),- child: Padding(- padding: const EdgeInsets.all(4),- child: Icon(- _copied == i ? LucideIcons.check : LucideIcons.copy,- size: 14,- color: _copied == i- ? grid.AppPalette.accentOnSurface- : grid.AppPalette.textSecondary,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ label,+ style: TextStyle(+ fontFamily: grid.AppFont.sans,+ fontSize: 13.5,+ color: ink,+ ),),- ),+ if (detail != null) ...[+ const SizedBox(height: 3),+ Text(+ detail!,+ style: TextStyle(+ fontFamily: grid.AppFont.sans,+ fontSize: 11.5,+ color: grid.AppPalette.textSecondary,+ ),+ ),+ ],+ ],),),+ const SizedBox(width: 10),+ Icon(+ LucideIcons.arrowRight,+ size: 15,+ color: enabled+ ? grid.AppPalette.textSecondary+ : grid.AppPalette.textFaint,+ ),],),),- ],- ],- );+ ),+ );+ }}diff --git a/desktop/test/models_menu_test.dart b/desktop/test/models_menu_test.dartindex 823e94577..8fe0899c8 100644--- a/desktop/test/models_menu_test.dart+++ b/desktop/test/models_menu_test.dart@@ -354,17 +354,17 @@ void main() {(_) => reply.complete(),);await tester.pumpAndSettle();- expect(find.text('Models that live on your machine'), findsOneWidget);+ expect(find.text('Run a model on this machine'), findsOneWidget);// Nothing is missing on this machine, so nothing about it is said.expect(find.byKey(const Key('run-local-model-status')), findsNothing);expect(conn.creates, isEmpty);- await tester.tap(find.byKey(const Key('run-local-model-start')));+ await tester.tap(find.text('Open Model manager'));await tester.pumpAndSettle();// The handler answers only once the dialog is done, the way every// dialog door does, so native focus is not handed back mid-dialog.await reply.future;- expect(find.text('Models that live on your machine'), findsNothing);+ expect(find.text('Run a model on this machine'), findsNothing);final create = conn.creates.single;expect(create['engine'], 'opencode');expect(create['agent'], AppNotifier.localModelAgent);@@ -426,7 +426,7 @@ void main() {(_) => reply.complete(),);await tester.pumpAndSettle();- await tester.tap(find.byKey(const Key('run-local-model-start')));+ await tester.tap(find.text('Open Model manager'));await tester.pumpAndSettle();await reply.future;diff --git a/desktop/test/run_local_model_dialog_test.dart b/desktop/test/run_local_model_dialog_test.dartindex 76e2f579b..57f1215fb 100644--- a/desktop/test/run_local_model_dialog_test.dart+++ b/desktop/test/run_local_model_dialog_test.dart@@ -142,30 +142,35 @@ void main() {await tester.pumpAndSettle();}- final start = find.byKey(const Key('run-local-model-start'));+ // The three ways to begin ARE the action now, so "is Start enabled" became "does an option+ // lead anywhere". They fail together — every one opens the same pane.+ final start = find.text('Open Model manager');+ final coding = find.text('A model for coding');final status = find.byKey(const Key('run-local-model-status'));String statusText(WidgetTester tester) => tester.widget<Text>(status).data!;- bool startEnabled(WidgetTester tester) =>- tester.widget<FilledButton>(start).onPressed != null;+ bool startEnabled(WidgetTester tester) => tester+ .widget<InkWell>(find.ancestor(of: start, matching: find.byType(InkWell)).first)+ .onTap != null;testWidgets('the copy is the plan\'s, and names no plumbing', (tester) async {await open(tester);- expect(find.text('Models that live on your machine'), findsOneWidget);+ expect(find.text('Run a model on this machine'), findsOneWidget);expect(find.text(- "Model manager is an agent that looks after the models on one of your computers. "- "Say what you need and it helps you pick a model that fits that computer and the work, "- "then sets it up there. Once a model is up, every agent on every machine can switch to "- "it from its model picker.",+ "Model manager is an agent that finds a model to fit this computer, downloads it, and "+ "keeps it running. Once it is up, any agent on any of your machines can switch to it.",),findsOneWidget,);// No "Don't show this again": the dialog is where the machine is chosen, and a dialog that// could be waved off would take the choice with it.expect(find.text("Don't show this again"), findsNothing);- expect(find.text('Not now'), findsOneWidget);- expect(find.text('Start'), findsOneWidget);+ expect(find.text('Cancel'), findsOneWidget);+ // No Start beside the options: it would be a fourth way to begin that means the same as one+ // of them. Pressing an option IS the start.+ expect(find.text('Start'), findsNothing);+ expect(start, findsOneWidget);// The product's two rules for this dialog: never the CLI's name, never one vendor's noun for// a computer. The app runs on Linux too.expect(find.textContaining('grid'), findsNothing);@@ -183,8 +188,8 @@ void main() {// One slim row, not a control: with one machine there is nothing to choose.expect(find.byKey(const Key('run-local-model-machine')), findsOneWidget);expect(find.text('This machine (studio-7)'), findsOneWidget);- // No chips, no "…", no prompt to pick: one machine is a statement, not a choice.- expect(find.text('Select the machine to run the model'), findsNothing);+ // No chips and no "…": one machine is a statement, not a choice. The LABEL is the same either+ // way — "Runs on" reads right for both — so the chips are what say which of the two this is.expect(find.byKey(const ValueKey('run-local-model-machine-local')),findsNothing,@@ -193,58 +198,41 @@ void main() {expect(find.textContaining('(this computer)'), findsNothing);});- testWidgets(- 'two starter prompts, each copied to the clipboard on its button',- (tester) async {- // An empty composer is where people stall; two things to say, copied rather than typed. The- // clipboard is faked so the copy is observable and never touches the real one.- final copied = <String>[];- tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(- SystemChannels.platform,- (call) async {- if (call.method == 'Clipboard.setData') {- copied.add((call.arguments as Map)['text'] as String);- }- return null;- },- );- addTearDown(- () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(- SystemChannels.platform,- null,- ),- );- await open(tester);+ testWidgets('an opener starts the manager WITH its message', (tester) async {+ // These were example sentences with a copy button each — the best a dialog could do when the+ // pane did not exist yet: copy, open, paste, send. The pane is created from what this dialog+ // returns, so the button carries the message itself and the other three steps disappear.+ await open(tester);- expect(find.text('Try saying'), findsOneWidget);- expect(- find.text(- 'Set up a model for my coding work, just for me on this machine',- ),- findsOneWidget,- );- expect(- find.text(- 'I want a model for chat and writing. What fits this machine?',- ),- findsOneWidget,- );+ expect(find.text('Start with'), findsOneWidget);+ expect(coding, findsOneWidget);+ expect(find.text('A model for chat and writing'), findsOneWidget);+ // Nothing to copy any more, so nothing claims there is.+ expect(find.text('Try saying'), findsNothing);+ expect(find.byIcon(LucideIcons.copy), findsNothing);- await tester.tap(- find.byKey(const ValueKey('run-local-model-prompt-copy-1')),- );- await tester.pump();- expect(copied, [- 'I want a model for chat and writing. What fits this machine?',- ]);- // The button says so for a moment, then goes back to being a copy button.- expect(find.byIcon(LucideIcons.check), findsOneWidget);- await tester.pump(const Duration(seconds: 3));- expect(find.byIcon(LucideIcons.check), findsNothing);- // Copying starts nothing.- expect(conn.creates, isEmpty);- },- );+ await tester.tap(coding);+ await tester.pumpAndSettle();++ expect(conn.creates, hasLength(1));+ expect(+ conn.creates.single['prompt'],+ 'Set up a model for my coding work on this machine.',+ );+ });++ testWidgets('the plain door sends nothing', (tester) async {+ // The third option is for a person who would rather word it themselves, so it must not put+ // words in their mouth — `prompt` absent, exactly as before this dialog had buttons.+ await open(tester);++ expect(find.text('Decide what you need in the conversation'), findsOneWidget);+ await tester.tap(start);+ await tester.pumpAndSettle();++ expect(conn.creates, hasLength(1));+ expect(conn.creates.single.containsKey('prompt'), isFalse);+ });testWidgets('missing opencode is said, and disables Start', (tester) async {build(@@ -260,7 +248,7 @@ void main() {expect(startEnabled(tester), isFalse);await tester.tap(start, warnIfMissed: false);await tester.pumpAndSettle();- expect(find.text('Start'), findsOneWidget);+ expect(start, findsOneWidget);expect(conn.creates, isEmpty);});@@ -565,7 +553,7 @@ void main() {await tester.pumpAndSettle();// Named plainly, under the same label the chooser wears, and NOT called this machine.- expect(find.text('The model will run on'), findsOneWidget);+ expect(find.text('Runs on'), findsOneWidget);expect(find.text('studio-7'), findsOneWidget);expect(find.textContaining('This machine'), findsNothing);expect(@@ -576,7 +564,6 @@ void main() {find.byKey(const ValueKey('run-local-model-machine-studio')),findsNothing,);- expect(find.text('Select the machine to run the model'), findsNothing);await tester.tap(start);await tester.pumpAndSettle();@@ -639,7 +626,7 @@ void main() {await tester.pumpAndSettle();// Both machines as chips on one row, this computer first, the door's machine chosen — and// one sentence saying what the chips are for.- expect(find.text('Select the machine to run the model'), findsOneWidget);+ expect(find.text('Runs on'), findsOneWidget);final localChip = find.byKey(const ValueKey('run-local-model-machine-local'),);