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.

test(desktop): the New Harness coverage gate is back to 100% (#1840)

0xken15c934c64c93ac
diff --git a/desktop/test/finder/finder_new_harness_test.dart b/desktop/test/finder/finder_new_harness_test.dart
index fee6e7cd0..0af45184a 100644
--- a/desktop/test/finder/finder_new_harness_test.dart
+++ b/desktop/test/finder/finder_new_harness_test.dart
@@ -3,6 +3,7 @@ import 'package:harness/finder/finder_availability.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/state/new_harness.dart';
import 'package:harness/state/pane_arrangement.dart';
+import 'package:harness/state/terminal_pane.dart';
import 'package:harness/ws/ws_conn.dart';
import '../swarm_state_test.dart' show createApp;
@@ -153,6 +154,21 @@ void main() {
expect(picker.isFinder, isFalse);
});
+ test('picking Finder after a shell gives it an agent as its chat', () {
+ final picker = NewHarnessController(
+ app,
+ machineId: 'm',
+ engine: 'terminal',
+ folder: '/work/repo',
+ );
+ addTearDown(picker.dispose);
+ expect(picker.engine, 'terminal');
+ picker.focusField(NewHarnessField.harness);
+ picker.applyOption(picker.options.firstWhere((o) => o.id == 'finder'));
+ expect(picker.isFinder, isTrue);
+ expect(picker.engine, 'opencode', reason: 'nothing remembered, no account');
+ });
+
test('a shell cannot be a Finder\'s chat', () {
expect(box(engine: 'terminal').engine, isNot('terminal'));
});
@@ -182,6 +198,23 @@ void main() {
expect(tab.panes.where((p) => p.isFinder), isEmpty);
});
+ test('a full tab starts the chat and says the Finder did not open', () async {
+ final tab = app.activeSwarm;
+ for (var i = 1; i < AppNotifier.maxPanes; i++) {
+ tab.panes.add(TerminalPane(id: 100 + i, machineId: 'm', agentId: 'b$i'));
+ }
+ final finder = box();
+ expect(await finder.create(), NewHarnessOutcome.failed);
+ expect(
+ finder.error,
+ 'Chat started. This tab is full, so the Finder could not open beside '
+ 'the chat.',
+ );
+ expect(connection.creates, hasLength(1));
+ expect(tab.panes.last.agentId, 'chat');
+ expect(tab.panes.where((p) => p.isFinder), isEmpty);
+ });
+
test('Finder needs a folder', () async {
final finder = box(folder: null);
await pumpEventQueue();
diff --git a/desktop/test/swarm_launch_recovery_test.dart b/desktop/test/swarm_launch_recovery_test.dart
index dbfcc25c7..fb057acf6 100644
--- a/desktop/test/swarm_launch_recovery_test.dart
+++ b/desktop/test/swarm_launch_recovery_test.dart
@@ -208,6 +208,63 @@ void main() {
},
);
+ testWidgets('Discard asks before dropping a request on an unreachable '
+ 'machine, and Keep request keeps it', (tester) async {
+ late SuperTabLaunchFixture f;
+ late NewHarnessController box;
+ await tester.runAsync(() async {
+ f = await stuckProject();
+ box = await reopen(f);
+ });
+ f.connection.creationRecovery = (_, _) async =>
+ throw StateError('Connection lost');
+ var closed = 0;
+ await tester.binding.setSurfaceSize(const Size(1200, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Center(
+ child: SizedBox(
+ width: 850,
+ height: 500,
+ child: NewHarnessForm(
+ controller: box,
+ desktop: true,
+ onClose: () => closed++,
+ onCreated: () {},
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pump();
+ const question =
+ 'Could not reach Test host, so it may still start the Lead. '
+ 'Discard anyway?';
+
+ await tester.tap(find.text('Discard request'));
+ await tester.runAsync(pumpEventQueue);
+ await tester.pumpAndSettle();
+ expect(find.text(question), findsOneWidget);
+ await tester.tap(find.text('Keep request'));
+ await tester.pumpAndSettle();
+ expect(find.text(question), findsNothing);
+ expect(closed, 0);
+ expect(journal(f), isNotNull);
+
+ await tester.tap(find.text('Discard request'));
+ await tester.runAsync(pumpEventQueue);
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Discard anyway'));
+ await tester.runAsync(pumpEventQueue);
+ await tester.pumpAndSettle();
+ expect(closed, 1);
+ expect(journal(f), isNull);
+ await tester.pumpWidget(const SizedBox());
+ });
+
test('a deleted project offers Discard instead of a stuck request', () async {
final f = await stuckProject();
final projectId = journal(f)!['projectId'];