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.

feat(mobile): pin Connect computer to Computers and unify setup steps

tonyd1d696fcd2e8
diff --git a/mobile/lib/phone/find_row.dart b/mobile/lib/phone/find_row.dart
index f3d8361b5..26b44c2e8 100644
--- a/mobile/lib/phone/find_row.dart
+++ b/mobile/lib/phone/find_row.dart
@@ -35,6 +35,7 @@ class FindRow extends StatelessWidget {
this.said,
this.accessory,
this.accessoryRoom = 0,
+ this.minHeight = FindRow.height,
});
final String title;
@@ -89,6 +90,10 @@ 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.
+ final double minHeight;
+
/// Above line 1 and below line 2.
static const double _pad = 9;
@@ -115,7 +120,7 @@ class FindRow extends StatelessWidget {
final tty = Tty.of(context);
final ink = enabled ? tty.text : tty.faint;
final row = TtyTap(
- minHeight: height,
+ minHeight: minHeight,
onTap: enabled && onTap != null
? () {
HapticFeedback.selectionClick();
@@ -261,8 +266,8 @@ class FindRow extends StatelessWidget {
/// How far below the row's top the middle of line 1 is.
///
/// Arithmetic, not a measurement: [Tty.style] pins every line to its size × its `height`, and
- /// [TtyTap] centres content shorter than [height] — which a row of two lines at the default text
- /// size is.
+ /// [TtyTap] centres content shorter than [minHeight] — which a row of two lines at the default
+ /// text size is.
double _lineOneCenter(BuildContext context, Tty tty) {
final scaler = MediaQuery.textScalerOf(context);
double line(double size) {
@@ -275,7 +280,7 @@ class FindRow extends StatelessWidget {
? _gap + line(TtySize.meta)
: 0.0;
final content = _pad * 2 + one + two;
- return math.max(0.0, (height - content) / 2) + _pad + one / 2;
+ return math.max(0.0, (minHeight - content) / 2) + _pad + one / 2;
}
}
diff --git a/mobile/lib/phone/machine_index.dart b/mobile/lib/phone/machine_index.dart
index 2665a844b..7b4905630 100644
--- a/mobile/lib/phone/machine_index.dart
+++ b/mobile/lib/phone/machine_index.dart
@@ -4,12 +4,12 @@ import 'phone_status.dart';
/// Every machine the Machines tab draws, in the order a finger meets them.
///
-/// The tab draws two sections — the ones that work, then the ones wanting something — and that
-/// concatenation, not account order, is what somebody actually sees. The machine page swipes along
-/// it, so it has to be built in ONE place: a pager computing "the next machine" from a slightly
-/// different order than the list it was opened from would skip a machine, or hand back the one just
-/// left, and nothing on screen would explain why. The same rule the Agents tab follows with
-/// `visibleAgents`.
+/// The tab draws three runs — the ones that work, then the ones wanting a password, then the ones
+/// asleep — and that concatenation, not account order, is what somebody actually sees. The machine
+/// page swipes along it, so it has to be built in ONE place: a pager computing "the next machine"
+/// from a slightly different order than the list it was opened from would skip a machine, or hand
+/// back the one just left, and nothing on screen would explain why. The same rule the Agents tab
+/// follows with `visibleAgents`.
///
/// Unlike the agent list this one keeps EVERY machine, including the ones that need a password or
/// are offline. A machine row that cannot be opened is still worth a page: the password form is
@@ -20,20 +20,25 @@ List<MachineState> visibleMachines(AppNotifier notifier) {
for (final machine in notifier.machines)
?notifier.stateOf(machine.machineId),
];
- // Two runs, by whether the machine is usable as it stands — the split [MachinesTab] renders as
- // its two sections. A machine merely connecting belongs with the working ones: it needs nothing
- // from anybody, it is just not ready yet.
+ // Usable as it stands first; then what each of the others wants, each kind together — a password
+ // (something to do here) before asleep (something to do at the computer). Together, because
+ // [MachinesTab] says what a run of them needs once, over the run, rather than under every row;
+ // interleaved, as account order left them, a locked one split the asleep ones into two runs. A
+ // machine merely connecting belongs with the working ones: it needs nothing from anybody, it is
+ // just not ready yet.
final working = <MachineState>[];
- final needsAttention = <MachineState>[];
+ final locked = <MachineState>[];
+ final asleep = <MachineState>[];
for (final state in states) {
switch (phoneMachineStatusOf(state)) {
case PhoneMachineStatus.needsPassword:
+ locked.add(state);
case PhoneMachineStatus.offline:
- needsAttention.add(state);
+ asleep.add(state);
case PhoneMachineStatus.connecting:
case PhoneMachineStatus.ready:
working.add(state);
}
}
- return [...working, ...needsAttention];
+ return [...working, ...locked, ...asleep];
}
diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dart
index 7d1e88c76..64512afab 100644
--- a/mobile/lib/phone/machines_tab.dart
+++ b/mobile/lib/phone/machines_tab.dart
@@ -9,6 +9,7 @@ import 'package:harness_mobile/shared/widgets/empty_state.dart';
import 'package:harness_mobile/state/app_state.dart';
import 'welcome/connect_computer.dart';
+import 'welcome/set_up_computer.dart' show ComputerSteps;
import 'tty_controls.dart';
import 'tty.dart';
import 'find_row.dart';
@@ -96,7 +97,9 @@ class MachinesTab extends StatelessWidget {
if (large) PhoneSettingsButton(notifier: notifier),
],
),
- Expanded(child: _Body(notifier: notifier)),
+ Expanded(
+ child: _Body(notifier: notifier, home: large),
+ ),
],
),
),
@@ -138,15 +141,18 @@ class _SwipeBackState extends State<_SwipeBack> {
}
class _Body extends StatelessWidget {
- const _Body({required this.notifier});
+ const _Body({required this.notifier, required this.home});
final AppNotifier notifier;
+ /// This list is the home screen ([MachinesTab.large]), not pushed over it.
+ final bool home;
+
@override
Widget build(BuildContext context) {
- // The order a swipe on the machine page walks, split back into the two sections this list draws.
+ // The order a swipe on the machine page walks, split back into the runs this list draws.
// Taken from [visibleMachines] rather than partitioned here so the page and the list cannot
- // drift apart — the split below is presentation, the order is not.
+ // drift apart — the split below ([_rows]) is presentation, the order is not.
final ordered = visibleMachines(notifier);
if (ordered.isEmpty &&
(notifier.machinesLoading || notifier.machinesRefreshing)) {
@@ -185,32 +191,96 @@ class _Body extends StatelessWidget {
}
final tty = Tty.of(context);
- return RefreshIndicator(
- onRefresh: notifier.retryMachines,
- child: ListView(
- physics: const AlwaysScrollableScrollPhysics(),
- padding: EdgeInsets.only(
- bottom: MediaQuery.paddingOf(context).bottom + 24,
- ),
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(Tty.origin, 0, Tty.origin, 8),
- child: Text(
- 'Your harnesses run on these.',
- style: tty.style(size: TtySize.meta, color: tty.faint),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Expanded(
+ child: RefreshIndicator(
+ onRefresh: notifier.retryMachines,
+ child: ListView(
+ physics: const AlwaysScrollableScrollPhysics(),
+ // The bar under the list keeps clear of the home indicator; the list only of the bar.
+ padding: const EdgeInsets.only(bottom: 16),
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(
+ Tty.origin,
+ 0,
+ Tty.origin,
+ 8,
+ ),
+ child: Text(
+ 'Your harnesses run on these.',
+ style: tty.style(size: TtySize.meta, color: tty.faint),
+ ),
+ ),
+ ..._rows(context, ordered, tty),
+ ],
),
),
- for (final state in ordered) _row(context, state, tty),
- const SizedBox(height: 8),
- FindAddRow(
- label: 'Set up another computer',
- onTap: () => _setUpComputer(context),
- ),
- ],
- ),
+ ),
+ _ConnectBar(
+ key: const ValueKey('machines-connect-bar'),
+ notifier: notifier,
+ home: home,
+ onSetUp: () => _setUpComputer(context),
+ ),
+ ],
);
}
+ /// [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.
+ ///
+ /// 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 —
+ /// and are never gathered. Runs, not sorting: [visibleMachines] already puts each kind together.
+ List<Widget> _rows(
+ BuildContext context,
+ List<MachineState> ordered,
+ Tty tty,
+ ) {
+ final rows = <Widget>[];
+ var start = 0;
+ while (start < ordered.length) {
+ final status = phoneMachineStatusOf(ordered[start]);
+ var end = start + 1;
+ while (end < ordered.length &&
+ phoneMachineStatusOf(ordered[end]) == status) {
+ end++;
+ }
+ final group = _groupOf(status);
+ final gathered = group != null && end - start > 1;
+ if (group != null && gathered) {
+ rows.add(_GroupLine(word: group.word, hint: group.hint));
+ }
+ for (final state in ordered.sublist(start, end)) {
+ rows.add(_row(context, state, tty, ownLine: !gathered));
+ }
+ start = end;
+ }
+ 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.
+ static ({String word, String hint})? _groupOf(PhoneMachineStatus status) =>
+ switch (status) {
+ PhoneMachineStatus.needsPassword => (
+ word: 'locked',
+ hint: 'tap one to unlock: scan its code',
+ ),
+ PhoneMachineStatus.offline => (
+ word: 'asleep',
+ hint: 'turn them on, or run harness start there',
+ ),
+ PhoneMachineStatus.ready || PhoneMachineStatus.connecting => null,
+ };
+
+ /// A row whose second line its group's own line says instead — one line, a thumb's height.
+ static const double _gatheredRowHeight = 48;
+
/// Connect your computer over this list — the download link, the steps, and a scan that pairs —
/// for a computer not on the account yet.
void _setUpComputer(BuildContext context) => unawaited(
@@ -225,7 +295,13 @@ class _Body extends StatelessWidget {
),
);
- Widget _row(BuildContext context, MachineState state, Tty tty) {
+ /// [ownLine] false: its run's [_GroupLine] says what the second line would have, so it has none.
+ Widget _row(
+ BuildContext context,
+ MachineState state,
+ Tty tty, {
+ bool ownLine = true,
+ }) {
final status = phoneMachineStatusOf(state);
final count = state.agents.length;
final machineId = state.machine.machineId;
@@ -258,7 +334,8 @@ class _Body extends StatelessWidget {
}
return FindRow(
title: state.machine.displayName,
- detail: detail,
+ detail: ownLine ? detail : null,
+ 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
@@ -275,6 +352,178 @@ class _Body extends StatelessWidget {
openMachineActions(context, notifier, state.machine.machineId);
}
+/// 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.
+class _GroupLine extends StatelessWidget {
+ const _GroupLine({required this.word, required this.hint});
+
+ final String word;
+ final String hint;
+
+ @override
+ Widget build(BuildContext context) {
+ final tty = Tty.of(context);
+ return Semantics(
+ header: true,
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(Tty.origin, 16, Tty.origin, 4),
+ // Wraps rather than clips: at a large text size the hint is two lines, and the half cut off
+ // was the half that said what to do.
+ child: Text.rich(
+ TextSpan(
+ children: [
+ TextSpan(
+ text: word,
+ style: tty.style(
+ color: tty.text,
+ size: TtySize.meta,
+ weight: FontWeight.w600,
+ ),
+ ),
+ TextSpan(text: ' · $hint'),
+ ],
+ ),
+ style: tty.style(color: tty.faint, size: TtySize.meta),
+ ),
+ ),
+ );
+ }
+}
+
+/// The foot of Computers, under the list and kept there however long it grows: Connect computer —
+/// the camera at once, for a computer already showing its QR code, the button the desktop's Add
+/// Phone tells somebody to tap — and Set up another computer, for one with no Harness on it yet.
+///
+/// Pinned, not the list's last rows: at the end of a list they sat after every computer, read as
+/// two more of them, and went below the fold at nine. Down here they are where a thumb already is.
+/// The button is Connect your computer's own, so the two screens show one thing by one name.
+///
+/// How a scan goes is said on a line over the button — under the list, where the computer it pairs
+/// turns up; once paired, the computer is in the list.
+class _ConnectBar extends StatefulWidget {
+ const _ConnectBar({
+ super.key,
+ required this.notifier,
+ required this.home,
+ required this.onSetUp,
+ });
+
+ final AppNotifier notifier;
+
+ /// This list is the home screen, which a computer turning up takes away: the code goes to the
+ /// home screen to pair by, as on Connect your computer at home — [scanAndPairComputer]'s
+ /// `handOff`.
+ final bool home;
+
+ /// Set up another computer: Connect your computer, pushed over this list.
+ final VoidCallback onSetUp;
+
+ @override
+ State<_ConnectBar> createState() => _ConnectBarState();
+}
+
+class _ConnectBarState extends State<_ConnectBar> {
+ /// What the last scan came to, while it is worth saying: pairing, or why it did not.
+ String? _said;
+ bool _failed = false;
+
+ /// A scan under way, from the camera to its answer: one at a time, so a one-time code is never
+ /// spent on two pairings.
+ bool _scanning = false;
+
+ void _say(String? message, {bool failed = false}) => setState(() {
+ _said = message;
+ _failed = failed;
+ });
+
+ Future<void> _scan() async {
+ if (_scanning) return;
+ setState(() => _scanning = true);
+ try {
+ await scanAndPairComputer(
+ context,
+ widget.notifier,
+ say: _say,
+ handOff: widget.home,
+ // ⚠️ Said on the camera, because nothing here says it. The camera only scans (owner,
+ // 2026-10-08) and leaves the steps on the computer to the page it is opened from — Set up
+ // another computer has them under its own Connect computer. Opened from here, somebody who
+ // came to the phone first faced a camera and "Scan the code on your computer" with no code
+ // on the computer and no word of how to bring one up. That page's steps, word for word.
+ steps: ComputerSteps(account: widget.notifier.currentUser?.email),
+ );
+ } finally {
+ if (mounted) setState(() => _scanning = false);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final tty = Tty.of(context);
+ final said = _said;
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ color: tty.ground,
+ // The new-device banner's rule: the list scrolls under this edge, and without it the last
+ // row ran into the button.
+ border: Border(top: BorderSide(color: tty.dim.withValues(alpha: 0.25))),
+ ),
+ child: Padding(
+ // SafeArea leaves the foot to this page: the bar keeps clear of the home indicator itself.
+ padding: EdgeInsets.only(
+ top: 12,
+ bottom: MediaQuery.paddingOf(context).bottom,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: Tty.origin),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ if (said != null)
+ Padding(
+ padding: const EdgeInsets.only(bottom: 8),
+ child: Text(
+ _failed ? '✗ $said' : said,
+ key: const ValueKey('machines-connect-status'),
+ style: tty.style(
+ size: TtySize.meta,
+ color: _failed ? tty.red : tty.faint,
+ ),
+ ),
+ ),
+ TtyPrimaryButton(
+ key: const ValueKey('machines-connect-computer'),
+ icon: LucideIcons.qrCode300,
+ label: 'Connect computer',
+ // Green and still while a scan is looked up or paired; the line over it says
+ // which.
+ busy: _scanning,
+ onPressed: () => unawaited(_scan()),
+ ),
+ const SizedBox(height: 8),
+ // "QR code", not "Add Phone code": a desktop menu's name read as a noun stack
+ // under a button named for the other side — and the camera takes a computer's
+ // sign-in QR too.
+ Text(
+ 'Scan the QR code on your computer.',
+ style: tty.style(size: TtySize.meta, color: tty.faint),
+ ),
+ ],
+ ),
+ ),
+ FindAddRow(label: 'Set up another computer', onTap: widget.onSetUp),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
/// The list read again — what a pull does ([AppNotifier.retryMachines]) — as a glyph beside
/// Settings.
///
diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dart
index 706be6733..02d2aa0e8 100644
--- a/mobile/lib/phone/welcome/connect_computer.dart
+++ b/mobile/lib/phone/welcome/connect_computer.dart
@@ -32,7 +32,7 @@ import 'set_up_computer.dart';
/// │ Don’t have it? Get it › (and the sample, while it installs)
/// ② Sign in on your computer
/// │ With the same account.
-/// ③ Not showing up? Click Add Phone
+/// ③ Click Add Phone
/// Mac: Harness menu
/// Linux: Ctrl+Shift+P → add phone
/// ```
@@ -150,10 +150,6 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
/// one is still being looked up or paired is not a second pairing by the same one-time code.
bool _scanning = false;
- /// How long the account gets to say whether it has the scanned computer before the page says it
- /// is still looking — and goes on looking ([_lookUp]).
- static const _lookUpPatience = Duration(seconds: 5);
-
Future<void> _scanToPair() async {
if (_scanning) return;
_scanning = true;
@@ -178,99 +174,16 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
/// the way a code scanned at sign-in is paired. Pushed from Computers, which nothing takes away,
/// the page pairs itself, and goes back on success. Gone either way, it hands the code over.
Future<void> _scanAndPair() async {
- // Read before the camera: once this page is gone, its widget is not to be reached through.
- final notifier = widget.notifier;
- final atHome = widget.onBack == null;
- // ⚠️ Where an approval is asked from if this page is gone by the time the camera hands back a
- // computer's sign-in code — taken away under it, at home, by a computer turning up. Its own
- // context then reads as unmounted (it threw, and the approval was dropped); the root
- // navigator's outlives any one page, and the approval's dialog stands on it anyway.
- final approveFrom = Navigator.of(context, rootNavigator: true).context;
- final code = await scanForCode(
+ final paired = await scanAndPairComputer(
context,
- fallbackLabel: 'Not now',
+ widget.notifier,
+ say: _say,
+ handOff: widget.onBack == null,
camera: widget.scanCamera,
- // The computer may be showing its sign-in QR instead: approving that signs it in, which is
- // what setting it up needs anyway.
- onSignInCode: (code) => unawaited(
- approveComputerSignIn(mounted ? context : approveFrom, notifier, code),
- ),
);
- if (code == null) return;
- final machineId = code.machineId, pairCode = code.pairCode;
- if (machineId == null || pairCode == null) {
- if (!mounted) return;
- _say('That’s not the Add Phone code.', failed: true);
- return;
- }
- if (mounted) _say('Pairing…');
- final lookup = await _lookUp(notifier, machineId);
- if (lookup == _Lookup.missing) {
- // The account answered, and the computer is not on it: no code to hold for it.
- if (!mounted) return;
- _say(
- "That computer isn't on your account. Sign in to Harness on it "
- 'with ${notifier.currentUser?.email ?? 'this account'}.',
- failed: true,
- );
- return;
- }
- if (lookup == _Lookup.unreachable && mounted) {
- _say(
- "Couldn't reach your account. Check your connection and scan again.",
- failed: true,
- );
- return;
- }
- // Known — or, with this page gone, not known either way: a list that answers without the
- // computer lets a held code go by itself (`AppNotifier._refreshMachines`).
- if (atHome || !mounted) {
- notifier.holdPendingPairing(machineId, pairCode);
- return;
- }
- final error = await notifier.connectWithCode(machineId, pairCode);
- if (!mounted) return;
- if (error == null) {
- HapticFeedback.mediumImpact();
- _say(null);
- // From Computers, the list it came from has the computer now; at home, the shell moves on
- // by itself once a computer is ready.
- if (widget.onBack case final back?) back();
- } else {
- HapticFeedback.heavyImpact();
- _say(error, failed: true);
- }
- }
-
- /// Whether the account has [machineId], asked of the account when the list held here does not
- /// have it yet.
- ///
- /// ⚠️ **Slow is not "no".** The look used to be cut at 5 seconds and the list read as it stood:
- /// a slow `/api/machines` came back as "That computer isn't on your account" — right under "Not
- /// you? Sign out", about a computer that was on it — and the answer landing a moment later took
- /// the page away with the scanned code. Past [_lookUpPatience] the page says it is still looking,
- /// and waits for the account's actual answer.
- Future<_Lookup> _lookUp(AppNotifier notifier, String machineId) async {
- if (notifier.machineStates.containsKey(machineId)) return _Lookup.found;
- final refresh = notifier.refreshMachines();
- try {
- final answered = await refresh
- .then((_) => true)
- .timeout(_lookUpPatience, onTimeout: () => false);
- if (!answered) {
- if (mounted) _say('Still looking for that computer on your account…');
- await refresh;
- }
- } catch (_) {
- // A list that could not be read says nothing about whether the computer is on the account —
- // unless it already has it.
- return notifier.machineStates.containsKey(machineId)
- ? _Lookup.found
- : _Lookup.unreachable;
- }
- return notifier.machineStates.containsKey(machineId)
- ? _Lookup.found
- : _Lookup.missing;
+ // From Computers, the list it came from has the computer now; at home, the shell moves on by
+ // itself once a computer is ready.
+ if (paired && mounted) widget.onBack?.call();
}
@override
@@ -334,6 +247,142 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
}
}
+/// What a Connect computer press has to say while it runs — `Pairing…`, or why it stopped — on the
+/// line under the button that started it. Null takes the line away.
+typedef ConnectComputerSay = void Function(String? message, {bool failed});
+
+/// Connect computer, wherever it is pressed — Connect your computer's button, and the same button
+/// at the foot of Computers: the camera, then the computer whose Add Phone code it read, looked up
+/// on the account and paired with by the code. True once it is paired here.
+///
+/// [say] is the caller's line, and is called only while [context] is still mounted.
+///
+/// [steps]: under the camera's title, the steps on the computer that bring the code up — for a
+/// caller whose own page does not say them ([ScanToConnectPage.steps]).
+///
+/// [handOff]: [context] is the home screen, which a computer turning up takes away — see
+/// [_ConnectComputerPageState._scanAndPair]. The code then goes to the home screen
+/// ([AppNotifier.holdPendingPairing]) the moment the computer is known, and its pairing page pairs
+/// by it; and so it does whatever [handOff] says when [context] has gone by then.
+Future<bool> scanAndPairComputer(
+ BuildContext context,
+ AppNotifier notifier, {
+ required ConnectComputerSay say,
+ bool handOff = false,
+ Widget? camera,
+ Widget? steps,
+}) async {
+ // ⚠️ Where an approval is asked from if [context] is gone by the time the camera hands back a
+ // computer's sign-in code — taken away under it, at home, by a computer turning up. Its own
+ // context then reads as unmounted (it threw, and the approval was dropped); the root
+ // navigator's outlives any one page, and the approval's dialog stands on it anyway.
+ final approveFrom = Navigator.of(context, rootNavigator: true).context;
+ final code = await scanForCode(
+ context,
+ fallbackLabel: 'Not now',
+ camera: camera,
+ steps: steps,
+ // The computer may be showing its sign-in QR instead: approving that signs it in, which is
+ // what setting it up needs anyway.
+ onSignInCode: (code) => unawaited(
+ approveComputerSignIn(
+ context.mounted ? context : approveFrom,
+ notifier,
+ code,
+ ),
+ ),
+ );
+ if (code == null) return false;
+ final machineId = code.machineId, pairCode = code.pairCode;
+ if (machineId == null || pairCode == null) {
+ if (!context.mounted) return false;
+ say('That’s not the Add Phone code.', failed: true);
+ return false;
+ }
+ if (context.mounted) say('Pairing…');
+ final lookup = await _lookUp(notifier, machineId, (
+ message, {
+ failed = false,
+ }) {
+ if (context.mounted) say(message, failed: failed);
+ });
+ if (lookup == _Lookup.missing) {
+ // The account answered, and the computer is not on it: no code to hold for it.
+ if (!context.mounted) return false;
+ say(
+ "That computer isn't on your account. Sign in to Harness on it "
+ 'with ${notifier.currentUser?.email ?? 'this account'}.',
+ failed: true,
+ );
+ return false;
+ }
+ if (lookup == _Lookup.unreachable && context.mounted) {
+ say(
+ "Couldn't reach your account. Check your connection and scan again.",
+ failed: true,
+ );
+ return false;
+ }
+ // Known — or, with [context] gone, not known either way: a list that answers without the
+ // computer lets a held code go by itself (`AppNotifier._refreshMachines`).
+ if (handOff || !context.mounted) {
+ notifier.holdPendingPairing(machineId, pairCode);
+ // The home screen's pairing page says how it goes from here. Where that page does not come up
+ // (a computer the account reads as connected already), "Pairing…" would stand here for good.
+ if (context.mounted) say(null);
+ return false;
+ }
+ final error = await notifier.connectWithCode(machineId, pairCode);
+ if (!context.mounted) return false;
+ if (error == null) {
+ HapticFeedback.mediumImpact();
+ say(null);
+ return true;
+ }
+ HapticFeedback.heavyImpact();
+ say(error, failed: true);
+ return false;
+}
+
+/// How long the account gets to say whether it has the scanned computer before the line says it is
+/// still looking — and goes on looking ([_lookUp]).
+const _lookUpPatience = Duration(seconds: 5);
+
+/// Whether the account has [machineId], asked of the account when the list held here does not have
+/// it yet.
+///
+/// ⚠️ **Slow is not "no".** The look used to be cut at 5 seconds and the list read as it stood: a
+/// slow `/api/machines` came back as "That computer isn't on your account" — right under "Not you?
+/// Sign out", about a computer that was on it — and the answer landing a moment later took the page
+/// away with the scanned code. Past [_lookUpPatience] the line says it is still looking, and waits
+/// for the account's actual answer. [say] minds whether its line is still there.
+Future<_Lookup> _lookUp(
+ AppNotifier notifier,
+ String machineId,
+ ConnectComputerSay say,
+) async {
+ if (notifier.machineStates.containsKey(machineId)) return _Lookup.found;
+ final refresh = notifier.refreshMachines();
+ try {
+ final answered = await refresh
+ .then((_) => true)
+ .timeout(_lookUpPatience, onTimeout: () => false);
+ if (!answered) {
+ say('Still looking for that computer on your account…');
+ await refresh;
+ }
+ } catch (_) {
+ // A list that could not be read says nothing about whether the computer is on the account —
+ // unless it already has it.
+ return notifier.machineStates.containsKey(machineId)
+ ? _Lookup.found
+ : _Lookup.unreachable;
+ }
+ return notifier.machineStates.containsKey(machineId)
+ ? _Lookup.found
+ : _Lookup.missing;
+}
+
/// `Waiting for your computer…` with a terminal spinner — the page is watching.
class _Watching extends StatefulWidget {
const _Watching();
diff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dart
index 266b0f058..c6121d07b 100644
--- a/mobile/lib/phone/welcome/phone_welcome.dart
+++ b/mobile/lib/phone/welcome/phone_welcome.dart
@@ -27,7 +27,7 @@ import 'sign_in_provider_button.dart';
/// ① Open Harness on your computer
/// Don’t have it? Get it › → Get it → Installed? Connect computer ›
/// Try the sample while you wait
-/// ② Click Add Phone ③ Scan the QR code
+/// ② Sign in on your computer ③ Click Add Phone
/// ```
///
/// **Connect computer** scans the code the desktop app shows ([ScanToConnectPage]), and the scan signs
diff --git a/mobile/lib/phone/welcome/scan_to_connect.dart b/mobile/lib/phone/welcome/scan_to_connect.dart
index 4763e9113..9a428dc7e 100644
--- a/mobile/lib/phone/welcome/scan_to_connect.dart
+++ b/mobile/lib/phone/welcome/scan_to_connect.dart
@@ -58,6 +58,7 @@ class ScanToConnectPage extends StatefulWidget {
this.acceptConnectCodes = true,
this.title = 'Scan the code on your computer',
this.step,
+ this.steps,
});
final ValueChanged<ConnectCode> onCode;
@@ -74,6 +75,12 @@ class ScanToConnectPage extends StatefulWidget {
/// has not said so already. Null says nothing more.
final String? step;
+ /// Under the title, from the page's edge: the steps on the computer that bring the code up —
+ /// `ComputerSteps`, Set up another computer's own — for a camera opened where nothing has said
+ /// them (Computers' Connect computer). The square shrinks on a short screen to keep them on it,
+ /// and the page scrolls where even that is not enough.
+ final Widget? steps;
+
final VoidCallback onUseEmail;
final VoidCallback onBack;
@@ -289,6 +296,10 @@ class _ScanToConnectPageState extends State<ScanToConnectPage>
style: faint.copyWith(height: 1.5),
),
],
+ if (widget.steps case final steps?) ...[
+ const SizedBox(height: 24),
+ steps,
+ ],
],
),
),
@@ -400,11 +411,15 @@ class _CameraProblem extends StatelessWidget {
///
/// [onSignInCode]: a computer's sign-in QR read here instead is handed on (after the camera closes)
/// rather than ignored — the person pointed the phone at a computer, whichever code it showed.
+///
+/// [steps]: the steps on the computer that bring the code up, for a caller that has not said them
+/// itself — see [ScanToConnectPage.steps].
Future<ConnectCode?> scanForCode(
BuildContext context, {
required String fallbackLabel,
Widget? camera,
ValueChanged<SignInCode>? onSignInCode,
+ Widget? steps,
}) async {
ConnectCode? scanned;
SignInCode? signIn;
@@ -416,6 +431,7 @@ Future<ConnectCode?> scanForCode(
child: ScanToConnectPage(
camera: camera,
fallbackLabel: fallbackLabel,
+ steps: steps,
onCode: (code) {
scanned = code;
Navigator.of(page).pop();
diff --git a/mobile/lib/phone/welcome/set_up_computer.dart b/mobile/lib/phone/welcome/set_up_computer.dart
index 3d6770d86..eb58429b5 100644
--- a/mobile/lib/phone/welcome/set_up_computer.dart
+++ b/mobile/lib/phone/welcome/set_up_computer.dart
@@ -35,10 +35,11 @@ const double _gutter = 20;
///
/// ① Open Harness on your computer
/// │ Don’t have it? Get it ›
-/// ② Click Add Phone (signed in: Sign in on your computer)
-/// │ Mac: Harness menu
-/// │ Linux: Ctrl+Shift+P → add phone
-/// ③ Scan the QR code (signed in: Not showing up? Click Add Phone)
+/// ② Sign in on your computer
+/// │ With [email protected]. (signed in only: which account)
+/// ③ Click Add Phone
+/// Mac: Harness menu
+/// Linux: Ctrl+Shift+P → add phone
/// ```
///
/// ⚠️ **One edge (owner, 2026-10-11).** Everything starts at [_gutter] — the wordmark, the words,
@@ -101,27 +102,17 @@ class SetUpComputerPage extends StatelessWidget {
/// button that started it.
final Widget? scanStatus;
- /// The steps after the first (Harness on the computer, with Get it). Signed out: Add Phone, and
- /// where it is, then its code. Signed in: sign in on the computer with the same account — it then
- /// turns up by itself, with no code — and Add Phone, and where it is, for one that does not.
- ///
- /// ⚠️ **Where Add Phone is is said either way.** Signed in, it was left out as needed only for the
- /// scan — and that is exactly when it is needed: a computer whose account already has this phone
- /// does not open Add Phone by itself, and one slow to read the phone's key does not turn up.
- List<({String title, String? note})> get _nextSteps => switch (account) {
- null => const [
- (title: 'Click Add Phone', note: kAddPhoneWhere),
- (title: 'Scan the QR code', note: null),
- ],
- final account => [
- (
- title: 'Sign in on your computer',
- // From Computers nothing above names the account.
- note: watching ? 'With the same account.' : 'With $account.',
- ),
- (title: 'Not showing up? Click Add Phone', note: kAddPhoneWhere),
- ],
- };
+ /// The steps after the first (Harness on the computer, with Get it) — [_stepsAfterOpening], the
+ /// same signed in or out; only the line under signing in differs: none signed out, the account
+ /// signed in.
+ List<({String title, String? note})> get _nextSteps =>
+ _stepsAfterOpening(switch (account) {
+ null => null,
+ // At home the line over the button names the account already.
+ _ when watching => 'With the same account.',
+ // From Computers nothing above names it.
+ final account => 'With $account.',
+ });
@override
Widget build(BuildContext context) {
@@ -194,7 +185,7 @@ class SetUpComputerPage extends StatelessWidget {
// steps, centred, for a question the first step raises.
_HowItWorksRow(
number: 1,
- title: 'Open Harness on your computer',
+ title: _openHarness,
link: _StepLink(
key: const ValueKey('set-up-get-it'),
lead: 'Don’t have it? ',
@@ -224,14 +215,17 @@ class SetUpComputerPage extends StatelessWidget {
///
/// ```
/// ‹
-/// Open this on your computer
-/// ┌───────────────────────────────────┐
-/// │ harness.autonomous.ai/desktop ⇪ │
-/// └───────────────────────────────────┘
+/// Get Harness
+/// on your computer
+/// In your computer’s browser, go to:
+/// ┌───────────────────────────────────┐
+/// │ harness.autonomous.ai/desktop ⇪ │
+/// └───────────────────────────────────┘
+/// Or tap to send it with AirDrop or Messages.
///
-/// ⋮
-/// Installed? Connect computer › ← the foot of the screen: after the computer
-/// Try the sample while you wait
+/// ⋮
+/// Installed? Connect computer › ← the foot of the screen: after the computer
+/// Try the sample while you wait
/// ```
///
/// ⚠️ **The address is the page (owner, 2026-10-11).** It used to lead with "Send to my computer" —
@@ -239,6 +233,12 @@ class SetUpComputerPage extends StatelessWidget {
/// to. Typed, the address works on any computer. The share sheet is behind the address itself, for
/// AirDrop to a Mac beside you.
///
+/// ⚠️ **But said, not left to be worked out (owner, 2026-10-12).** The title was "Open this on your
+/// computer", with nothing between it and the address: it named neither what "this" was for nor
+/// what to open it in, and somebody new read the address as a link to tap here. The title now says
+/// what the page is for — Get it's own words — the line under it where, and a line under the
+/// address what its glyph does, which nothing said either.
+///
/// The page gives the website, not a file: it offers each computer its own download (Mac, Linux,
/// the command line), which a phone cannot tell apart.
class GetHarnessPage extends StatelessWidget {
@@ -280,41 +280,59 @@ class GetHarnessPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
AppTheme.watch(context);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Align(
- alignment: Alignment.centerLeft,
- child: TtyBackButton(onPressed: onBack),
- ),
- Expanded(
- // The links at the foot of the screen, apart from the address: they are for after the
- // computer, not now. A short screen scrolls instead.
- child: LayoutBuilder(
- builder: (context, box) => SingleChildScrollView(
- child: ConstrainedBox(
- constraints: BoxConstraints(
- minHeight: box.hasBoundedHeight ? box.maxHeight : 0,
- ),
- child: IntrinsicHeight(
- child: Padding(
- padding: const EdgeInsets.fromLTRB(
- Tty.origin,
- 32,
- Tty.origin,
- 20,
+ final tty = Tty.of(context);
+ // What a tap on the address brings up, by its names here: there is no AirDrop off Apple.
+ final shareHint = Theme.of(context).platform == TargetPlatform.iOS
+ ? 'Or tap to send it with AirDrop or Messages.'
+ : 'Or tap to send it to yourself.';
+ // ⚠️ **One edge, the page it is opened from's (owner, 2026-10-12).** Connect your computer
+ // starts everything at [_gutter] — its title, the button across the page, the steps — and this
+ // page, centred at the terminal's origin, read as a different app one tap in. The same edge,
+ // the same headline, the address across the page as the button is, and a tablet's phone column.
+ return Center(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 480),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Align(
+ alignment: Alignment.centerLeft,
+ // Its chevron sits at the terminal's origin: over to the page's edge, as on Connect
+ // your computer.
+ child: Padding(
+ padding: const EdgeInsets.only(left: _gutter - Tty.origin),
+ child: TtyBackButton(onPressed: onBack),
+ ),
+ ),
+ Expanded(
+ // The links at the foot of the screen, apart from the address: they are for after the
+ // computer, not now. A short screen scrolls instead.
+ child: LayoutBuilder(
+ builder: (context, box) => SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minHeight: box.hasBoundedHeight ? box.maxHeight : 0,
),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- // The title says what to do and where, the address what: no sentence
- // between them. "Get Harness" was the link here, and is in the address.
- const _Hero(title: 'Open this on your computer'),
- const SizedBox(height: 24),
- Center(
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 360),
- child: Builder(
+ child: IntrinsicHeight(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(
+ _gutter,
+ 36,
+ _gutter,
+ 20,
+ ),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // What the page is for, in Get it's words; then where the address
+ // goes. Broken by hand, as the first screen's title is.
+ const _Hero(
+ title: 'Get Harness\non your computer',
+ body: 'In your computer’s browser, go to:',
+ start: true,
+ ),
+ const SizedBox(height: 28),
+ Builder(
builder: (address) => _AddressCard(
key: const ValueKey('get-it-send'),
address: kDesktopDownloadUrl.replaceFirst(
@@ -324,37 +342,41 @@ class GetHarnessPage extends StatelessWidget {
onPressed: () => unawaited(_sendLink(address)),
),
),
- ),
- ),
- const Spacer(),
- const SizedBox(height: 36),
- // Nothing about signing in there: the desktop app asks for it itself, and
- // opens Add Phone by itself once it is.
- Center(
- child: _TextLink(
- key: const ValueKey('get-it-pair'),
- lead: 'Installed? ',
- action: 'Connect computer ›',
- onTap: onPair,
- ),
- ),
- if (onTrySample case final onTrySample?)
- Center(
- child: _TextLink(
- key: const ValueKey('get-it-sample'),
- action: 'Try the sample while you wait',
- onTap: onTrySample,
+ const SizedBox(height: 10),
+ Text(
+ shareHint,
+ key: const ValueKey('get-it-share-hint'),
+ style: tty
+ .style(color: tty.faint, size: TtySize.meta)
+ .copyWith(height: 1.45),
),
- ),
- ],
+ const Spacer(),
+ const SizedBox(height: 36),
+ // Nothing about signing in there: the desktop app asks for it itself,
+ // and opens Add Phone by itself once it is.
+ _TextLink(
+ key: const ValueKey('get-it-pair'),
+ lead: 'Installed? ',
+ action: 'Connect computer ›',
+ onTap: onPair,
+ ),
+ if (onTrySample case final onTrySample?)
+ _TextLink(
+ key: const ValueKey('get-it-sample'),
+ action: 'Try the sample while you wait',
+ onTap: onTrySample,
+ ),
+ ],
+ ),
+ ),
),
),
),
),
),
- ),
+ ],
),
- ],
+ ),
);
}
}
@@ -421,6 +443,60 @@ class _Wordmark extends StatelessWidget {
}
}
+/// The first step on the computer, signed in or out.
+const _openHarness = 'Open Harness on your computer';
+
+/// The steps after [_openHarness]: sign in on the computer, then Add Phone and where it is.
+///
+/// ⚠️ **One set, wherever they are shown (owner, 2026-10-12)** — the first screen, Set up another
+/// computer, and Connect computer's camera from Computers. They used to be two: signed out "Click
+/// Add Phone ③ Scan the QR code", signed in "Sign in on your computer ③ Not showing up? Click Add
+/// Phone" — one button on one page, and steps that changed under it, and on the camera "Not showing
+/// up?" was asked of somebody already scanning. Both halves hold either way: Add Phone asks a
+/// computer that is not signed in to sign in before it shows a code, and a computer that turns up
+/// by itself is paired just as well by its code. The scan is the button above the steps, and the
+/// camera's own title, so it is not a step of its own.
+///
+/// [signIn]: under signing in, which account — the phone's, when it has one to name. Null signed
+/// out, where the scan signs the phone in to whichever account the computer has.
+List<({String title, String? note})> _stepsAfterOpening(String? signIn) => [
+ (title: 'Sign in on your computer', note: signIn),
+ (title: 'Click Add Phone', note: kAddPhoneWhere),
+];
+
+/// The steps on the computer under Connect computer's camera, opened from Computers — where the
+/// page it came from says none of them ([ScanToConnectPage.steps]).
+///
+/// Set up another computer's own steps, word for word, so the two pages say one thing; without its
+/// Get it, which is that page's — Connect computer is for a computer that has Harness, and the row
+/// for one that has not is right under the button.
+class ComputerSteps extends StatelessWidget {
+ const ComputerSteps({super.key, required this.account});
+
+ /// This phone's account, named in the sign-in step.
+ final String? account;
+
+ @override
+ Widget build(BuildContext context) {
+ final account = this.account;
+ final next = _stepsAfterOpening(account == null ? null : 'With $account.');
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const _HowItWorksRow(number: 1, title: _openHarness),
+ for (final (i, step) in next.indexed)
+ _HowItWorksRow(
+ number: i + 2,
+ title: step.title,
+ note: step.note,
+ last: i == next.length - 1,
+ ),
+ ],
+ );
+ }
+}
+
/// One step: its number in a ring, a thread down to the next one's, what to do, and under it a
/// quieter line when one is needed — or a link ([link]: Get it).
class _HowItWorksRow extends StatelessWidget {
@@ -577,9 +653,10 @@ class _StepLink extends StatelessWidget {
}
}
-/// A small centred link: faint words, and the part that acts in the terminal's green — "Installed?
-/// Connect computer ›". With no [lead] at all the whole link is the faint words ("Try the sample
-/// while you wait").
+/// A small link from the page's edge: faint words, and the part that acts in the terminal's green —
+/// "Installed? Connect computer ›". With no [lead] at all the whole link is the faint words ("Try
+/// the sample while you wait"). Its touch room is round the words, but not before them: the words
+/// start on the edge everything else does.
class _TextLink extends StatelessWidget {
const _TextLink({
super.key,
@@ -609,7 +686,7 @@ class _TextLink extends StatelessWidget {
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 44),
child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
+ padding: const EdgeInsets.fromLTRB(0, 10, 8, 10),
child: Text.rich(
TextSpan(
children: [
@@ -626,7 +703,7 @@ class _TextLink extends StatelessWidget {
),
],
),
- textAlign: TextAlign.center,
+ textAlign: TextAlign.start,
style: tty.style(color: tty.faint, size: TtySize.meta),
),
),
diff --git a/mobile/test/connect_computer_test.dart b/mobile/test/connect_computer_test.dart
index c61a9f9b5..448903c4d 100644
--- a/mobile/test/connect_computer_test.dart
+++ b/mobile/test/connect_computer_test.dart
@@ -119,7 +119,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('set-up-get-it')));
await tester.pumpAndSettle();
expect(find.byType(GetHarnessPage), findsOneWidget);
- expect(find.text('Open this on your computer'), findsOneWidget);
+ expect(find.text('Get Harness\non your computer'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('get-it-sample')));
await tester.pumpAndSettle();
expect(samples, 1);
diff --git a/mobile/test/phone_edge/welcome_behavior_test.dart b/mobile/test/phone_edge/welcome_behavior_test.dart
index affe9a8cd..6d62a30df 100644
--- a/mobile/test/phone_edge/welcome_behavior_test.dart
+++ b/mobile/test/phone_edge/welcome_behavior_test.dart
@@ -183,7 +183,7 @@ void main() {
// Back from the camera is Get it, where it was opened, and back from that the first screen.
await tester.tap(find.bySemanticsLabel(RegExp('Back')).first);
await frames(tester);
- expect(find.text('Open this on your computer'), findsOneWidget);
+ expect(find.text('Get Harness\non your computer'), findsOneWidget);
await tester.tap(find.bySemanticsLabel(RegExp('Back')).first);
await frames(tester);
expect(find.text('Your agents\nin your pocket.'), findsOneWidget);
@@ -198,7 +198,7 @@ void main() {
await frames(tester);
await tapInView(tester, find.text('Try the sample while you wait'));
await frames(tester);
- expect(find.text('Open this on your computer'), findsOneWidget);
+ expect(find.text('Get Harness\non your computer'), findsOneWidget);
await close(tester, app);
});
});
diff --git a/mobile/test/phone_edge/welcome_layout_test.dart b/mobile/test/phone_edge/welcome_layout_test.dart
index d9f01684f..f6d7ba408 100644
--- a/mobile/test/phone_edge/welcome_layout_test.dart
+++ b/mobile/test/phone_edge/welcome_layout_test.dart
@@ -97,7 +97,7 @@ void main() {
await pump(tester, welcome(app), scale, brightness);
await tapInView(tester, find.byKey(const ValueKey('set-up-get-it')));
await frames(tester);
- expect(find.text('Open this on your computer'), findsOneWidget);
+ expect(find.text('Get Harness\non your computer'), findsOneWidget);
await tester.drag(
find.descendant(
of: find.byType(GetHarnessPage),
diff --git a/mobile/test/phone_welcome_first_screen_test.dart b/mobile/test/phone_welcome_first_screen_test.dart
index da2514721..0e04ff3cf 100644
--- a/mobile/test/phone_welcome_first_screen_test.dart
+++ b/mobile/test/phone_welcome_first_screen_test.dart
@@ -124,12 +124,14 @@ void main() {
expect(find.text('Connect computer'), findsOneWidget);
for (final line in [
'Open Harness on your computer',
+ 'Sign in on your computer',
'Click Add Phone',
kAddPhoneWhere,
- 'Scan the QR code',
]) {
expect(find.text(line), findsOneWidget, reason: line);
}
+ // The scan is the button above the steps, not a step of its own.
+ expect(find.text('Scan the QR code'), findsNothing);
expect(find.byKey(const ValueKey('set-up-get-it')), findsOneWidget);
// The accounts are behind the camera's "Can’t scan?", and the sample behind Get it.
expect(find.text('Continue with Google'), findsNothing);
@@ -159,7 +161,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('set-up-get-it')));
await tester.pump();
expect(find.byType(GetHarnessPage), findsOneWidget);
- expect(find.text('Open this on your computer'), findsOneWidget);
+ expect(find.text('Get Harness\non your computer'), findsOneWidget);
expect(
find.textContaining('harness.autonomous.ai/desktop'),
findsOneWidget,