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
feat(mobile): delete a harness and its saved conversation, reviewed first as desktop does
tonyb33b6e496c9f
diff --git a/mobile/lib/e2ee/envelope.dart b/mobile/lib/e2ee/envelope.dartindex a11ba153d..d072de08b 100644--- a/mobile/lib/e2ee/envelope.dart+++ b/mobile/lib/e2ee/envelope.dart@@ -39,6 +39,9 @@ const Set<String> encryptedDownTypes = {// refuses them unsealed (E2EE_REQUIRED) — without them the switch could never start.'agent_handoff_prepare','agent_close',+ // Delete Harness (`AppNotifier.purgeAgent`): reviewed, then deleted under that review. A+ // `MACHINE_REQUESTS` type in the CLI, refused unsealed (E2EE_REQUIRED).+ 'agent_purge','agent_recent','agent_update','agent_files',diff --git a/mobile/lib/phone/agents_page.dart b/mobile/lib/phone/agents_page.dartindex 3b12ff8f6..56d13be77 100644--- a/mobile/lib/phone/agents_page.dart+++ b/mobile/lib/phone/agents_page.dart@@ -260,6 +260,16 @@ Future<void> showAgentActions(confirmDeleteAgent(context, notifier, machineId, agent.id, agent.name),),),+ // The conversation too, for good — not for a terminal, which keeps none.+ if (agent.engine != 'terminal')+ PhoneSheetAction(+ icon: LucideIcons.trash300,+ label: 'Delete Harness…',+ destructive: true,+ onTap: () => unawaited(+ confirmPurgeAgent(context, notifier, machineId, agent.id, agent.name),+ ),+ ),],);diff --git a/mobile/lib/phone/delete_agent.dart b/mobile/lib/phone/delete_agent.dartindex 17ddbaf82..61f3369c1 100644--- a/mobile/lib/phone/delete_agent.dart+++ b/mobile/lib/phone/delete_agent.dart@@ -60,3 +60,39 @@ Future<void> confirmDeleteAgent(ScaffoldMessenger.maybeOf(context)?.showSnackBar(SnackBar(content: Text(error)));}++/// Delete Harness: a harness and its saved conversation, gone for good ([AppNotifier.purgeAgent]) —+/// the desktop's `confirmDeleteHarness`, in its words. Stop keeps the conversation to reopen; this+/// is how a harness leaves for good. Opened from the same places as Stop, beside it.+///+/// Like Stop, nothing here takes anything off the screen: [AppNotifier.purgeAgent] drops the agent+/// and detaches its pane, and the page showing it leaves on its own.+Future<void> confirmPurgeAgent(+ BuildContext context,+ AppNotifier notifier,+ String machineId,+ String agentId,+ String agentName,+) async {+ final machine = notifier.stateOf(machineId);+ final agent = machine?.agents.where((a) => a.id == agentId).firstOrNull;+ final confirmed = await confirmPhoneAction(+ context,+ icon: LucideIcons.trash300,+ title: 'Delete $agentName?',+ detail: [+ ?machine?.machine.displayName,+ ?agent?.project?.label,+ ].where((part) => part.isNotEmpty).join(' · '),+ message:+ 'Delete this harness and its saved conversation? It stops if running, '+ 'and it cannot be opened again. Project files are kept. To keep the '+ 'conversation to reopen later, use Stop Harness instead.',+ confirmLabel: 'Delete',+ );+ if (!confirmed || !context.mounted) return;+ final messenger = ScaffoldMessenger.maybeOf(context);+ final error = await notifier.purgeAgent(machineId, agentId);+ if (error == null) return;+ messenger?.showSnackBar(SnackBar(content: Text(error)));+}diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex e5c462651..36a8c9f97 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -2774,7 +2774,14 @@ class _TerminalPageState extends State<TerminalPage>),],),- PhoneSheetSection(actions: [_stopAction(agent)]),+ PhoneSheetSection(+ actions: [+ _stopAction(agent),+ // Stop's harder sibling, under it: the conversation goes too. Not for a terminal,+ // which keeps none.+ if (agent.engine != 'terminal') _purgeAction(agent),+ ],+ ),],);unawaited(@@ -3121,6 +3128,32 @@ class _TerminalPageState extends State<TerminalPage>),);+ /// Delete Harness — see [confirmPurgeAgent]. Small at the foot beside Stop, and saying so while a+ /// delete is out, as Restart does: the review and the delete can take a while. In its label, in+ /// the desktop's word for it — a quiet row draws no value.+ PhoneSheetAction _purgeAction(Agent agent) {+ final deleting = widget.notifier.agentPurging(+ widget.machineId,+ widget.agentId,+ );+ return PhoneSheetAction(+ icon: LucideIcons.trash300,+ label: deleting ? 'Deleting…' : 'Delete this harness…',+ enabled: !deleting,+ destructive: true,+ quiet: true,+ onTap: () => unawaited(+ confirmPurgeAgent(+ context,+ widget.notifier,+ widget.machineId,+ widget.agentId,+ agent.name,+ ),+ ),+ );+ }+/// Asks for the terminal this pane is only watching, or reopens the stream it lost — a tap or a/// scroll on a terminal held elsewhere.///diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 6bf25cd85..6b3923b5b 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -7065,6 +7065,108 @@ class AppNotifier extends ChangeNotifier {return null;}+ /// Deletes on their way, by machine and agent — what a second press joins rather than reviewing+ /// the same harness twice.+ final Map<(String, String), Future<String?>> _agentPurges = {};++ /// Whether a Delete of this agent is on its way: the menu's row says so, as Restart does.+ bool agentPurging(String machineId, String agentId) =>+ _agentPurges.containsKey((machineId, agentId));++ /// Delete Harness — the desktop's `purgeAgent`. Unlike Stop ([deleteAgent]), which keeps the+ /// conversation to reopen, this stops a running harness and deletes its saved conversation for+ /// good, so it can never be opened again. Project files and worktrees are kept.+ ///+ /// The machine's reviewed deletion (`agent_purge`): `inspect` first, then `delete` under that+ /// review's id, both naming the harness exactly — id, conversation and when it was registered —+ /// so a delete meant for one that has since been replaced under the same id is refused rather+ /// than taking the replacement. Null on success, or the sentence to show.+ ///+ /// ⚠️ **A lost reply is not a failed delete.** The second step may have run; the answer says to+ /// check rather than inviting another press that would only find nothing to delete.+ Future<String?> purgeAgent(String machineId, String agentId) {+ final key = (machineId, agentId);+ if (_agentPurges[key] case final pending?) return pending;+ final request = _purgeAgent(machineId, agentId).whenComplete(() {+ _agentPurges.remove(key);+ if (!_disposed) notifyListeners();+ });+ _agentPurges[key] = request;+ notifyListeners();+ return request;+ }++ Future<String?> _purgeAgent(String machineId, String agentId) async {+ final machine = machineStates[machineId];+ final agent = machine?.agents+ .where((agent) => agent.id == agentId)+ .firstOrNull;+ final createdAt = agent?.createdAt;+ if (machine == null || agent == null || createdAt == null) {+ return 'This harness is no longer listed. Refresh and try again.';+ }+ // The desktop's rule: a terminal keeps no conversation, so there is nothing to delete past+ // what Stop already does.+ if (agent.engine == 'terminal') {+ return 'A terminal keeps no conversation. Stop it instead.';+ }+ final revision = _authRevision;+ final sessionId = agent.sessionId;+ final target = {+ 'agentId': agentId,+ 'sessionId': sessionId == null || sessionId.isEmpty ? null : sessionId,+ 'createdAt': createdAt.millisecondsSinceEpoch,+ };+ String refused(Object? code, Object? detail) =>+ 'Delete failed: ${detail is String && detail.isNotEmpty ? detail : code}';+ const unconfirmed =+ 'Could not confirm the deletion. Refresh harnesses to check.';+ var deleting = false;+ try {+ final review = await _conn(machineId).request(+ 'agent_purge',+ payload: {...target, 'mode': 'inspect'},+ timeout: const Duration(seconds: 30),+ );+ if (review['error'] != null) {+ return refused(review['error'], review['detail']);+ }+ final reviewId = review['reviewId'];+ if (reviewId is! String) {+ return 'Could not review this harness for deletion.';+ }+ if (!_machineWorkCurrent(machine, revision)) {+ return 'The machine changed before the delete. Try again.';+ }+ deleting = true;+ final result = await _conn(machineId).request(+ 'agent_purge',+ payload: {...target, 'mode': 'delete', 'reviewId': reviewId},+ timeout: const Duration(seconds: 60),+ );+ if (result['error'] != null) {+ return refused(result['error'], result['detail']);+ }+ if (result['deleted'] != true) return unconfirmed;+ } on WsRequestFailure catch (failure) {+ return refused(failure.code, failure.detail);+ } on WsRequestTimeout {+ return deleting+ ? unconfirmed+ : 'Could not review this harness for deletion. Try again.';+ } catch (_) {+ return deleting+ ? unconfirmed+ : 'Could not delete the harness. Try again.';+ }+ if (_disposed || !_machineWorkCurrent(machine, revision)) return null;+ await _removeAgent(machine, agentId);+ // Gone from the machine, so gone from the desk — as Stop does ([deleteAgent]).+ _desk.drop((machineId: machineId, agentId: agentId));+ notifyListeners();+ return null;+ }+/// Bring a stopped agent back, so something can be opened on it.////// The desktop's `resumeAgent`: a thin guard over [restartAgent], which is thediff --git a/mobile/test/phone_delete_agent_test.dart b/mobile/test/phone_delete_agent_test.dartindex d97544a79..0ec0552db 100644--- a/mobile/test/phone_delete_agent_test.dart+++ b/mobile/test/phone_delete_agent_test.dart@@ -30,9 +30,21 @@ class _Conn extends WsConn {Duration timeout = const Duration(seconds: 20),}) async {calls.add((type, payload));+ // Delete Harness: a review, then the delete under it.+ if (type == 'agent_purge') {+ return payload['mode'] == 'inspect'+ ? {'reviewId': 'review-1'}+ : {'deleted': true};+ }return {};}+ List<(String, String)> get purged => [+ for (final (type, payload) in calls)+ if (type == 'agent_purge')+ (payload['agentId'] as String, payload['mode'] as String),+ ];+List<String> get deleted => [for (final (type, payload) in calls)if (type == 'agent_delete') payload['agentId'] as String,@@ -43,7 +55,9 @@ class _Conn extends WsConn {////// The second is the case the row's hold exists for — it cannot be opened, so a menu hung off the/// tap would never reach it.-AppNotifier _app(_Conn conn) {+///+/// [withTerminal] adds a third, a terminal — the one harness Delete is not offered for.+AppNotifier _app(_Conn conn, {bool withTerminal = false}) {final app = AppNotifier(config: AppConfig.dev,authSession: AuthSession(),@@ -63,19 +77,28 @@ AppNotifier _app(_Conn conn) {..nodeOnline = true..connectionStatus = ConnectionStatus.connected..agentLoadStatus = AgentLoadStatus.loaded- ..agents = const [+ ..agents = [Agent(id: 'a0',name: 'Live one',engine: 'codex',+ sessionId: 's0',terminalAvailable: true,+ createdAt: DateTime.utc(2026, 10, 16, 1),),- Agent(+ const Agent(id: 'a1',name: 'Gone one',engine: 'codex',terminalAvailable: false,),+ if (withTerminal)+ const Agent(+ id: 't0',+ name: 'Shell',+ engine: 'terminal',+ terminalAvailable: true,+ ),];return app;}@@ -156,4 +179,59 @@ void main() {expect(conn.deleted, ['a1']);});++ testWidgets('holding an agent offers Delete Harness too, and confirming '+ 'reviews then deletes it, conversation and all', (tester) async {+ final conn = _Conn();+ final app = _app(conn);+ addTearDown(app.dispose);+ await _pump(tester, app);++ await tester.longPress(find.byType(AgentTile).first);+ await tester.pumpAndSettle();+ await tester.tap(find.text('Delete Harness…'));+ await tester.pumpAndSettle();+ expect(find.text('Delete Live one?'), findsOneWidget);+ expect(+ find.textContaining('it cannot be opened again'),+ findsOneWidget,+ reason: 'says what Stop does not',+ );+ await tester.tap(find.widgetWithText(FilledButton, 'Delete'));+ await tester.pumpAndSettle();++ expect(conn.purged, [('a0', 'inspect'), ('a0', 'delete')]);+ expect(conn.deleted, isEmpty, reason: 'not a Stop');+ expect(app.machineStates['m']!.agents.map((agent) => agent.id), ['a1']);+ });++ testWidgets('Delete Harness backed out of asks nothing', (tester) async {+ final conn = _Conn();+ final app = _app(conn);+ addTearDown(app.dispose);+ await _pump(tester, app);++ await tester.longPress(find.byType(AgentTile).first);+ await tester.pumpAndSettle();+ await tester.tap(find.text('Delete Harness…'));+ await tester.pumpAndSettle();+ await tester.tap(find.text('Cancel'));+ await tester.pumpAndSettle();++ expect(conn.purged, isEmpty);+ expect(app.machineStates['m']!.agents, hasLength(2));+ });++ testWidgets('a terminal offers Stop only — it keeps no conversation to '+ 'delete', (tester) async {+ final conn = _Conn();+ final app = _app(conn, withTerminal: true);+ addTearDown(app.dispose);+ await _pump(tester, app);++ await tester.longPress(find.widgetWithText(AgentTile, 'Shell'));+ await tester.pumpAndSettle();+ expect(find.text('Stop Harness…'), findsOneWidget);+ expect(find.text('Delete Harness…'), findsNothing);+ });}diff --git a/mobile/test/phone_edge/focus_behavior_test.dart b/mobile/test/phone_edge/focus_behavior_test.dartindex 8a7c5a881..01ba44a1a 100644--- a/mobile/test/phone_edge/focus_behavior_test.dart+++ b/mobile/test/phone_edge/focus_behavior_test.dart@@ -677,6 +677,90 @@ void main() {await frames(tester);}+ /// A machine that reviews then deletes what it is asked to — or, with [review], answers the+ /// review only when that does.+ EdgeConn purging({Future<Map<String, dynamic>>? review}) =>+ _PurgeConn(review ?? Future.value({'reviewId': 'review-1'}))+ ..handshaken = true;++ testWidgets('Delete is offered beside Stop, and not on a terminal', (+ tester,+ ) async {+ var focus = await openMenu(tester);+ expect(find.text('Stop this harness…'), findsOneWidget);+ expect(find.text('Delete this harness…'), findsOneWidget);+ await focus.close();++ focus = await openMenu(tester, engine: 'terminal');+ expect(find.text('Stop this harness…'), findsOneWidget);+ expect(find.text('Delete this harness…'), findsNothing);+ await focus.close();+ });++ testWidgets('Delete, confirmed, reviews then deletes the harness this page '+ 'shows, conversation and all', (tester) async {+ final conn = purging();+ final focus = await _Focus.open(+ tester,+ agents: [switchable()],+ connection: conn,+ );+ await tester.tap(find.byKey(const ValueKey('terminal-title')));+ await frames(tester);+ await tapInView(tester, find.text('Delete this harness…'));+ await frames(tester);+ expect(find.text('Delete a?'), findsOneWidget);+ await tester.tap(find.widgetWithText(FilledButton, 'Delete'));+ await frames(tester);++ expect(+ [for (final p in conn.payloads['agent_purge']!) p['mode']],+ ['inspect', 'delete'],+ );+ expect(conn.payloads['agent_purge']!.last, {+ 'agentId': 'a',+ 'sessionId': 'session-a',+ 'createdAt': DateTime.utc(2026, 10, 16, 1).millisecondsSinceEpoch,+ 'mode': 'delete',+ 'reviewId': 'review-1',+ });+ expect(conn.requests, isNot(contains('agent_delete')));+ expect(focus.app.stateOf('m')!.agents, isEmpty);+ await focus.close();+ });++ testWidgets('Delete, while it is out, says so and cannot be pressed '+ 'again', (tester) async {+ final review = Completer<Map<String, dynamic>>();+ final conn = purging(review: review.future);+ final focus = await _Focus.open(+ tester,+ agents: [switchable()],+ connection: conn,+ );+ await tester.tap(find.byKey(const ValueKey('terminal-title')));+ await frames(tester);+ await tapInView(tester, find.text('Delete this harness…'));+ await frames(tester);+ await tester.tap(find.widgetWithText(FilledButton, 'Delete'));+ await frames(tester);++ await tester.tap(find.byKey(const ValueKey('terminal-title')));+ await frames(tester);+ expect(find.text('Delete this harness…'), findsNothing);+ await tapInView(tester, find.text('Deleting…'));+ await frames(tester);+ expect(find.text('Delete a?'), findsNothing, reason: 'took no tap');++ await tester.tapAt(const Offset(200, 40));+ await frames(tester);+ review.complete({'error': 'OWNER_REQUIRED'});+ await frames(tester);+ expect(find.text('Delete failed: OWNER_REQUIRED'), findsOneWidget);+ expect(conn.payloads['agent_purge'], hasLength(1));+ await focus.close();+ });+testWidgets('Change agent is named by the agent it is on, and offered to ''an agent only', (tester) async {var focus = await openMenu(tester);@@ -2510,6 +2594,29 @@ class _HeldForkConn extends EdgeConn {}}+/// A machine that answers Delete's review with [review], and deletes under any review id.+class _PurgeConn extends EdgeConn {+ _PurgeConn(this.review);++ final Future<Map<String, dynamic>> review;++ @override+ Future<Map<String, dynamic>> request(+ String type, {+ Map<String, dynamic> payload = const {},+ Duration timeout = const Duration(seconds: 20),+ }) {+ if (type != 'agent_purge') {+ return super.request(type, payload: payload, timeout: timeout);+ }+ requests.add(type);+ (payloads[type] ??= []).add(payload);+ return payload['mode'] == 'inspect'+ ? review+ : Future.value({'deleted': true});+ }+}+class _Pushes extends NavigatorObserver {_Pushes(this.pushed);diff --git a/mobile/test/state/purge_agent_test.dart b/mobile/test/state/purge_agent_test.dartnew file mode 100644index 000000000..2c24d1305--- /dev/null+++ b/mobile/test/state/purge_agent_test.dart@@ -0,0 +1,204 @@+import 'dart:async';++import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/core/models.dart';+import 'package:harness_mobile/ws/ws_conn.dart';++import '../viewer_app_fixture.dart';++/// Delete Harness from the phone: a harness and its saved conversation, gone for good — the+/// desktop's `purgeAgent`. Reviewed first, then deleted under that review, naming the harness+/// exactly; and a reply that never came is not taken for a delete that did not happen.+void main() {+ const created = '2026-10-16T01:00:00.000Z';+ final createdMs = DateTime.parse(created).millisecondsSinceEpoch;++ /// The harness to delete: Claude Code, mid-conversation, registered at [created].+ Map<String, dynamic> source({+ String id = 'a',+ String engine = 'claude',+ String? sessionId = 's1',+ bool registered = true,+ }) => agentJson(+ id,+ engine: engine,+ sessionId: sessionId,+ extra: {if (registered) 'createdAt': created},+ );++ /// A signed-in phone whose machine `m` lists [agents], and reviews then deletes as a current+ /// machine does.+ Future<ViewerRig> rigWith(List<Map<String, dynamic>> agents) async {+ final rig = viewerApp();+ rig.api.onMachines = () async => [remoteMachine('m')];+ final answers = rig.conn('m').answers;+ answers['agents_list'] = (_) => {'agents': agents};+ answers['terminal_capabilities'] = (_) => capabilities();+ answers['agent_purge'] = (p) => p['mode'] == 'inspect'+ ? {'reviewId': 'review-1', 'items': <Object>[]}+ : {'deleted': true};+ await rig.app.bootstrap();+ await settle();+ rig.app.connectionStatusForTest('m', ConnectionStatus.connected);+ await settle();+ addTearDown(rig.app.dispose);+ return rig;+ }++ List<String> listed(ViewerRig rig) => [+ for (final agent in rig.app.stateOf('m')!.agents) agent.id,+ ];++ test('reviews, then deletes under that review, naming the harness '+ 'exactly — and it leaves the list', () async {+ final rig = await rigWith([source(), source(id: 'b')]);++ final error = await rig.app.purgeAgent('m', 'a');++ expect(error, isNull);+ expect(rig.conn('m').payloadsOf('agent_purge'), [+ {+ 'agentId': 'a',+ 'sessionId': 's1',+ 'createdAt': createdMs,+ 'mode': 'inspect',+ },+ {+ 'agentId': 'a',+ 'sessionId': 's1',+ 'createdAt': createdMs,+ 'mode': 'delete',+ 'reviewId': 'review-1',+ },+ ]);+ expect(listed(rig), ['b']);+ expect(rig.app.agentPurging('m', 'a'), isFalse);+ });++ test('a harness with no conversation yet is named by a null one', () async {+ final rig = await rigWith([source(sessionId: null)]);++ await rig.app.purgeAgent('m', 'a');++ final [review, _] = rig.conn('m').payloadsOf('agent_purge');+ expect(review.containsKey('sessionId'), isTrue);+ expect(review['sessionId'], isNull);+ });++ test('a refused review deletes nothing and says why, in the machine’s '+ 'words when it has them', () async {+ final rig = await rigWith([source()]);+ final conn = rig.conn('m');+ conn.answers['agent_purge'] = (_) => throw refusal('OWNER_REQUIRED');+ expect(await rig.app.purgeAgent('m', 'a'), 'Delete failed: OWNER_REQUIRED');++ conn.answers['agent_purge'] = (_) => {+ 'error': 'AGENT_CHANGED',+ 'detail': 'The harness changed since it was reviewed.',+ };+ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'Delete failed: The harness changed since it was reviewed.',+ );++ expect(conn.payloadsOf('agent_purge').map((p) => p['mode']), [+ 'inspect',+ 'inspect',+ ]);+ expect(listed(rig), ['a']);+ });++ test('a review with no id is not deleted under', () async {+ final rig = await rigWith([source()]);+ rig.conn('m').answers['agent_purge'] = (_) => {'items': <Object>[]};++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'Could not review this harness for deletion.',+ );+ expect(rig.conn('m').payloadsOf('agent_purge'), hasLength(1));+ expect(listed(rig), ['a']);+ });++ test('a delete whose reply never came asks to check, and keeps the '+ 'row', () async {+ final rig = await rigWith([source()]);+ rig.conn('m').answers['agent_purge'] = (p) => p['mode'] == 'inspect'+ ? {'reviewId': 'review-1'}+ : throw const WsRequestTimeout('agent_purge');++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'Could not confirm the deletion. Refresh harnesses to check.',+ );+ expect(listed(rig), ['a']);+ });++ test('a review whose reply never came deleted nothing, and says to try '+ 'again', () async {+ final rig = await rigWith([source()]);+ rig.conn('m').answers['agent_purge'] = (_) =>+ throw const WsRequestTimeout('agent_purge');++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'Could not review this harness for deletion. Try again.',+ );+ expect(rig.conn('m').payloadsOf('agent_purge'), hasLength(1));+ });++ test('a delete the machine does not confirm is not taken for one', () async {+ final rig = await rigWith([source()]);+ rig.conn('m').answers['agent_purge'] = (p) =>+ p['mode'] == 'inspect' ? {'reviewId': 'review-1'} : {'deleted': false};++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'Could not confirm the deletion. Refresh harnesses to check.',+ );+ expect(listed(rig), ['a']);+ });++ test('a harness its machine never said it registered is not asked '+ 'about', () async {+ final rig = await rigWith([source(registered: false)]);++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'This harness is no longer listed. Refresh and try again.',+ );+ expect(rig.conn('m').payloadsOf('agent_purge'), isEmpty);+ });++ test('a terminal keeps no conversation, so it is stopped, not '+ 'deleted', () async {+ final rig = await rigWith([source(engine: 'terminal')]);++ expect(+ await rig.app.purgeAgent('m', 'a'),+ 'A terminal keeps no conversation. Stop it instead.',+ );+ expect(rig.conn('m').payloadsOf('agent_purge'), isEmpty);+ });++ test('pressed again while it is out joins the first', () async {+ final rig = await rigWith([source()]);+ final review = Completer<Map<String, dynamic>>();+ rig.conn('m').answers['agent_purge'] = (p) =>+ p['mode'] == 'inspect' ? review.future : {'deleted': true};++ final first = rig.app.purgeAgent('m', 'a');+ final second = rig.app.purgeAgent('m', 'a');+ expect(rig.app.agentPurging('m', 'a'), isTrue);+ review.complete({'reviewId': 'review-1'});++ expect(await first, isNull);+ expect(await second, isNull);+ expect(rig.conn('m').payloadsOf('agent_purge'), hasLength(2));+ expect(rig.app.agentPurging('m', 'a'), isFalse);+ });++ test('Agent reads when it was registered', () {+ expect(Agent.fromJson(source()).createdAt, DateTime.parse(created));+ });+}