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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(mobile): explain sign-in steps and sign-outs on onboarding
tony4168627fb1d2
diff --git a/mobile/lib/phone/settings_page.dart b/mobile/lib/phone/settings_page.dartindex d73eca621..54d8cd5e9 100644--- a/mobile/lib/phone/settings_page.dart+++ b/mobile/lib/phone/settings_page.dart@@ -282,11 +282,33 @@ class _Body extends StatelessWidget {icon: LucideIcons.logOut300,label: 'Sign out',destructive: true,- onTap: () => unawaited(notifier.logout()),+ onTap: () => unawaited(_confirmSignOut(context, notifier)),),],);}++ /// 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.+ Future<void> _confirmSignOut(+ BuildContext context,+ AppNotifier notifier,+ ) async {+ 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.',+ confirmLabel: 'Sign out',+ );+ if (!confirmed) return;+ await notifier.logout();+ }}class _Avatar extends StatelessWidget {diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dartindex fed35f2dc..81fb8e27d 100644--- a/mobile/lib/phone/welcome/connect_computer.dart+++ b/mobile/lib/phone/welcome/connect_computer.dart@@ -1,4 +1,5 @@import '../approve_sign_in.dart';+import 'dart:async';import 'package:flutter/material.dart';@@ -24,7 +25,7 @@ import 'set_up_computer.dart';////// Send it to your computer: (the download menu)/// …-/// Then open it, and scan the code it shows.+/// Then open it, sign in with Google or Apple, and scan the code in Add Phone…./// Scan to connect ›/// See how it works ▶/// Try the sample while you waitdiff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dartindex b00780e07..5d980898b 100644--- a/mobile/lib/phone/welcome/phone_welcome.dart+++ b/mobile/lib/phone/welcome/phone_welcome.dart@@ -98,6 +98,24 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {/// Between a scan and the session it signs in: the scan page says so.bool _signingInWithScan = false;++ /// The scan read a computer's own sign-in QR — "Scan with your phone" on its sign-in sheet, the+ /// button someone adding a phone is most likely to press there. It needs a phone that is signed in+ /// already, so the scan page says what to do instead. Gone when the step is left.+ bool _readComputerSignIn = false;++ /// Under the scan page's hint. A desktop app opens signed out (its guest mode), and its Add Phone+ /// then shows no code, only "Sign in to add your phone." — with no way to sign in from there.+ static const _signInThereFirst =+ 'Does it say “Sign in to add your phone”? Sign in on the computer first '+ '(Settings ▸ Account, with Google or Apple), then open Add Phone… again.';++ /// In its place once a computer's sign-in QR is read ([_readComputerSignIn]).+ static const _notThatCode =+ 'That code signs a computer in from a phone that is already signed in. '+ 'On the computer, choose Continue with Google or Apple instead, then scan the code in '+ 'Add Phone….';+String? _error;int _resendIn = 0;Timer? _resendTimer;@@ -168,6 +186,7 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {setState(() {_step = step;_error = null;+ _readComputerSignIn = false;});if (step == _Step.email) _emailFocus.requestFocus();if (step == _Step.code) _codeFocus.requestFocus();@@ -269,6 +288,7 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {? null: (provider) => unawaited(_signInWith(provider)),waitingOn: widget.notifier.signInProvider,+ signedOutReason: widget.notifier.signedOutReason,// Past the page and the exchange, the session is saved and the machines are on// their way: nothing is waited on in the browser any more, and nothing to cancel.entering:@@ -288,6 +308,12 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {_Step.scan => ScanToConnectPage(camera: widget.scanCamera,onCode: (code) => unawaited(_onScanned(code)),+ // Read, not ignored: a phone pointed at a computer's sign-in QR is a person who chose+ // the wrong button there, and nothing happening was all they used to get.+ onSignInCode: (_) => setState(() => _readComputerSignIn = true),+ signInCodeEndsScan: false,+ note: _readComputerSignIn ? _notThatCode : _signInThereFirst,+ noteWarns: _readComputerSignIn,signingIn: _signingInWithScan,onUseEmail: () => _go(_Step.email),onBack: () => _go(_Step.hello),@@ -379,8 +405,13 @@ class _Hello extends StatelessWidget {this.waitingOn,this.entering = false,this.error,+ this.signedOutReason,});+ /// Why the phone is back here when it was signed in a moment ago ([AppNotifier.signedOutReason]):+ /// said above the question, or the welcome reads as a first run with no account behind it.+ final String? signedOutReason;+final VoidCallback onScan;final VoidCallback onSetUp;@@ -446,6 +477,10 @@ class _Hello extends StatelessWidget {style: hero,),const Spacer(),+ if (signedOutReason case final reason?) ...[+ _SignedOutNotice(reason: reason),+ const SizedBox(height: 18),+ ],TtyText('Is Harness on your computer?',color: tty.faint,@@ -550,6 +585,44 @@ class _Answer extends StatelessWidget {}}+/// Why a phone that was signed in is back on the welcome: a raised block over the question, the+/// sign-out mark in the terminal's yellow beside the sentence. Not the red of [_Hello.error] — the+/// person did nothing wrong, and signing in again is the whole of what to do.+class _SignedOutNotice extends StatelessWidget {+ const _SignedOutNotice({required this.reason});++ final String reason;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Semantics(+ liveRegion: true,+ child: Container(+ key: const ValueKey('welcome-signed-out'),+ padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),+ decoration: BoxDecoration(+ color: ttyRaised(tty),+ borderRadius: BorderRadius.circular(10),+ ),+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Padding(+ padding: const EdgeInsets.only(top: 1),+ child: Icon(LucideIcons.logOut300, size: 16, color: tty.yellow),+ ),+ const SizedBox(width: 10),+ Expanded(+ child: Text(reason, style: tty.style(size: TtySize.row)),+ ),+ ],+ ),+ ),+ );+ }+}+/// The line between the question's answers and the accounts: a rule each side of a few faint/// words, in the terminal's own furniture colour.class _OrDivider extends StatelessWidget {diff --git a/mobile/lib/phone/welcome/scan_to_connect.dart b/mobile/lib/phone/welcome/scan_to_connect.dartindex d7e02d560..e405154c3 100644--- a/mobile/lib/phone/welcome/scan_to_connect.dart+++ b/mobile/lib/phone/welcome/scan_to_connect.dart@@ -46,6 +46,9 @@ class ScanToConnectPage extends StatefulWidget {this.acceptConnectCodes = true,this.title = 'Scan the code on your computer',this.hint = 'On your Mac: Harness ▸ Add Phone…',+ this.note,+ this.noteWarns = false,+ this.signInCodeEndsScan = true,});final ValueChanged<ConnectCode> onCode;@@ -53,6 +56,18 @@ class ScanToConnectPage extends StatefulWidget {/// A computer's sign-in QR ([SignInCode]) was read — offered only where the page takes one.final ValueChanged<SignInCode>? onSignInCode;+ /// Whether reading a sign-in QR ends the scan, as it does where the page is pushed to fetch one.+ /// False keeps the camera reading after [onSignInCode] — for the first screen, which can only say+ /// why that code is not the one, and then has to read the right one. The same code still in frame+ /// is answered once, not every frame.+ final bool signInCodeEndsScan;++ /// A line or two under the hint, in words that wrap: what to do when the computer cannot show the+ /// code yet, or why the code just read is not the one. [noteWarns] draws it in the terminal's+ /// yellow, for the second.+ final String? note;+ final bool noteWarns;+/// Whether an Add Phone QR ([ConnectCode]) is one this page takes.final bool acceptConnectCodes;@@ -80,6 +95,10 @@ class _ScanToConnectPageState extends State<ScanToConnectPage>/// Set once a code of ours is read: the camera keeps reporting it every frame.bool _done = false;+ /// The sign-in QR last answered while the scan went on ([ScanToConnectPage.signInCodeEndsScan]+ /// false) — still in frame, it is reported every frame and must not be answered every frame.+ String? _answeredSignIn;+/// The camera, held here rather than left to [MobileScanner] — null when [ScanToConnectPage.camera]/// stands in for it.///@@ -167,6 +186,13 @@ class _ScanToConnectPageState extends State<ScanToConnectPage>for (final barcode in capture.barcodes) {final raw = barcode.rawValue ?? '';final signIn = widget.onSignInCode == null ? null : SignInCode.parse(raw);+ if (signIn != null && !widget.signInCodeEndsScan) {+ if (raw == _answeredSignIn) continue;+ _answeredSignIn = raw;+ HapticFeedback.mediumImpact();+ widget.onSignInCode!(signIn);+ continue;+ }if (signIn != null) {_done = true;HapticFeedback.mediumImpact();@@ -258,6 +284,25 @@ class _ScanToConnectPageState extends State<ScanToConnectPage>],),),+ if (widget.note case final note?) ...[+ const SizedBox(height: 12),+ Padding(+ padding: const EdgeInsets.symmetric(horizontal: Tty.origin),+ // Wraps, unlike the hint above it: a sentence of what to do, not a label. Announced when+ // it changes — it is the page's only answer to a code it will not take.+ child: Semantics(+ liveRegion: true,+ child: Text(+ note,+ key: const ValueKey('scan-note'),+ style: tty.style(+ size: TtySize.meta,+ color: widget.noteWarns ? tty.yellow : tty.faint,+ ),+ ),+ ),+ ),+ ],const SizedBox(height: 16),Center(child: TtyTextButton(diff --git a/mobile/lib/phone/welcome/set_up_computer.dart b/mobile/lib/phone/welcome/set_up_computer.dartindex c304664df..b6fc109fa 100644--- a/mobile/lib/phone/welcome/set_up_computer.dart+++ b/mobile/lib/phone/welcome/set_up_computer.dart@@ -108,7 +108,7 @@ Future<Map<String, String>> loadDesktopDownloads({Dio? dio}) async {/// └──────────────────────────────────────┘/// or open harness.autonomous.ai/desktop there.///-/// Then open it, and scan the code it shows.+/// Then open it, sign in with Google or Apple, and scan the code in Add Phone…./// Scan to connect ›/// ```class SetUpComputerPage extends StatefulWidget {@@ -287,7 +287,14 @@ class _SetUpComputerPageState extends State<SetUpComputerPage> {style: faint,),const SizedBox(height: 28),- Text('Then open it, and scan the code it shows.', style: faint),+ // ⚠️ **Sign in, and with which buttons.** The desktop app opens signed out, and shows no+ // code until it is signed in — "Then open it, and scan the code it shows" sent people to+ // an Add Phone that only said "Sign in to add your phone.". Google or Apple by name: its+ // third way, "Scan with your phone", needs a phone that is already signed in.+ Text(+ 'Then open it, sign in with Google or Apple, and scan the code in Add Phone….',+ style: faint,+ ),const SizedBox(height: 4),Align(alignment: Alignment.centerLeft,diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex ca39e569c..d24f06c15 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -1112,6 +1112,23 @@ class AppNotifier extends ChangeNotifier {notifyListeners();}+ /// Why this phone was signed out while it was in use — its session ended for good, or another+ /// device removed it from the account — for the welcome screen to say. Without it the phone lands+ /// on the first-run welcome as if it had never been signed in. Null after a Sign out by hand, and+ /// cleared the moment a sign-in starts.+ String? signedOutReason;++ /// A Sign out by hand is under way or done, until the next sign-in. ⚠️ That sign-out takes this+ /// phone's key out of the device log, and the log reading its own removal back calls+ /// [ViewerDeviceLog.onSignedOut] — the very call a removal from another device makes. This is what+ /// tells the two apart, so the person who pressed Sign out is not told the phone was removed.+ bool _leftByHand = false;++ static const _signedOutEnded =+ 'You were signed out. Sign in again to reach your computers.';+ static const _signedOutRemoved =+ 'This phone was removed from your account on another device. Sign in again to use it here.';+String get autonomousEnv => _autonomousEnv;static const offlineRetryInterval = Duration(seconds: 5);@@ -1417,6 +1434,10 @@ class AppNotifier extends ChangeNotifier {// end in a read of the device log, which must be judged by THIS sign-in (a hand sign-in mints its// id here), not the previous account's. Synchronous: no await may come first._beginDeviceLogSignIn(revision);+ // Signed in again: a removal the log reads from here on was made by another device. Not before+ // this line — the last Sign out by hand may still be reading its own removal back until the log+ // knows about this sign-in, which the line above just told it.+ _leftByHand = false;// Stays on the pre-navigation `bootstrapping` screen (main.dart) until the local state is// restored. A phone has no local service to start — the desktop's "Starting local service…"// was a sentence about somebody else's computer shown while this one read its own disk.@@ -1578,8 +1599,14 @@ class AppNotifier extends ChangeNotifier {_keptScreenStore?.clear();unawaited(_pool?.closeAll());_pool = null;+ // ⚠️ The saved session goes too. The socket that said so (a refresh refused, 4403) is the only+ // judge of it, and a session left on disk signed the NEXT launch straight back in — only to be+ // refused again, with the person never told why. Best effort, as [logout]'s own: a store that+ // cannot be written to must not surface as an unhandled error on the way out.+ unawaited(cliLogin.logout().catchError((Object _) {}));_lastError = message;_lastErrorRetryable = true;+ signedOutReason = _signedOutEnded;status = AppStatus.unauthenticated;notifyListeners();}@@ -1612,6 +1639,7 @@ class AppNotifier extends ChangeNotifier {final revision = _invalidateAuthWork();_closedHistory.clear();_lastError = null;+ signedOutReason = null;signingIn = true;notifyListeners();try {@@ -1642,6 +1670,7 @@ class AppNotifier extends ChangeNotifier {final revision = _invalidateAuthWork();_closedHistory.clear();_lastError = null;+ signedOutReason = null;signingIn = true;notifyListeners();try {@@ -1675,6 +1704,7 @@ class AppNotifier extends ChangeNotifier {final revision = _invalidateAuthWork();_closedHistory.clear();_lastError = null;+ signedOutReason = null;signingIn = true;signInProvider = provider;notifyListeners();@@ -1733,7 +1763,16 @@ class AppNotifier extends ChangeNotifier {viewer.login.cancel();}- Future<void> logout() async {+ /// Sign out by hand — Settings ▸ account ▸ Sign out. The welcome screen it lands on says nothing:+ /// the person knows why they are there.+ Future<void> logout() {+ _leftByHand = true;+ return _endSession();+ }++ /// Everything a sign-out does, whoever asked for it. [reason] is what the welcome screen says+ /// ([signedOutReason]): null when the person chose it.+ Future<void> _endSession({String? reason}) async {// Signing out takes this phone's key out of the account's devices, while the sign-in still works// to say so. Best effort, and brief.if (_deviceLog case final log?) {@@ -1801,6 +1840,7 @@ class AppNotifier extends ChangeNotifier {_clearDeviceNotices();expandedMachines.clear();selectedMachineId = null;+ signedOutReason = reason;status = AppStatus.unauthenticated;notifyListeners();}@@ -2518,7 +2558,10 @@ class AppNotifier extends ChangeNotifier {onRemoved: (n) => _whenSignedIn(() => announceDeviceRemoval(n)),onSignedOut: () async {// Sign out first: it takes this phone's key out of the log, which needs the key it is about.- await logout();+ // After a Sign out by hand this is that sign-out reading its own removal back — nothing to+ // tell anyone ([_leftByHand]). Otherwise another device removed this phone, and the welcome+ // screen it lands on says so.+ await _endSession(reason: _leftByHand ? null : _signedOutRemoved);await viewer.keys.forgetIdentity();},onChanged: () {