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): sort a copy of the agent memo, update stale tests

tony51ee54c3e900
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index f46ee7c96..70a2b7aab 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -933,7 +933,8 @@ class _TerminalPageState extends State<TerminalPage>
break;
}
}
- last ??= (entries..sort(compareMonitorOrder))
+ // Sorted as a copy: [visibleAgents] hands back its memo, unmodifiable.
+ last ??= ([...entries]..sort(compareMonitorOrder))
.where((entry) => !here(entry) && entry.isOpenable)
.firstOrNull;
if (last == null) {
diff --git a/mobile/test/agent_pager_attach_test.dart b/mobile/test/agent_pager_attach_test.dart
index a83ed2e85..608f2077a 100644
--- a/mobile/test/agent_pager_attach_test.dart
+++ b/mobile/test/agent_pager_attach_test.dart
@@ -9,6 +9,14 @@ import 'package:harness_mobile/state/app_state.dart';
import 'agent_pager_fixture.dart';
+/// A [PagerConn] already through its handshake. A `terminal_open` waits for the machine's
+/// handshake before it goes (`AppNotifier._sendTerminalFrame`), and a fake socket never has one:
+/// left to wait, every open below would still be held when the test looks.
+class _HandshakenConn extends PagerConn {
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) async {}
+}
+
/// The pager holds a HANDFUL of agents open — the one being read, the ones a swipe or two away, and
/// the two just left — and hands the rest back a beat after each swipe. See `AgentSwipeHost._keepSet`.
///
@@ -39,7 +47,7 @@ void main() {
WidgetTester tester, {
bool long = false,
}) async {
- final conn = PagerConn();
+ final conn = _HandshakenConn();
final app = pagerApp(conn);
addTearDown(app.dispose);
if (long) lengthen(app);
@@ -65,7 +73,7 @@ void main() {
/// every page of the pager — down. As a root it can only no-op, so the regression this guards
/// against is invisible there.
Future<(AppNotifier, PagerConn)> pushPager(WidgetTester tester) async {
- final conn = PagerConn();
+ final conn = _HandshakenConn();
final app = pagerApp(conn);
addTearDown(app.dispose);
final list = pagerList(app);
diff --git a/mobile/test/agent_swipe_keyboard_test.dart b/mobile/test/agent_swipe_keyboard_test.dart
index 8a2195991..529e5f33b 100644
--- a/mobile/test/agent_swipe_keyboard_test.dart
+++ b/mobile/test/agent_swipe_keyboard_test.dart
@@ -6,6 +6,15 @@ import 'package:xterm/xterm.dart';
import 'agent_pager_fixture.dart';
+/// [PagerConn] with its handshake already done. A swipe opens the agent it
+/// lands on, and an open waits for the handshake (`_sendTerminalFrame` in
+/// `state/app_state.dart`) — on a fake with no socket, for its whole budget,
+/// a timer still pending when the tree is torn down.
+class _HandshakenConn extends PagerConn {
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) async {}
+}
+
/// The pager puts the keyboard away for a swipe between agents — and for nothing else.
void main() {
bool terminalHasFocus(WidgetTester tester) =>
@@ -14,7 +23,7 @@ void main() {
null;
Future<AppNotifier> pumpPager(WidgetTester tester) async {
- final app = pagerApp(PagerConn());
+ final app = pagerApp(_HandshakenConn());
addTearDown(app.dispose);
final session = await liveAgent(app, 'b');
for (var line = 0; line < 400; line++) {
diff --git a/mobile/test/app_state_terminals_test.dart b/mobile/test/app_state_terminals_test.dart
index e0e01ff3d..9a46d9374 100644
--- a/mobile/test/app_state_terminals_test.dart
+++ b/mobile/test/app_state_terminals_test.dart
@@ -25,6 +25,11 @@ void main() {
].join('\n');
}
+ /// How long an open the machine has said nothing to waits before its
+ /// watchdog gives up on the socket — `TerminalSession._openSilentPatience`,
+ /// private there. Real time: the watchdog reads the wall clock.
+ const silentPatience = Duration(seconds: 10);
+
/// The pager warming [agentId] on `m`, its parked page measuring itself.
Future<void> warm(ViewerRig rig, String agentId) async {
final warming = rig.app.warmAgentPane('m', agentId);
@@ -502,10 +507,15 @@ void main() {
session.reportViewport(80, 24);
await opening;
- // No terminal_ready: past the session's watchdog, the socket is suspect.
+ // No terminal_ready, and not a word from the machine: past the session's
+ // watchdog the open is still waited on — a slow relay is not a dead one…
await Future<void>.delayed(
session.resyncTimeout + const Duration(milliseconds: 100),
);
+ expect(rig.conn('m').redials, 0);
+
+ // …until the machine has been silent for as long as an open waits.
+ await Future<void>.delayed(silentPatience - session.resyncTimeout);
expect(rig.conn('m').redials, 1);
expect(opensFor(rig, 'a'), hasLength(2), reason: 'the same open, again');
@@ -527,8 +537,10 @@ void main() {
session.reportViewport(80, 24);
await opening;
+ // Given up on once a silent machine would be — but the dial in progress
+ // is left to finish.
await Future<void>.delayed(
- session.resyncTimeout + const Duration(milliseconds: 100),
+ silentPatience + const Duration(milliseconds: 100),
);
expect(rig.conn('m').redials, 0);
diff --git a/mobile/test/focus_swipes_test.dart b/mobile/test/focus_swipes_test.dart
index be5c90269..bc302c215 100644
--- a/mobile/test/focus_swipes_test.dart
+++ b/mobile/test/focus_swipes_test.dart
@@ -3,6 +3,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/auth/auth_session.dart';
import 'package:harness_mobile/core/config.dart';
+import 'package:harness_mobile/phone/machines_tab.dart';
import 'package:harness_mobile/phone/terminal_page.dart';
import 'package:harness_mobile/phone/terminal_search.dart';
import 'package:harness_mobile/phone/voice_input_controller.dart';
@@ -14,7 +15,7 @@ import 'voice_fakes.dart';
/// Focus is Snapchat's camera: a swipe right on the terminal pulls Find in from
/// the left edge, a tap on the agent's name opens it too, and a swipe left
-/// opens a new agent.
+/// opens Computers. A new harness is Find's `New Harness` now.
void main() {
late AppNotifier notifier;
late TerminalSession session;
@@ -137,20 +138,21 @@ void main() {
expect(find.byType(TerminalSearchOverlay), findsNothing);
});
- testWidgets('a swipe left on the terminal opens a new agent', (tester) async {
+ testWidgets('a swipe left on the terminal opens Computers', (tester) async {
final pushed = await pumpFocus(tester);
await tester.drag(find.byType(TerminalView), const Offset(-200, 0));
- // Pushed, and not pumped further: the new-agent form asks its machine for
- // folders and engines as it opens, and this fixture has no machine to ask.
expect(pushed, hasLength(1));
expect(find.byType(TerminalSearchOverlay), findsNothing);
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ expect(find.byType(MachinesTab), findsOneWidget);
});
group('VoiceOver', () {
// VoiceOver keeps one-finger swipes for itself, and xterm draws no semantics: the terminal
- // node is the only way it reaches the agent's words, Find and a new harness.
+ // node is the only way it reaches the agent's words, Find and Computers.
SemanticsNode terminalNode(WidgetTester tester) =>
tester.getSemantics(find.bySemanticsLabel(RegExp(r', terminal$')));
@@ -171,7 +173,7 @@ void main() {
final find_ = node.getSemanticsData().customSemanticsActionIds!.map(
CustomSemanticsAction.getAction,
);
- expect(find_.map((a) => a!.label), containsAll(['Find', 'New harness']));
+ expect(find_.map((a) => a!.label), containsAll(['Find', 'Computers']));
node.owner!.performAction(
node.id,
SemanticsAction.customAction,
@@ -185,7 +187,7 @@ void main() {
handle.dispose();
});
- testWidgets('New harness is an action, and it opens the form', (
+ testWidgets('Computers is an action, and it opens Computers', (
tester,
) async {
final handle = tester.ensureSemantics();
@@ -195,10 +197,13 @@ void main() {
node.id,
SemanticsAction.customAction,
CustomSemanticsAction.getIdentifier(
- const CustomSemanticsAction(label: 'New harness'),
+ const CustomSemanticsAction(label: 'Computers'),
),
);
expect(pushed, hasLength(1));
+ await tester.pump();
+ await tester.pump(const Duration(milliseconds: 400));
+ expect(find.byType(MachinesTab), findsOneWidget);
handle.dispose();
});
});
diff --git a/mobile/test/keyboard_fakes.dart b/mobile/test/keyboard_fakes.dart
index 57aa20a20..f8bab0211 100644
--- a/mobile/test/keyboard_fakes.dart
+++ b/mobile/test/keyboard_fakes.dart
@@ -4,6 +4,11 @@ import 'package:flutter_test/flutter_test.dart';
/// What UIKit's `deleteBackward` does to the buffer it holds: one character
/// fewer, and NOTHING at all once the buffer is empty. Android's
/// `deleteSurroundingText` reaches Dart the same way, as an edited buffer.
+///
+/// One press at a person's pace. The terminal hands the keyboard its buffer
+/// back a few milliseconds after the key, not inside it (`_pushSoon` in xterm's
+/// `custom_text_edit.dart`), and `editingState` is only ever what it was last
+/// handed — so the clock moves on past that before the next press reads it.
Future<void> deleteBackward(WidgetTester tester) async {
final text = tester.testTextInput.editingState!['text'] as String;
if (text.isEmpty) return;
@@ -14,5 +19,9 @@ Future<void> deleteBackward(WidgetTester tester) async {
selection: TextSelection.collapsed(offset: left.length),
),
);
- await tester.pump();
+ await tester.pump(_betweenPresses);
}
+
+/// Well past the terminal's push to the keyboard, and well short of anyone's
+/// next Backspace.
+const _betweenPresses = Duration(milliseconds: 20);
diff --git a/mobile/test/p2p/fakes.dart b/mobile/test/p2p/fakes.dart
index 79b6f5da6..0b9cc7e78 100644
--- a/mobile/test/p2p/fakes.dart
+++ b/mobile/test/p2p/fakes.dart
@@ -341,10 +341,16 @@ Map<String, dynamic> linkMode(String streamId, String mode) => {
///
/// Under [async], the plugin's clock is the fake one — `DateTime.now()` is not
/// faked on its own, and the retry budget and migration sweep read the clock.
+///
+/// The session coming up starts no channel: the connection's first terminal
+/// does (`prepareOpen`). Unless [firstTerminal] is false, that first open has
+/// been asked for — no frame sent, only the ask — so the channel is
+/// negotiating, as the app has it by the time anything else happens.
({TerminalP2pPlugin plugin, FakeHost host, FakeLinkFactory links}) bootPlugin({
Map<String, dynamic>? policy = enabledPolicy,
int peerVersion = 1,
FakeAsync? async,
+ bool firstTerminal = true,
}) {
final host = FakeHost(codec: FakeCodec(terminalP2pVersion: peerVersion));
final links = FakeLinkFactory();
@@ -358,5 +364,6 @@ Map<String, dynamic> linkMode(String streamId, String mode) => {
host.plugin = plugin;
plugin.onConnectedAck({'machineId': 'machine-1234567890', 'p2p': policy});
plugin.onSessionReady();
+ if (firstTerminal) unawaited(plugin.prepareOpen('first-terminal'));
return (plugin: plugin, host: host, links: links);
}
diff --git a/mobile/test/p2p/terminal_p2p_plugin_edges_test.dart b/mobile/test/p2p/terminal_p2p_plugin_edges_test.dart
index 82c06b62d..0153d0476 100644
--- a/mobile/test/p2p/terminal_p2p_plugin_edges_test.dart
+++ b/mobile/test/p2p/terminal_p2p_plugin_edges_test.dart
@@ -1,3 +1,4 @@
+import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
@@ -96,6 +97,8 @@ class _Links extends FakeLinkFactory {
host.plugin = plugin;
plugin.onConnectedAck({'machineId': 'machine-1', 'p2p': enabledPolicy});
plugin.onSessionReady();
+ // The connection's first terminal is what starts the channel (`prepareOpen`).
+ unawaited(plugin.prepareOpen('first-terminal'));
return (plugin: plugin, host: host, links: links);
}
@@ -129,6 +132,7 @@ void main() {
for (final plugin in [a, b]) {
plugin.onConnectedAck({'p2p': enabledPolicy});
plugin.onSessionReady();
+ unawaited(plugin.prepareOpen('first-terminal'));
}
// Both fail to negotiate; both wait out a retry.
links.created[0].failNegotiation('peer_failed');
@@ -255,6 +259,7 @@ void main() {
host.plugin = plugin;
plugin.onConnectedAck({'p2p': enabledPolicy});
plugin.onSessionReady();
+ unawaited(plugin.prepareOpen('first-terminal'));
final link = links.last;
link.open();
flush(async);
diff --git a/mobile/test/p2p/terminal_p2p_plugin_test.dart b/mobile/test/p2p/terminal_p2p_plugin_test.dart
index 0b22bf243..47bb1a2e1 100644
--- a/mobile/test/p2p/terminal_p2p_plugin_test.dart
+++ b/mobile/test/p2p/terminal_p2p_plugin_test.dart
@@ -32,6 +32,17 @@ void main() {
b.plugin.dispose();
});
+ test('starts on the first terminal, not when the session comes up', () {
+ final b = bootPlugin(firstTerminal: false);
+ expect(b.links.created, isEmpty);
+ b.host.sendTerminalFrame('terminal_open', {'requestId': 'r0'});
+ expect(b.links.created, hasLength(1));
+ // Once only: a second open finds it started.
+ b.host.sendTerminalFrame('terminal_open', {'requestId': 'r1'});
+ expect(b.links.created, hasLength(1));
+ b.plugin.dispose();
+ });
+
test(
'signals go out sealed over the socket, answers reach the link',
() async {
@@ -129,7 +140,7 @@ void main() {
});
});
- test('waits openWaitMs, then falls back to the socket', () {
+ test('an open before the channel is up rides the socket at once', () {
fakeAsync((async) {
final b = bootPlugin(async: async);
var done = false;
@@ -137,14 +148,11 @@ void main() {
.sendTerminalFrame('terminal_open', {'requestId': 'r1'})
.then((_) => done = true);
flush(async);
- expect(b.host.wsFrames, isEmpty, reason: 'still waiting');
- async.elapse(const Duration(milliseconds: 1500));
- flush(async);
+ // No wait for the channel (`prepareOpen`), and so no
+ // `open_wait_elapsed` either: nothing ran out.
expect(done, isTrue);
expect(b.host.wsTypes, ['terminal_open']);
- final result = p2pResults(b.host).single;
- expect(result['outcome'], 'relay');
- expect(result['reason'], 'open_wait_elapsed');
+ expect(p2pResults(b.host), isEmpty);
b.plugin.dispose();
});
});
diff --git a/mobile/test/p2p/terminal_p2p_redial_test.dart b/mobile/test/p2p/terminal_p2p_redial_test.dart
index 19a1a48cb..08ac923bd 100644
--- a/mobile/test/p2p/terminal_p2p_redial_test.dart
+++ b/mobile/test/p2p/terminal_p2p_redial_test.dart
@@ -22,7 +22,7 @@ typedef Booted = ({
/// The first terminal starts the negotiation and rides the relay; nothing is up yet.
Booted started(FakeAsync async) {
- final b = bootPlugin(async: async);
+ final b = bootPlugin(async: async, firstTerminal: false);
b.host.sendTerminalFrame('terminal_open', {'requestId': 'r0'});
flush(async);
expect(b.links.created, hasLength(1));
diff --git a/mobile/test/perf_fixture_test.dart b/mobile/test/perf_fixture_test.dart
index b46026363..f411983e6 100644
--- a/mobile/test/perf_fixture_test.dart
+++ b/mobile/test/perf_fixture_test.dart
@@ -19,6 +19,26 @@ void main() {
addTearDown(tester.view.reset);
}
+ /// [terminal]'s keyframe, written to the end. A long one is written in
+ /// slices a frame apart (`writeKeyframeInSlices`), and under the test's fake
+ /// clock the next slice only comes once the clock moves.
+ Future<void> keyframe(
+ WidgetTester tester,
+ FixtureTerminal terminal,
+ String text, {
+ required int cols,
+ required int rows,
+ }) async {
+ var written = false;
+ final writing = terminal
+ .keyframe(text, cols: cols, rows: rows)
+ .whenComplete(() => written = true);
+ while (!written) {
+ await tester.pump(Duration.zero);
+ }
+ await writing;
+ }
+
testWidgets('an idle terminal page draws nothing', (tester) async {
phone(tester);
final fixture = PerfFixture.create();
@@ -29,11 +49,19 @@ void main() {
await tester.pump(const Duration(milliseconds: 100));
// The attach as the benchmark does it: the machine's size, the phone's
// resize, and a keyframe back at the phone's grid.
- await a.keyframe(ClaudeOutput(cols: 80).keyframe(20), cols: 80, rows: 24);
+ await keyframe(
+ tester,
+ a,
+ ClaudeOutput(cols: 80).keyframe(20),
+ cols: 80,
+ rows: 24,
+ );
await tester.pump(const Duration(milliseconds: 100));
await tester.pump(const Duration(milliseconds: 100));
final (cols, rows) = a.lastResize!;
- await a.keyframe(
+ await keyframe(
+ tester,
+ a,
ClaudeOutput(cols: cols).keyframe(2000),
cols: cols,
rows: rows,
@@ -64,7 +92,7 @@ void main() {
final fixture = PerfFixture.create();
final a = fixture.terminals['agent-a']!;
final output = ClaudeOutput(cols: 40);
- await a.keyframe(output.keyframe(200), cols: 40, rows: 49);
+ await keyframe(tester, a, output.keyframe(200), cols: 40, rows: 49);
final buffer = a.session.terminal.buffer;
final lines = buffer.lines.length;
final cursor = buffer.cursorY;
@@ -95,7 +123,9 @@ void main() {
),
);
for (final id in ['agent-a', 'agent-b']) {
- await fixture.terminals[id]!.keyframe(
+ await keyframe(
+ tester,
+ fixture.terminals[id]!,
ClaudeOutput(cols: 40).keyframe(100),
cols: 40,
rows: 49,
diff --git a/mobile/test/phone_edge/edge_fixture.dart b/mobile/test/phone_edge/edge_fixture.dart
index 8f467cccf..44938463e 100644
--- a/mobile/test/phone_edge/edge_fixture.dart
+++ b/mobile/test/phone_edge/edge_fixture.dart
@@ -134,6 +134,17 @@ class EdgeConn extends WsConn {
/// Every request's payload, by type, in order.
final Map<String, List<Map<String, dynamic>>> payloads = {};
+ /// Whether the socket counts as handshaken, as one that just answered a request is. Off, a
+ /// `terminal_open` waits out the handshake it never gets — fifteen seconds
+ /// (`AppNotifier._sendTerminalFrame`) — so a harness that is created, or resumed, and then
+ /// attached reaches its page that much later. On for a test that waits for that page.
+ bool handshaken = false;
+
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) => handshaken
+ ? Future<void>.value()
+ : super.waitUntilReady(timeout: timeout);
+
/// How many times a terminal was asked to open.
int get opens => frames.where((frame) => frame.$1 == 'terminal_open').length;
diff --git a/mobile/test/phone_edge/find_behavior_test.dart b/mobile/test/phone_edge/find_behavior_test.dart
index 77c9a3453..a40a85923 100644
--- a/mobile/test/phone_edge/find_behavior_test.dart
+++ b/mobile/test/phone_edge/find_behavior_test.dart
@@ -55,10 +55,10 @@ void main() {
FakeTranscriber stt,
})
>
- openFind(WidgetTester tester) async {
+ openFind(WidgetTester tester, {bool handshaken = false}) async {
setPhone(tester, largePhone);
final app = edgeApp(
- conn: EdgeConn(const {}, machine),
+ conn: EdgeConn(const {}, machine)..handshaken = handshaken,
agents: [
edgeAgent('a0', name: 'on-screen'),
edgeAgent('work', name: 'working'),
@@ -121,18 +121,23 @@ void main() {
await tester.pump(const Duration(seconds: 30));
}
+ /// A row's state word, at the end of its first line: alone, or ahead of the row's age
+ /// (`done · 5m`).
+ Finder state(String word) =>
+ find.textContaining(RegExp('^${RegExp.escape(word)}( · |\$)'));
+
testWidgets('each row says what its harness is doing', (tester) async {
final (:app, closes: _, opened: _, voice: _, stt: _) = await openFind(
tester,
);
- expect(find.text('working'), findsWidgets);
- expect(find.text('done'), findsOneWidget);
- expect(find.text('paused'), findsOneWidget);
- expect(find.text('exited'), findsOneWidget);
- expect(
- find.textContaining('· current', findRichText: true),
- findsOneWidget,
- );
+ // `working` is that harness's name too: its word is the one ahead of its age.
+ expect(find.textContaining(RegExp(r'^working · ')), findsOneWidget);
+ expect(state('done'), findsOneWidget);
+ expect(state('paused'), findsOneWidget);
+ expect(state('exited'), findsOneWidget);
+ // The harness on screen says `current` where its age would be — and, idle, no word ahead of
+ // it: idle says nothing (owner, 2026-09-30).
+ expect(find.text('current'), findsOneWidget);
await close(tester, app);
});
@@ -150,10 +155,15 @@ void main() {
await close(tester, app);
});
- testWidgets('Find accepts a query immediately on opening', (tester) async {
+ testWidgets('Find opens with the keys down, and a tap on the field takes a '
+ 'query', (tester) async {
final (:app, closes: _, opened: _, voice: _, stt: _) = await openFind(
tester,
);
+ // The rows are what Find is opened to see: the keyboard comes with a tap on the field.
+ expect(tester.testTextInput.isVisible, isFalse);
+ await tester.tap(find.byType(TextField));
+ await tester.pump();
expect(tester.testTextInput.isVisible, isTrue);
tester.testTextInput.updateEditingValue(
const TextEditingValue(text: 'working'),
@@ -178,7 +188,11 @@ void main() {
testWidgets('a conversation Harness did not start: resumed as a harness', (
tester,
) async {
- final (:app, closes: _, :opened, voice: _, stt: _) = await openFind(tester);
+ // The harness it becomes is opened once its terminal is asked for, which waits for the socket.
+ final (:app, closes: _, :opened, voice: _, stt: _) = await openFind(
+ tester,
+ handshaken: true,
+ );
await tester.tap(find.byType(TextField));
await tester.enterText(find.byType(TextField), 'dial');
await frames(tester, count: 6);
diff --git a/mobile/test/phone_edge/focus_behavior_test.dart b/mobile/test/phone_edge/focus_behavior_test.dart
index 258de66c9..82fe983aa 100644
--- a/mobile/test/phone_edge/focus_behavior_test.dart
+++ b/mobile/test/phone_edge/focus_behavior_test.dart
@@ -3,12 +3,12 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/demo/sample_mode.dart';
+import 'package:harness_mobile/phone/machines_tab.dart';
import 'package:harness_mobile/phone/phone_search_catalog.dart'
show phoneAgentId;
import 'package:harness_mobile/phone/phone_shell_scope.dart';
import 'package:harness_mobile/phone/terminal_page.dart';
import 'package:harness_mobile/phone/terminal_search.dart';
-import 'package:harness_mobile/phone/new_agent_page.dart';
import 'package:harness_mobile/phone/settings_page.dart';
import 'package:harness_mobile/phone/voice_input_controller.dart';
import 'package:harness_mobile/phone/voice_mic_button.dart';
@@ -201,7 +201,7 @@ void main() {
await focus.close();
});
- testWidgets('back and forth between Focus, Find and New, quickly', (
+ testWidgets('back and forth between Focus, Find and Computers, quickly', (
tester,
) async {
final focus = await _Focus.open(tester);
@@ -223,20 +223,20 @@ void main() {
);
await frames(tester);
expect(find.byType(TerminalSearchOverlay), findsNothing);
- // Left on the terminal: New.
+ // Left on the terminal: Computers. A new harness is Find's `New Harness` now.
await tester.dragFrom(
centre + const Offset(120, 0),
const Offset(-300, 0),
);
await frames(tester);
- expect(find.byType(NewAgentPage), findsOneWidget);
- // Right on New: back.
+ expect(find.byType(MachinesTab), findsOneWidget);
+ // Right on Computers: back.
await tester.dragFrom(
- tester.getCenter(find.byType(NewAgentPage)),
+ tester.getCenter(find.byType(MachinesTab)),
const Offset(300, 0),
);
await frames(tester, count: 6);
- expect(find.byType(NewAgentPage), findsNothing);
+ expect(find.byType(MachinesTab), findsNothing);
}
expect(tester.takeException(), isNull);
expect(find.byType(TerminalView), findsOneWidget);
@@ -431,15 +431,19 @@ void main() {
return focus;
}
- testWidgets('its keys beside the mic press its first and last answers', (
- tester,
- ) async {
+ // No keys beside the mic since the owner's call (2026-09-29): each answer is a band over its
+ // own lines, pressed by a tap there (the next test) — and, to a screen reader, a button named
+ // for the answer.
+ testWidgets('each answer is a button to VoiceOver, and presses its own '
+ 'number', (tester) async {
+ final semantics = tester.ensureSemantics();
final focus = await asked(tester);
- await tester.tap(find.bySemanticsLabel(RegExp('^Answer 1')));
- await tester.tap(find.bySemanticsLabel(RegExp('^Answer 3')));
+ tester.semantics.tap(find.semantics.byLabel(RegExp('^Answer 1 ')));
+ tester.semantics.tap(find.semantics.byLabel(RegExp('^Answer 3 ')));
await frames(tester);
expect(focus.typed, containsAllInOrder(['1', '3']));
await focus.close();
+ semantics.dispose();
});
testWidgets('a tap on an answer\'s own line presses it', (tester) async {
diff --git a/mobile/test/phone_edge/focus_layout_test.dart b/mobile/test/phone_edge/focus_layout_test.dart
index 577334dfd..1d95720ee 100644
--- a/mobile/test/phone_edge/focus_layout_test.dart
+++ b/mobile/test/phone_edge/focus_layout_test.dart
@@ -90,15 +90,21 @@ void main() {
});
});
- testWidgets('a question open, with its keys beside the mic', (tester) async {
+ // No keys beside the mic since the owner's call (2026-09-29): each answer is a band over its own
+ // lines, which a screen reader is given as a button named for it.
+ testWidgets('a question open, its answers banded on their own lines', (
+ tester,
+ ) async {
+ final semantics = tester.ensureSemantics();
await expectNoLayoutErrors(tester, (scale, brightness) async {
final app = edgeApp(agents: [edgeAgent('a', name: longName)]);
addTearDown(app.dispose);
final session = await liveTerminal(app, 'a');
session.terminal.write(permissionDialog);
await pumpFocus(tester, app, scale, brightness);
- expect(find.bySemanticsLabel(RegExp('^Answer 1')), findsOneWidget);
+ expect(find.semantics.byLabel(RegExp('^Answer 1 ')), findsOne);
});
+ semantics.dispose();
});
testWidgets('the keyboard up, with the pane\'s own keys on the strip', (
diff --git a/mobile/test/phone_edge/new_behavior_test.dart b/mobile/test/phone_edge/new_behavior_test.dart
index 7077b43e7..9e4a41fd3 100644
--- a/mobile/test/phone_edge/new_behavior_test.dart
+++ b/mobile/test/phone_edge/new_behavior_test.dart
@@ -152,6 +152,8 @@ void main() {
tester,
) async {
final (:app, :conn) = await openNew(tester);
+ // The harness's page comes once its terminal is asked for, which waits for the socket.
+ conn.handshaken = true;
final start = tester.getCenter(find.text('Start'));
await tester.tapAt(start);
await tester.pump(const Duration(milliseconds: 40));
diff --git a/mobile/test/phone_new_agent_opens_test.dart b/mobile/test/phone_new_agent_opens_test.dart
index 095d4aa18..09147b2c4 100644
--- a/mobile/test/phone_new_agent_opens_test.dart
+++ b/mobile/test/phone_new_agent_opens_test.dart
@@ -5,6 +5,7 @@ import 'package:harness_mobile/core/config.dart';
import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/phone/agent_swipe.dart';
import 'package:harness_mobile/phone/new_agent_page.dart';
+import 'package:harness_mobile/phone/tty_controls.dart' show TtyFormRow;
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/ws/ws_conn.dart';
@@ -83,6 +84,15 @@ AppNotifier _app(_Conn conn) {
return app;
}
+/// What the form's [label] row says.
+String _row(WidgetTester tester, String label) => tester
+ .widget<TtyFormRow>(
+ find.byWidgetPredicate(
+ (widget) => widget is TtyFormRow && widget.label == label,
+ ),
+ )
+ .value;
+
void main() {
testWidgets(
'creating an agent opens it, and leaves no form to come back to',
@@ -99,9 +109,11 @@ void main() {
);
await tester.pump();
- // The desktop's ⌘N defaults: the project last started here and the engine
- // the form starts on are already chosen, so the button is the whole flow.
- expect(find.text('Test host:grid', findRichText: true), findsOneWidget);
+ // The desktop's ⌘N defaults: the computer, the project last started here
+ // and the engine the form starts on are already chosen, so the button is
+ // the whole flow. The computer has a row of its own, above the project's.
+ expect(_row(tester, 'computer'), 'Test host');
+ expect(_row(tester, 'project'), 'grid');
// Start is the button.
await tester.tap(find.text('Start'));
// The create resolves on a microtask, then the route it pushes has to slide in — and only once
diff --git a/mobile/test/phone_open_claims_test.dart b/mobile/test/phone_open_claims_test.dart
index d0c2c1e3a..dccc4abf9 100644
--- a/mobile/test/phone_open_claims_test.dart
+++ b/mobile/test/phone_open_claims_test.dart
@@ -6,6 +6,14 @@ import 'package:harness_mobile/state/app_state.dart';
import 'agent_pager_fixture.dart';
+/// A [PagerConn] already through its handshake. A `terminal_open` waits for the machine's
+/// handshake before it goes (`AppNotifier._sendTerminalFrame`), and a fake socket never has one:
+/// left to wait, the open would still be held when the test looks.
+class _HandshakenConn extends PagerConn {
+ @override
+ Future<void> waitUntilReady({required Duration timeout}) async {}
+}
+
/// Arriving on an agent TAKES its terminal.
///
/// ⚠️ **Why this has a test of its own.** The phone asked politely for a while, and what that
@@ -41,7 +49,7 @@ void main() {
}
testWidgets('opening an agent claims its terminal', (tester) async {
- final conn = PagerConn();
+ final conn = _HandshakenConn();
final app = pagerApp(conn);
addTearDown(app.dispose);
@@ -61,7 +69,7 @@ void main() {
});
testWidgets('a tile opened ahead of the thumb asks politely', (tester) async {
- final conn = PagerConn();
+ final conn = _HandshakenConn();
final app = pagerApp(conn);
addTearDown(app.dispose);
// A guess is only made where the daemon honours the key at all — see [warmAgentPane].
diff --git a/mobile/test/phone_search_test.dart b/mobile/test/phone_search_test.dart
index a93825c4f..c697336fe 100644
--- a/mobile/test/phone_search_test.dart
+++ b/mobile/test/phone_search_test.dart
@@ -7,6 +7,7 @@ import 'package:harness_mobile/core/config.dart';
import 'package:harness_mobile/core/models.dart';
import 'package:harness_mobile/phone/agent_index.dart';
import 'package:harness_mobile/phone/agents_list_page.dart';
+import 'package:harness_mobile/phone/find_row.dart';
import 'package:harness_mobile/phone/phone_destination.dart';
import 'package:harness_mobile/phone/phone_search_catalog.dart';
import 'package:harness_mobile/phone/phone_search_controller.dart';
@@ -192,7 +193,7 @@ class _SearchConn extends WsConn {
}
/// A machine answering `agent_recent` with what was asked of each agent, and
-/// nothing else.
+/// `session_search` from the same words — its own index — and nothing else.
class _RecentConn extends WsConn {
_RecentConn(this.asks)
: super(
@@ -221,6 +222,26 @@ class _RecentConn extends WsConn {
Map<String, dynamic> payload = const {},
Duration timeout = const Duration(seconds: 20),
}) async {
+ // What Find searches what was said with, since it reads no previews of its
+ // own (`PhoneSearchController.contentHitFor`).
+ if (type == 'session_search') {
+ final query = (payload['query'] as String).toLowerCase();
+ return {
+ 'hits': [
+ for (final MapEntry(key: agentId, value: said) in asks.entries)
+ for (final ask in said)
+ if (ask.toLowerCase().contains(query))
+ {
+ 'agentId': agentId,
+ 'sessionId': 'session-$agentId',
+ 'field': 'ask',
+ 'snippet': ask,
+ 'together': true,
+ 'score': 1,
+ },
+ ],
+ };
+ }
// ⚠️ A real [WsConn] completes an error reply as an error (`ws_conn.dart`),
// never as a map. Returning one here let `agents_list` read `agents: null`
// as "this machine has no agents" and wipe the list the test had set up.
@@ -373,11 +394,20 @@ List<PhoneDestination> _rank(
);
/// Find as the terminal puts it up — the phone's one search — all the way open.
-Widget _findOver(AppNotifier app, {VoidCallback? onClose}) => MaterialApp(
+///
+/// ⚠️ [AlwaysStoppedAnimation] stands at 1 but says it is still on its way
+/// (`forward`), so the reach for the fleet that waits for the slide to finish
+/// (`PhoneSearchResults._reachOnceOpen`) never starts. Pass
+/// [kAlwaysCompleteAnimation] for a test that needs it.
+Widget _findOver(
+ AppNotifier app, {
+ VoidCallback? onClose,
+ Animation<double> animation = const AlwaysStoppedAnimation(1),
+}) => MaterialApp(
home: Scaffold(
body: TerminalSearchOverlay(
notifier: app,
- animation: const AlwaysStoppedAnimation(1),
+ animation: animation,
onClose: onClose ?? () {},
),
),
@@ -386,6 +416,21 @@ Widget _findOver(AppNotifier app, {VoidCallback? onClose}) => MaterialApp(
/// A Find row's name, or any other line Find draws as rich text.
Finder _row(String text) => find.text(text, findRichText: true);
+/// A Find row's state word, at the end of its first line: alone, or ahead of
+/// the row's age (`paused · 1m`).
+Finder _state(String word) =>
+ find.textContaining(RegExp('^${RegExp.escape(word)}( · |\$)'));
+
+/// The state word of the Find row named [title]: null for a harness with
+/// nothing to say — idle, whose first line ends in its age alone.
+String? _stateOf(WidgetTester tester, String title) => tester
+ .widget<FindRow>(
+ find.byWidgetPredicate(
+ (widget) => widget is FindRow && widget.title == title,
+ ),
+ )
+ .state;
+
void main() {
group('Agent.fromJson', () {
test('reads the title and when the conversation last moved', () {
@@ -562,6 +607,14 @@ void main() {
},
});
await _settle();
+ // Marked, not read: nothing reads previews in the background any more
+ // (owner, 2026-10-01). The next screen that asks reads it again, though
+ // well inside freshFor.
+ expect(conn.asked, ['live']);
+ app.sessionPreviews.warm([
+ app.previewKey('box', app.machineStates['box']!.agents.single),
+ ]);
+ await _settle();
expect(conn.asked, ['live', 'live']);
expect(_agentIds(_rank(app, 'deploy')), ['live']);
},
@@ -770,7 +823,10 @@ void main() {
await tester.enterText(find.byType(TextField), '@');
await tester.pump();
- expect(_row('Machine · 2 harnesses'), findsOneWidget);
+ // The machine's state is the word at the row's right edge; the line under
+ // its name says what it holds.
+ expect(_row('2 harnesses'), findsOneWidget);
+ expect(_state('ready'), findsOneWidget);
});
testWidgets('> runs a command by name', (tester) async {
@@ -916,11 +972,12 @@ void main() {
await tester.pump();
// Taps wait for the resume, but the live agent still HAS its terminal — `exited` over it
- // would be a claim about the agent that the in-flight resume had nothing to do with.
+ // would be a claim about the agent that the in-flight resume had nothing to do with. Idle,
+ // it has no word at all (owner, 2026-09-30).
expect(conn.resumed, ['saved']);
- expect(find.text('resuming'), findsOneWidget);
- expect(find.text('exited'), findsNothing);
- expect(find.text('idle'), findsOneWidget);
+ expect(_state('resuming'), findsOneWidget);
+ expect(_state('exited'), findsNothing);
+ expect(_stateOf(tester, 'work · live'), isNull);
// The list's own notify debounce, so no timer outlives the test.
await tester.pump(const Duration(milliseconds: 100));
});
@@ -939,8 +996,8 @@ void main() {
await tester.pump();
// `paused` would promise a resume the machine can only refuse.
- expect(find.text('stopped'), findsOneWidget);
- expect(find.text('paused'), findsNothing);
+ expect(_state('stopped'), findsOneWidget);
+ expect(_state('paused'), findsNothing);
final blank = _agentRows(app)
.firstWhere((row) => row.entry!.agent.id == 'blank');
expect(blank.entry!.isOpenable, isFalse);
@@ -967,8 +1024,8 @@ void main() {
// The desktop's `canPauseAndResume`: a current daemon resumes every engine, some as a new
// conversation, so the row is paused work a tap brings back.
- expect(find.text('paused'), findsOneWidget);
- expect(find.text('stopped'), findsNothing);
+ expect(_state('paused'), findsOneWidget);
+ expect(_state('stopped'), findsNothing);
expect(_agentRows(app).single.entry!.isOpenable, isTrue);
await tester.pump(const Duration(milliseconds: 100));
});
@@ -986,8 +1043,8 @@ void main() {
// `paused` says a tap will bring it back; `exited` would say a tap does
// nothing. The two must not be confused for each other.
- expect(find.text('paused'), findsOneWidget);
- expect(find.text('exited'), findsNothing);
+ expect(_state('paused'), findsOneWidget);
+ expect(_state('exited'), findsNothing);
});
});
@@ -1203,7 +1260,10 @@ void main() {
final app = _app([box, lab], connFor: (machineId) => conns[machineId]!);
addTearDown(app.dispose);
- await tester.pumpWidget(_findOver(app));
+ // All the way up: the reach waits for Find's slide to finish.
+ await tester.pumpWidget(
+ _findOver(app, animation: kAlwaysCompleteAnimation),
+ );
await tester.pump(const Duration(milliseconds: 100));
// Opening the search asked BOTH — the whole point. Before this it asked
@@ -1422,7 +1482,7 @@ void main() {
);
testWidgets(
- 'opening search warms content, and what was asked finds a harness',
+ 'opening search reads no previews, and what was asked still finds a harness',
(tester) async {
final conn = _RecentConn({
'3188': ['which llama.cpp build is running?'],
@@ -1437,13 +1497,22 @@ void main() {
await tester.pumpWidget(_findOver(app));
// The store publishes on an 80 ms beat, as on the desktop.
await tester.pump(const Duration(milliseconds: 100));
- expect(conn.asked, ['3188', '2312']);
+ // ⚠️ No `agent_recent` reads from Find, on opening or per row (owner,
+ // 2026-10-01): they queued on the relay ahead of the terminal being
+ // attached.
+ expect(conn.asked, isEmpty);
- // What was asked of 3188 is what finds it: neither name says `llama`.
+ // What was asked of 3188 is what finds it — through its machine's own
+ // index (`session_search`): neither name says `llama`.
await tester.enterText(find.byType(TextField), 'llama');
+ await tester.pump(const Duration(milliseconds: 300));
await tester.pump();
expect(_row('work · 3188'), findsOneWidget);
expect(_row('work · 2312'), findsNothing);
+ expect(conn.asked, isEmpty);
+ // Typing asks the machines: let their timers run out.
+ await tester.pumpWidget(const SizedBox());
+ await tester.pump(const Duration(seconds: 30));
},
);
diff --git a/mobile/test/sample_mode_test.dart b/mobile/test/sample_mode_test.dart
index 30924ae15..97c278183 100644
--- a/mobile/test/sample_mode_test.dart
+++ b/mobile/test/sample_mode_test.dart
@@ -96,7 +96,15 @@ void main() {
expect(find.text('Sample'), findsOneWidget);
final dot = find.byKey(const ValueKey('sample-guide-dot'));
final dotBefore = tester.getRect(dot);
- expect(dotBefore.left, 12);
+ // The dot and its words stand centred over the mic, as the mic is centred.
+ final words = find.descendant(
+ of: find.ancestor(of: dot, matching: find.byType(Row)).first,
+ matching: find.byType(Text),
+ );
+ expect(
+ (dotBefore.left + tester.getRect(words).right) / 2,
+ moreOrLessEquals(tester.getCenter(find.byType(VoiceMicCore)).dx),
+ );
await settle(tester, const Duration(seconds: 6));
expect(
tester.getRect(dot),
@@ -187,7 +195,9 @@ void main() {
await open(tester, 'sample-refactor-db');
expect(screenOf(notifier, 'sample-refactor-db'), contains('❯ 1. Yes'));
- await tester.tap(find.textContaining('1 yes', findRichText: true).first);
+ // Pressed where it is read: each answer is a band over its own lines, a button to a screen
+ // reader as well — there are no answer keys beside the mic.
+ tester.semantics.tap(find.semantics.byLabel(RegExp('^Answer 1 ')));
await settle(tester, const Duration(seconds: 12));
final screen = screenOf(notifier, 'sample-refactor-db');
@@ -221,11 +231,13 @@ void main() {
) async {
final notifier = await openSample(tester);
- // New is a swipe left from the terminal.
+ // New is the button at Find's foot, and Find a swipe right from the terminal.
await tester.dragFrom(
- tester.getCenter(find.byType(TerminalPage).first) + const Offset(120, 0),
- const Offset(-240, 0),
+ tester.getCenter(find.byType(TerminalPage).first) - const Offset(120, 0),
+ const Offset(300, 0),
);
+ await settle(tester, const Duration(milliseconds: 600));
+ await tester.tap(find.byKey(const ValueKey('find-new-harness')));
await settle(tester, const Duration(seconds: 1));
await tester.tap(find.text('project'));
await settle(tester, const Duration(milliseconds: 500));
diff --git a/mobile/test/terminal_painter_test.dart b/mobile/test/terminal_painter_test.dart
index 91821f9d8..0f4234c96 100644
--- a/mobile/test/terminal_painter_test.dart
+++ b/mobile/test/terminal_painter_test.dart
@@ -37,7 +37,10 @@ void main() {
}
test('a space costs no glyph', () {
- expect(glyphsDrawnFor('a b '), 2);
+ // `a b` is one run ([GlyphRun]): the blanks between ride in it, and the
+ // ones after it are not drawn.
+ expect(glyphsDrawnFor('a b '), 1);
+ expect(glyphsDrawnFor(' '), 0);
});
test('an underlined space still draws its underline', () {
diff --git a/mobile/test/terminal_panel_phone_test.dart b/mobile/test/terminal_panel_phone_test.dart
index 4655393a4..20d1ba904 100644
--- a/mobile/test/terminal_panel_phone_test.dart
+++ b/mobile/test/terminal_panel_phone_test.dart
@@ -188,6 +188,14 @@ void main() {
TerminalView view(WidgetTester tester) =>
tester.widget<TerminalView>(find.byType(TerminalView));
+ /// The frames the pane's menu (Copy, Select All) takes to follow the
+ /// selection: shown or hidden after the frame the change lands in, from the
+ /// app's root overlay, and built or taken down in the one after.
+ Future<void> pumpMenu(WidgetTester tester) async {
+ await tester.pump();
+ await tester.pump();
+ }
+
/// The rendered row height — `RenderTerminal` itself is not exported.
double lineHeight(WidgetTester tester) => tester
.state<TerminalViewState>(find.byType(TerminalView))
@@ -283,6 +291,8 @@ void main() {
view(tester).terminal.buffer.lines[0].getText(),
startsWith('the screen after the resize'),
);
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
});
testWidgets('keeps a reader at the end at the end', (tester) async {
@@ -298,6 +308,8 @@ void main() {
final position = scroll(tester);
expect(position.pixels, position.maxScrollExtent);
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
});
testWidgets('keeps a reader in the history on the line they were reading', (
@@ -326,6 +338,8 @@ void main() {
reason: 'the screen moved under the reader, not the reader',
);
expect(scroll(tester).pixels, lessThan(scroll(tester).maxScrollExtent));
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
});
testWidgets('keeps a selection whose text is still there', (tester) async {
@@ -336,7 +350,7 @@ void main() {
final before = view(tester).terminal.buffer;
view(tester).controller!
.setSelection(before.createAnchor(0, 2), before.createAnchor(14, 2));
- await tester.pump();
+ await pumpMenu(tester);
expect(find.text('Copy'), findsOneWidget);
await keyframe(tester, pane, 1, lines(8));
@@ -346,6 +360,8 @@ void main() {
final selection = view(tester).controller!.selection;
expect(selection, isNotNull);
expect(view(tester).terminal.buffer.getText(selection), 'history line 2');
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
});
testWidgets('lets a selection go when its text is not', (tester) async {
@@ -356,7 +372,8 @@ void main() {
final before = view(tester).terminal.buffer;
view(tester).controller!
.setSelection(before.createAnchor(0, 2), before.createAnchor(14, 2));
- await tester.pump();
+ await pumpMenu(tester);
+ expect(find.text('Copy'), findsOneWidget);
await keyframe(tester, pane, 1, lines(8, from: 50));
await tester.pump();
@@ -364,6 +381,8 @@ void main() {
expect(view(tester).controller!.selection, isNull);
expect(find.text('Copy'), findsNothing);
+ // The session's wait for a screen of the size it asked for runs out.
+ await tester.pump(const Duration(seconds: 2));
});
// Back puts the keyboard away without a word to the app: the terminal keeps its focus and its
@@ -418,15 +437,20 @@ void main() {
testWidgets('copies what is selected and lets it go', (tester) async {
final platform = _Platform(tester);
final pane = session();
- pane.terminal.write('npm test\r\nall 42 passed');
+ // At the foot of the screen: the menu shows nothing while what it is
+ // about is scrolled out of the pane.
+ pane.terminal.write('${_blank}npm test\r\nall 42 passed');
await pumpPanel(tester, pane);
final buffer = pane.terminal.buffer;
- view(tester).controller!
- .setSelection(buffer.createAnchor(0, 1), buffer.createAnchor(13, 1));
- await tester.pump();
+ final row = buffer.lines.length - 1;
+ view(tester).controller!.setSelection(
+ buffer.createAnchor(0, row),
+ buffer.createAnchor(13, row),
+ );
+ await pumpMenu(tester);
await tester.tap(find.text('Copy'));
- await tester.pump();
+ await pumpMenu(tester);
expect(platform.copied, 'all 42 passed');
expect(view(tester).controller!.selection, isNull);
@@ -437,21 +461,30 @@ void main() {
);
});
- testWidgets('× lets it go without copying', (tester) async {
+ testWidgets('a tap lets it go without copying', (tester) async {
final platform = _Platform(tester);
final pane = session();
- pane.terminal.write('npm test');
+ pane.terminal.write('${_blank}npm test');
await pumpPanel(tester, pane);
final buffer = pane.terminal.buffer;
- view(tester).controller!
- .setSelection(buffer.createAnchor(0, 0), buffer.createAnchor(3, 0));
- await tester.pump();
+ final row = buffer.lines.length - 1;
+ view(tester).controller!.setSelection(
+ buffer.createAnchor(0, row),
+ buffer.createAnchor(3, row),
+ );
+ await pumpMenu(tester);
+ expect(find.text('Copy'), findsOneWidget);
- await tester.tap(find.bySemanticsLabel('Clear selection'));
- await tester.pump();
+ // The system's menu has no button for it: a tap on the terminal, away
+ // from the selection's handles, lets it go as it would in a text field.
+ await tester.tap(find.byType(TerminalView));
+ // Past the double-tap window, which is what holds a single tap back.
+ await tester.pump(kDoubleTapTimeout);
+ await pumpMenu(tester);
expect(platform.copied, isNull);
expect(view(tester).controller!.selection, isNull);
+ expect(find.text('Copy'), findsNothing);
});
});
diff --git a/mobile/test/terminal_session_protocol_test.dart b/mobile/test/terminal_session_protocol_test.dart
index 5218f6739..c0d0169ba 100644
--- a/mobile/test/terminal_session_protocol_test.dart
+++ b/mobile/test/terminal_session_protocol_test.dart
@@ -1008,16 +1008,22 @@ void main() {
});
test(
- 'clearing the prompt is ctrl-E then ctrl-U, and the keyboard\'s buffer',
+ 'clearing the prompt is ctrl-K then ctrl-U, and the keyboard\'s buffer',
() async {
- final (s, _) = await live();
+ // A prompt two rows from the foot of the screen, its footer under it
+ // and the cursor back in it, as Claude Code draws one.
+ final (s, _) = await live(
+ screen: '${'\r\n' * 22}❯ fix it\r\n ? for shortcuts\x1b[23;9H',
+ );
final viewport = _Viewport();
s.attachViewport(viewport);
s.clearPrompt();
- await until(() => _typed(wire).length == 2);
+ await until(() => _typed(wire).length == 8);
- expect(_typed(wire), '\x05\x15');
+ // One kill is one row as wrapped, and a kill past the prompt's ends
+ // does nothing — so two each way for each of its two rows.
+ expect(_typed(wire), '${'\x0b' * 4}${'\x15' * 4}');
expect(viewport.cleared, 1);
s.detachViewport(_Viewport());
s.resetInputBuffer();
diff --git a/mobile/test/ws/fake_relay.dart b/mobile/test/ws/fake_relay.dart
index b03d250ef..b0745041a 100644
--- a/mobile/test/ws/fake_relay.dart
+++ b/mobile/test/ws/fake_relay.dart
@@ -62,7 +62,9 @@ class FakeRelay {
/// Close each new socket with this code as soon as the phone selects.
int? closeOnSelect;
- /// Never answer the select.
+ /// Never answer the select — nor the hello the phone sends right behind it: the real relay
+ /// takes a socket's frames strictly in order (`backend/src/lib/orderedInbox.ts`), so nothing
+ /// queued behind a select it is stuck on ever reaches the machine.
bool silentOnSelect = false;
/// Answer the hello with `e2e_denied` instead.
@@ -153,6 +155,8 @@ class FakeRelay {
},
});
case 'e2e_hello':
+ // Behind a select the relay never answered — see [silentOnSelect].
+ if (silentOnSelect) break;
if (deny) {
link.send({
'type': 'e2e_denied',