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.

cli+desktop: say when the machine has no grid to run, before offering to start one

Kelvina0fce6efd10c
diff --git a/cli/src/backendSocket.spec.ts b/cli/src/backendSocket.spec.ts
index 78da4ab1a..2a50dec1d 100644
--- a/cli/src/backendSocket.spec.ts
+++ b/cli/src/backendSocket.spec.ts
@@ -1469,6 +1469,45 @@ describe('agent_create with a prompt, a name and a named agent', () => {
})
})
+/**
+ * The picker and the Local model dialog gate on `gridName` — whether the ACCOUNT has a grid — and
+ * had nothing to tell them whether the MACHINE has a `grid` to run at all. A user with no CLI got a
+ * dialog that started an agent, which died at the skill's second step. The answer travels beside
+ * the list, as `localModelEngines` does, and says which grid it is: the managed runtime, one found
+ * on PATH, or none.
+ */
+describe('grid_models_list says whether this machine has a grid CLI', () => {
+ const { gridName: GRID_NAME, plan } = fakeGridAnswers()
+
+ let fake: FakeGrid | null = null
+ afterEach(async () => {
+ fake?.dispose()
+ fake = null
+ wsMock.instances.length = 0
+ })
+
+ async function listModels(): Promise<Record<string, unknown> | undefined> {
+ const socket = new BackendSocket('token')
+ socket.connect()
+ const ws = wsMock.instances[0]
+ ws.open()
+ ws.message({ t: 'down', connId: 'web-1', frame: { type: 'machine_meta', payload: { name: 'mac', gridName: GRID_NAME } } })
+ ws.message({ t: 'down', connId: 'web-1', frame: { type: 'grid_models_list', payload: { requestId: 'r' } } })
+ await vi.waitFor(() => expect(parseSent(ws).some((item) => (item.frame as { type?: string } | undefined)?.type === 'grid_models_list_result')).toBe(true), { timeout: 10_000 })
+ const reply = parseSent(ws)
+ .map((item) => item.frame as { type?: string; payload?: Record<string, unknown> } | undefined)
+ .find((frame) => frame?.type === 'grid_models_list_result')
+ await socket.stop()
+ return reply?.payload
+ }
+
+ it('names the grid it would run — the fixture is a developer override, so `path`', async () => {
+ fake = installFakeGrid(plan)
+
+ expect(await listModels()).toMatchObject({ gridName: GRID_NAME, gridCli: 'path' })
+ })
+})
+
/** The read-only hardware line for the run-a-harness-compute dialog, answered next to `grid_models_list`. */
describe('Autonomous direct isolation from existing relay/browser behavior', () => {
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index 81ca3c06a..fdf617d28 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -27,6 +27,7 @@ import { registry, projectDisplayName, type RegisteredSession } from './lib/regi
import { ENGINES, type AgentEngine } from './engines/types.js'
import { listDir } from './lib/fsBrowse.js'
import { linkCodexProfile, listCodexProfiles } from './lib/codexProfiles.js'
+import { gridCliPresence } from './lib/gridExec.js'
import { gridCapableEngines, parseGridLaunchOverride, type GridLaunchOverride } from './lib/gridLaunch.js'
import { listGridModels, resolveGridTarget } from './lib/gridModels.js'
import { AGENT_NAME_RE, FirstPromptUnsupportedError, MAX_FIRST_PROMPT_CHARS, NamedAgentUnsupportedError, supportsFirstPrompt, supportsNamedAgent } from './lib/engineLaunch.js'
@@ -1484,6 +1485,11 @@ export class BackendSocket {
// whose retarget the daemon would refuse. An older app ignores the field; an older
// daemon omits it, which the app reads as "offer everything", as before.
localModelEngines: gridCapableEngines(),
+ // Whether this MACHINE has a `grid` to run at all — `managed`, `path` or `missing` —
+ // as distinct from `gridName`, which is about the account. The Local model dialog was
+ // gating on the account alone and starting an agent whose second step is `grid`; this
+ // is what lets it, and the picker, say so first. An older app ignores the field.
+ gridCli: gridCliPresence(),
})
return
}
diff --git a/desktop/lib/core/models.dart b/desktop/lib/core/models.dart
index bf5f46e9c..b924f705a 100644
--- a/desktop/lib/core/models.dart
+++ b/desktop/lib/core/models.dart
@@ -676,6 +676,25 @@ class GridModel {
const GridModel({required this.id, required this.node});
}
+/// Which `grid` a machine would run, as its daemon reports beside the model list (`gridCli`).
+///
+/// `managed` is the runtime Harness itself carries and pins; `path` is one the person installed
+/// (runnable, but not the pin); `missing` is nothing to run — the one value that changes what the
+/// picker and the Local model dialog say, because an agent started on that machine would die on
+/// its first `grid`. An older daemon sends no field, read as null: nothing is claimed either way.
+enum GridCli {
+ managed,
+ path,
+ missing;
+
+ static GridCli? parse(Object? raw) => switch (raw) {
+ 'managed' => GridCli.managed,
+ 'path' => GridCli.path,
+ 'missing' => GridCli.missing,
+ _ => null,
+ };
+}
+
/// The picker's whole answer: which grid was asked, and what it offers.
///
/// `gridName` is null when the machine has no grid yet — told apart from "a grid with nothing on
@@ -689,6 +708,10 @@ class GridModels {
/// daemon is older and sends no such list — read as "offer everything", the behaviour before.
final Set<String>? localModelEngines;
+ /// Which `grid` the machine would run — see [GridCli]. Null when the daemon is older and does
+ /// not say, which claims nothing.
+ final GridCli? gridCli;
+
/// Did the machine ANSWER? False when the request failed — offline, timed out, or a daemon too
/// old to know the call.
///
@@ -701,15 +724,17 @@ class GridModels {
required this.gridName,
required this.models,
this.localModelEngines,
+ this.gridCli,
this.reachable = true,
});
/// The machine could not be asked. Says nothing about the account, because nothing is known —
- /// including which engines it would have offered.
+ /// including which engines it would have offered, or whether it has a `grid`.
const GridModels.unreachable()
: gridName = null,
models = const [],
localModelEngines = null,
+ gridCli = null,
reachable = false;
/// Whether [engine] may be pointed at one of [models]: unknown engines are refused only when the
diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dart
index 9af58cbc6..ffd0c3b0e 100644
--- a/desktop/lib/state/app_state.dart
+++ b/desktop/lib/state/app_state.dart
@@ -291,6 +291,7 @@ class AppNotifier extends ChangeNotifier {
final AuthSession session;
AppConfig config;
late ApiClient api;
+
/// Signs in, and says whether this computer is signed in: the harness CLI in a desktop build,
/// [ViewerServices.login] in a viewer build — which has no CLI — under one name, so every call
/// site reads the same in both.
@@ -3458,6 +3459,7 @@ class AppNotifier extends ChangeNotifier {
localModelEngines: capable is List
? capable.whereType<String>().map((e) => e.toLowerCase()).toSet()
: null,
+ gridCli: GridCli.parse(response['gridCli']),
);
} catch (_) {
// NOT `gridName: null` with an empty list — that is the shape of "this account has no grid",
diff --git a/desktop/lib/widgets/grid_model_picker.dart b/desktop/lib/widgets/grid_model_picker.dart
index 690b57867..24db58677 100644
--- a/desktop/lib/widgets/grid_model_picker.dart
+++ b/desktop/lib/widgets/grid_model_picker.dart
@@ -265,7 +265,9 @@ class _GridModelPickerState extends State<GridModelPicker> {
// 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.
- _ManagerInvitation(onPressed: () => close(const _Choice.runLocalModel())),
+ _ManagerInvitation(
+ onPressed: () => close(const _Choice.runLocalModel()),
+ ),
],
);
if (chosen == null) return;
@@ -291,6 +293,11 @@ class _GridModelPickerState extends State<GridModelPicker> {
/// nothing (null): the "Talk to Local model manager" row under it is what a person does about that.
String? _emptySentence(GridModels answer) {
if (!answer.reachable) return 'Could not reach this machine.';
+ // The machine's gap before the account's: with no `grid` on this computer there is nothing a
+ // sign-in could set up here, and the feature's name is the only word for it a person knows.
+ if (answer.gridCli == GridCli.missing) {
+ return "Harness Compute isn't installed on this machine.";
+ }
if (answer.gridName == null) return 'No local models on this account yet.';
return null;
}
@@ -395,12 +402,17 @@ class _GridModelPickerState extends State<GridModelPicker> {
}
static bool _sameAnswer(GridModels a, GridModels b) {
- if (a.reachable != b.reachable || a.gridName != b.gridName) return false;
+ if (a.reachable != b.reachable ||
+ a.gridName != b.gridName ||
+ a.gridCli != b.gridCli) {
+ return false;
+ }
if (a.models.length != b.models.length) return false;
for (var i = 0; i < a.models.length; i += 1) {
if (a.models[i].id != b.models[i].id ||
- a.models[i].node != b.models[i].node)
+ a.models[i].node != b.models[i].node) {
return false;
+ }
}
return true;
}
diff --git a/desktop/lib/widgets/run_local_model_dialog.dart b/desktop/lib/widgets/run_local_model_dialog.dart
index 2d75d68ee..cfc7de0e7 100644
--- a/desktop/lib/widgets/run_local_model_dialog.dart
+++ b/desktop/lib/widgets/run_local_model_dialog.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
+import '../core/models.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_checkbox.dart';
import '../shared/widgets/app_dialog.dart';
@@ -37,7 +38,7 @@ Future<({bool skipNextTime})?> showRunLocalModelDialog(
/// machine line's place, with Start disabled. Present and satisfied, nothing
/// is said — a checklist of green ticks would make a two-second decision look
/// like a setup screen.
-enum _Prerequisite { opencode, grid }
+enum _Prerequisite { opencode, gridCli, grid }
class _RunLocalModelDialog extends StatefulWidget {
const _RunLocalModelDialog({required this.notifier, required this.machineId});
@@ -55,6 +56,10 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {
/// New Agent keeps for a missing engine.
bool? _hasGrid;
+ /// Which `grid` the machine would run, once it answers — null until then,
+ /// and null from a daemon too old to say, which claims nothing.
+ GridCli? _gridCli;
+
bool _skipNextTime = false;
bool _skipHovered = false;
@@ -77,7 +82,10 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {
Future<void> _readGrid() async {
final models = await widget.notifier.gridModels(widget.machineId);
if (!mounted) return;
- setState(() => _hasGrid = models.gridName != null);
+ setState(() {
+ _hasGrid = models.gridName != null;
+ _gridCli = models.gridCli;
+ });
}
/// The first missing prerequisite, or null when nothing has been found
@@ -90,6 +98,9 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {
return _Prerequisite.opencode;
}
}
+ // The machine's own gap before the account's: a sign-in cannot help until
+ // there is a `grid` on this computer to sign in with.
+ if (_gridCli == GridCli.missing) return _Prerequisite.gridCli;
if (_hasGrid == false) return _Prerequisite.grid;
return null;
}
@@ -106,6 +117,8 @@ class _RunLocalModelDialogState extends State<_RunLocalModelDialog> {
// nothing about the machine: the body is the whole message.
final status = switch (missing) {
_Prerequisite.opencode => 'Needs opencode on this machine first.',
+ _Prerequisite.gridCli =>
+ "Harness Compute isn't installed on this machine.",
_Prerequisite.grid => 'Sign in to Harness again to set this up.',
null => null,
};
diff --git a/desktop/test/grid_model_picker_test.dart b/desktop/test/grid_model_picker_test.dart
index 638dfda7e..944fe8c29 100644
--- a/desktop/test/grid_model_picker_test.dart
+++ b/desktop/test/grid_model_picker_test.dart
@@ -17,6 +17,7 @@ class _Conn extends WsConn {
this.models, {
this.localModelEngines,
this.gridName,
+ this.gridCli,
this.fails = false,
}) : super(
wsBaseUrl: 'ws://fixture.invalid',
@@ -38,6 +39,10 @@ class _Conn extends WsConn {
/// be told apart from "no grid".
final String? gridName;
+ /// Which `grid` the machine would run — `managed`, `path` or `missing`; null = an older daemon
+ /// that does not say.
+ final String? gridCli;
+
/// Make the request FAIL, the way an offline machine or a daemon too old for the call does.
final bool fails;
@@ -52,6 +57,7 @@ class _Conn extends WsConn {
'gridName': gridName ?? (models.isEmpty ? null : 'someone-7f3a91c4'),
'models': models,
if (localModelEngines != null) 'localModelEngines': localModelEngines,
+ if (gridCli != null) 'gridCli': gridCli,
};
}
}
@@ -63,6 +69,7 @@ void main() {
List<Map<String, Object?>> models = const [],
List<String>? localModelEngines,
String? gridName,
+ String? gridCli,
bool fails = false,
}) {
notifier = AppNotifier(
@@ -73,6 +80,7 @@ void main() {
models,
localModelEngines: localModelEngines,
gridName: gridName,
+ gridCli: gridCli,
fails: fails,
),
);
@@ -162,6 +170,23 @@ void main() {
expect(find.textContaining('grid'), findsNothing);
});
+ testWidgets(
+ 'a machine without the CLI says so, ahead of anything about the account',
+ (tester) async {
+ // The account has a grid; the machine has no `grid` to serve it with. The machine's sentence
+ // wins — it is the one thing a person can act on — and, like the rest, names the feature and
+ // never the binary.
+ build(gridName: 'someone-7f3a91c4', gridCli: 'missing');
+ await open(tester);
+ expect(
+ find.text("Harness Compute isn't installed on this machine."),
+ findsOneWidget,
+ );
+ expect(find.text('No local models on this account yet.'), findsNothing);
+ expect(find.textContaining('grid'), findsNothing);
+ },
+ );
+
testWidgets(
'a grid serving nothing says nothing — the run row is the answer',
(tester) async {
@@ -465,7 +490,15 @@ void main() {
// 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']) {
+ 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".
@@ -502,10 +535,7 @@ void main() {
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),
- ),
+ find.descendant(of: find.byType(Row), matching: find.byType(Container)),
findsWidgets,
);
});
diff --git a/desktop/test/run_local_model_dialog_test.dart b/desktop/test/run_local_model_dialog_test.dart
index a544688b1..e4471c4f9 100644
--- a/desktop/test/run_local_model_dialog_test.dart
+++ b/desktop/test/run_local_model_dialog_test.dart
@@ -33,7 +33,7 @@ class _MemoryStore implements LocalKeyValueStore {
/// rather than the dialog. Anything else asked of it (a terminal open after the create, say) is
/// left pending, which is what a machine that has not answered yet looks like.
class _Conn extends WsConn {
- _Conn({required this.engines, required this.gridName})
+ _Conn({required this.engines, required this.gridName, this.gridCli})
: super(
wsBaseUrl: 'ws://fixture.invalid',
autonomousEnv: 'test',
@@ -47,6 +47,10 @@ class _Conn extends WsConn {
final List<Map<String, Object?>> engines;
final String? gridName;
+ /// Which `grid` the machine would run — `managed`, `path` or `missing`; null = an older daemon
+ /// that does not say.
+ final String? gridCli;
+
/// Every `agent_create` payload, verbatim — the wire is what the plan specifies.
final creates = <Map<String, dynamic>>[];
@@ -60,7 +64,11 @@ class _Conn extends WsConn {
case 'engines_probe':
return Future.value({'engines': engines});
case 'grid_models_list':
- return Future.value({'gridName': gridName, 'models': <Object?>[]});
+ return Future.value({
+ 'gridName': gridName,
+ 'models': <Object?>[],
+ if (gridCli != null) 'gridCli': gridCli,
+ });
case 'fs_list_dir':
return Future.value({
'path': '/home/remote',
@@ -95,10 +103,11 @@ void main() {
void build({
List<Map<String, Object?>> engines = _installed,
String? gridName = 'someone-7f3a91c4',
+ String? gridCli,
ConfigStore? configStore,
bool local = true,
}) {
- conn = _Conn(engines: engines, gridName: gridName);
+ conn = _Conn(engines: engines, gridName: gridName, gridCli: gridCli);
notifier = AppNotifier(
config: AppConfig.dev,
authSession: AuthSession(),
@@ -210,6 +219,37 @@ void main() {
expect(startEnabled(tester), isFalse);
});
+ testWidgets('a machine without the CLI says so, and disables Start', (
+ tester,
+ ) async {
+ // `gridCli: missing` is the daemon saying there is no `grid` on this computer to serve with —
+ // the agent it would start dies at the skill's second step. Said in the feature's name, never
+ // the binary's, like every other sentence here.
+ build(gridCli: 'missing');
+ await open(tester);
+
+ expect(
+ statusText(tester),
+ "Harness Compute isn't installed on this machine.",
+ );
+ expect(find.textContaining('grid'), findsNothing);
+ expect(startEnabled(tester), isFalse);
+ });
+
+ testWidgets('a missing CLI is said before a missing account grid', (
+ tester,
+ ) async {
+ // Both missing: the machine's is the one to fix first, and the sign-in sentence would send the
+ // person somewhere that cannot help until it is.
+ build(gridCli: 'missing', gridName: null);
+ await open(tester);
+
+ expect(
+ statusText(tester),
+ "Harness Compute isn't installed on this machine.",
+ );
+ });
+
testWidgets('Not now creates nothing', (tester) async {
await open(tester);
await tester.tap(find.byKey(const Key('run-local-model-not-now')));