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.

feat(desktop): a decision model says Serving or Start, and runs in its own app

bitcoinbuilder2818a2c35183
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index bbb89bc42..b56646dda 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -319,6 +319,12 @@ class SwarmSearchController extends ChangeNotifier {
// A decision model on a grid says it is serving. Enter copies how to call it, which the pane and
// its hint say; "Copy" at the end of the row read as the model's state.
if (_jevServing(entry)) return 'Serving';
+ // A decision model of yours says one of two things: Serving, or Start. "Running" (its engine up while
+ // the grid sleeps) is serving — the first call wakes the grid — and "Downloaded" beside Serving and
+ // Start read as a third state to work out, for a model that is only ever started.
+ if (entry.isJev && local.downloaded) {
+ return local.running ? 'Serving' : 'Start';
+ }
return modelRowAction(row) ??
(local.running
? 'Running'
diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dart
index 517ff4a58..be480a87e 100644
--- a/desktop/lib/widgets/swarm_resource_preview.dart
+++ b/desktop/lib/widgets/swarm_resource_preview.dart
@@ -865,8 +865,12 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
final mine = jev.local;
final operating =
mine != null && owner.operationFor(mine)?.active == true;
+ // An engine of yours its grid no longer serves (a `grid leave` from elsewhere) is started again,
+ // as its row says: Stop on a model the row calls not running read as the wrong button.
+ final restart =
+ mine != null && mine.canStop && mine.canStart && !mine.running;
return [
- if (mine != null && mine.canStop)
+ if (mine != null && mine.canStop && !restart)
_ResourceAction(
'Stop',
busy || operating || owner.busy
@@ -1611,7 +1615,13 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
'on your grid, beside the models already running there.',
'',
if (local.sizeBytes case final size?) ('Size', gigabytesLabel(size)),
- ('Runs in', 'Grid\'s llama.cpp'),
+ // A decision model another app downloaded (Ollama's tev1) runs in that app.
+ (
+ 'Runs in',
+ local.app == null || local.app == 'Grid'
+ ? 'Grid\'s llama.cpp'
+ : local.app!,
+ ),
],
if (served == null)
...[]
diff --git a/desktop/test/local_model_picker_test.dart b/desktop/test/local_model_picker_test.dart
index f8273a393..53ddbe90d 100644
--- a/desktop/test/local_model_picker_test.dart
+++ b/desktop/test/local_model_picker_test.dart
@@ -921,6 +921,78 @@ void main() {
},
);
+ testWidgets(
+ 'a decision model of yours says only Serving or Start, whatever its engine is doing',
+ (tester) async {
+ final app = await _localFixture();
+ try {
+ Map<String, dynamic> jev(
+ String id,
+ String name,
+ String state, {
+ bool canStart = false,
+ bool? canStop,
+ }) => {
+ 'id': id,
+ 'name': name,
+ 'kind': 'decision',
+ 'state': state,
+ 'sizeBytes': _gib,
+ 'canStart': canStart,
+ 'canStop': canStop ?? state == 'running',
+ };
+ app.localInventory = {
+ ..._inventory(),
+ 'models': [
+ ...(_inventory()['models'] as List),
+ // Its engine is up and its grid sleeps, so the grid lists nothing: the first call wakes it.
+ jev('jev:ggml-org/Kev-0.8B-GGUF', 'kev-0.8b', 'running'),
+ // Here, and not startable this moment (another model's operation): what Enter does once it is.
+ jev('jev:ggml-org/Laya-GGUF', 'laya-english', 'downloaded'),
+ {
+ ...jev(
+ 'jev:ollama:tev1:latest',
+ 'tev1',
+ 'downloaded',
+ canStart: true,
+ ),
+ 'app': 'Ollama',
+ },
+ // Its engine runs on, but a `grid leave` from elsewhere took it off the grid: Start puts it back.
+ jev(
+ 'jev:ggml-org/lev-GGUF',
+ 'lev',
+ 'downloaded',
+ canStart: true,
+ canStop: true,
+ ),
+ ],
+ };
+ app.inventory = const GridModels(gridName: 'home', models: []);
+ await app.modelManager.refresh(force: true);
+ final picker = await _open(tester, app);
+ expect(picker.modelRowStatus(_row(picker, 'kev-0.8b')), 'Serving');
+ expect(picker.modelRowStatus(_row(picker, 'laya-english')), 'Start');
+ expect(picker.modelRowStatus(_row(picker, 'tev1')), 'Start');
+ final dropped = _row(picker, 'lev');
+ expect(picker.modelRowStatus(dropped), 'Start');
+ picker.move(picker.rows.indexOf(dropped) - picker.cursor);
+ await tester.pumpAndSettle();
+ expect(
+ find.byKey(const ValueKey('resource-action:picker.model_start')),
+ findsOneWidget,
+ );
+ expect(
+ find.byKey(const ValueKey('resource-action:picker.model_stop')),
+ findsNothing,
+ );
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
testWidgets(
'Get on a Jev model starts it, never moves the harness, and then it is one Jev row to stop or call',
(tester) async {