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
Merge origin/feat/harness-grid into feat/harness-grid
Tim5619fdd43d75
diff --cc cli/src/backendSocket.tsindex 356fc91ce,ed22effc3..81ca3c06a--- a/cli/src/backendSocket.ts+++ b/cli/src/backendSocket.ts@@@ -27,9 -27,8 +27,9 @@@ import { registry, projectDisplayName,import { ENGINES, type AgentEngine } from './engines/types.js'import { listDir } from './lib/fsBrowse.js'import { linkCodexProfile, listCodexProfiles } from './lib/codexProfiles.js'- import { parseGridLaunchOverride, type GridLaunchOverride } from './lib/gridLaunch.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'import { readAccountUsage, type AccountUsageReading } from './lib/accountUsage.js'import { probeEngines } from './lib/engineProbe.js'import { AgentCreationReceipts, AgentCreationReceiptError, creationFingerprint, validCreationId, type AgentCreationStatus } from './lib/agentCreationReceipt.js'diff --cc desktop/lib/state/app_state.dartindex e9ee13614,0849691c3..193bff08e--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@@ -3346,18 -3120,19 +3364,19 @@@ class AppNotifier extends ChangeNotifie/// that timed out are all "nothing to offer", which is what the picker shows.Future<GridModels> gridModels(String machineId) async {try {- final response = await _conn(machineId).request(- 'grid_models_list',- timeout: const Duration(seconds: 12),- );+ final response = await _conn(machineId)+ .request('grid_models_list', timeout: const Duration(seconds: 12));final models = (response['models'] as List<dynamic>? ?? []).whereType<Map<String, dynamic>>()- .map((m) => GridModel(- id: (m['id'] as String?) ?? '',- node: (m['node'] as String?) ?? '',- ))+ .map(+ (m) => GridModel(+ id: (m['id'] as String?) ?? '',+ node: (m['node'] as String?) ?? '',+ ),+ ).where((m) => m.id.isNotEmpty).toList();+ final capable = response['localModelEngines'];return GridModels(gridName: response['gridName'] as String?,models: models,diff --cc desktop/lib/widgets/grid_model_picker.dartindex 02e61c728,792751228..771eb9834--- a/desktop/lib/widgets/grid_model_picker.dart+++ b/desktop/lib/widgets/grid_model_picker.dart@@@ -162,7 -162,7 +169,8 @@@ class _GridModelPickerState extends Staif (!mounted) return;final box = context.findRenderObject() as RenderBox?;-- final overlay = Overlay.of(context).context.findRenderObject() as RenderBox?;++ final overlay =++ Overlay.of(context).context.findRenderObject() as RenderBox?;if (box == null || overlay == null) return;final origin = box.localToGlobal(Offset.zero, ancestor: overlay);final position = RelativeRect.fromLTRB(@@@ -189,55 -182,39 +190,53 @@@child: _Row(selected: widget.currentModel == null,engine: widget.engineLabel,-- title: (subscription?['title'] as String?) ?? engineIdentity(widget.engineLabel).label,++ title:++ (subscription?['title'] as String?) ??++ engineIdentity(widget.engineLabel).label,detail: (subscription?['account'] as String?) ?? '',// Absent rather than "unknown": a row that cannot say how much is left says nothing,// which reads as "no figure" instead of as a figure that happens to be missing.status: subscription?['status'] as String?,),),- const PopupMenuDivider(),+ Divider(height: 9, thickness: 1, color: AppColors.border),_header('Local'),- // Nothing served is not a sentence here: the "Run a local model" row at the end of this- // section IS the answer, and a line saying the list is empty above an empty list is noise.- // No grid at all is a different fact the row cannot fix, so that one is said.- if (answer.models.isEmpty && answer.gridName == null)- PopupMenuItem<_Choice>(- enabled: false,- height: 30,- padding: const EdgeInsets.only(left: _menuInset + _rowPadding),- child: Text(- // "Local models", in the user's own vocabulary: the grid is how a Local model is- // served, not a thing this menu asks anyone to know about.- 'No local models on this account yet — sign in again to set them up.',- style: TextStyle(fontSize: 11, color: AppColors.textSoft),- ),- ),- for (final model in answer.models)- PopupMenuItem<_Choice>(- value: _Choice.model(model),- // Taller only for the current row carrying a sentence; every other row keeps its height- // so the menu does not grow for a fact about one agent.- height: _subtitleFor(model) != null ? 46 : 32,- padding: EdgeInsets.zero,- child: _Row(- selected: widget.currentModel == model.id,- title: model.id,- // Which of the user's machines answers it — the part that makes a private grid- // legible, and the reason `node` is carried through at all.- status: model.node.isEmpty ? null : model.node,- subtitle: _subtitleFor(model),+ // An engine with no way onto a Local model (Cursor talks only to its own API; the daemon+ // refuses the move) is told so here, instead of being offered rows whose click would do+ // nothing. The daemon names the capable engines beside the list; an older daemon names+ // none, and then every row is offered as before.+ if (!answer.canRunLocally(widget.engineLabel))- _empty('${engineIdentity(widget.engineLabel).label} can only run on its own login.')- // THREE different facts, three sentences. "We could not ask", "this account has no grid"- // and "the grid is serving nothing" send a person to three different places, and the one- // that used to cover two of them told a signed-in user to sign in again.- else if (answer.models.isEmpty)- _empty(_emptySentence(answer)),++ _empty(++ '${engineIdentity(widget.engineLabel).label} can only run on its own login.',++ )++ // Two different facts, two sentences. "We could not ask" and "this account has no grid"++ // send a person to two different places, and the one that used to cover both told a++ // signed-in user to sign in again. "The grid is serving nothing" is NOT a sentence here:++ // the "Run a local model" row that ends this section is the answer, and a line saying the++ // list is empty above an empty list is noise.++ else if (answer.models.isEmpty && _emptySentence(answer) != null)++ _empty(_emptySentence(answer)!),+ if (answer.canRunLocally(widget.engineLabel))+ for (final model in answer.models)+ _item(+ onTap: () => close(_Choice.model(model)),+ child: _Row(+ selected: widget.currentModel == model.id,+ title: model.id,+ // Which of the user's machines answers it — the part that makes a private grid+ // legible, and the reason `node` is carried through at all.+ status: model.node.isEmpty ? null : model.node,+ 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.- PopupMenuItem<_Choice>(- value: const _Choice.runLocalModel(),- height: 32,- padding: EdgeInsets.zero,++ // 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: 'Run a local model'),+ ),],);if (chosen == null) return;@@@ -250,15 -223,119 +249,128 @@@if (widget.currentModel != null) widget.onUseOwnLogin?.call();return;}-- if (chosen.model!.id != widget.currentModel) widget.onSelected?.call(chosen.model!);++ if (chosen.model!.id != widget.currentModel)++ widget.onSelected?.call(chosen.model!);+ }++ /// What the Local section says when it lists nothing.+ ///- /// Three states, because they are three different situations and only one of them is about the- /// account. Folding the first two together is what put "sign in again to set them up" in front of- /// a signed-in user whose daemon happened to be offline — advice that was wrong, and that would- /// not have helped even if the diagnosis had been right.- String _emptySentence(GridModels answer) {++ /// Two sentences, because they are two different situations and only one of them is about the++ /// account. Folding them together is what put "sign in again to set them up" in front of a++ /// signed-in user whose daemon happened to be offline — advice that was wrong, and that would++ /// not have helped even if the diagnosis had been right. A reachable grid serving nothing says++ /// nothing (null): the "Run a local model" row under it is what a person does about that.++ String? _emptySentence(GridModels answer) {+ if (!answer.reachable) return 'Could not reach this machine.';+ if (answer.gridName == null) return 'No local models on this account yet.';- return 'Nothing is being served yet.';++ return null;+ }++ /// Show the menu in an OVERLAY rather than as a modal route.+ ///+ /// `showMenu` puts a full-screen modal barrier under its menu, and that barrier EATS the click+ /// that dismisses it: closing the menu and then clicking what you meant to click took two clicks,+ /// with the first one going nowhere. A menu is not a decision you have to finish before the app+ /// will listen again.+ ///+ /// So the dismisser is a translucent [Listener] instead. Translucent hit-test behaviour means it+ /// receives the pointer AND reports no hit, so the overlay below it — the app — is hit-tested next+ /// and gets the same event. One click closes the menu and lands where it was aimed.+ Future<_Choice?> _showMenu({+ required RelativeRect position,+ required List<Widget> Function(void Function(_Choice?) close) children,+ }) {+ final overlayState = Overlay.of(context);+ final completer = Completer<_Choice?>();+ late final OverlayEntry entry;+ late final void Function() deregister;+ var closed = false;+ void close(_Choice? choice) {+ // Guarded: a pointer-down outside and a row tap can both arrive for one gesture, and removing+ // an entry twice throws.+ if (closed) return;+ closed = true;+ deregister();+ entry.remove();+ if (!completer.isCompleted) completer.complete(choice);+ }+++ // A click on the window's NATIVE tab strip is not a pointer event Flutter ever sees, so the+ // dismisser below cannot fire for it — the menu was left floating over a tab it no longer+ // belonged to. The titlebar reports its own clicks instead; see [dismissTransientMenus].+ deregister = registerTransientMenu(() => close(null));+ _close = () => close(null);++ entry = OverlayEntry(+ builder: (context) => Stack(+ children: [+ Positioned.fill(+ child: Listener(+ behavior: HitTestBehavior.translucent,+ onPointerDown: (_) => close(null),+ child: const SizedBox.expand(),+ ),+ ),+ Positioned(+ // Right-aligned to the control, which sits at the right end of a pane header — anchoring+ // the left edge would push a wide menu off-screen.+ right: position.right,+ top: position.top,+ child: ConstrainedBox(+ // Wide enough that a status can sit right-aligned against a model id without the two+ // meeting, and for a full GGUF-style model id beside its node without either cut.+ constraints: const BoxConstraints(minWidth: 340, maxWidth: 540),+ // ⚠️ IntrinsicWidth, or the menu is ALWAYS 540 wide. `Positioned` hands down unbounded+ // width, the ConstrainedBox turns that into "up to 540", and a stretching Column takes+ // all of it — so a two-line menu wore the width of the longest model id it could ever+ // hold. This measures the rows and the clamp then applies to what they actually need.+ child: IntrinsicWidth(- child: Material(++ child: Material(+ color: AppColors.surface,+ elevation: 8,+ borderRadius: BorderRadius.circular(8),+ clipBehavior: Clip.antiAlias,+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 6),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: children(close),+ ),+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ );+ overlayState.insert(entry);+ return completer.future.whenComplete(() => _close = null);}+ /// One selectable row.- Widget _item({required VoidCallback onTap, required Widget child}) => InkWell(- onTap: onTap,- child: child,- );++ Widget _item({required VoidCallback onTap, required Widget child}) =>++ InkWell(onTap: onTap, child: child);++ /// A line that states something rather than offering it — no hover, no tap.+ Widget _empty(String text) => Padding(- padding: const EdgeInsets.fromLTRB(_menuInset + _rowPadding, 5, _menuInset + _rowPadding, 6),- child: Text(text, style: TextStyle(fontSize: 11, color: AppColors.textSoft)),++ padding: const EdgeInsets.fromLTRB(++ _menuInset + _rowPadding,++ 5,++ _menuInset + _rowPadding,++ 6,++ ),++ child: Text(++ text,++ style: TextStyle(fontSize: 11, color: AppColors.textSoft),++ ),+ );+/// A section label. Non-interactive and short, so the two groups read as groups rather than as/// entries someone failed to make clickable.- PopupMenuItem<_Choice> _header(String label) => PopupMenuItem<_Choice>(- enabled: false,- height: 22,- padding: EdgeInsets.zero,+ Widget _header(String label) => Padding(+ padding: const EdgeInsets.only(top: 3, bottom: 3),child: Padding(// The row's margin plus its internal padding, so a header sits directly above the text it// heads rather than a few pixels to either side of it.@@@ -281,33 -358,43 +393,49 @@@return Tooltip(// The same sentence the menu shows, one line under the control's own — so a person can learn// the agent has no web search without opening the menu at all.-- message: sentence == null ? 'Where this agent runs' : 'Where this agent runs\n$sentence',++ message: sentence == null++ ? 'Where this agent runs'++ : 'Where this agent runs\n$sentence',waitDuration: const Duration(milliseconds: 700),- child: InkWell(- onTap: _open,- borderRadius: BorderRadius.circular(4),- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- // No leading glyph: the word carries the control, and a header this dense reads better- // with one fewer mark in it. The spinner takes that space only while a read is in- // flight, so the label does not shift when nothing is happening.- if (_loading) ...[- const SizedBox(- width: 11,- height: 11,- child: CircularProgressIndicator(strokeWidth: 1.5),+ child: MouseRegion(+ // Stated rather than inherited. The pane header sits over a terminal, and the cursor a+ // person sees while hovering this was whatever the surface underneath asked for — so a+ // control that opens a menu did not look like one until you clicked it.+ cursor: SystemMouseCursors.click,+ child: InkWell(+ onTap: _open,+ // Stated on the InkWell as well as on the MouseRegion above it. The cursor a person sees is+ // the INNERMOST annotation under the pointer, and InkWell installs one of its own — so an+ // ancestor asking for a hand is not, by itself, the thing that decides.+ mouseCursor: SystemMouseCursors.click,+ borderRadius: BorderRadius.circular(4),+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 3),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ // No leading glyph: the word carries the control, and a header this dense reads+ // better with one fewer mark in it. The spinner takes that space only while a read+ // is in flight, so the label does not shift when nothing is happening.+ if (_loading) ...[+ const SizedBox(+ width: 11,+ height: 11,+ child: CircularProgressIndicator(strokeWidth: 1.5),+ ),+ const SizedBox(width: 5),+ ],+ Text(+ 'Model',+ style: TextStyle(fontSize: 11, color: AppColors.textSoft),+ ),- Icon(Icons.arrow_drop_down, size: 14, color: AppColors.mutedStrong),++ Icon(++ Icons.arrow_drop_down,++ size: 14,++ color: AppColors.mutedStrong,+ ),- const SizedBox(width: 5),],- Text(- 'Model',- style: TextStyle(fontSize: 11, color: AppColors.textSoft),- ),- Icon(Icons.arrow_drop_down, size: 14, color: AppColors.mutedStrong),- ],+ ),),),),@@@ -363,7 -450,7 +491,10 @@@ class _Row extends StatelessWidget),if (detail.isNotEmpty) ...[const SizedBox(width: 6),-- Text(detail, style: TextStyle(fontSize: 11, color: AppColors.mutedStrong)),++ Text(++ detail,++ style: TextStyle(fontSize: 11, color: AppColors.mutedStrong),++ ),],if (status != null) ...[const SizedBox(width: 14),diff --cc desktop/test/grid_model_picker_test.dartindex 6caed92d2,5907eba22..e75f9a223--- a/desktop/test/grid_model_picker_test.dart+++ b/desktop/test/grid_model_picker_test.dart@@@ -13,16 -13,16 +13,20 @@@ import 'package:harness/ws/ws_conn.dart/// request's own 12-second timeout, and a spinner that never stops means `pumpAndSettle` never/// returns — the test would be measuring the timeout rather than the menu.class _Conn extends WsConn {- _Conn(this.models)- _Conn(this.models, {this.localModelEngines, this.gridName, this.fails = false})-- : super(-- wsBaseUrl: 'ws://fixture.invalid',-- autonomousEnv: 'test',-- machineId: 'local',-- accessTokenProvider: (_, _) async => '',-- onAuthFailure: (_) {},-- onEvent: (_) {},-- onStatus: (_) {},-- );++ _Conn(++ this.models, {++ this.localModelEngines,++ this.gridName,++ this.fails = false,++ }) : super(++ wsBaseUrl: 'ws://fixture.invalid',++ autonomousEnv: 'test',++ machineId: 'local',++ accessTokenProvider: (_, _) async => '',++ onAuthFailure: (_) {},++ onEvent: (_) {},++ onStatus: (_) {},++ );final List<Map<String, Object?>> models;@@@ -53,35 -81,34 +85,40 @@@ void main()WidgetTester tester, {String? currentModel,GridWebSearch? webSearch,+ String engine = 'claude',VoidCallback? onOwnLogin,ValueChanged<GridModel>? onSelected,+ VoidCallback? onRunLocalModel,}) async {tester.view.physicalSize = const Size(1200, 900);tester.view.devicePixelRatio = 1;addTearDown(tester.view.reset);-- await tester.pumpWidget(MaterialApp(-- home: Scaffold(-- body: Center(-- child: GridModelPicker(-- notifier: notifier,-- machineId: 'local',- engineLabel: 'claude',- engineLabel: engine,-- currentModel: currentModel,-- webSearch: webSearch,-- onUseOwnLogin: onOwnLogin,-- onSelected: onSelected,- onRunLocalModel: onRunLocalModel,++ await tester.pumpWidget(++ MaterialApp(++ home: Scaffold(++ body: Center(++ child: GridModelPicker(++ notifier: notifier,++ machineId: 'local',++ engineLabel: engine,++ currentModel: currentModel,++ webSearch: webSearch,++ onUseOwnLogin: onOwnLogin,++ onSelected: onSelected,++ onRunLocalModel: onRunLocalModel,++ ),),),),-- ));++ );await tester.tap(find.text('Model'));// The menu waits on the grid read AND the usage read; settle covers both plus the open animation.await tester.pumpAndSettle();}-- testWidgets('shows both sections, and the way back is in the first one', (tester) async {++ testWidgets('shows both sections, and the way back is in the first one', (++ tester,++ ) async {await open(tester);// The two sections this picker has, and NOT the API section the window's own Models menu@@@ -99,147 -126,192 +136,360 @@@expect(find.textContaining('usage'), findsOneWidget);});- testWidgets('no grid at all says so; an empty grid says nothing — the run row is the answer', (tester) async {- // The daemon answers `{gridName: null, models: []}` when it cannot reach a grid at all: that- // sends you to sign in, which the run row cannot do for you. An empty grid gets no sentence —- // the "Run a local model" row under Local is what a person does about it.- // THREE situations, three sentences, one test each — a single test cannot cover them, because- // re-pumping the same widget reuses the State and the picker answers from the memo 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.- testWidgets('a machine that did not answer says so, and does not blame the account', (tester) async {- build(fails: true);- await open(tester);- expect(find.text('Could not reach this machine.'), findsOneWidget);- expect(find.textContaining('sign in'), findsNothing);- });-- testWidgets('an account with no grid says there are no local models yet', (tester) async {++ // THREE situations, two sentences and one silence, one test each — a single test cannot cover++ // them, because re-pumping the same widget reuses the State and the picker answers from the memo++ // 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 "Run a local model" row under Local is what a person does about it.++ testWidgets(++ 'a machine that did not answer says so, and does not blame the account',++ (tester) async {++ build(fails: true);++ await open(tester);++ expect(find.text('Could not reach this machine.'), findsOneWidget);++ expect(find.textContaining('sign in'), findsNothing);++ },++ );++++ testWidgets('an account with no grid says there are no local models yet', (++ tester,++ ) async {await open(tester);- expect(find.textContaining('sign in again'), findsOneWidget);+ expect(find.text('No local models on this account yet.'), findsOneWidget);// The user's vocabulary is "Local models", never "grid" — the grid is how a Local model is// served, not a thing the picker asks anyone to know about.- expect(find.text('No local models on this account yet — sign in again to set them up.'), findsOneWidget);expect(find.textContaining('grid'), findsNothing);});- testWidgets('a served model shows under Local with the machine answering it', (tester) async {- build(models: [- {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},- ]);- GridModel? picked;- await open(tester, onSelected: (m) => picked = m);- testWidgets('a grid serving nothing is the one state that asks for a model', (tester) async {- build(gridName: 'someone-7f3a91c4');- await open(tester);- expect(find.text('Nothing is being served yet.'), findsOneWidget);- });++ testWidgets(++ 'a grid serving nothing says nothing — the run row is the answer',++ (tester) async {++ build(gridName: 'someone-7f3a91c4');++ await open(tester);++ expect(find.text('Nothing is being served yet.'), findsNothing);++ expect(find.text('Could not reach this machine.'), findsNothing);++ expect(find.text('Run a local model'), findsOneWidget);++ },++ );++ // `Positioned` hands down unbounded width, so a stretching Column takes every pixel its constraints+ // allow — a two-line menu wore the width of the longest model id it could ever hold. The minimum is+ // what keeps a status off a model id; the maximum is a CEILING, not a target. One test each, because+ // re-pumping reuses the State and the second open would answer from the first one's memo.- testWidgets('a short menu is not as wide as the widest menu could be', (tester) async {++ testWidgets('a short menu is not as wide as the widest menu could be', (++ tester,++ ) async {+ await open(tester);+ final width = tester.getSize(find.byType(Material).last).width;- expect(width, greaterThanOrEqualTo(340), reason: 'a status still clears a model id');- expect(width, lessThan(540), reason: 'and nothing is padded out to the ceiling');++ expect(++ width,++ greaterThanOrEqualTo(340),++ reason: 'a status still clears a model id',++ );++ expect(++ width,++ lessThan(540),++ reason: 'and nothing is padded out to the ceiling',++ );+ });+- testWidgets('a long model id is given room, up to the ceiling', (tester) async {- build(models: [- {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL-with-a-deliberately-long-tail', 'node': 'macbook-m1max'},- ]);++ testWidgets('a long model id is given room, up to the ceiling', (++ tester,++ ) async {++ build(++ models: [++ {++ 'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL-with-a-deliberately-long-tail',++ 'node': 'macbook-m1max',++ },++ ],++ );+ await open(tester);+ final width = tester.getSize(find.byType(Material).last).width;- expect(width, greaterThan(340), reason: 'a row longer than the minimum asks for more');- expect(width, lessThanOrEqualTo(540), reason: 'and never more than the ceiling');++ expect(++ width,++ greaterThan(340),++ reason: 'a row longer than the minimum asks for more',++ );++ expect(++ width,++ lessThanOrEqualTo(540),++ reason: 'and never more than the ceiling',++ );+ });- expect(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'), findsOneWidget);- // The node is what makes a PRIVATE grid legible: it names which of the user's own machines- // answers, which is the whole difference from a model on somebody else's grid.- expect(find.text('macbook-m1max'), findsOneWidget);- testWidgets('a click outside closes the menu AND reaches what it was aimed at', (tester) async {- // `showMenu` puts a modal barrier under the menu and that barrier EATS the dismissing click, so- // closing the menu and then pressing a button took two clicks with the first going nowhere.- var pressed = 0;- tester.view.physicalSize = const Size(1200, 900);- tester.view.devicePixelRatio = 1;- addTearDown(tester.view.reset);- await tester.pumpWidget(MaterialApp(- home: Scaffold(- body: Stack(- children: [- Positioned(- left: 20,- top: 400,- child: ElevatedButton(- onPressed: () => pressed += 1,- child: const Text('underneath'),- ),- ),- Align(- alignment: Alignment.topRight,- child: GridModelPicker(- notifier: notifier,- machineId: 'local',- engineLabel: 'claude',- ),++ testWidgets(++ 'a click outside closes the menu AND reaches what it was aimed at',++ (tester) async {++ // `showMenu` puts a modal barrier under the menu and that barrier EATS the dismissing click, so++ // closing the menu and then pressing a button took two clicks with the first going nowhere.++ var pressed = 0;++ tester.view.physicalSize = const Size(1200, 900);++ tester.view.devicePixelRatio = 1;++ addTearDown(tester.view.reset);++ await tester.pumpWidget(++ MaterialApp(++ home: Scaffold(++ body: Stack(++ children: [++ Positioned(++ left: 20,++ top: 400,++ child: ElevatedButton(++ onPressed: () => pressed += 1,++ child: const Text('underneath'),++ ),++ ),++ Align(++ alignment: Alignment.topRight,++ child: GridModelPicker(++ notifier: notifier,++ machineId: 'local',++ engineLabel: 'claude',++ ),++ ),++ ],+ ),- ],++ ),+ ),- ),- ));- await tester.tap(find.text('Model'));- await tester.pumpAndSettle();- expect(find.text('Subscription'), findsOneWidget);++ );++ await tester.tap(find.text('Model'));++ await tester.pumpAndSettle();++ expect(find.text('Subscription'), findsOneWidget);+- await tester.tap(find.text('underneath'));- await tester.pumpAndSettle();++ await tester.tap(find.text('underneath'));++ await tester.pumpAndSettle();- await tester.tap(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'));- expect(find.text('Subscription'), findsNothing, reason: 'the menu closes');- expect(pressed, 1, reason: 'and the same click lands on the button under it');- });++ expect(++ find.text('Subscription'),++ findsNothing,++ reason: 'the menu closes',++ );++ expect(++ pressed,++ 1,++ reason: 'and the same click lands on the button under it',++ );++ },++ );+- testWidgets('the control says it is clickable before it is clicked', (tester) async {++ testWidgets('the control says it is clickable before it is clicked', (++ tester,++ ) async {+ // The pane header sits over a terminal, and without this the cursor over the control was+ // whatever the surface underneath asked for — so a menu control did not look like one.+ tester.view.physicalSize = const Size(1200, 900);+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);- await tester.pumpWidget(MaterialApp(- home: Scaffold(- body: Center(- child: GridModelPicker(notifier: notifier, machineId: 'local', engineLabel: 'claude'),++ await tester.pumpWidget(++ MaterialApp(++ home: Scaffold(++ body: Center(++ child: GridModelPicker(++ notifier: notifier,++ machineId: 'local',++ engineLabel: 'claude',++ ),++ ),+ ),+ ),- ));++ );+ // The control prefetches on mount; settle so the test is not measuring that work's timers.await tester.pumpAndSettle();- expect(picked?.id, 'Qwen3.6-35B-A3B-UD-Q5_K_XL');++ // BOTH annotations, because the innermost one under the pointer is what a person actually sees:+ // InkWell installs its own MouseRegion, so an ancestor asking for a hand does not decide alone.+ //+ // ⚠️ This asserts the widgets' contract, NOT the cursor the OS ends up drawing. Reading that back+ // through `MouseTracker.debugDeviceActiveCursor` does not work in this harness — a bare+ // `MouseRegion(cursor: click)` over a plain box resolves to `basic` there — so a test written+ // that way would have been measuring the harness rather than the app.- final region = tester.widget<MouseRegion>(find.ancestor(- of: find.byType(InkWell),- matching: find.byType(MouseRegion),- ).first);++ final region = tester.widget<MouseRegion>(++ find++ .ancestor(++ of: find.byType(InkWell),++ matching: find.byType(MouseRegion),++ )++ .first,++ );+ expect(region.cursor, SystemMouseCursors.click);- expect(tester.widget<InkWell>(find.byType(InkWell)).mouseCursor, SystemMouseCursors.click);- });-- testWidgets('a served model shows under Local with the machine answering it', (tester) async {- build(models: [- {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},- ]);- GridModel? picked;- await open(tester, onSelected: (m) => picked = m);-- expect(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'), findsOneWidget);- // The node is what makes a PRIVATE grid legible: it names which of the user's own machines- // answers, which is the whole difference from a model on somebody else's grid.- expect(find.text('macbook-m1max'), findsOneWidget);-- await tester.tap(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'));- await tester.pumpAndSettle();- expect(picked?.id, 'Qwen3.6-35B-A3B-UD-Q5_K_XL');++ expect(++ tester.widget<InkWell>(find.byType(InkWell)).mouseCursor,++ SystemMouseCursors.click,++ );});-- testWidgets('a long model id is not truncated while space sits beside it', (tester) async {++ testWidgets(++ 'a served model shows under Local with the machine answering it',++ (tester) async {++ build(++ models: [++ {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},++ ],++ );++ GridModel? picked;++ await open(tester, onSelected: (m) => picked = m);++++ expect(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'), findsOneWidget);++ // The node is what makes a PRIVATE grid legible: it names which of the user's own machines++ // answers, which is the whole difference from a model on somebody else's grid.++ expect(find.text('macbook-m1max'), findsOneWidget);++++ await tester.tap(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'));++ await tester.pumpAndSettle();++ expect(picked?.id, 'Qwen3.6-35B-A3B-UD-Q5_K_XL');++ },++ );++++ testWidgets('a long model id is not truncated while space sits beside it', (++ tester,++ ) async {// ⚠️ REGRESSION. The status column used to take the flexible half, which cut// `Qwen3.6-35B-A3B-UD-Q5_K_XL` down to `Qwen3.6-35B-A3B-UD-Q5_K…` with empty menu beside it.// The long string in this menu is the model id, so the model id is what gets the room.-- build(models: [-- {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},-- ]);++ build(++ models: [++ {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},++ ],++ );await open(tester);final title = tester.widget<Text>(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'));-- expect(title.overflow, TextOverflow.ellipsis); // still guarded for a truly absurd name-- final rendered = tester.renderObject<RenderBox>(find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'));++ expect(++ title.overflow,++ TextOverflow.ellipsis,++ ); // still guarded for a truly absurd name++ final rendered = tester.renderObject<RenderBox>(++ find.text('Qwen3.6-35B-A3B-UD-Q5_K_XL'),++ );// Laid out at its natural width rather than clipped: the painted box is as wide as the string// wants, which is the thing that was failing.expect(rendered.size.width, greaterThan(160));});-- testWidgets('the current row is marked by a highlight, not by a tick column', (tester) async {-- // The tick reserved a fixed column at the start of EVERY row to keep labels aligned, which cost-- // every row that indent for one row's sake. Filling the current row instead says the same thing-- // and gives the space back.-- build(models: [-- {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},-- ]);-- await open(tester, currentModel: 'Qwen3.6-35B-A3B-UD-Q5_K_XL');-- expect(find.byIcon(Icons.check), findsNothing);++ testWidgets(++ 'the current row is marked by a highlight, not by a tick column',++ (tester) async {++ // The tick reserved a fixed column at the start of EVERY row to keep labels aligned, which cost++ // every row that indent for one row's sake. Filling the current row instead says the same thing++ // and gives the space back.++ build(++ models: [++ {'id': 'Qwen3.6-35B-A3B-UD-Q5_K_XL', 'node': 'macbook-m1max'},++ ],++ );++ await open(tester, currentModel: 'Qwen3.6-35B-A3B-UD-Q5_K_XL');+- Container rowFor(String text) => tester.widget<Container>(- find.ancestor(of: find.text(text), matching: find.byType(Container)).first,- );- // The selected row is filled; the other is not.- expect((rowFor('Qwen3.6-35B-A3B-UD-Q5_K_XL').decoration as BoxDecoration?)?.color, isNotNull);- expect(rowFor('Anthropic').decoration, isNull);- });++ expect(find.byIcon(Icons.check), findsNothing);- testWidgets('choosing the engine login only fires when the agent is NOT already on it', (tester) async {- var calls = 0;- // Already on its own login: re-selecting it would respawn the pane for nothing.- await open(tester, currentModel: null, onOwnLogin: () => calls++);- await tester.tap(find.text('Anthropic'));- await tester.pumpAndSettle();- expect(calls, 0);- expect(find.byIcon(Icons.check), findsNothing);++ Container rowFor(String text) => tester.widget<Container>(++ find++ .ancestor(of: find.text(text), matching: find.byType(Container))++ .first,++ );++ // The selected row is filled; the other is not.++ expect(++ (rowFor('Qwen3.6-35B-A3B-UD-Q5_K_XL').decoration as BoxDecoration?)++ ?.color,++ isNotNull,++ );++ expect(rowFor('Anthropic').decoration, isNull);++ },++ );++++ testWidgets(++ 'choosing the engine login only fires when the agent is NOT already on it',++ (tester) async {++ var calls = 0;++ // Already on its own login: re-selecting it would respawn the pane for nothing.++ await open(tester, currentModel: null, onOwnLogin: () => calls++);++ await tester.tap(find.text('Anthropic'));++ await tester.pumpAndSettle();++ expect(calls, 0);+- // On a grid model: now it has somewhere to go.- await open(tester, currentModel: 'Qwen-Test', onOwnLogin: () => calls++);- await tester.tap(find.text('Anthropic'));- await tester.pumpAndSettle();- expect(calls, 1);- });++ // On a grid model: now it has somewhere to go.++ await open(tester, currentModel: 'Qwen-Test', onOwnLogin: () => calls++);++ await tester.tap(find.text('Anthropic'));++ await tester.pumpAndSettle();++ expect(calls, 1);++ },++ );++ group('the last row under Local starts a local model', () {+ const served = [+ {'id': 'Qwen-Test', 'node': 'macbook-m1max'},+ ];++ testWidgets('is there after the served models', (tester) async {+ build(models: served);+ await open(tester);+ expect(find.text('Run a local model'), 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('Run a local model'));+ final model = tester.getTopLeft(find.text('Qwen-Test'));+ expect(row.dy, greaterThan(model.dy));+ });- 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.- await open(tester);- expect(find.text('Run a local model'), findsOneWidget);- final row = tester.getTopLeft(find.text('Run a local model'));- final sentence = tester.getTopLeft(find.textContaining('sign in again'));- expect(row.dy, greaterThan(sentence.dy));- // Never the plumbing's name, in this row as in the rest of the menu.- expect(find.textContaining('grid'), findsNothing);- });- Container rowFor(String text) => tester.widget<Container>(- find.ancestor(of: find.text(text), matching: find.byType(Container)).first,++ 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.++ await open(tester);++ expect(find.text('Run a local model'), findsOneWidget);++ final row = tester.getTopLeft(find.text('Run a local model'));++ 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.textContaining('grid'), findsNothing);++ },+ );- // The selected row is filled; the other is not.- expect((rowFor('Qwen3.6-35B-A3B-UD-Q5_K_XL').decoration as BoxDecoration?)?.color, isNotNull);- expect(rowFor('Anthropic').decoration, isNull);- });- testWidgets('is never filled: an action is nowhere, so it cannot be the current row', (tester) async {- build(models: served);- await open(tester, currentModel: 'Qwen-Test');- expect(find.byIcon(Icons.check), findsNothing);- Container rowFor(String text) => tester.widget<Container>(- find.ancestor(of: find.text(text), matching: find.byType(Container)).first,- );- expect((rowFor('Qwen-Test').decoration as BoxDecoration?)?.color, isNotNull);- expect(rowFor('Run a local model').decoration, isNull);- });- testWidgets('choosing the engine login only fires when the agent is NOT already on it', (tester) async {- var calls = 0;- // Already on its own login: re-selecting it would respawn the pane for nothing.- await open(tester, currentModel: null, onOwnLogin: () => calls++);- await tester.tap(find.text('Anthropic'));- await tester.pumpAndSettle();- expect(calls, 0);++ testWidgets(++ 'is never filled: an action is nowhere, so it cannot be the current row',++ (tester) async {++ build(models: served);++ await open(tester, currentModel: 'Qwen-Test');++ expect(find.byIcon(Icons.check), findsNothing);++ Container rowFor(String text) => tester.widget<Container>(++ find++ .ancestor(of: find.text(text), matching: find.byType(Container))++ .first,++ );++ expect(++ (rowFor('Qwen-Test').decoration as BoxDecoration?)?.color,++ isNotNull,++ );++ expect(rowFor('Run a local model').decoration, isNull);++ },++ );- // On a grid model: now it has somewhere to go.- await open(tester, currentModel: 'Qwen-Test', onOwnLogin: () => calls++);- await tester.tap(find.text('Anthropic'));- await tester.pumpAndSettle();- expect(calls, 1);+ testWidgets('fires onRunLocalModel and nothing else', (tester) async {+ build(models: served);+ var runs = 0;+ var logins = 0;+ GridModel? picked;+ await open(+ tester,+ currentModel: 'Qwen-Test',+ onRunLocalModel: () => runs++,+ onOwnLogin: () => logins++,+ onSelected: (m) => picked = m,+ );+ await tester.tap(find.text('Run a local model'));+ 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('Run a local model'), findsNothing);+ });});group('web search on the current Local model', () {@@@ -250,9 -322,9 +500,16 @@@testWidgets('says nothing when it is on', (tester) async {build(models: served);-- await open(tester, currentModel: 'Qwen-Test', webSearch: GridWebSearch.on);++ await open(++ tester,++ currentModel: 'Qwen-Test',++ webSearch: GridWebSearch.on,++ );expect(find.textContaining('Web search'), findsNothing);-- expect(tester.widget<Tooltip>(find.byType(Tooltip)).message, 'Where this agent runs');++ expect(++ tester.widget<Tooltip>(find.byType(Tooltip)).message,++ 'Where this agent runs',++ );});testWidgets('says nothing when the daemon said nothing', (tester) async {@@@ -261,39 -333,70 +518,107 @@@expect(find.textContaining('Web search'), findsNothing);});-- testWidgets('a subtitle under the current row, and the tooltip, when it is unavailable', (tester) async {++ testWidgets(++ 'a subtitle under the current row, and the tooltip, when it is unavailable',++ (tester) async {++ build(models: served);++ await open(++ tester,++ currentModel: 'Qwen-Test',++ webSearch: GridWebSearch.unavailable,++ );++ expect(find.text('Web search unavailable'), findsOneWidget);++ // Under the CURRENT model, not every model: the status is about this agent's launch, and the++ // other rows are places it could go, about which nothing is yet known.++ final subtitle = tester.getTopLeft(find.text('Web search unavailable'));++ final current = tester.getTopLeft(find.text('Qwen-Test'));++ final other = tester.getTopLeft(find.text('Other-Model'));++ expect(subtitle.dy, greaterThan(current.dy));++ expect(subtitle.dy, lessThan(other.dy));++ expect(++ tester.widget<Tooltip>(find.byType(Tooltip)).message,++ 'Where this agent runs\nWeb search unavailable',++ );++ },++ );++++ testWidgets('the other sentence when the engine cannot take it', (++ tester,++ ) async {build(models: served);-- await open(tester, currentModel: 'Qwen-Test', webSearch: GridWebSearch.unavailable);-- expect(find.text('Web search unavailable'), findsOneWidget);-- // Under the CURRENT model, not every model: the status is about this agent's launch, and the-- // other rows are places it could go, about which nothing is yet known.-- final subtitle = tester.getTopLeft(find.text('Web search unavailable'));-- final current = tester.getTopLeft(find.text('Qwen-Test'));-- final other = tester.getTopLeft(find.text('Other-Model'));-- expect(subtitle.dy, greaterThan(current.dy));-- expect(subtitle.dy, lessThan(other.dy));++ await open(++ tester,++ currentModel: 'Qwen-Test',++ webSearch: GridWebSearch.unsupported,++ );+ expect(- tester.widget<Tooltip>(find.byType(Tooltip)).message,- 'Where this agent runs\nWeb search unavailable',++ find.text('Web search not supported by this engine'),++ findsOneWidget,+ );- });-- testWidgets('the other sentence when the engine cannot take it', (tester) async {- build(models: served);- await open(tester, currentModel: 'Qwen-Test', webSearch: GridWebSearch.unsupported);- expect(find.text('Web search not supported by this engine'), findsOneWidget);expect(tester.widget<Tooltip>(find.byType(Tooltip)).message,- 'Where this agent runs\nWeb search unavailable',+ 'Where this agent runs\nWeb search not supported by this engine',);});- testWidgets('the other sentence when the engine cannot take it', (tester) async {- testWidgets('never under the Subscription row, which has its own web tools', (tester) async {- // A stale status with no current model (the agent came home, the frame has not caught up):- // the subscription row must not inherit a sentence about a launch it was never part of.-- build(models: served);- await open(tester, currentModel: 'Qwen-Test', webSearch: GridWebSearch.unsupported);- expect(find.text('Web search not supported by this engine'), findsOneWidget);- await open(tester, currentModel: null, webSearch: GridWebSearch.unavailable);- expect(find.textContaining('Web search'), findsNothing);- });++ testWidgets(++ 'never under the Subscription row, which has its own web tools',++ (tester) async {++ // A stale status with no current model (the agent came home, the frame has not caught up):++ // the subscription row must not inherit a sentence about a launch it was never part of.++ build(models: served);++ await open(++ tester,++ currentModel: null,++ webSearch: GridWebSearch.unavailable,++ );++ expect(find.textContaining('Web search'), findsNothing);++ },++ );+ });++ group('an engine that cannot run on a Local model', () {+ const served = [+ {'id': 'qwen/qwen3.6-35b-a3b', 'node': 'macbook-m1max'},+ ];- const capable = ['claude', 'codex', 'opencode', 'hermes', 'grok', 'pi', 'copilot'];++ const capable = [++ 'claude',++ 'codex',++ 'opencode',++ 'hermes',++ 'grok',++ 'pi',++ 'copilot',++ ];++ testWidgets('is told so under Local, and offered no rows', (tester) async {+ // The daemon refuses a Cursor retarget (`GRID_ENGINE_UNSUPPORTED`): Cursor Agent can only be+ // re-pointed at another Cursor API. Offering the row anyway was a dead end that said nothing.+ build(models: served, localModelEngines: capable);+ GridModel? picked;+ await open(tester, engine: 'cursor', onSelected: (m) => picked = m);- expect(find.text('Cursor can only run on its own login.'), findsOneWidget);+ expect(- tester.widget<Tooltip>(find.byType(Tooltip)).message,- 'Where this agent runs\nWeb search not supported by this engine',++ find.text('Cursor can only run on its own login.'),++ findsOneWidget,+ );+ expect(find.text('qwen/qwen3.6-35b-a3b'), findsNothing);+ expect(picked, isNull);});- testWidgets('never under the Subscription row, which has its own web tools', (tester) async {- // A stale status with no current model (the agent came home, the frame has not caught up):- // the subscription row must not inherit a sentence about a launch it was never part of.- build(models: served);- await open(tester, currentModel: null, webSearch: GridWebSearch.unavailable);- expect(find.textContaining('Web search'), findsNothing);+ testWidgets('a capable engine still gets the rows', (tester) async {+ build(models: served, localModelEngines: capable);+ await open(tester, engine: 'codex');+ expect(find.text('qwen/qwen3.6-35b-a3b'), findsOneWidget);+ expect(find.textContaining('own login'), findsNothing);});+- testWidgets('an older daemon that names no engines offers everything, as before', (tester) async {- build(models: served);- await open(tester, engine: 'cursor');- expect(find.text('qwen/qwen3.6-35b-a3b'), findsOneWidget);- });++ testWidgets(++ 'an older daemon that names no engines offers everything, as before',++ (tester) async {++ build(models: served);++ await open(tester, engine: 'cursor');++ expect(find.text('qwen/qwen3.6-35b-a3b'), findsOneWidget);++ },++ );});}