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
fix(desktop): the Models list stays where it is scrolled; a shared model's machine on its own line
bitcoinbuilder7c66766e1626
diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dartindex b59d12b91..1e839a7eb 100644--- a/desktop/lib/models/model_search_catalog.dart+++ b/desktop/lib/models/model_search_catalog.dart@@ -11,6 +11,9 @@ import 'api_connections_controller.dart';import 'local_model.dart';import 'model_manager_controller.dart';+/// Between a shared model's name and the machine serving it, in its row's title.+const modelMachineSeparator = ' · ';+enum ModelSearchSection {subscriptions('Subscriptions'),apis('APIs'),@@ -103,7 +106,9 @@ class ModelSearchEntry {id: id,modelId: id,// An API's model is listed under its API's row, so it is named alone.- title: sharedBy?.isNotEmpty == true ? '$name · $sharedBy' : name,+ title: sharedBy?.isNotEmpty == true+ ? '$name$modelMachineSeparator$sharedBy'+ : name,detail: [source, node, status].whereType<String>().join(' · '),swarmId: null,current: false,diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dartindex 4171d17ac..7cc5a0264 100644--- a/desktop/lib/state/swarm_search.dart+++ b/desktop/lib/state/swarm_search.dart@@ -331,6 +331,18 @@ class SwarmSearchController extends ChangeNotifier {return row.title;}+ /// The end of the model's name in a row titled `gemma-4-31B-it · video-editor-tom` — a shared+ /// model with the machine serving it, which is drawn on a second line under the name. Null for a+ /// row that names no machine.+ int? modelRowNameEnd(SwarmDestination row) {+ final entry = models?.entries[row.modelId];+ final machine = entry?.sharedBy;+ if (entry == null || machine == null || machine.isEmpty) return null;+ return row.title == '${entry.name}$modelMachineSeparator$machine'+ ? entry.name.length+ : null;+ }+/// Whether the harness this picker chooses for is on [row]'s model now: the grid model the/// daemon read off its process, or a saved API's model at that API's address.bool modelRowInUse(SwarmDestination row) {diff --git a/desktop/lib/widgets/search_result_text.dart b/desktop/lib/widgets/search_result_text.dartindex 159dfca8c..de4443613 100644--- a/desktop/lib/widgets/search_result_text.dart+++ b/desktop/lib/widgets/search_result_text.dart@@ -135,23 +135,52 @@ class SearchResultText extends StatelessWidget {required this.style,this.inlineIcon,this.iconOffset = 0,+ this.from = 0,+ this.to,});final String text;final Iterable<SearchFieldMatch> matches;final TextStyle style;+ /// Draw only `text[from, to)`, emphasised as the matches emphasise the whole [text]: one label+ /// shown in parts, such as a shared model's name over the machine that serves it, keeps the+ /// emphasis of a match that spans both. [iconOffset] counts from [from].+ final int from;+ final int? to;+/// Insert a decorative mark without changing searchable text or match offsets.final Widget? inlineIcon;final int iconOffset;@overrideWidget build(BuildContext context) {- final runs = searchTextRuns(text, matches);+ final end = (to ?? text.length).clamp(0, text.length);+ final start = from.clamp(0, end);+ final shown = text.substring(start, end);+ var runs = searchTextRuns(text, matches);+ if (start > 0 || end < text.length) {+ final clipped = <SearchTextRun>[];+ var at = 0;+ for (final run in runs) {+ final after = at + run.text.length;+ if (after > start && at < end) {+ clipped.add((+ text: text.substring(+ at < start ? start : at,+ after > end ? end : after,+ ),+ matched: run.matched,+ ));+ }+ at = after;+ }+ runs = clipped;+ }final insertIcon =- inlineIcon != null && iconOffset >= 0 && iconOffset < text.length;+ inlineIcon != null && iconOffset >= 0 && iconOffset < shown.length;if (!insertIcon && !runs.any((run) => run.matched)) {return Text(- text,+ shown,maxLines: 1,overflow: TextOverflow.ellipsis,style: style,@@ -191,7 +220,7 @@ class SearchResultText extends StatelessWidget {}return Text.rich(TextSpan(children: spans),- semanticsLabel: insertIcon ? text : null,+ semanticsLabel: insertIcon ? shown : null,maxLines: 1,overflow: TextOverflow.ellipsis,style: style,diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex 4e47f7ae9..bb76e6d86 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -547,8 +547,12 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {final _resultsKey = GlobalKey();double _rowHeight = 56;double _modelHeadingHeight = 28;+ double _twoLineRowHeight = 56;bool _desktopRows = false;bool _revealScheduled = false;++ /// The selection and query the list last brought into view.+ (String?, String)? _revealed;bool _createPinned = false;int _lastPage = 0;(Size, double)? _geometry;@@ -589,12 +593,15 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {return items;}- double _modelItemHeight(({int? index, String? heading, String? key}) item) =>- !_desktopRows || item.index != null- ? _rowHeight- : item.heading == null- ? 8- : _modelHeadingHeight;+ double _modelItemHeight(({int? index, String? heading, String? key}) item) {+ if (!_desktopRows) return _rowHeight;+ final index = item.index;+ if (index == null) return item.heading == null ? 8 : _modelHeadingHeight;+ // A shared model's row is two lines: its name, and the machine serving it under it.+ return search.modelRowNameEnd(search.rows[index]) != null+ ? _twoLineRowHeight+ : _rowHeight;+ }double _fittedHeight(BoxConstraints constraints, {@@ -638,6 +645,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {}});search.addListener(_changed);+ _revealed = (search.selected?.id, search.query);terminalFontStore.addListener(_fontChanged);_lastPage = search.resultPage.value;search.resultPage.addListener(_pageResults);@@ -658,6 +666,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {_lastPage = search.resultPage.value;_announced = null;_rowWidgets.clear();+ _revealed = (search.selected?.id, search.query);_revealSelection();}}@@ -686,8 +695,15 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {void _changed() {_watchActivity();setState(() {});- _scrollToSelection();- _revealSelection();+ // Only a new selection or query brings the selection into view. A refresh that leaves both+ // as they were keeps the list where it was scrolled: the picker re-reads its models every few+ // seconds, and each read pulled a list scrolled by the wheel back up to the selection.+ final shown = (search.selected?.id, search.query);+ if (shown != _revealed) {+ _revealed = shown;+ _scrollToSelection();+ _revealSelection();+ }// Focus stays in the input while the arrows move a highlight the screen// reader never visits; say the row it landed on.final row = search.selected;@@ -747,7 +763,9 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {.take(index).fold(0.0, (height, item) => height + _modelItemHeight(item)): index * _rowHeight;- final bottom = top + _rowHeight;+ final bottom =+ top ++ (search.isModelMode ? _modelItemHeight(modelRows[index]) : _rowHeight);final position = _scroll.position;final offset = top < position.pixels? top@@ -849,11 +867,12 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {// is still a resource row, and keeps the 44-point target every one of those has — the// slot is 4 points taller than the row it holds.final oneLine = scale.scale(14) * 1.5 + 16;+ _twoLineRowHeight = scale.scale(14) * 2.8 + 16;_rowHeight = search.isCommandMode? oneLine: search.isModelMode? oneLine.clamp(48, double.infinity)- : scale.scale(14) * 2.8 + 16;+ : _twoLineRowHeight;}_desktopRows = desktop;_modelHeadingHeight = scale.scale(12) * 1.45 + 12;@@ -1761,6 +1780,11 @@ class _SearchRowContentState extends State<_SearchRowContent> {final subscription = row.isModel? widget.search.models?.entries[row.modelId]?.subscription: null;+ // A shared model's machine goes on a second line under its name, where it cannot be read as+ // part of the name: "DeepSeek-V4-Flash · zeus" on one line read as one long model name.+ final nameEnd = row.isModel && title == row.title+ ? widget.search.modelRowNameEnd(row)+ : null;final account = '${subscription?['account'] ?? ''}'.trim();final subscriptionAccount = subscription != null && account.isNotEmpty? (@@ -1842,6 +1866,7 @@ class _SearchRowContentState extends State<_SearchRowContent> {): SearchResultText(title,+ to: nameEnd,matches: matches.where((match) => match.title),style: DesktopChrome.text(color: unavailable == null ? ink : muted,@@ -1884,6 +1909,16 @@ class _SearchRowContentState extends State<_SearchRowContent> {],],),+ if (nameEnd != null) ...[+ const SizedBox(height: 2),+ SearchResultText(+ title,+ key: ValueKey('model-row-machine:${row.id}'),+ from: nameEnd + modelMachineSeparator.length,+ matches: matches.where((match) => match.title),+ style: DesktopChrome.metadata(color: muted),+ ),+ ],if (!widget.search.isModelMode &&!row.isCommand &&!underApi &&diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dartindex 4df587801..abf90d9b8 100644--- a/desktop/test/resource_picker_test.dart+++ b/desktop/test/resource_picker_test.dart@@ -1167,6 +1167,99 @@ void main() {},);+ testWidgets('a refresh keeps the models list where it was scrolled', (+ tester,+ ) async {+ GridModels inventory(int shared) => GridModels(+ gridName: 'home',+ models: const [],+ grids: [+ const GridSection(+ name: 'home',+ own: true,+ models: [GridModel(id: 'qwen3.8-27b', node: 'mac.lan')],+ ),+ GridSection(+ name: 'Team',+ own: false,+ models: [+ for (var i = 0; i < shared; i++)+ GridModel(id: 'shared-$i', node: 'box-$i.lan'),+ ],+ ),+ ],+ );+ final app = _ModelSelectionApp()..inventory = inventory(12);+ await fixture(provided: app);+ final map = MemoryKeymap();+ try {+ await configured.mount(tester, app, map);+ await key(tester, LogicalKeyboardKey.keyI, cmd: true);+ final selected = search(tester).selected!.id;+ final list = tester+ .state<ScrollableState>(+ find+ .ancestor(+ of: find.text('Your models', findRichText: true),+ matching: find.byType(Scrollable),+ )+ .first,+ )+ .position;+ // Scrolled by the wheel: the list moves, the selection stays above it.+ list.jumpTo(list.maxScrollExtent);+ await tester.pumpAndSettle();+ final scrolled = list.pixels;+ expect(scrolled, greaterThan(0));+ // A shared model's machine is on a second line, under its name and quieter than it.+ final machine = tester+ .widgetList<SearchResultText>(find.byType(SearchResultText))+ .firstWhere(+ (widget) => '${widget.key}'.contains('model-row-machine:'),+ );+ final sharedRow = search(tester).rows.singleWhere(+ (row) => '${machine.key}'.contains('model-row-machine:${row.id}'),+ );+ final name = sharedRow.title.substring(0, sharedRow.title.indexOf(' · '));+ expect(+ machine.text.substring(machine.from),+ sharedRow.title.split(' · ').last,+ );+ final nameLine = tester.widget<SearchResultText>(+ find.byWidgetPredicate(+ (widget) =>+ widget is SearchResultText &&+ widget.text == sharedRow.title &&+ widget.to == name.length,+ ),+ );+ expect(machine.style.color, isNot(nameLine.style.color));+ expect(+ tester.getTopLeft(find.byWidget(machine)).dy,+ greaterThan(tester.getBottomLeft(find.byWidget(nameLine)).dy - 1),+ );+ expect(find.text(name, findRichText: true), findsOneWidget);++ app.inventory = inventory(13);+ await app.modelManager.refresh(force: true);+ await tester.pumpAndSettle();+ expect(+ search(tester).rows.map((row) => row.title),+ contains(startsWith('shared-12')),+ );+ expect(search(tester).selected!.id, selected);+ expect(list.pixels, scrolled);++ // A new selection is still brought into view.+ await key(tester, LogicalKeyboardKey.arrowDown);+ expect(list.pixels, lessThan(scrolled));+ } finally {+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ map.dispose();+ }+ });+testWidgets('platform picker and command shortcuts',(tester) async {diff --git a/desktop/test/search_result_text_test.dart b/desktop/test/search_result_text_test.dartindex c67a94ebe..0e90e4c3d 100644--- a/desktop/test/search_result_text_test.dart+++ b/desktop/test/search_result_text_test.dart@@ -142,4 +142,46 @@ void main() {semantics.dispose();},);++ testWidgets(+ 'a label drawn in parts keeps the emphasis of a match across them',+ (tester) async {+ Future<List<(String, bool)>> runsOf(+ int from,+ int? to,+ Iterable<SearchFieldMatch> matches,+ ) async {+ await tester.pumpWidget(+ MaterialApp(+ home: Scaffold(+ body: SearchResultText(+ 'nimble · zeus',+ from: from,+ to: to,+ matches: matches,+ style: const TextStyle(fontSize: 13),+ ),+ ),+ ),+ );+ final rich = tester.widget<RichText>(find.byType(RichText).last).text;+ final spans = (rich as TextSpan).children;+ if (spans == null) return [(rich.toPlainText(), false)];+ // Text.rich wraps the widget's span in its own.+ final own = spans.single as TextSpan;+ return [+ for (final span in own.children!.cast<TextSpan>())+ (span.text!, span.style?.fontWeight == FontWeight.w700),+ ];+ }++ const across = [+ (field: 'nimble · zeus', term: 'le · ze', title: true, strict: false),+ ];+ expect(await runsOf(0, 6, const []), [('nimble', false)]);+ expect(await runsOf(0, 6, across), [('nimb', false), ('le', true)]);+ expect(await runsOf(9, null, across), [('ze', true), ('us', false)]);+ expect(tester.takeException(), isNull);+ },+ );}