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 resume notices for ten seconds with an explicit close button (#722)

Dee5cc775e158ba
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 2c7b589a0..c523ed21d 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -37,6 +37,7 @@ import '../sharing/share_harness_dialog.dart';
import '../shared/theme/appearance_prefs_store.dart';
import '../shared/theme/status_line_style.dart';
import '../shared/theme/pull_request_icon.dart';
+import '../shared/widgets/app_icon_button.dart';
import '../shortcuts/app_shortcuts.dart';
import '../core/models.dart';
import '../shortcuts/app_keymap.dart';
@@ -3617,26 +3618,49 @@ class _SwarmScreenState extends State<SwarmScreen> {
?.agents
.where((agent) => agent.id == row.agentId)
.firstOrNull;
- ScaffoldMessenger.of(context).showSnackBar(
+ final messenger = ScaffoldMessenger.of(context);
+ // A conversation Harness did not start says what stopped it (open in
+ // a terminal, gone); a new, empty one is not what was asked for.
+ final action = row.external == null
+ ? SnackBarAction(
+ label: 'Start New Conversation',
+ onPressed: () => _openNewHarness(
+ machineId: row.machineId!,
+ engine: agent?.dsh ?? agent?.engine,
+ folder: agent?.project?.cwd,
+ swarmId: app.swarms.any((tab) => tab.id == target)
+ ? target
+ : app.activeSwarmId,
+ placement: placement,
+ task: '',
+ ),
+ )
+ : null;
+ messenger.showSnackBar(
SnackBar(
- content: Text(failure.message),
- // A conversation Harness did not start says what stopped it (open in
- // a terminal, gone); a new, empty one is not what was asked for.
- action: row.external != null
- ? null
- : SnackBarAction(
- label: 'Start New Conversation',
- onPressed: () => _openNewHarness(
- machineId: row.machineId!,
- engine: agent?.dsh ?? agent?.engine,
- folder: agent?.project?.cwd,
- swarmId: app.swarms.any((tab) => tab.id == target)
- ? target
- : app.activeSwarmId,
- placement: placement,
- task: '',
- ),
+ content: Row(
+ children: [
+ Expanded(
+ child: OverflowBar(
+ alignment: MainAxisAlignment.spaceBetween,
+ overflowAlignment: OverflowBarAlignment.end,
+ spacing: 16,
+ overflowSpacing: 8,
+ children: [Text(failure.message), ?action],
),
+ ),
+ const SizedBox(width: 8),
+ AppIconButton(
+ icon: AppIcons.close,
+ tooltip: 'Dismiss notice',
+ onPressed: () => messenger.hideCurrentSnackBar(
+ reason: SnackBarClosedReason.dismiss,
+ ),
+ ),
+ ],
+ ),
+ duration: const Duration(seconds: 10),
+ persist: false,
),
);
}
diff --git a/desktop/test/machines_menu_stopped_test.dart b/desktop/test/machines_menu_stopped_test.dart
index 7ce9aeff2..850c0af1a 100644
--- a/desktop/test/machines_menu_stopped_test.dart
+++ b/desktop/test/machines_menu_stopped_test.dart
@@ -166,6 +166,11 @@ void main() {
expect(app.panes.map((pane) => pane.agentId), isNot(contains('old')));
expect(find.text('The saved conversation is gone.'), findsOneWidget);
expect(find.text('Start New Conversation'), findsOneWidget);
+ await tester.tap(find.byTooltip('Dismiss notice'));
+ await tester.pumpAndSettle();
+ expect(find.byType(SnackBar), findsNothing);
+ expect(app.resumed, ['old']);
+ expect(app.panes.map((pane) => pane.agentId), isNot(contains('old')));
await finish(tester);
});
}
diff --git a/desktop/test/stopped_harness_test.dart b/desktop/test/stopped_harness_test.dart
index 6ac1b3ea9..9ec4f43c9 100644
--- a/desktop/test/stopped_harness_test.dart
+++ b/desktop/test/stopped_harness_test.dart
@@ -445,39 +445,53 @@ void main() {
);
}
- testWidgets('Enter submits resume immediately with no confirmation dialog', (
- tester,
- ) async {
- await mount(tester, app);
- await chord(tester, LogicalKeyboardKey.keyT);
- await openHarnessPicker(tester);
- await tester.pump();
- await tester.enterText(
- find.byKey(const ValueKey('swarm-search-input')),
- 'Saved work',
- );
- await tester.pump();
- // The preview offers the same action for pointer users; Return submits
- // directly from search without first opening a confirmation dialog.
- expect(find.widgetWithText(TextButton, 'Open'), findsOneWidget);
- expect(find.byType(AlertDialog), findsNothing);
- expect(connection.types, isEmpty);
- await tester.sendKeyEvent(LogicalKeyboardKey.enter);
- await tester.pump();
- expect(connection.types, ['agent_resume']);
- expect(find.byType(AlertDialog), findsNothing);
- connection.restartReplies.single.complete({
- 'creationId': connection.requests.single['creationId'],
- 'state': 'failed',
- 'failure': {
- 'code': 'RESUME_UNAVAILABLE',
- 'detail': 'Conversation missing',
- },
- });
- await tester.pump();
- expect(find.text('Conversation missing'), findsOneWidget);
- expect(find.text('Start New Conversation'), findsOneWidget);
- expect(app.allPanes, isEmpty);
- await tester.pumpWidget(const SizedBox());
- });
+ testWidgets(
+ 'Enter submits resume immediately and its failure notice expires',
+ (tester) async {
+ await mount(tester, app);
+ await chord(tester, LogicalKeyboardKey.keyT);
+ await openHarnessPicker(tester);
+ await tester.pump();
+ await tester.enterText(
+ find.byKey(const ValueKey('swarm-search-input')),
+ 'Saved work',
+ );
+ await tester.pump();
+ // The preview offers the same action for pointer users; Return submits
+ // directly from search without first opening a confirmation dialog.
+ expect(find.widgetWithText(TextButton, 'Open'), findsOneWidget);
+ expect(find.byType(AlertDialog), findsNothing);
+ expect(connection.types, isEmpty);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(connection.types, ['agent_resume']);
+ expect(find.byType(AlertDialog), findsNothing);
+ connection.restartReplies.single.complete({
+ 'creationId': connection.requests.single['creationId'],
+ 'state': 'failed',
+ 'failure': {
+ 'code': 'RESUME_UNAVAILABLE',
+ 'detail': 'Conversation missing',
+ },
+ });
+ await tester.pump();
+ expect(find.text('Conversation missing'), findsOneWidget);
+ expect(find.text('Start New Conversation'), findsOneWidget);
+ expect(find.byTooltip('Dismiss notice'), findsOneWidget);
+ expect(app.allPanes, isEmpty);
+ // Let the notice finish appearing, then check both sides of its timeout.
+ await tester.pumpAndSettle();
+ await tester.pump(const Duration(seconds: 9));
+ expect(find.text('Conversation missing'), findsOneWidget);
+ expect(find.text('Start New Conversation'), findsOneWidget);
+ await tester.pump(const Duration(seconds: 1));
+ await tester.pumpAndSettle();
+ expect(find.text('Conversation missing'), findsNothing);
+ expect(find.text('Start New Conversation'), findsNothing);
+ expect(find.byTooltip('Dismiss notice'), findsNothing);
+ expect(connection.types, ['agent_resume']);
+ expect(app.allPanes, isEmpty);
+ await tester.pumpWidget(const SizedBox());
+ },
+ );
}