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): one word per machine state, copy and connectors fixes

tony9ea8aeef0ec5
diff --git a/mobile/lib/phone/approve_sign_in.dart b/mobile/lib/phone/approve_sign_in.dart
index df840180e..a617282b8 100644
--- a/mobile/lib/phone/approve_sign_in.dart
+++ b/mobile/lib/phone/approve_sign_in.dart
@@ -62,10 +62,11 @@ Future<void> approveComputerSignIn(
);
return;
}
+ final label = asking['label'] is String ? (asking['label'] as String).trim() : '';
final answer = await showAppDialog<_Answer>(
context: context,
builder: (_) => _ApproveDialog(
- label: (asking['label'] as String?)?.trim().isNotEmpty == true ? asking['label'] as String : 'A computer',
+ label: label.isEmpty ? null : label,
computer: asking['kind'] == 'computer',
sameNetwork: asking['sameNetwork'] == true,
where: [
@@ -144,11 +145,19 @@ class _ApproveDialog extends StatelessWidget {
required this.where,
});
- final String label;
+ /// The name it gave itself; null when it gave none.
+ final String? label;
final bool computer;
final bool sameNetwork;
final String where;
+ /// Its name when it gave one, else what it is: a name-shaped "A computer" made "Sign in A
+ /// computer?", and said "computer" of an app too.
+ String get _title => switch (label) {
+ final label? => 'Sign in $label?',
+ null => computer ? 'Sign in a computer?' : 'Sign in an app?',
+ };
+
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
@@ -183,7 +192,7 @@ class _ApproveDialog extends StatelessWidget {
const SizedBox(width: 14),
Expanded(
child: Text(
- 'Sign in $label?',
+ _title,
key: const Key('approve-sign-in-title'),
style: TextStyle(
color: AppPalette.textPrimary,
diff --git a/mobile/lib/phone/connectors_page.dart b/mobile/lib/phone/connectors_page.dart
index a6bee70bc..d229e6b9b 100644
--- a/mobile/lib/phone/connectors_page.dart
+++ b/mobile/lib/phone/connectors_page.dart
@@ -61,10 +61,21 @@ class _ConnectorsPageState extends State<ConnectorsPage>
String? _machineId;
List<_Card>? _cards;
String _query = '';
- String _notice = '';
bool _loading = false;
final Set<String> _busy = {};
+ /// Whether [_machineId] passes a connection on to the account's other computers (`list` `shared`):
+ /// one that keeps them to itself is used only when no other answers ([_pickReachable]), and the
+ /// messages must not promise "all your computers" for it.
+ bool _shared = false;
+
+ /// What the last action came to, or why the list could not be read. Set through [_say].
+ String _notice = '';
+ Timer? _noticeTimer;
+
+ /// How long an action's outcome stays, as on the desktop (`connectors_controller.dart`).
+ static const _noticeFor = Duration(seconds: 20);
+
AppNotifier get _app => widget.notifier;
@override
@@ -77,11 +88,25 @@ class _ConnectorsPageState extends State<ConnectorsPage>
@override
void dispose() {
+ _noticeTimer?.cancel();
WidgetsBinding.instance.removeObserver(this);
_app.removeListener(_machinesMayHaveChanged);
super.dispose();
}
+ /// Sets the notice; call inside `setState`. [fades]: an action's outcome ("Linear connected…"),
+ /// gone after [_noticeFor] — a "disconnected" from an hour ago still stood there. A list that could
+ /// not be read keeps its reason: with no list under it, that is all the page says.
+ void _say(String text, {bool fades = false}) {
+ _notice = text;
+ _noticeTimer?.cancel();
+ _noticeTimer = null;
+ if (!fades || text.isEmpty) return;
+ _noticeTimer = Timer(_noticeFor, () {
+ if (mounted) setState(() => _notice = '');
+ });
+ }
+
/// Back from the browser (or from anywhere): a sign-in may have finished while this page was
/// hidden, so read the connections again rather than wait for a pull.
@override
@@ -123,7 +148,7 @@ class _ConnectorsPageState extends State<ConnectorsPage>
setState(() {
_machineId = machineId;
_lastMachine = machineId;
- _notice = '';
+ _say('');
});
_show(reply);
}
@@ -149,6 +174,7 @@ class _ConnectorsPageState extends State<ConnectorsPage>
void _show(Map<String, dynamic> reply) {
setState(() {
_loading = false;
+ _shared = reply['shared'] == true;
_cards = (reply['connections'] as List? ?? const [])
.whereType<Map>()
.map((row) => _Card(row.cast<String, dynamic>()))
@@ -173,7 +199,7 @@ class _ConnectorsPageState extends State<ConnectorsPage>
setState(() {
_loading = false;
_cards = null;
- _notice = _failure(reply);
+ _say(_failure(reply));
});
return;
}
@@ -210,7 +236,7 @@ class _ConnectorsPageState extends State<ConnectorsPage>
_machineId = machine.machine.machineId;
_lastMachine = _machineId;
_cards = null;
- _notice = '';
+ _say('');
});
unawaited(_refresh());
},
@@ -225,7 +251,7 @@ class _ConnectorsPageState extends State<ConnectorsPage>
if (machineId == null || _busy.contains(card.code)) return;
setState(() {
_busy.add(card.code);
- _notice = '';
+ _say('');
});
HttpServer? loopback;
try {
@@ -250,11 +276,11 @@ class _ConnectorsPageState extends State<ConnectorsPage>
);
if (!opened) throw _Notice('Could not open the browser.');
}
- final outcome = await _follow(machineId, flow);
+ final outcome = await _follow(machineId, flow, card.name);
if (!mounted) return;
- setState(() => _notice = outcome);
+ setState(() => _say(outcome, fades: true));
} on _Notice catch (notice) {
- if (mounted) setState(() => _notice = notice.text);
+ if (mounted) setState(() => _say(notice.text, fades: true));
} finally {
await loopback?.close(force: true);
if (mounted) setState(() => _busy.remove(card.code));
@@ -331,8 +357,9 @@ class _ConnectorsPageState extends State<ConnectorsPage>
}
}
- /// The computer finishes the sign-in on its own; this follows it for up to six minutes.
- Future<String> _follow(String machineId, String flow) async {
+ /// The computer finishes the sign-in on its own; this follows it for up to six minutes. [name] is
+ /// the service's, for the desktop's words when it is done.
+ Future<String> _follow(String machineId, String flow, String name) async {
final deadline = DateTime.now().add(const Duration(minutes: 6));
while (mounted && DateTime.now().isBefore(deadline)) {
await Future<void>.delayed(const Duration(seconds: 1));
@@ -345,8 +372,10 @@ class _ConnectorsPageState extends State<ConnectorsPage>
if (reply['error'] == 'UNAVAILABLE') continue;
if (reply['error'] != null) return _failure(reply);
switch (reply['state']) {
+ // The desktop's words (`connectors_controller.dart`): no "on all your computers", which a
+ // computer that keeps its connections to itself ([_shared] false) would not make true.
case 'connected':
- return 'Connected on all your computers.';
+ return '$name connected. Your agents can use it now.';
case 'failed':
return reply['reason'] as String? ??
'The sign-in did not finish. Try again.';
@@ -427,18 +456,42 @@ class _ConnectorsPageState extends State<ConnectorsPage>
);
}
+ /// Where a connection made or taken away through [_machineId] reaches: every computer of the
+ /// account, or that one alone ([_shared]).
+ String get _where =>
+ _shared ? 'all your computers' : _machineName(_machineId);
+
+ /// Asked first, as on the desktop (`connectors_section.dart`): it takes the account from the
+ /// agents at once, and the service itself still trusts it until revoked there.
Future<void> _disconnect(_Card card) async {
final machineId = _machineId;
if (machineId == null) return;
+ // Read before the question and kept after it: the answer is about the computer it named, even if
+ // the page moved to another while it was up (back in front, it looks for one that answers).
+ final where = _where;
+ final confirmed = await confirmPhoneAction(
+ context,
+ // The sheet row's own icon — see [confirmPhoneAction].
+ icon: LucideIcons.unplug300,
+ title: 'Disconnect ${card.name}?',
+ message:
+ 'Agents on $where stop using this account. To revoke it everywhere, use the '
+ 'service’s settings.',
+ confirmLabel: 'Disconnect',
+ );
+ if (!confirmed || !mounted) return;
final reply = await _app.connectors(machineId, {
'action': 'disconnect',
'connector': card.code,
});
if (!mounted) return;
setState(
- () => _notice = reply['error'] != null
- ? _failure(reply)
- : '${card.name} disconnected on all your computers.',
+ () => _say(
+ reply['error'] != null
+ ? _failure(reply)
+ : '${card.name} disconnected on $where.',
+ fades: true,
+ ),
);
await _refresh();
}
diff --git a/mobile/lib/phone/device_detail_page.dart b/mobile/lib/phone/device_detail_page.dart
index 038ec763a..98538d051 100644
--- a/mobile/lib/phone/device_detail_page.dart
+++ b/mobile/lib/phone/device_detail_page.dart
@@ -14,6 +14,11 @@ import 'settings_row.dart';
import 'tty.dart';
import 'tty_controls.dart';
+/// The answer to a new device — on its page here and on the "New device" banner, as the desktop's
+/// own band and page say it (`desktop/lib/widgets/new_device_notice.dart`,
+/// `account_device_detail.dart`).
+const kItsMine = 'It’s mine';
+
/// One device in full: its facts, its whole key code to compare on that device, and what to do about
/// it. [isNew] offers "It’s mine"; [onMine] tells the page that opened this one it was used.
class DeviceDetailPage extends StatefulWidget {
@@ -196,7 +201,7 @@ class _DeviceDetailPageState extends State<DeviceDetailPage> {
if (widget.isNew)
SettingsRow(
key: const Key('device-detail-mine'),
- title: 'It’s mine',
+ title: kItsMine,
onTap: _removing ? null : _mine,
),
if (!_row.self)
diff --git a/mobile/lib/phone/find_row.dart b/mobile/lib/phone/find_row.dart
index 26b44c2e8..5bc014f71 100644
--- a/mobile/lib/phone/find_row.dart
+++ b/mobile/lib/phone/find_row.dart
@@ -91,7 +91,7 @@ class FindRow extends StatelessWidget {
static const double height = 60;
/// [height], or less for a row of one line where its second has been said once for a group of
- /// them — Computers' asleep ones. Never under a thumb's 44.
+ /// them — Computers' offline ones. Never under a thumb's 44.
final double minHeight;
/// Above line 1 and below line 2.
diff --git a/mobile/lib/phone/machine_profile_picker.dart b/mobile/lib/phone/machine_profile_picker.dart
index 13aa92113..60612fb1a 100644
--- a/mobile/lib/phone/machine_profile_picker.dart
+++ b/mobile/lib/phone/machine_profile_picker.dart
@@ -15,8 +15,9 @@ String machineProfileLabel(AppNotifier notifier) {
return notifier.stateOf(id)?.machine.displayName ?? 'One computer';
}
-/// Settings ▸ Profile: show every computer's tabs, or only one computer's — the desktop's Profiles
-/// section (`desktop/lib/settings/sections/profiles_section.dart`) as a phone sheet.
+/// Settings ▸ Profile: show every computer's tabs, or only one computer's — the desktop's "Show in
+/// this window" at the top of its Machines picker (`MachineWindowChoice`,
+/// `desktop/lib/widgets/machine_picker_extras.dart`) as a phone sheet.
///
/// One sign-in, one desk: picking a computer hides the other computers' tabs on THIS phone only
/// ([AppNotifier.setMachineProfile]). A tab is that computer's when every harness on it runs there.
@@ -60,12 +61,9 @@ PhoneSheetAction _choice(
final picked = id == chosen;
final status = phoneMachineStatusOf(machine);
// The words the Computers page uses for the same states, so a row reads the same in both places.
- final unavailable = switch (status) {
- PhoneMachineStatus.ready => null,
- PhoneMachineStatus.connecting => 'connecting',
- PhoneMachineStatus.needsPassword => 'locked',
- PhoneMachineStatus.offline => 'asleep',
- };
+ final unavailable = status == PhoneMachineStatus.ready
+ ? null
+ : phoneMachineWord(status);
return PhoneSheetAction(
icon: picked ? LucideIcons.check300 : LucideIcons.laptopMinimal300,
label: machine.machine.displayName,
diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dart
index 22765b09b..acc5e1162 100644
--- a/mobile/lib/phone/machines_tab.dart
+++ b/mobile/lib/phone/machines_tab.dart
@@ -237,8 +237,8 @@ class _Body extends StatelessWidget {
}
/// [ordered]'s rows — each run of computers that want the same thing under one line that says it
- /// once, `asleep · turn them on, or run harness start there`, rather than the same words under
- /// every row: six asleep computers said it six times, half the screen of one sentence.
+ /// once, `offline · turn them on, or run harness start there`, rather than the same words under
+ /// every row: six offline computers said it six times, half the screen of one sentence.
///
/// A run of one keeps its own second line: a header over a single row is two lines saying what
/// one did, and in the singular. The working ones each say their own thing — how many harnesses —
@@ -270,16 +270,16 @@ class _Body extends StatelessWidget {
return rows;
}
- /// What a run of computers in [status] is called over it, and what to do about them, said once —
- /// null for the ones that need nothing.
+ /// What a run of computers in [status] is called over it ([phoneMachineWord]), and what to do
+ /// about them, said once — null for the ones that need nothing.
static ({String word, String hint})? _groupOf(PhoneMachineStatus status) =>
switch (status) {
PhoneMachineStatus.needsPassword => (
- word: 'locked',
+ word: phoneMachineWord(status),
hint: 'tap one to unlock: scan its code',
),
PhoneMachineStatus.offline => (
- word: 'asleep',
+ word: phoneMachineWord(status),
hint: 'turn them on, or run harness start there',
),
PhoneMachineStatus.ready || PhoneMachineStatus.connecting => null,
@@ -307,22 +307,20 @@ class _Body extends StatelessWidget {
final status = phoneMachineStatusOf(state);
final count = state.agents.length;
final machineId = state.machine.machineId;
- var (String word, Color color, String detail) = switch (status) {
+ var word = phoneMachineWord(status);
+ var (Color color, String detail) = switch (status) {
PhoneMachineStatus.ready => (
- 'ready',
tty.green,
count == 0
? 'nothing running'
: '$count harness${count == 1 ? '' : 'es'}',
),
- PhoneMachineStatus.connecting => ('connecting', tty.faint, 'one moment…'),
+ PhoneMachineStatus.connecting => (tty.faint, 'one moment…'),
PhoneMachineStatus.needsPassword => (
- 'locked',
tty.yellow,
'tap to unlock: scan its code',
),
PhoneMachineStatus.offline => (
- 'asleep',
tty.faint,
'turn it on, or run harness start there',
),
@@ -340,7 +338,7 @@ class _Body extends StatelessWidget {
minHeight: ownLine ? FindRow.height : _gatheredRowHeight,
state: word,
stateColor: color,
- // ⚠️ An asleep computer is tappable now. It used to be drawn inert, with nothing a tap could do
+ // ⚠️ An offline computer is tappable now. It used to be drawn inert, with nothing a tap could do
// for it — and it is exactly the one somebody wants to try again, rename, or take off the
// account.
onTap: () => _open(context, state),
@@ -355,7 +353,7 @@ class _Body extends StatelessWidget {
}
/// Over a run of computers that want the same thing: what they are, then what to do about them —
-/// `asleep · turn them on, or run harness start there` — said once for the run.
+/// `offline · turn them on, or run harness start there` — said once for the run.
class _GroupLine extends StatelessWidget {
const _GroupLine({required this.word, required this.hint});
diff --git a/mobile/lib/phone/new_device_banner.dart b/mobile/lib/phone/new_device_banner.dart
index c026281de..486e8daad 100644
--- a/mobile/lib/phone/new_device_banner.dart
+++ b/mobile/lib/phone/new_device_banner.dart
@@ -6,6 +6,7 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'package:harness_mobile/viewer/device_log_sync.dart';
+import 'device_detail_page.dart' show kItsMine;
import 'device_history_page.dart';
import 'devices_page.dart';
import 'phone_navigation.dart' show phoneRoute;
@@ -152,12 +153,12 @@ class NewDeviceBanner extends StatelessWidget {
),
TextButton(
// A key a fork suspended stays suspended however often the banner is dismissed (the next
- // read of the log would bring it back), so "Mine" opens its page, which says why and
- // is where the person can vouch for it.
+ // read of the log would bring it back), so "It’s mine" opens its page, which says why
+ // and is where the person can vouch for it.
onPressed: () => notifier.newDeviceSuspended(m.pub)
? unawaited(_open(m.pub))
: notifier.dismissNewDevice(m.pub),
- child: const Text('Mine'),
+ child: const Text(kItsMine),
),
TextButton(
// One new device goes straight to its key code; several go to the list, where each is a row.
diff --git a/mobile/lib/phone/phone_search_results.dart b/mobile/lib/phone/phone_search_results.dart
index a4c9eff8c..7c6a9bb33 100644
--- a/mobile/lib/phone/phone_search_results.dart
+++ b/mobile/lib/phone/phone_search_results.dart
@@ -605,27 +605,22 @@ class PhoneSearchResultsState extends State<PhoneSearchResults> {
) {
final machine = row.machine;
if (machine == null) return null;
- return switch (phoneMachineStatusOf(machine)) {
- PhoneMachineStatus.ready => (
- word: 'online',
- color: tty.green,
- asks: false,
- ),
+ final status = phoneMachineStatusOf(machine);
+ // Computers' word for the same state ([phoneMachineWord]), so a computer reads the same here.
+ final word = phoneMachineWord(status);
+ return switch (status) {
+ PhoneMachineStatus.ready => (word: word, color: tty.green, asks: false),
PhoneMachineStatus.needsPassword => (
- word: 'locked',
+ word: word,
color: tty.yellow,
asks: true,
),
PhoneMachineStatus.connecting => (
- word: 'connecting',
- color: tty.faint,
- asks: false,
- ),
- PhoneMachineStatus.offline => (
- word: 'offline',
+ word: word,
color: tty.faint,
asks: false,
),
+ PhoneMachineStatus.offline => (word: word, color: tty.faint, asks: false),
};
}
diff --git a/mobile/lib/phone/phone_shell.dart b/mobile/lib/phone/phone_shell.dart
index b95dd36e7..f421ed08e 100644
--- a/mobile/lib/phone/phone_shell.dart
+++ b/mobile/lib/phone/phone_shell.dart
@@ -150,9 +150,9 @@ class _PhoneShellState extends State<PhoneShell> with WidgetsBindingObserver {
setState(() => _canPop = false);
}
- /// The computer whose "Scan with your phone" QR the welcome screen read before this phone was
- /// signed in ([AppNotifier.pendingComputerSignIn]): the approval it asked for, now that it can be
- /// given. Spent here whatever the answer — a code is one computer's sign-in, once.
+ /// The computer whose sign-in QR (`harness login --qr`) the welcome screen read before this phone
+ /// was signed in ([AppNotifier.pendingComputerSignIn]): the approval it asked for, now that it can
+ /// be given. Spent here whatever the answer — a code is one computer's sign-in, once.
///
/// From this shell's context and not a page's: the home page under it is still settling (the
/// machines loading, "Waiting for your computer…" swapping with "Looking for your computers…") and
diff --git a/mobile/lib/phone/phone_status.dart b/mobile/lib/phone/phone_status.dart
index 1942e3248..6c07def85 100644
--- a/mobile/lib/phone/phone_status.dart
+++ b/mobile/lib/phone/phone_status.dart
@@ -50,7 +50,7 @@ bool phoneAccountSaysOnline(String? status) =>
/// agrees.
///
/// ⚠️ **Both, because the socket alone flaps.** One that drops while it is still being dialled
-/// marks the node offline for a moment, for a machine that answers seconds later — saying "asleep"
+/// marks the node offline for a moment, for a machine that answers seconds later — saying "offline"
/// over that would flash a wrong word at every redial. A machine the account also lists as down is
/// one with nothing on the way: switched off, or Harness not running there yet (a computer just
/// restarted was measured taking 70s to reach the relay).
@@ -87,22 +87,39 @@ bool phoneMachineListsAgents(MachineState machine) =>
PhoneMachineStatus.needsPassword || PhoneMachineStatus.offline => false,
};
-PhoneSummary phoneMachineSummary(MachineState machine) =>
- switch (phoneMachineStatusOf(machine)) {
- PhoneMachineStatus.needsPassword => (
- label: 'Needs its password',
- tone: PhoneTone.attention,
- ),
- PhoneMachineStatus.offline => (label: 'Offline', tone: PhoneTone.bad),
- PhoneMachineStatus.connecting => (
- label: 'Connecting…',
- tone: PhoneTone.busy,
- ),
- PhoneMachineStatus.ready => (
- label: _agentCount(machine.agents.length),
- tone: PhoneTone.good,
- ),
- };
+/// What a computer in [status] is called — one word, the same on every phone screen that names it:
+/// Computers, Find, Settings ▸ Profile, a harness whose computer is away, and (capitalised, by
+/// [phoneMachineSummary]) the New form's computer and a computer's own page.
+///
+/// ⚠️ **One word per state.** Computers and Profile said "asleep" and "locked" while the New form
+/// and a computer's page said "Offline" and "Needs its password": one computer, two names a screen
+/// apart. "offline" is the desktop's word. "locked" is kept over the desktop's "Link required"
+/// because the phone's way in is Unlock — the row's "tap to unlock", the sheet's "Unlock…", the
+/// Unlock page — and its first way is a scanned code, not a password.
+String phoneMachineWord(PhoneMachineStatus status) => switch (status) {
+ PhoneMachineStatus.ready => 'ready',
+ PhoneMachineStatus.connecting => 'connecting',
+ PhoneMachineStatus.needsPassword => 'locked',
+ PhoneMachineStatus.offline => 'offline',
+};
+
+PhoneSummary phoneMachineSummary(MachineState machine) {
+ final status = phoneMachineStatusOf(machine);
+ final word = phoneMachineWord(status);
+ final label = '${word[0].toUpperCase()}${word.substring(1)}';
+ return switch (status) {
+ PhoneMachineStatus.needsPassword => (
+ label: label,
+ tone: PhoneTone.attention,
+ ),
+ PhoneMachineStatus.offline => (label: label, tone: PhoneTone.bad),
+ PhoneMachineStatus.connecting => (label: '$label…', tone: PhoneTone.busy),
+ PhoneMachineStatus.ready => (
+ label: _agentCount(machine.agents.length),
+ tone: PhoneTone.good,
+ ),
+ };
+}
String _agentCount(int count) => switch (count) {
0 => 'No harnesses yet',
diff --git a/mobile/lib/phone/remove_machine.dart b/mobile/lib/phone/remove_machine.dart
index 81d2e2ee8..3be1cc6ea 100644
--- a/mobile/lib/phone/remove_machine.dart
+++ b/mobile/lib/phone/remove_machine.dart
@@ -45,7 +45,7 @@ Future<void> confirmRemoveMachine(
?.showSnackBar(SnackBar(content: Text(error)));
}
-/// "Try again" on a computer that reads asleep or is stuck connecting — see
+/// "Try again" on a computer that reads offline or is stuck connecting — see
/// [AppNotifier.retryMachine]. The row's own word moves with the answer, so this says something only
/// when the account itself could not be read.
Future<void> retryComputer(
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index f077fc143..9ae4b779a 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -2905,7 +2905,7 @@ class _MachineAway extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
- '$name is asleep',
+ '$name is ${phoneMachineWord(PhoneMachineStatus.offline)}',
textAlign: TextAlign.center,
style: tty.style(
size: TtySize.row,
diff --git a/mobile/lib/phone/terminal_title.dart b/mobile/lib/phone/terminal_title.dart
index 962118630..aa957063f 100644
--- a/mobile/lib/phone/terminal_title.dart
+++ b/mobile/lib/phone/terminal_title.dart
@@ -4,6 +4,7 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
+import 'phone_status.dart' show PhoneMachineStatus, phoneMachineWord;
import 'tty.dart';
import 'tty_controls.dart';
@@ -68,11 +69,15 @@ class TerminalTitle extends StatelessWidget {
final Widget? daemon;
/// The harness's machine is away (`phoneMachineAway`) and the screen under the title is the last
- /// one it sent: `computer asleep` at the right end, under [asking] when there is one (see
+ /// one it sent: `computer offline` at the right end, under [asking] when there is one (see
/// [_notes]). Two words and no more, by the owner's call (2026-10-08) — `reconnects when back`
/// under it went. Not a button of its own — the page comes back by itself.
final bool away;
+ /// [away]'s two words, in Computers' word for the state ([phoneMachineWord]).
+ static final _awayWords =
+ 'computer ${phoneMachineWord(PhoneMachineStatus.offline)}';
+
/// Four terminal rows: three lines of text and half a row of air above and below.
static double heightOf(Tty tty) => 4 * tty.row;
@@ -126,11 +131,11 @@ class TerminalTitle extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (asking != null) note(asking, tty.yellow),
- // The app's warning amber, not the terminal's red: a machine asleep is something
+ // The app's warning amber, not the terminal's red: a machine offline is something
// to know, not an error — and the 16 ANSI colours have no orange.
if (away)
note(
- 'computer asleep',
+ _awayWords,
AppPalette.warn,
key: const ValueKey('terminal-title-away'),
),
@@ -143,7 +148,7 @@ class TerminalTitle extends StatelessWidget {
if (asking == null) return words;
return Semantics(
button: true,
- label: ['$asking — open Find', if (away) 'computer asleep'].join('. '),
+ label: ['$asking — open Find', if (away) _awayWords].join('. '),
excludeSemantics: true,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
diff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dart
index 649b3105f..4b9849faa 100644
--- a/mobile/lib/phone/welcome/phone_welcome.dart
+++ b/mobile/lib/phone/welcome/phone_welcome.dart
@@ -177,7 +177,7 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {
_go(_Step.email, error: _error);
}
- /// A computer's own sign-in code — its "Scan with your phone" — read before this phone has an
+ /// A computer's own sign-in code — its `harness login --qr` — read before this phone has an
/// account to approve it with. Held for the sign-in this phone does first
/// ([AppNotifier.pendingComputerSignIn]); the home screen asks for the approval once it is in.
void _onComputerSignInCode(SignInCode code) {
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index e725be3f1..79bd1ac95 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -3300,7 +3300,7 @@ class AppNotifier extends ChangeNotifier {
/// A computer's own sign-in QR (the bare `hnq_…` code, [SignInCode] in
/// `phone/welcome/connect_code.dart`) read on the welcome screen by a phone not yet signed in —
- /// the desktop app's "Scan with your phone". Only a signed-in phone can approve it, so the welcome
+ /// `harness login --qr`'s. Only a signed-in phone can approve it, so the welcome
/// signs this one in first and holds the code across that sign-in; the signed-in shell then asks
/// to approve it (`phone/phone_shell.dart`), and spends it. Null the rest of the time.
///
diff --git a/mobile/test/approve_sign_in_test.dart b/mobile/test/approve_sign_in_test.dart
index 75632cb63..5b15fd57c 100644
--- a/mobile/test/approve_sign_in_test.dart
+++ b/mobile/test/approve_sign_in_test.dart
@@ -92,6 +92,23 @@ void main() {
expect(api.answers, ['deny:$_code']);
});
+ testWidgets('a computer with no name is "a computer", never "Sign in A computer?"', (tester) async {
+ await pump(tester, {'label': ' ', 'kind': 'computer', 'sameNetwork': true, 'status': 'pending'});
+ expect(find.text('Sign in a computer?'), findsOneWidget);
+ expect(find.textContaining('A computer?'), findsNothing);
+ });
+
+ testWidgets('an app with no name is "an app", not a computer', (tester) async {
+ await pump(tester, {'kind': 'viewer', 'sameNetwork': true, 'status': 'pending'});
+ expect(find.text('Sign in an app?'), findsOneWidget);
+ expect(find.textContaining('computer?'), findsNothing);
+ });
+
+ testWidgets('an app with a name is asked by its name', (tester) async {
+ await pump(tester, {'label': 'Harness in Safari', 'kind': 'viewer', 'sameNetwork': true, 'status': 'pending'});
+ expect(find.text('Sign in Harness in Safari?'), findsOneWidget);
+ });
+
testWidgets('a code already answered asks nothing', (tester) async {
final api = await pump(tester, {'label': 'x', 'kind': 'computer', 'sameNetwork': true, 'status': 'approved'});
expect(find.byKey(const Key('approve-sign-in-title')), findsNothing);
diff --git a/mobile/test/connectors_page_test.dart b/mobile/test/connectors_page_test.dart
new file mode 100644
index 000000000..fd55d4cbc
--- /dev/null
+++ b/mobile/test/connectors_page_test.dart
@@ -0,0 +1,191 @@
+import 'package:flutter/material.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/core/models.dart';
+import 'package:harness_mobile/phone/connectors_page.dart';
+import 'package:harness_mobile/state/app_state.dart';
+
+/// One computer, answering `connectors` from a script: its connections, and whether it passes
+/// them on to the account's other computers ([shared]). Records what it was asked.
+class _App extends AppNotifier {
+ _App({required this.shared})
+ : super(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ ) {
+ machines = [studio];
+ machineStates['studio'] = MachineState(studio)..nodeOnline = true;
+ }
+
+ static const studio = Machine(
+ machineId: 'studio',
+ authMode: MachineAuthMode.remote,
+ name: 'studio',
+ );
+
+ final bool shared;
+ final asked = <Map<String, dynamic>>[];
+
+ /// Tracker is connected; Wiki is not. Codes with no bundled icon: the page draws an initial.
+ @override
+ Future<Map<String, dynamic>> connectors(
+ String machineId,
+ Map<String, dynamic> payload, {
+ Duration timeout = const Duration(seconds: 30),
+ }) async {
+ asked.add({'machine': machineId, ...payload});
+ return switch (payload['action']) {
+ 'list' => {
+ 'shared': shared,
+ 'connections': [
+ {
+ 'connector': 'tracker',
+ 'name': 'Tracker',
+ 'description': 'Issues',
+ 'auth': 'dcr',
+ 'state': 'connected',
+ },
+ {
+ 'connector': 'wiki',
+ 'name': 'Wiki',
+ 'description': 'Pages',
+ 'auth': 'dcr',
+ 'state': 'not_connected',
+ },
+ ],
+ },
+ // No address to open: the sign-in is the computer's own, and the page only follows it.
+ 'connect' => {'flow': 'f1'},
+ 'flow' => {'state': 'connected'},
+ _ => {},
+ };
+ }
+
+ List<String> get actions => [
+ for (final payload in asked) payload['action'] as String,
+ ];
+}
+
+void main() {
+ Future<_App> pump(WidgetTester tester, {required bool shared}) async {
+ final app = _App(shared: shared);
+ addTearDown(app.dispose);
+ await tester.pumpWidget(MaterialApp(home: ConnectorsPage(notifier: app)));
+ await tester.pumpAndSettle();
+ return app;
+ }
+
+ /// Tracker's sheet, then its Disconnect: the question it asks, on screen.
+ Future<void> askToDisconnect(WidgetTester tester) async {
+ await tester.tap(find.text('Tracker'));
+ await tester.pumpAndSettle();
+ await tester.tap(find.text('Disconnect'));
+ await tester.pumpAndSettle();
+ }
+
+ testWidgets('Disconnect asks first; Cancel leaves the connection alone', (
+ tester,
+ ) async {
+ final app = await pump(tester, shared: true);
+ await askToDisconnect(tester);
+
+ expect(find.text('Disconnect Tracker?'), findsOneWidget);
+ expect(
+ find.text(
+ 'Agents on all your computers stop using this account. To revoke it '
+ 'everywhere, use the service’s settings.',
+ ),
+ findsOneWidget,
+ );
+ expect(app.actions, isNot(contains('disconnect')));
+
+ await tester.tap(find.text('Cancel'));
+ await tester.pumpAndSettle();
+ expect(find.text('Disconnect Tracker?'), findsNothing);
+ expect(app.actions, isNot(contains('disconnect')));
+ expect(find.textContaining('disconnected'), findsNothing);
+ });
+
+ testWidgets('confirmed, it disconnects, and says so on all your computers '
+ 'when the computer shares its connections', (tester) async {
+ final app = await pump(tester, shared: true);
+ await askToDisconnect(tester);
+ await tester.tap(find.text('Disconnect'));
+ await tester.pumpAndSettle();
+
+ expect(
+ app.asked,
+ contains(
+ equals({
+ 'machine': 'studio',
+ 'action': 'disconnect',
+ 'connector': 'tracker',
+ }),
+ ),
+ );
+ expect(
+ find.text('Tracker disconnected on all your computers.'),
+ findsOneWidget,
+ );
+ });
+
+ testWidgets('a computer that keeps its connections to itself is named, '
+ 'never "all your computers"', (tester) async {
+ final app = await pump(tester, shared: false);
+ await askToDisconnect(tester);
+
+ expect(
+ find.text(
+ 'Agents on studio stop using this account. To revoke it everywhere, '
+ 'use the service’s settings.',
+ ),
+ findsOneWidget,
+ );
+ await tester.tap(find.text('Disconnect'));
+ await tester.pumpAndSettle();
+
+ expect(app.actions, contains('disconnect'));
+ expect(find.text('Tracker disconnected on studio.'), findsOneWidget);
+ expect(find.textContaining('all your computers'), findsNothing);
+ });
+
+ testWidgets('a connection made says so in the desktop\'s words, whichever '
+ 'computer it went through', (tester) async {
+ final app = await pump(tester, shared: false);
+ await tester.tap(find.text('Wiki'));
+ // The page asks after the sign-in once a second.
+ await tester.pump(const Duration(seconds: 1));
+ await tester.pumpAndSettle();
+
+ expect(app.actions, containsAllInOrder(['connect', 'flow']));
+ expect(
+ find.text('Wiki connected. Your agents can use it now.'),
+ findsOneWidget,
+ );
+ expect(find.textContaining('all your computers'), findsNothing);
+ });
+
+ testWidgets('what an action came to goes away on its own', (tester) async {
+ await pump(tester, shared: true);
+ await askToDisconnect(tester);
+ await tester.tap(find.text('Disconnect'));
+ await tester.pumpAndSettle();
+ expect(
+ find.text('Tracker disconnected on all your computers.'),
+ findsOneWidget,
+ );
+
+ await tester.pump(const Duration(seconds: 19));
+ expect(
+ find.text('Tracker disconnected on all your computers.'),
+ findsOneWidget,
+ );
+ await tester.pump(const Duration(seconds: 2));
+ expect(
+ find.text('Tracker disconnected on all your computers.'),
+ findsNothing,
+ );
+ });
+}
diff --git a/mobile/test/phone/new_device_banner_test.dart b/mobile/test/phone/new_device_banner_test.dart
index e55537798..d5039b897 100644
--- a/mobile/test/phone/new_device_banner_test.dart
+++ b/mobile/test/phone/new_device_banner_test.dart
@@ -278,8 +278,8 @@ void main() {
},
);
- testWidgets('Mine on a suspended entry opens its page instead of dismissing '
- '(a dismissal could not hold: the next read brings it back)', (
+ testWidgets('It’s mine on a suspended entry opens its page instead of '
+ 'dismissing (a dismissal could not hold: the next read brings it back)', (
tester,
) async {
final m = member(pubOf(7), label: 'iPad', addedAt: 1);
@@ -288,7 +288,7 @@ void main() {
..suspendedNew.add(m.pub)
..newDevices.add(m);
await pump(tester);
- await tester.tap(find.text('Mine'));
+ await tester.tap(find.text('It’s mine'));
await tester.pumpAndSettle();
expect(app.dismissed, isEmpty);
@@ -313,18 +313,37 @@ void main() {
expect(find.textContaining('Not trusted here'), findsOneWidget);
});
- testWidgets('Mine on the banner keeps a fork suspension (pubs only)', (
+ testWidgets('It’s mine on the banner keeps a fork suspension (pubs only)', (
tester,
) async {
final m = member(pubOf(7), label: 'iPad', addedAt: 1);
app.newDevices.add(m);
await pump(tester);
- await tester.tap(find.text('Mine'));
+ await tester.tap(find.text('It’s mine'));
await tester.pumpAndSettle();
expect(app.dismissed, [(pub: m.pub, liftSuspension: false)]);
expect(app.newDevices, isEmpty);
});
+ testWidgets('the banner answers in the device page\'s words: It’s mine, '
+ 'as the desktop says it', (tester) async {
+ final m = member(pubOf(7), label: 'iPad', addedAt: 1);
+ app
+ ..rows = [row(m, pending: true)]
+ ..newDevices.add(m);
+ await pump(tester);
+ expect(find.text('It’s mine'), findsOneWidget);
+ expect(find.text('Mine'), findsNothing);
+
+ await tester.tap(find.text('Review'));
+ await tester.pumpAndSettle();
+ final mine = find.byKey(const Key('device-detail-mine'));
+ expect(
+ find.descendant(of: mine, matching: find.text('It’s mine')),
+ findsOneWidget,
+ );
+ });
+
group('a device that joined and left before anyone looked', () {
testWidgets('self sign-out: the sentence alone, neutral; Got it saves the '
'dismissal and clears the band', (tester) async {
@@ -667,7 +686,7 @@ void main() {
);
});
- testWidgets('the new-device sentence wraps beside Mine and Review: '
+ testWidgets('the new-device sentence wraps beside It’s mine and Review: '
'"(+N more)" is not clipped', (tester) async {
tester.view.physicalSize = const Size(360, 800);
tester.view.devicePixelRatio = 1;
@@ -687,7 +706,7 @@ void main() {
// It has the room left of the buttons, and is taller than one line.
expect(
tester.getRect(text).right,
- lessThanOrEqualTo(tester.getRect(find.text('Mine')).left),
+ lessThanOrEqualTo(tester.getRect(find.text('It’s mine')).left),
);
expect(find.textContaining('(+2 more)'), findsOneWidget);
});
diff --git a/mobile/test/phone_machine_words_test.dart b/mobile/test/phone_machine_words_test.dart
new file mode 100644
index 000000000..f7964a31d
--- /dev/null
+++ b/mobile/test/phone_machine_words_test.dart
@@ -0,0 +1,162 @@
+import 'package:flutter/material.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/core/models.dart';
+import 'package:harness_mobile/phone/agents_page.dart';
+import 'package:harness_mobile/phone/machine_profile_picker.dart';
+import 'package:harness_mobile/phone/machines_tab.dart';
+import 'package:harness_mobile/phone/phone_status.dart';
+import 'package:harness_mobile/phone/terminal_title.dart';
+import 'package:harness_mobile/state/app_state.dart';
+
+/// One computer, one name for its state, on every phone screen: "offline" (the desktop's word) and
+/// "locked" (the phone's Unlock), never "asleep" on one screen and "Offline" on the next, or
+/// "locked" here and "Needs its password" there.
+void main() {
+ Machine machine(String id) =>
+ Machine(machineId: id, authMode: MachineAuthMode.remote, name: id);
+
+ void locked(MachineState state) {
+ state
+ ..nodeOnline = true
+ ..needsLink = true;
+ }
+
+ void offline(MachineState state) {
+ state.nodeOnline = false;
+ }
+
+ /// An account whose computers are [states], in that order, each set up by its function.
+ AppNotifier appWith(Map<String, void Function(MachineState)> states) {
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+ addTearDown(app.dispose);
+ app.machines = [for (final id in states.keys) machine(id)];
+ for (final MapEntry(key: id, value: prepare) in states.entries) {
+ prepare(app.machineStates[id] = MachineState(machine(id)));
+ }
+ return app;
+ }
+
+ Finder anyText(String text) => find.textContaining(text, findRichText: true);
+
+ test('one word per state, from one place', () {
+ expect(phoneMachineWord(PhoneMachineStatus.offline), 'offline');
+ expect(phoneMachineWord(PhoneMachineStatus.needsPassword), 'locked');
+ expect(phoneMachineWord(PhoneMachineStatus.connecting), 'connecting');
+ expect(phoneMachineWord(PhoneMachineStatus.ready), 'ready');
+ });
+
+ test(
+ 'the New form and a computer\'s page say the same words, capitalised',
+ () {
+ MachineState stateOf(void Function(MachineState) prepare) {
+ final state = MachineState(machine('m'));
+ prepare(state);
+ return state;
+ }
+
+ expect(phoneMachineSummary(stateOf(offline)).label, 'Offline');
+ expect(phoneMachineSummary(stateOf(locked)).label, 'Locked');
+ expect(
+ phoneMachineSummary(stateOf((s) => s.nodeOnline = true)).label,
+ 'Connecting…',
+ );
+ },
+ );
+
+ testWidgets('Computers: a locked and an offline computer, each in its word', (
+ tester,
+ ) async {
+ final app = appWith({'studio': locked, 'mini': offline});
+ await tester.pumpWidget(MaterialApp(home: MachinesTab(notifier: app)));
+
+ expect(find.text('locked', findRichText: true), findsOneWidget);
+ expect(find.text('tap to unlock: scan its code'), findsOneWidget);
+ expect(find.text('offline', findRichText: true), findsOneWidget);
+ expect(find.text('turn it on, or run harness start there'), findsOneWidget);
+ expect(anyText('asleep'), findsNothing);
+ });
+
+ testWidgets('Computers: a run of offline computers is named once, over it', (
+ tester,
+ ) async {
+ final app = appWith({'studio': offline, 'mini': offline});
+ await tester.pumpWidget(MaterialApp(home: MachinesTab(notifier: app)));
+
+ expect(
+ find.text(
+ 'offline · turn them on, or run harness start there',
+ findRichText: true,
+ ),
+ findsOneWidget,
+ );
+ expect(anyText('asleep'), findsNothing);
+ });
+
+ testWidgets('Settings ▸ Profile: Computers\' words', (tester) async {
+ final app = appWith({'studio': locked, 'mini': offline});
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: Builder(
+ builder: (context) => TextButton(
+ onPressed: () => showMachineProfilePicker(context, app),
+ child: const Text('profile'),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('profile'));
+ await tester.pumpAndSettle();
+
+ expect(find.text('Show tabs from'), findsOneWidget);
+ expect(find.text('locked'), findsOneWidget);
+ expect(find.text('offline'), findsOneWidget);
+ expect(anyText('asleep'), findsNothing);
+ });
+
+ testWidgets('a computer\'s own page: Offline, or Locked, in its header', (
+ tester,
+ ) async {
+ final app = appWith({'studio': locked, 'mini': offline});
+ await tester.pumpWidget(
+ MaterialApp(
+ home: AgentsPage(notifier: app, machineId: 'mini'),
+ ),
+ );
+ expect(find.text('Offline'), findsOneWidget);
+
+ await tester.pumpWidget(
+ MaterialApp(
+ home: AgentsPage(notifier: app, machineId: 'studio'),
+ ),
+ );
+ expect(find.text('Locked'), findsOneWidget);
+ expect(find.text('Needs its password'), findsNothing);
+ });
+
+ testWidgets('a harness whose computer is away: "computer offline"', (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: TerminalTitle(
+ name: 'fix-login',
+ onTap: () {},
+ onFind: () {},
+ away: true,
+ ),
+ ),
+ ),
+ );
+ expect(find.text('computer offline'), findsOneWidget);
+ expect(anyText('asleep'), findsNothing);
+ });
+}