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
perf(desktop): reduce Cmd+O picker first-frame work (#226)
Dee04f26d8c52ec
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dartindex e9888487a..892693bc3 100644--- a/desktop/lib/widgets/swarm_switcher.dart+++ b/desktop/lib/widgets/swarm_switcher.dart@@ -1,6 +1,7 @@import 'swarm_search_field.dart';import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart' show ScrollCacheExtent;import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:flutter/services.dart';@@ -797,6 +798,14 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {horizontal: 8,),controller: _scroll,+ // The dock only shows a few rows. Building the+ // default 250 px beyond each edge can do more+ // work than the visible results on Cmd+O. Keep+ // one extra row for Tab focus traversal; arrows+ // and paging reveal targets by their fixed size.+ scrollCacheExtent: ScrollCacheExtent.pixels(+ _rowHeight,+ ),reverse: search.resultsFromBottom,itemCount:search.rows.length - (pinCreate ? 1 : 0),diff --git a/desktop/test/open_picker_rendering_test.dart b/desktop/test/open_picker_rendering_test.dartnew file mode 100644index 000000000..81d25f6ce--- /dev/null+++ b/desktop/test/open_picker_rendering_test.dart@@ -0,0 +1,46 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/widgets/swarm_switcher.dart';++import 'keymap_host_test.dart' show MemoryKeymap, key;+import 'keymap_runtime_test.dart' show mount;+import 'swarm_screen_test.dart' show terminal;+import 'swarm_state_test.dart' show createApp;++void main() {+ testWidgets('Open Harness builds a small window and Tab reaches later rows', (+ tester,+ ) async {+ final app = createApp();+ app.machineStates['m']!.nodeOnline = true;+ app.adoptSessionForTest(terminal('a0', []));+ final map = MemoryKeymap();+ await mount(tester, app, map);+ await key(tester, LogicalKeyboardKey.keyO, cmd: true);+ final results = find.byType(SwarmSearchResults);+ final search = tester.widget<SwarmSearchResults>(results).search;+ final rows = find.descendant(of: results, matching: find.byType(ListTile));+ expect(search.rows.length, greaterThan(50));+ expect(rows.evaluate().length, lessThan(12));+ final visited = <String>{};+ for (var step = 0; step < 35; step++) {+ await key(tester, LogicalKeyboardKey.tab);+ await tester.pumpAndSettle();+ final row = FocusManager.instance.primaryFocus?.context+ ?.findAncestorWidgetOfExactType<ListTile>();+ if (row != null) {+ final id = (row.key! as ValueKey<String>).value;+ visited.add(id);+ expect(search.selected?.id, id);+ expect(find.byKey(row.key!).hitTestable(), findsOneWidget);+ }+ }+ // Focus crosses the initial viewport repeatedly as new rows are built.+ expect(visited.length, greaterThan(15));+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox());+ app.dispose();+ map.dispose();+ });+}