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
Swarm local models: Manage models in the sidebar, models on each machine
bitcoinbuilder690c867ea110
diff --git a/desktop/lib/models/swarm_models_target.dart b/desktop/lib/models/swarm_models_target.dartindex 7a18a28ae..eb87d2128 100644--- a/desktop/lib/models/swarm_models_target.dart+++ b/desktop/lib/models/swarm_models_target.dart@@ -2,6 +2,10 @@ import 'package:flutter/foundation.dart';import '../state/app_state.dart';+/// Models shared with the person on someone else's grid, and offering them to a Swarm. Hidden for now (owner,+/// 2026-10-23); the code stays, and turning this on brings it back everywhere it was.+const swarmSharedWithYouShown = false;+/// The Models picker opened for a Swarm's Local models (docs/plans/2026-10-23-swarm-local-models.md): the same/// sections as ⌘I's Models, less Subscriptions, whose actions put a model on the Swarm's grid instead of starting a/// harness on it. A model of this computer's runs for the Swarm; a saved API is shared with it, on this computer's key;diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dartindex 1324303e6..72bddd8c8 100644--- a/desktop/lib/state/swarm_search.dart+++ b/desktop/lib/state/swarm_search.dart@@ -2244,6 +2244,10 @@ class SwarmSearchController extends ChangeNotifier {if (modelSection(row) == ModelSearchSection.subscriptions) {return false;}+ if (!swarmSharedWithYouShown &&+ modelSection(row) == ModelSearchSection.shared) {+ return false;+ }final entry = models?.entries[row.modelId];return entry?.local != null || entry?.gridModel?.grid != swarm.grid;}).toList();diff --git a/desktop/lib/super_tabs/local_models.dart b/desktop/lib/super_tabs/local_models.dartindex 10b7a3a59..adfdd4dea 100644--- a/desktop/lib/super_tabs/local_models.dart+++ b/desktop/lib/super_tabs/local_models.dart@@ -6,6 +6,7 @@ import '../models/model_search_catalog.dart';import '../models/swarm_models_target.dart';import '../shared/theme/app_icons.dart';import '../shared/widgets/app_dialog.dart';+import '../shared/widgets/app_icon_button.dart';import '../state/app_state.dart';import '../state/swarm_navigation.dart';import '../state/swarm_search.dart';@@ -95,10 +96,10 @@ class _SwarmModelsWindow extends StatelessWidget {),),const SizedBox(width: 4),- IconButton(+ AppIconButton(key: const ValueKey('super-local-models-close'),tooltip: 'Close',- icon: const Icon(Icons.close, size: 18),+ icon: AppIcons.close,onPressed: () => Navigator.pop(context),),],@@ -309,24 +310,19 @@ String _sentence(String text) {return RegExp(r'[.!?]$').hasMatch(t) ? t : '$t.';}-/// The Local models part of a machine's details: what it runs for the Swarm, and on the viewer's own machine, a way to-/// run or stop one.+/// The Local models part of a machine's details: what it runs for the Swarm. Running, sharing and offering are in the+/// sidebar's Local models.class SuperTabMachineLocalModels extends StatelessWidget {const SuperTabMachineLocalModels({super.key,required this.controller,required this.machineId,- required this.mine,- this.app,this.now = DateTime.now,});final SuperTabController controller;final String machineId;- /// The viewer's own machine, which their window can reach: only they start a model on it.- final bool mine;- final AppNotifier? app;final DateTime Function() now;@override@@ -336,34 +332,64 @@ class SuperTabMachineLocalModels extends StatelessWidget {final pool = controller.snapshot?.machines.where((m) => m['machineId'] == machineId).firstOrNull;- final served = superTabServedModels(pool, local.grid, now: now());+ // A fresh reading only, as the route reads it; then each model by what it is: an API this machine's person+ // shares, or a model of theirs running for the Swarm.+ final fresh = superTabServedModels(pool, local.grid, now: now());+ final apis = <String>[], models = <String>[];+ final observed = pool?['observation'];+ for (final m+ in observed is Map && observed['localModels'] is List+ ? observed['localModels'] as List+ : const []) {+ if (m is! Map || m['grid'] != local.grid || m['model'] is! String) {+ continue;+ }+ if (!fresh.any((f) => f.model == m['model'])) continue;+ final model = m['model'] as String;+ if (m['kind'] == 'api') {+ apis.add(+ model.contains('/')+ ? model.substring(model.lastIndexOf('/') + 1)+ : model,+ );+ } else {+ models.add(m['name'] is String ? m['name'] as String : model);+ }+ }+ Widget line(String label, List<String> names) => Padding(+ padding: const EdgeInsets.symmetric(vertical: 5),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ SizedBox(+ width: 104,+ child: Text(label, style: DesktopChrome.metadata()),+ ),+ const SizedBox(width: 16),+ Expanded(+ child: Text(+ names.isEmpty ? 'None' : names.join(', '),+ style: names.isEmpty+ ? DesktopChrome.control(color: DesktopChrome.muted)+ : DesktopChrome.control(),+ ),+ ),+ ],+ ),+ );return Padding(key: ValueKey('super-machine-local-models-$machineId'),padding: const EdgeInsets.only(top: 24),child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [- Text('Local models', style: DesktopChrome.control(medium: true)),- const SizedBox(height: 8),Text(- served.isEmpty- ? 'Not running a model for this Swarm.'- : 'Running ${served.map((m) => m.name).join(', ')} for this Swarm.',- style: DesktopChrome.control(),+ 'Models for this Swarm',+ style: DesktopChrome.control(medium: true),),- if (mine && app != null) ...[- const SizedBox(height: 8),- Align(- alignment: Alignment.centerLeft,- child: OutlinedButton(- key: const ValueKey('super-machine-local-models-run'),- onPressed: () => unawaited(- showSwarmLocalModels(context, controller, app: app, now: now),- ),- child: const Text('Run a local model…'),- ),- ),- ],+ const SizedBox(height: 8),+ line('API models', apis),+ line('Local models', models),],),);diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex 16e60a2d8..9052bcde7 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -27,6 +27,7 @@ import 'controller.dart';import 'dialog_scope.dart';import 'identity.dart';import 'local_models.dart';+import '../models/swarm_models_target.dart' show swarmSharedWithYouShown;import 'machine_details.dart';import 'machine_status.dart';import 'model.dart';@@ -1061,7 +1062,41 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {].join('\n'),),];+ // The models this machine offers the Swarm, from the same reading: an API's by its model, without the+ // provider's folder ("deepseek/…"), the API's name on hover.+ final apiModels = <_ServedModel>[], localModels = <_ServedModel>[];+ if (c.snapshot?.localModels case final local? when local.enabled) {+ for (final m+ in observation['localModels'] is List+ ? observation['localModels'] as List+ : const []) {+ if (m is! Map || m['model'] is! String) continue;+ final model = m['model'] as String;+ final named = m['name'] is String ? m['name'] as String : model;+ switch (m['kind']) {+ case 'api' when m['grid'] == local.grid:+ final via = named.contains(' · ')+ ? named.substring(named.lastIndexOf(' · ') + 3)+ : null;+ apiModels.add((+ name: model.contains('/')+ ? model.substring(model.lastIndexOf('/') + 1)+ : model,+ tip: [model, if (via != null) 'Shared from $via'].join('\n'),+ ));+ case 'shared' when swarmSharedWithYouShown:+ localModels.add((name: named, tip: '$named\nShared with you'));+ case 'local' || null when m['grid'] == local.grid:+ localModels.add((+ name: named,+ tip: '$named\nRunning on this machine',+ ));+ }+ }+ }return _MachineView(+ apiModels: apiModels,+ localModels: localModels,id: id,name: name,owner: person,@@ -1381,11 +1416,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {footer: SuperTabMachineLocalModels(controller: c,machineId: id,- // Only on a machine of the viewer's own that this window reaches does Run start anything.- mine:- (person?.id ?? contributor) == c.accountId &&- widget.app?.stateOf(id) != null,- app: widget.app,now: widget.now,),),@@ -1718,26 +1748,6 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {? () => unawaited(_contribute()): null,addTooltip: 'Add machine',- // The Local models add-on: the owner turns it on here; everyone else sees it once it is on.- actions: [- if (c.isOwner || c.snapshot?.localModels?.enabled == true)- AppIconButton(- key: const ValueKey('super-local-models'),- icon: AppIcons.cpu,- tooltip: 'Local models',- color: c.snapshot?.localModels?.enabled == true- ? DesktopChrome.accent- : DesktopChrome.muted,- onPressed: () => unawaited(- showSwarmLocalModels(- context,- c,- app: widget.app,- now: widget.now,- ),- ),- ),- ],// Only a Swarm that can't be read is news; a live one says nothing.trailing: c.backendUnreachable? SuperTabMachinesPill(@@ -1860,6 +1870,8 @@ class _MachineView {required this.engines,required this.allowances,required this.tip,+ this.apiModels = const [],+ this.localModels = const [],});final String id, name, details, tip;@@ -1881,8 +1893,15 @@ class _MachineView {/// What the row's chips show, Claude first; empty while offline or out of reach.final List<_Allowance> allowances;++ /// What this machine offers the Swarm on its grid, as its reading says: the APIs its person shares, and its own+ /// models running for the Swarm (docs/plans/2026-10-23-swarm-local-models.md). Empty while the add-on is off.+ final List<_ServedModel> apiModels, localModels;}+/// A model a machine offers its Swarm: its short name on the row, the whole of it on hover.+typedef _ServedModel = ({String name, String tip});+/// One engine's allowance on a machine: its mark and remaining share on the row, its windows on hover.class _Allowance {const _Allowance({@@ -2072,69 +2091,129 @@ class _MachineReadings extends StatelessWidget {if (diskFree != null)('SSD ${resourceBytes(diskFree)}', 'Storage available'),];- final style = DesktopChrome.metadata().copyWith(- fontFeatures: const [FontFeature.tabularFigures()],- );+ final label = DesktopChrome.metadata();+ final style = DesktopChrome.metadata(color: DesktopChrome.foreground)+ .copyWith(fontFeatures: const [FontFeature.tabularFigures()]);Widget readings(List<(String, String)> readings) => Wrap(spacing: 10,runSpacing: 2,children: [- for (final (label, meaning) in readings)+ for (final (text, meaning) in readings)Tooltip(message: meaning,- child: Text(label, style: style),+ child: Text(text, style: style),),],);- if (usage.isEmpty && capacity.isEmpty && view.allowances.isEmpty) {- return const SizedBox.shrink();- }- return Padding(- key: ValueKey('super-machine-readings-${view.id}'),- padding: const EdgeInsets.fromLTRB(36, 4, 32, 10),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- if (usage.isNotEmpty) readings(usage),- if (capacity.isNotEmpty) readings(capacity),- if (view.allowances.isNotEmpty)- Padding(- padding: const EdgeInsets.only(top: 4),- child: Wrap(- spacing: 12,- runSpacing: 4,- children: [- for (final allowance in view.allowances)- Tooltip(- message: allowance.detail,- child: Semantics(- label:- '${allowance.name} ${allowance.figure} remaining',- excludeSemantics: true,- child: Row(+ Widget models(List<_ServedModel> models, String kind) => Wrap(+ spacing: 10,+ runSpacing: 2,+ children: [+ for (final model in models)+ Tooltip(+ message: model.tip,+ child: Text(+ model.name,+ key: ValueKey('super-machine-$kind-${view.id}-${model.name}'),+ style: style,+ ),+ ),+ ],+ );+ final hardware = [...usage, ...capacity];+ // One labelled line each, the labels in a column as wide as the widest, so values line up at any text size.+ final lines = <(String, Widget)>[+ if (hardware.isNotEmpty) ('Hardware', readings(hardware)),+ if (view.allowances.isNotEmpty)+ (+ 'Subscriptions',+ Wrap(+ spacing: 12,+ runSpacing: 4,+ children: [+ for (final allowance in view.allowances)+ Tooltip(+ message: allowance.detail,+ child: Semantics(+ label: '${allowance.name} ${allowance.figure} remaining',+ excludeSemantics: true,+ child: Row(+ key: ValueKey(+ 'super-machine-allowance-${view.id}-${allowance.engine}',+ ),+ mainAxisSize: MainAxisSize.min,+ children: [+ EngineMark(engine: allowance.engine, size: 14),+ const SizedBox(width: 4),+ Text(+ allowance.figure,key: ValueKey(- 'super-machine-allowance-${view.id}-${allowance.engine}',+ 'super-machine-figure-${view.id}-${allowance.engine}',),- mainAxisSize: MainAxisSize.min,- children: [- EngineMark(engine: allowance.engine, size: 14),- const SizedBox(width: 4),- Text(- allowance.figure,- key: ValueKey(- 'super-machine-figure-${view.id}-${allowance.engine}',- ),- style: style.copyWith(color: allowance.ink),- ),- ],+ style: style.copyWith(color: allowance.ink),),- ),+ ],),+ ),+ ),+ ],+ ),+ ),+ if (view.apiModels.isNotEmpty)+ ('API models', models(view.apiModels, 'api')),+ if (view.localModels.isNotEmpty)+ ('Local models', models(view.localModels, 'local')),+ ];+ if (lines.isEmpty) return const SizedBox.shrink();+ return Padding(+ key: ValueKey('super-machine-readings-${view.id}'),+ padding: const EdgeInsets.fromLTRB(36, 6, 24, 12),+ child: LayoutBuilder(+ builder: (context, constraints) {+ // Side by side while there is room for a value beside its label; above it in a narrow sidebar or at+ // large text, where a column of labels would leave the values no width.+ final stacked =+ constraints.maxWidth < 240 ||+ MediaQuery.textScalerOf(context).scale(12) > 18;+ if (stacked) {+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ for (final (index, (name, value)) in lines.indexed) ...[+ if (index > 0) const SizedBox(height: 8),+ Text(name, style: label),+ const SizedBox(height: 2),+ value,],- ),- ),- ],+ ],+ );+ }+ return Table(+ columnWidths: const {+ 0: IntrinsicColumnWidth(),+ 1: FlexColumnWidth(),+ },+ children: [+ for (final (index, (name, value)) in lines.indexed)+ TableRow(+ children: [+ Padding(+ padding: EdgeInsets.only(+ right: 12,+ top: index == 0 ? 0 : 6,+ ),+ child: Text(name, style: label),+ ),+ Padding(+ padding: EdgeInsets.only(top: index == 0 ? 0 : 6),+ child: value,+ ),+ ],+ ),+ ],+ );+ },),);}diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dartindex d30e9ba59..45e462107 100644--- a/desktop/lib/super_tabs/model.dart+++ b/desktop/lib/super_tabs/model.dart@@ -311,6 +311,58 @@ class SuperTabLocalModels {final String? error;}+/// One model the Swarm can start Builders on now, as a machine's fresh reading says: on the Swarm's grid (`local`, a+/// member's engine; `api`, an API a member shares), usable from any machine; or shared with the machine's owner and+/// offered by them (`shared`), usable on that machine alone.+typedef SuperTabLocalModelRow = ({+ String grid,+ String model,+ String name,+ String machine,+ String kind,+});++/// Every model the Swarm can use now, once each, from the machines' fresh readings (backend `MACHINE_FRESH_MS`).+List<SuperTabLocalModelRow> superTabLocalModelRows(+ SuperTabSnapshot? snapshot, {+ required DateTime now,+ Duration freshFor = const Duration(seconds: 45),+}) {+ final local = snapshot?.localModels;+ if (local == null || !local.enabled) return const [];+ final rows = <SuperTabLocalModelRow>[];+ for (final pool in snapshot!.machines) {+ final observation = pool['observation'];+ if (observation is! Map) continue;+ final at = observation['receivedAt'];+ if (at is! num ||+ now.difference(DateTime.fromMillisecondsSinceEpoch(at.toInt())) >+ freshFor) {+ continue;+ }+ for (final m+ in observation['localModels'] is List+ ? observation['localModels'] as List+ : const []) {+ if (m is! Map || m['grid'] is! String || m['model'] is! String) continue;+ final grid = m['grid'] as String, model = m['model'] as String;+ if (rows.any((r) => r.grid == grid && r.model == model)) continue;+ rows.add((+ grid: grid,+ model: model,+ name: m['name'] is String ? m['name'] as String : model,+ machine: pool['name'] as String? ?? 'A machine',+ kind: m['kind'] is String+ ? m['kind'] as String+ : grid == local.grid+ ? 'local'+ : 'shared',+ ));+ }+ }+ return rows;+}+/// One model a machine serves on the Swarm's grid, as its last reading says.typedef SuperTabServedModel = ({String model, String name});diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dartindex 260f64d04..255bdf9db 100644--- a/desktop/lib/super_tabs/project_sidebar.dart+++ b/desktop/lib/super_tabs/project_sidebar.dart@@ -9,6 +9,7 @@ import '../state/app_state.dart';import '../terminal/terminal_theme_store.dart';import '../widgets/desktop_chrome.dart';import 'controller.dart';+import 'local_models.dart';import 'machines.dart';import 'model.dart';import 'section_heading.dart';@@ -365,6 +366,16 @@ class ProjectSidebar extends StatelessWidget {icon: AppIcons.plus,onTap: controller.canWrite ? onNewProject : null,),+ // The Local models add-on (docs/plans/2026-10-23-swarm-local-models.md): the owner turns it on here, and+ // everyone manages their models for the Swarm here once it is on. What each machine offers is on the machine.+ if (controller.isOwner || snapshot?.localModels?.enabled == true)+ _navigationRow(+ key: 'super-local-models',+ label: 'Manage models',+ icon: AppIcons.cpu,+ onTap: () =>+ showSwarmLocalModels(context, controller, app: app, now: now),+ ),if (onYourDevices != null)_navigationRow(key: 'super-your-devices',@@ -373,7 +384,10 @@ class ProjectSidebar extends StatelessWidget {onTap: onYourDevices,selected: devicesSelected,),- if (onNewProject != null || onYourDevices != null)+ if (onNewProject != null ||+ onYourDevices != null ||+ controller.isOwner ||+ snapshot?.localModels?.enabled == true)const SizedBox(height: 20),// Every person in the Swarm reads where the Product Managers talk.if (snapshot?.conversation(snapshot.leadsConversationId ?? '')diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex e509bb921..68bd40e06 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -29,6 +29,7 @@ import '../state/session_content_search.dart';import '../state/session_activity.dart';import '../state/swarm_search.dart';import '../models/model_search_catalog.dart';+import '../models/swarm_models_target.dart' show swarmSharedWithYouShown;import '../state/harness_sessions.dart'show SessionFilter, harnessActivityTooltip;import '../store/store_mark.dart';@@ -644,7 +645,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {// shared with you while Grid is not set up: the Set up row under Your models stands for it.// A Swarm's Local models have no Subscriptions: nothing in one can be given to a Swarm.if (search.swarmModels != null &&- section == ModelSearchSection.subscriptions) {+ (section == ModelSearchSection.subscriptions ||+ (!swarmSharedWithYouShown &&+ section == ModelSearchSection.shared))) {continue;}if (indices.isEmpty &&diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dartindex 53cb5d4b8..e75573f7b 100644--- a/desktop/test/super_tab_machines_test.dart+++ b/desktop/test/super_tab_machines_test.dart@@ -967,52 +967,10 @@ void main() {await tester.pumpAndSettle();}- final open = find.byKey(const ValueKey('super-local-models'));- final toggle = find.byKey(const ValueKey('super-local-models-switch'));-- testWidgets('the owner turns them on from Machines; it is off until then', (- tester,- ) async {- final server = ConversationServer();- server.state['machines'] = [machine()];- final c = server.controller();- await c.refresh();- await mount(tester, c);- await tester.tap(open);- await tester.pumpAndSettle();- expect(tester.widget<Switch>(toggle).value, isFalse);- expect(find.text('Off. Only you can turn it on.'), findsOneWidget);- await tester.tap(toggle);- await tester.pumpAndSettle();- expect(- server.posts- .map((p) => p['command'])- .where((cmd) => (cmd as Map)['type'] == 'localModels.set')- .single,- {'type': 'localModels.set', 'enabled': true},- );- await tester.tap(find.byKey(const ValueKey('super-local-models-close')));- await tester.pumpAndSettle();- await tester.pumpWidget(const SizedBox());- await c.flush();- c.dispose();- });-testWidgets(- 'others see them only once on, cannot switch them, and see what each machine runs',+ 'a machine\'s details say what it runs for the Swarm, and offer nothing to do there',(tester) async {final server = ConversationServer();- (server.state['people'] as List).add({- 'id': 'peer',- 'email': '[email protected]',- 'role': 'collaborator',- });- server.state['machines'] = [machine()];- final c = server.controller(account: 'peer');- await c.refresh();- await mount(tester, c);- expect(open, findsNothing);-server.state['localModels'] = {'grid': swarmGrid,'enabled': true,@@ -1023,23 +981,56 @@ void main() {served: [{'grid': swarmGrid, 'model': 'qwen3', 'name': 'Qwen 3'},{'grid': 'swarm-ffffffffffff', 'model': 'other'},+ {+ 'grid': swarmGrid,+ 'model': 'deepseek/deepseek-v4.1-flash',+ 'name': 'deepseek/deepseek-v4.1-flash · OpenRouter',+ 'kind': 'api',+ },+ {'grid': 'team', 'model': 'muse', 'kind': 'shared'},],),];- server.revision++;+ final c = server.controller();await c.refresh();+ await mount(tester, c);+ // Local models live in the sidebar now, not the Machines heading.+ expect(find.byKey(const ValueKey('super-local-models')), findsNothing);+ // Its expanded readings list what it offers, under labels; a model shared with its owner stays hidden.+ await tester.tap(+ find.byKey(const ValueKey('super-machine-toggle-studio')),+ );await tester.pumpAndSettle();- await tester.tap(open);- await tester.pumpAndSettle();- expect(tester.widget<Switch>(toggle).onChanged, isNull);- expect(find.text('Running now: Qwen 3 on Studio'), findsOneWidget);- await tester.tap(find.byKey(const ValueKey('super-local-models-close')));- await tester.pumpAndSettle();-- // The machine's details say what it runs; Run is for the machine's own person, in their window.+ expect(find.text('Local models'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('super-machine-local-studio-Qwen 3')),+ findsOneWidget,+ );+ expect(find.text('API models'), findsOneWidget);+ expect(+ find.byKey(+ const ValueKey('super-machine-api-studio-deepseek-v4.1-flash'),+ ),+ findsOneWidget,+ );+ expect(find.text('muse'), findsNothing);await tester.tap(find.byKey(const ValueKey('super-machine-studio')));await tester.pumpAndSettle();- expect(find.text('Running Qwen 3 for this Swarm.'), findsOneWidget);+ expect(find.text('Models for this Swarm'), findsOneWidget);+ expect(+ find.descendant(+ of: find.byKey(const ValueKey('super-machine-local-models-studio')),+ matching: find.text('Qwen 3'),+ ),+ findsOneWidget,+ );+ expect(+ find.descendant(+ of: find.byKey(const ValueKey('super-machine-local-models-studio')),+ matching: find.text('deepseek-v4.1-flash'),+ ),+ findsOneWidget,+ );expect(find.byKey(const ValueKey('super-machine-local-models-run')),findsNothing,diff --git a/desktop/test/super_tab_sidebar_test.dart b/desktop/test/super_tab_sidebar_test.dartindex 0b722ed12..1efaa32b4 100644--- a/desktop/test/super_tab_sidebar_test.dart+++ b/desktop/test/super_tab_sidebar_test.dart@@ -7,6 +7,7 @@ import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/state/app_state.dart';import 'package:harness/super_tabs/controller.dart';import 'package:harness/super_tabs/machine_status.dart';+import 'package:harness/super_tabs/model.dart';import 'package:harness/super_tabs/project_sidebar.dart';import 'package:harness/super_tabs/section_heading.dart';@@ -428,4 +429,183 @@ void main() {await reopened.flush();reopened.dispose();});++ group('Local models', () {+ const swarmGrid = 'swarm-0123456789ab';+ Map<String, dynamic> machine({+ List<Map<String, dynamic>> served = const [],+ int? receivedAt,+ }) => {+ 'machineId': 'studio',+ 'name': 'Studio.local',+ 'contributorId': 'owner',+ 'observation': {+ 'receivedAt': receivedAt ?? DateTime.now().millisecondsSinceEpoch,+ 'localModels': served,+ },+ };+ Future<void> mount(WidgetTester tester, SuperTabController c) async {+ await tester.binding.setSurfaceSize(const Size(900, 1000));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: ListenableBuilder(+ listenable: c,+ builder: (context, _) => ProjectSidebar(+ controller: c,+ onAddAgent: (_) {},+ needsHuman: (_) => 0,+ onSelect: c.select,+ ),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ }++ final open = find.byKey(const ValueKey('super-local-models'));+ final toggle = find.byKey(const ValueKey('super-local-models-switch'));++ testWidgets(+ 'the owner turns them on from the sidebar; it is off until then',+ (tester) async {+ final server = ConversationServer();+ server.state['machines'] = [machine()];+ final c = server.controller();+ await c.refresh();+ await mount(tester, c);+ expect(find.text('Manage models'), findsOneWidget);+ await tester.tap(open);+ await tester.pumpAndSettle();+ expect(tester.widget<Switch>(toggle).value, isFalse);+ expect(find.text('Off. Only you can turn it on.'), findsOneWidget);+ await tester.tap(toggle);+ await tester.pumpAndSettle();+ expect(+ server.posts+ .map((p) => p['command'])+ .where((cmd) => (cmd as Map)['type'] == 'localModels.set')+ .single,+ {'type': 'localModels.set', 'enabled': true},+ );+ await tester.tap(+ find.byKey(const ValueKey('super-local-models-close')),+ );+ await tester.pumpAndSettle();+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ },+ );++ testWidgets(+ 'others see Manage models once it is on, and cannot switch it',+ (tester) async {+ final server = ConversationServer();+ (server.state['people'] as List).add({+ 'id': 'peer',+ 'email': '[email protected]',+ 'role': 'collaborator',+ });+ server.state['machines'] = [machine()];+ final c = server.controller(account: 'peer');+ await c.refresh();+ await mount(tester, c);+ expect(open, findsNothing);++ server.state['localModels'] = {'grid': swarmGrid, 'enabled': true};+ server.state['machines'] = [+ machine(+ served: [+ {'grid': swarmGrid, 'model': 'qwen3', 'name': 'Qwen 3'},+ {+ 'grid': swarmGrid,+ 'model': 'deepseek/v4',+ 'name': 'deepseek/v4 · OpenRouter',+ 'kind': 'api',+ },+ {'grid': 'team', 'model': 'muse', 'kind': 'shared'},+ {'grid': swarmGrid, 'model': 'qwen3'},+ ],+ ),+ ];+ server.revision++;+ await c.refresh();+ await tester.pumpAndSettle();+ expect(open, findsOneWidget);+ // What each machine offers is on the machine now, not listed here.+ expect(find.text('Qwen 3'), findsNothing);++ // A model's row opens the same window, where the switch is the owner's alone.+ await tester.tap(open);+ await tester.pumpAndSettle();+ expect(tester.widget<Switch>(toggle).onChanged, isNull);+ await tester.tap(+ find.byKey(const ValueKey('super-local-models-close')),+ );+ await tester.pumpAndSettle();+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ },+ );++ test(+ 'lists only fresh readings, once each, and none while the add-on is off',+ () {+ final now = DateTime.fromMillisecondsSinceEpoch(1000000);+ SuperTabSnapshot snapshot({bool enabled = true, int at = 990000}) =>+ SuperTabSnapshot.fromJson({+ 'version': 1,+ 'id': 'tab',+ 'name': 'Swarm',+ 'ownerId': 'owner',+ 'people': <Object>[],+ 'agents': <Object>[],+ 'conversations': <Object>[],+ 'invitations': <Object>[],+ 'localModels': {'grid': swarmGrid, 'enabled': enabled},+ 'machines': [+ {'machineId': 'a', 'observation': 'junk'},+ {+ 'machineId': 'b',+ 'observation': {+ 'receivedAt': at,+ 'localModels': [+ {'grid': swarmGrid, 'model': 'm'},+ {'grid': 'team', 'model': 'n'},+ {'grid': swarmGrid, 'model': 7},+ 'junk',+ ],+ },+ },+ ],+ });+ expect(superTabLocalModelRows(snapshot(), now: now), [+ (+ grid: swarmGrid,+ model: 'm',+ name: 'm',+ machine: 'A machine',+ kind: 'local',+ ),+ (+ grid: 'team',+ model: 'n',+ name: 'n',+ machine: 'A machine',+ kind: 'shared',+ ),+ ]);+ expect(superTabLocalModelRows(snapshot(at: 900000), now: now), isEmpty);+ expect(+ superTabLocalModelRows(snapshot(enabled: false), now: now),+ isEmpty,+ );+ expect(superTabLocalModelRows(null, now: now), isEmpty);+ },+ );+ });}diff --git a/desktop/test/swarm_local_models_picker_test.dart b/desktop/test/swarm_local_models_picker_test.dartindex 89d42765d..20aa2535a 100644--- a/desktop/test/swarm_local_models_picker_test.dart+++ b/desktop/test/swarm_local_models_picker_test.dart@@ -148,45 +148,46 @@ void main() {SwarmDestination row(String modelId) =>search.rows.firstWhere((r) => r.modelId == 'model:local:$modelId');- test(- 'lists models shared with you, but not what the Swarm\'s own grid serves',- () async {- app.inventory = const GridModels(- gridName: 'home',- models: [],- grids: [- GridSection(- name: 'Team',- own: false,- models: [GridModel(id: 'Shared Qwen', node: 'team.lan')],- ),- GridSection(- name: _grid,- own: false,- models: [GridModel(id: 'deepseek/v4', node: 'This Mac')],- ),- ],- );- await app.modelManager.refresh(force: true);- final shared = search.rows- .where((r) => search.modelSection(r) == ModelSearchSection.shared)- .map((r) => r.title);- expect(shared, ['Shared Qwen · team.lan · Team']);- // Not offered until the person offers it, and then stopped the same way.- SwarmDestination qwen() =>- search.rows.firstWhere((r) => r.title.startsWith('Shared Qwen'));- expect(search.modelRowStatus(qwen()), isNull);- final offer = search.swarmModelAction(qwen())!;- expect(offer.label, 'Offer to Swarm');- expect(await offer.run!(), isNull);- expect(app.offered, {(sharedGrid: 'Team', model: 'Shared Qwen')});- expect(search.modelRowStatus(qwen()), 'Offered');- final stop = search.swarmModelAction(qwen())!;- expect(stop.label, 'Stop offering');- await stop.run!();- expect(app.offered, isEmpty);- },- );+ test('hides models shared with you for now, keeping their offer and what the Swarm\'s own grid serves apart', () async {+ app.inventory = const GridModels(+ gridName: 'home',+ models: [],+ grids: [+ GridSection(+ name: 'Team',+ own: false,+ models: [GridModel(id: 'Shared Qwen', node: 'team.lan')],+ ),+ GridSection(+ name: _grid,+ own: false,+ models: [GridModel(id: 'deepseek/v4', node: 'This Mac')],+ ),+ ],+ );+ await app.modelManager.refresh(force: true);+ // Hidden for now (swarmSharedWithYouShown): no Shared with you in the Swarm's window.+ expect(swarmSharedWithYouShown, isFalse);+ expect(+ search.rows.where(+ (r) => search.modelSection(r) == ModelSearchSection.shared,+ ),+ isEmpty,+ );+ // Its actions stay, for when it is shown again: not offered until the person offers it, then stopped the same way.+ SwarmDestination qwen() =>+ catalog.rows.firstWhere((r) => r.title.startsWith('Shared Qwen'));+ expect(search.modelRowStatus(qwen()), isNull);+ final offer = search.swarmModelAction(qwen())!;+ expect(offer.label, 'Offer to Swarm');+ expect(await offer.run!(), isNull);+ expect(app.offered, {(sharedGrid: 'Team', model: 'Shared Qwen')});+ expect(search.modelRowStatus(qwen()), 'Offered');+ final stop = search.swarmModelAction(qwen())!;+ expect(stop.label, 'Stop offering');+ await stop.run!();+ expect(app.offered, isEmpty);+ });test('lists no subscriptions: nothing in one can be given to a Swarm', () {expect(