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): close remaining onboarding gaps

tonyeacd6079bfed
diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dart
index 913a1916c..8541949ae 100644
--- a/mobile/lib/phone/machines_tab.dart
+++ b/mobile/lib/phone/machines_tab.dart
@@ -118,12 +118,19 @@ class _Body extends StatelessWidget {
);
}
if (ordered.isEmpty) {
- return const EmptyState(
+ // ⚠️ With the way to set one up, as the list's own last row offers it: reached from Settings
+ // on a phone with no computer yet, this was a sentence and nothing to press.
+ return EmptyState(
icon: LucideIcons.laptopMinimal300,
title: 'No computers yet',
message:
'Set up Harness on your computer, signed in to this account, and it '
'appears here.',
+ action: FilledButton(
+ key: const ValueKey('machines-set-up'),
+ onPressed: () => _setUpComputer(context),
+ child: const Text('Set up a computer'),
+ ),
);
}
@@ -147,21 +154,27 @@ class _Body extends StatelessWidget {
const SizedBox(height: 8),
FindAddRow(
label: 'Set up another computer',
- onTap: () => Navigator.of(context).push(
- phoneRoute(
- (route) => ConnectComputerPage(
- notifier: notifier,
- signedIn: false,
- onBack: () => Navigator.of(route).maybePop(),
- ),
- ),
- ),
+ onTap: () => _setUpComputer(context),
),
],
),
);
}
+ /// The set-up page over this list — downloads, steps, and a scan that pairs — for a computer not
+ /// on the account yet.
+ void _setUpComputer(BuildContext context) => unawaited(
+ Navigator.of(context).push(
+ phoneRoute(
+ (route) => ConnectComputerPage(
+ notifier: notifier,
+ signedIn: false,
+ onBack: () => Navigator.of(route).maybePop(),
+ ),
+ ),
+ ),
+ );
+
Widget _row(BuildContext context, MachineState state, Tty tty) {
final status = phoneMachineStatusOf(state);
final count = state.agents.length;
diff --git a/mobile/lib/phone/settings_page.dart b/mobile/lib/phone/settings_page.dart
index 66a3dd59f..a2f644108 100644
--- a/mobile/lib/phone/settings_page.dart
+++ b/mobile/lib/phone/settings_page.dart
@@ -301,20 +301,82 @@ class _Body extends StatelessWidget {
/// Asked first, because a sign-out is more than leaving this screen: the phone's key leaves the
/// account's devices ([AppNotifier.logout]), and signing in again makes a new one — which every
/// other device then announces as a new device. One stray tap in the sheet used to be all of it.
+///
+/// ⚠️ **"Signing out…" from the confirm on.** The sign-out takes up to 5 seconds before the welcome
+/// screen comes up ([AppNotifier.logout]), and the page it was asked from used to stand there
+/// unchanged meanwhile, its Sign out still there to press again. A page that cannot be left now
+/// says what is happening; the signed-in screen, and it with it, goes when the sign-out lands.
Future<void> confirmSignOut(BuildContext context, AppNotifier notifier) async {
+ if (notifier.signingOut) return;
final confirmed = await confirmPhoneAction(
context,
// The sheet row's own icon — see [confirmPhoneAction].
icon: LucideIcons.logOut300,
title: 'Sign out?',
detail: notifier.currentUser?.email,
- message:
- 'Your harnesses keep running on your computers. When you sign in again, '
- 'your other devices will see this phone as a new device.',
+ // "Your harnesses keep running" is news only to somebody who has harnesses: the account with
+ // no computer is the wrong-account case "Not you? Sign out" is for.
+ message: notifier.machines.isEmpty
+ ? 'When you sign in again, your other devices will see this phone as a '
+ 'new device.'
+ : 'Your harnesses keep running on your computers. When you sign in again, '
+ 'your other devices will see this phone as a new device.',
confirmLabel: 'Sign out',
);
if (!confirmed) return;
- await notifier.logout();
+ // The sign-out itself never waits on the page: one asked for is carried out.
+ Route<void>? shown;
+ if (context.mounted) {
+ final route = phoneRoute(
+ (_) => const _SigningOut(),
+ swipeToGoBack: false,
+ );
+ unawaited(Navigator.of(context).push(route));
+ shown = route;
+ }
+ try {
+ await notifier.logout();
+ } finally {
+ // Gone with the signed-in screen when the sign-out lands; still here only if it was cut short.
+ if (shown != null && shown.isActive) shown.navigator?.removeRoute(shown);
+ }
+}
+
+/// The page a Sign out by hand stands on until the welcome screen comes up — see [confirmSignOut].
+/// No way back from it: there is nothing left to go back to.
+class _SigningOut extends StatelessWidget {
+ const _SigningOut();
+
+ @override
+ Widget build(BuildContext context) {
+ AppTheme.watch(context);
+ return PopScope(
+ canPop: false,
+ child: Scaffold(
+ backgroundColor: AppPalette.windowBg,
+ body: Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ SizedBox.square(
+ dimension: 22,
+ child: CircularProgressIndicator(
+ strokeWidth: 2,
+ color: AppPalette.accent,
+ ),
+ ),
+ const SizedBox(height: 14),
+ Text(
+ 'Signing out…',
+ key: const ValueKey('signing-out'),
+ style: TextStyle(color: AppPalette.textSecondary, fontSize: 14),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
}
/// Settings over the current page — the page Find and a terminal's menu push.
diff --git a/mobile/lib/phone/tty_controls.dart b/mobile/lib/phone/tty_controls.dart
index 6855b3039..550f44873 100644
--- a/mobile/lib/phone/tty_controls.dart
+++ b/mobile/lib/phone/tty_controls.dart
@@ -104,11 +104,19 @@ class _TtyPrimaryButtonState extends State<TtyPrimaryButton> {
borderRadius: BorderRadius.circular(6),
),
alignment: Alignment.center,
- child: TtyText(
+ // One line, as a [TtyText] — but ending in "…" where it does not fit, not cut at the
+ // edge: a busy label names the computer ("Pairing with Tonys-MacBook-Pro.local…"), and
+ // a hostname that long lost its end, and the ellipsis that says it is still working.
+ child: Text(
widget.busy ? (widget.busyLabel ?? widget.label) : widget.label,
- color: ink,
- weight: FontWeight.w600,
- size: TtySize.title,
+ maxLines: 1,
+ softWrap: false,
+ overflow: TextOverflow.ellipsis,
+ style: tty.style(
+ color: ink,
+ weight: FontWeight.w600,
+ size: TtySize.title,
+ ),
),
),
),
diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dart
index 3d5ad95bf..bdaab7aa3 100644
--- a/mobile/lib/phone/welcome/connect_computer.dart
+++ b/mobile/lib/phone/welcome/connect_computer.dart
@@ -135,13 +135,20 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
// 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(
context,
fallbackLabel: 'Not now',
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(context, widget.notifier, code)),
+ onSignInCode: (code) => unawaited(
+ approveComputerSignIn(mounted ? context : approveFrom, notifier, code),
+ ),
);
if (code == null) return;
final machineId = code.machineId, pairCode = code.pairCode;
@@ -246,7 +253,21 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
topTrailing: widget.onBack == null
? PhoneSettingsButton(notifier: widget.notifier)
: null,
- status: widget.signedIn || scanned != null
+ // Under the button that started it ([SetUpComputerPage.scanStatus]), not up here.
+ scanStatus: scanned == null
+ ? null
+ : Padding(
+ padding: const EdgeInsets.only(bottom: 4),
+ child: Text(
+ _scanFailed ? '✗ $scanned' : scanned,
+ key: const ValueKey('connect-scan-status'),
+ style: tty.style(
+ size: TtySize.meta,
+ color: _scanFailed ? tty.red : tty.faint,
+ ),
+ ),
+ ),
+ status: widget.signedIn
? Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -270,18 +291,6 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
),
),
),
- if (scanned != null)
- Padding(
- padding: const EdgeInsets.only(top: 10),
- child: Text(
- _scanFailed ? '✗ $scanned' : scanned,
- key: const ValueKey('connect-scan-status'),
- style: tty.style(
- size: TtySize.meta,
- color: _scanFailed ? tty.red : tty.faint,
- ),
- ),
- ),
],
)
: null,
diff --git a/mobile/lib/phone/welcome/focus_hints.dart b/mobile/lib/phone/welcome/focus_hints.dart
index 2f5d6a9a3..687c9033d 100644
--- a/mobile/lib/phone/welcome/focus_hints.dart
+++ b/mobile/lib/phone/welcome/focus_hints.dart
@@ -130,15 +130,25 @@ class _FocusHintsState extends State<FocusHints> {
? CrossAxisAlignment.center
: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
+ // Text that wraps, not one-line [TtyText]s: the two swipe hints share the width, and on
+ // a 320pt phone or at the largest text size "all your harnesses" was cut at the edge.
+ // A line that fits is drawn exactly as before.
children: [
- TtyText(
+ Text(
big,
- size: TtySize.title,
- weight: FontWeight.w600,
- color: tty.green,
+ textAlign: align,
+ style: tty.style(
+ size: TtySize.title,
+ weight: FontWeight.w600,
+ color: tty.green,
+ ),
),
const SizedBox(height: 2),
- TtyText(small, size: TtySize.meta, color: tty.text),
+ Text(
+ small,
+ textAlign: align,
+ style: tty.style(size: TtySize.meta, color: tty.text),
+ ),
],
);
// ⚠️ **The touch goes THROUGH.** A hint that swallowed the swipe it teaches ("swipe right")
diff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dart
index c8baa9ecb..7bfe46d20 100644
--- a/mobile/lib/phone/welcome/phone_welcome.dart
+++ b/mobile/lib/phone/welcome/phone_welcome.dart
@@ -186,7 +186,8 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {
final sent = await _sendCode();
if (!mounted) return;
setState(() => _signingInWithScan = false);
- if (sent) return;
+ // Left meanwhile for another way in: its failure is not the screen's to take over.
+ if (sent || _step != _Step.scan) return;
_go(_Step.email, error: _error);
}
@@ -240,14 +241,23 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {
setState(() => _error = 'That doesn’t look like an email address.');
return false;
}
+ final from = _step;
final ok = await _run(
() => (widget.sendCode ?? widget.notifier.sendLoginCode)(email),
);
- if (!ok || !mounted) return false;
+ if (!mounted) return false;
+ if (!ok) {
+ // Nor its failure, under a step that is not about the email.
+ if (_step != from) setState(() => _error = null);
+ return false;
+ }
_sentTo = email;
_code.clear();
_startResend();
- _go(_Step.code);
+ // ⚠️ On from the step it was sent from only. Back pressed while it went — from the scan page's
+ // "Signing in…", say — had the first screen jump to "Check your email" a second later, under
+ // somebody who had just left the email way behind.
+ if (_step == from) _go(_Step.code);
return true;
}
@@ -557,10 +567,11 @@ class _Hello extends StatelessWidget {
_SignedOutNotice(reason: reason),
const SizedBox(height: 18),
],
- TtyText(
+ // Wraps where it does not fit — a 320pt phone at the largest text size — rather than
+ // losing its question mark at the edge, as a one-line TtyText did.
+ Text(
'Is Harness on your computer?',
- color: tty.faint,
- size: TtySize.row,
+ style: tty.style(color: tty.faint, size: TtySize.row),
),
const SizedBox(height: 12),
_Answer(label: 'Yes — scan to connect', onTap: onScan),
@@ -778,11 +789,12 @@ class _Answer extends StatelessWidget {
),
child: Row(
children: [
+ // Wraps rather than cut "Yes — scan to connect" short on a narrow phone at a large
+ // text size; one line wherever it fits.
Expanded(
- child: TtyText(
+ child: Text(
label,
- size: TtySize.row,
- weight: FontWeight.w600,
+ style: tty.style(size: TtySize.row, weight: FontWeight.w600),
),
),
Icon(LucideIcons.chevronRight300, size: 18, color: tty.faint),
@@ -892,7 +904,9 @@ class _Form extends StatelessWidget {
child: ListView(
padding: const EdgeInsets.fromLTRB(Tty.origin, 12, Tty.origin, 16),
children: [
- TtyText(title, size: 24, weight: FontWeight.w600),
+ // A title that wraps: "Check your email" at 24pt is more than a 320pt phone holds at
+ // the largest text size, and a one-line TtyText cut it there.
+ Text(title, style: tty.style(size: 24, weight: FontWeight.w600)),
const SizedBox(height: 12),
for (final line in lines)
Padding(
diff --git a/mobile/lib/phone/welcome/set_up_computer.dart b/mobile/lib/phone/welcome/set_up_computer.dart
index ec2f25007..a85f91fb8 100644
--- a/mobile/lib/phone/welcome/set_up_computer.dart
+++ b/mobile/lib/phone/welcome/set_up_computer.dart
@@ -132,12 +132,21 @@ class SetUpComputerPage extends StatefulWidget {
this.loadDownloads,
this.account,
this.topTrailing,
+ this.scanStatus,
});
/// At the right of the top row, across from `‹ Back` — on the home screen, where there is no back,
/// the way to Settings (`PhoneSettingsButton`).
final Widget? topTrailing;
+ /// What the last scan came to — pairing, or why it did not — right under "Scan to connect ›".
+ ///
+ /// ⚠️ **Under the button that started it, not under the title.** [status] is the page's top, and
+ /// the button its foot, some 600pt of downloads and steps apart: on a small phone, scrolled down
+ /// to press it, the person came back from the camera to a page that looked unchanged — the
+ /// answer had gone in above the screen's edge, and pushed the button down besides.
+ final Widget? scanStatus;
+
/// The account this phone is signed in to, when it is: the computer has to sign in to the same
/// one, and the steps say so by name. Null for a phone not signed in yet — its scan signs it in
/// to whichever account the computer chose.
@@ -352,6 +361,7 @@ class _SetUpComputerPageState extends State<SetUpComputerPage> {
),
),
),
+ ?widget.scanStatus,
const SizedBox(height: 32),
// Not at the computer: what it is like, in 30 seconds.
Align(
diff --git a/mobile/lib/phone/welcome/unlock_computer.dart b/mobile/lib/phone/welcome/unlock_computer.dart
index e42e52aa0..fdf073406 100644
--- a/mobile/lib/phone/welcome/unlock_computer.dart
+++ b/mobile/lib/phone/welcome/unlock_computer.dart
@@ -120,15 +120,20 @@ class _UnlockComputerState extends State<UnlockComputer> {
}
}
+ /// The camera is up for [_scan]. ⚠️ [_pairing] is only set once a code is back: a quick second
+ /// tap before that opened a second camera, and paired a second time by the same one-time code.
+ bool _scanning = false;
+
/// The camera, over this page; a code of this computer's pairs the phone with it, the way the
/// first one was added — its one-time code, armed by its Add Phone dialog, and no password.
Future<void> _scan() async {
- if (_busy || _pairing) return;
+ if (_busy || _pairing || _scanning) return;
+ _scanning = true;
final code = await scanForCode(
context,
fallbackLabel: 'Use its password instead',
camera: widget.scanCamera,
- );
+ ).whenComplete(() => _scanning = false);
if (!mounted || code == null) return;
final machine = widget.machineState.machine;
final pairCode = code.pairCode;
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index 410997158..f1e61e4e1 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -1788,11 +1788,41 @@ class AppNotifier extends ChangeNotifier {
viewer.login.cancel();
}
+ /// The Sign out by hand under way, from the confirm to the welcome screen — see [logout].
+ Future<void>? _signingOut;
+
+ /// A Sign out by hand is under way: it takes a few seconds (the device log, the sockets) before
+ /// the welcome screen comes up, and the screens that offer it say so meanwhile.
+ bool get signingOut => _signingOut != null;
+
/// Sign out by hand — Settings ▸ account ▸ Sign out. The welcome screen it lands on says nothing:
/// the person knows why they are there.
+ ///
+ /// ⚠️ **One at a time: a second call joins the first.** The first can take up to 5 seconds with
+ /// nothing on screen changing ([_endSession] waits on the device log), long enough to press Sign
+ /// out again — and the second, finishing after the first, invalidated the auth work of a sign-in
+ /// the person had started on the welcome screen meanwhile (Continue with Google, into the right
+ /// account): dropped, with nothing said.
Future<void> logout() {
+ final running = _signingOut;
+ if (running != null) return running;
_leftByHand = true;
- return _endSession();
+ late final Future<void> run;
+ run = () async {
+ try {
+ await _endSession();
+ } finally {
+ if (identical(_signingOut, run)) {
+ _signingOut = null;
+ // A sign-out cut short (another sign-in or -out moved the session on) changes no status
+ // of its own: whatever drew "Signing out…" is told it is over.
+ if (!_disposed) notifyListeners();
+ }
+ }
+ }();
+ _signingOut = run;
+ notifyListeners();
+ return run;
}
/// Everything a sign-out does, whoever asked for it. [reason] is what the welcome screen says
@@ -2481,7 +2511,8 @@ class AppNotifier extends ChangeNotifier {
if (result.error != null) return result.error;
final targetId = result.linkedMachineId ?? machineId;
final state = machineStates[targetId];
- if (state != null) {
+ // Already in by another way meanwhile — see [_keepsOpenConnection]: nothing to redial.
+ if (state != null && !_keepsOpenConnection(state)) {
state.needsLink = false;
state.agentLoadStatus = AgentLoadStatus.idle;
notifyListeners();
@@ -2951,11 +2982,14 @@ class AppNotifier extends ChangeNotifier {
notifyListeners();
}
- /// A code scanned, signed in, for [machineId] by a page that was gone by the time it could pair
- /// with it — "Waiting for your computer…", taken away under the camera by the very computer it
- /// was waiting for (`phone/welcome/connect_computer.dart`). Held like a code scanned at sign-in:
+ /// A code scanned, signed in, on "Waiting for your computer…" (`phone/welcome/connect_computer.dart`)
+ /// — a page the very computer it was waiting for takes away. Held like a code scanned at sign-in:
/// the home screen pairs with it once that computer is there and locked ([pendingPairing]).
///
+ /// That page looks the computer up on the account first, and holds no code the account answered
+ /// without; one held while the account could not be asked is let go by the next list that
+ /// answers without its computer ([_refreshMachines]).
+ ///
/// Not for a computer already open: nothing is left to pair, and a code kept would be spent the
/// next time it locks, in place of its password form (see where [pendingPairing] is cleared on
/// connect). Not once signed out either: the page then went because the account did, and its
@@ -3047,7 +3081,7 @@ class AppNotifier extends ChangeNotifier {
);
if (result.error != null) return result.error;
final state = machineStates[result.linkedMachineId ?? machineId];
- if (state != null) {
+ if (state != null && !_keepsOpenConnection(state)) {
state.needsLink = false;
state.agentLoadStatus = AgentLoadStatus.idle;
notifyListeners();
@@ -3058,6 +3092,18 @@ class AppNotifier extends ChangeNotifier {
return null;
}
+ /// Whether a machine just linked (by password or code) is already connected — let in meanwhile
+ /// by another way, the device log's vouched redial above all ([_redialOnceVouched]), which goes
+ /// on dialling behind a machine shown locked.
+ ///
+ /// ⚠️ **Then the link leaves its connection alone.** Both links used to close the machine and
+ /// dial it again whatever its state, to replace a socket that refused this phone — and an open
+ /// one went with it: the terminal on screen read "Connection lost. Reconnecting…" a moment after
+ /// the unlock that was meant to open it. A connected socket has passed the machine's welcome
+ /// (`WsConn._markReady`), so it is no refused one.
+ bool _keepsOpenConnection(MachineState state) =>
+ state.connectionStatus == ConnectionStatus.connected;
+
/// A test's stand-in for the trust-group roster swap; null uses [DirectLink.syncGroup].
late final GroupSync? _groupSyncOverride;