Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Keep disconnected preview state honest and verify its layout

dee76bdf6eb0607
diff --git a/desktop/lib/widgets/swarm_search_preview.dart b/desktop/lib/widgets/swarm_search_preview.dart
index d5347ae08..55f9a8b1d 100644
--- a/desktop/lib/widgets/swarm_search_preview.dart
+++ b/desktop/lib/widgets/swarm_search_preview.dart
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart' show ScrollCacheExtent;
import 'package:lucide_icons_flutter/lucide_icons.dart';
import '../core/models.dart';
@@ -127,7 +128,7 @@ class _SwarmSearchPreviewState extends State<SwarmSearchPreview> {
key: ValueKey('preview-content:${row.id}'),
controller: _scroll,
padding: EdgeInsets.all(widget.compactHeader ? 16 : 24),
- cacheExtent: 120,
+ scrollCacheExtent: const ScrollCacheExtent.pixels(120),
itemCount: agents.length + 1,
itemBuilder: (context, index) => index == 0
? Padding(
diff --git a/desktop/test/swarm_search_preview_test.dart b/desktop/test/swarm_search_preview_test.dart
index 82738da85..9b7c4fbd2 100644
--- a/desktop/test/swarm_search_preview_test.dart
+++ b/desktop/test/swarm_search_preview_test.dart
@@ -81,6 +81,38 @@ void main() {
rootBundle.load('packages/lucide_icons_flutter/assets/lucide.ttf'),
))
.load();
+ await (FontLoader('packages/lucide_icons_flutter/Lucide300')..addFont(
+ rootBundle.load(
+ 'packages/lucide_icons_flutter/assets/build_font/LucideVariable-w300.ttf',
+ ),
+ ))
+ .load();
+ });
+
+ testWidgets('offline previews retain text without claiming to work or wait', (
+ tester,
+ ) async {
+ final app = createApp();
+ await seedPreviews(app);
+ app.adoptSessionForTest(terminal('a69', []));
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyO);
+ final field = find.byKey(const ValueKey('swarm-search-input'));
+ await tester.enterText(field, 'Workspace sync');
+ await tester.pump();
+ expect(find.text('Needs your input'), findsOneWidget);
+ app.machineStates['m']!.connectionStatus = ConnectionStatus.disconnected;
+ app.notifyListeners();
+ await tester.pump();
+ expect(find.text('Offline'), findsOneWidget);
+ expect(find.text('Needs your input'), findsNothing);
+ expect(
+ find.textContaining('Keep shared workspaces in sync'),
+ findsOneWidget,
+ );
+ expect(find.textContaining('Saved text'), findsOneWidget);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
});
for (final inline in [false, true]) {
testWidgets(