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.

fix(mobile): mark agent_close as the phone's for usage counting

tony9e1bde0ee1f9
diff --git a/mobile/lib/ws/ws_conn.dart b/mobile/lib/ws/ws_conn.dart
index 7262bd7cd..29e133464 100644
--- a/mobile/lib/ws/ws_conn.dart
+++ b/mobile/lib/ws/ws_conn.dart
@@ -903,6 +903,7 @@ class WsConn {
'agent_retarget',
'agent_recent',
'agent_fork',
+ 'agent_close',
'agent_delete',
'session_search',
'session_tail',
diff --git a/mobile/test/widgets/fork_agent_dialog_test.dart b/mobile/test/widgets/fork_agent_dialog_test.dart
new file mode 100644
index 000000000..b8f084299
--- /dev/null
+++ b/mobile/test/widgets/fork_agent_dialog_test.dart
@@ -0,0 +1,19 @@
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness_mobile/widgets/fork_agent_dialog.dart';
+
+void main() {
+ group('forkNameFor', () {
+ test('marks the source name as a fork', () {
+ expect(forkNameFor('api server'), 'api server - fork');
+ });
+
+ test('trims the source name first', () {
+ expect(forkNameFor(' api server \n'), 'api server - fork');
+ });
+
+ test('an unnamed source forks as Harness', () {
+ expect(forkNameFor(''), 'Harness - fork');
+ expect(forkNameFor(' '), 'Harness - fork');
+ });
+ });
+}
diff --git a/mobile/test/ws/ws_conn_relay_test.dart b/mobile/test/ws/ws_conn_relay_test.dart
index 8045da2ad..35be22642 100644
--- a/mobile/test/ws/ws_conn_relay_test.dart
+++ b/mobile/test/ws/ws_conn_relay_test.dart
@@ -395,12 +395,14 @@ void main() {
conn.request(type, payload: payload).then((_) {}, onError: (_) {}),
);
ask('agent_create', {'engine': 'claude'});
+ ask('agent_close', {'agentId': 'a', 'mode': 'now'});
ask('agents_list', {'scope': 'all'});
conn.sendRaw('message', {'content': 'hi', 'agentId': 'a'});
conn.sendRaw('app_presence', {'focused': true});
await eventually(
() => [
'agent_create',
+ 'agent_close',
'agents_list',
'message',
'app_presence',
@@ -412,6 +414,7 @@ void main() {
'__e2e',
], reason: 'the relay sees no more than before');
expect(link.opened('agent_create').single['usageSurface'], 'phone');
+ expect(link.opened('agent_close').single['usageSurface'], 'phone');
expect(link.opened('message').single['usageSurface'], 'phone');
expect(
link.opened('agents_list').single.containsKey('usageSurface'),