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
feat(desktop): add Add Phone icon and sign-in-first dialog
tony107c1ca52286
diff --git a/desktop/lib/core/phone_app_links.dart b/desktop/lib/core/phone_app_links.dartindex 13dd72c70..2e6309be1 100644--- a/desktop/lib/core/phone_app_links.dart+++ b/desktop/lib/core/phone_app_links.dart@@ -9,3 +9,8 @@ const kAppStoreUrl =/// app's `applicationId` (mobile `android/app/build.gradle.kts`).const kGooglePlayUrl ='https://play.google.com/store/apps/details?id=ai.autonomous.harness.android';++/// The phone app, whichever phone opens it: the website sends an iPhone to+/// [kAppStoreUrl] and an Android phone to [kGooglePlayUrl], and anything else+/// to a page with both. Add Phone's one download code, instead of one per store.+const kPhoneAppUrl = 'https://harness.autonomous.ai/app';diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex 4651f29a3..9ae2a0646 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -1820,6 +1820,7 @@ class _SwarmScreenState extends State<SwarmScreen> {'reduceMotion': _reduceMotion,'activeId': app.activeSwarmId,'searchTooltip': _commandTooltip('Open Harness', 'harnesses.list'),+ 'addPhoneTooltip': _addPhoneTooltip,'storeTooltip': _commandTooltip('Explore Harness Store', 'app.store'),'devicesVisible': app.devicesEnabled,// The row's last control: Sign in, or whose account this is.@@ -7132,6 +7133,7 @@ class _SwarmScreenState extends State<SwarmScreen> {children: [_searchButton(theme),_notificationsButton(theme),+ _addPhoneButton(theme),if (app.devicesEnabled) _devicesButton(context),WorkspaceStoreButton(key: const ValueKey('swarm-store-button'),@@ -7961,7 +7963,7 @@ class _SwarmScreenState extends State<SwarmScreen> {final messagesColor = grid.AppPalette.accentOnSurface;final storeWidth = math.min(WorkspaceStoreButton.widthOf(context),- math.max(0.0, constraints.maxWidth - cell.width * 22),+ math.max(0.0, constraints.maxWidth - cell.width * 26),);// Sign in or the avatar always stays; see [_accountControl].final accountWidth = _accountControlWidth(context);@@ -7970,14 +7972,14 @@ class _SwarmScreenState extends State<SwarmScreen> {final devicesWidth = WorkspaceStoreButton.widthOf(context, devices: true);final showDevices =app.devicesEnabled &&- constraints.maxWidth - cell.width * 22 - accountWidth >=+ constraints.maxWidth - cell.width * 26 - accountWidth >=WorkspaceStoreButton.widthOf(context) + devicesWidth;- // Search, notifications, Devices, Store and the account — none of it- // here when the title bar holds them.+ // Search, notifications, Add Phone, Devices, Store and the account —+ // none of it here when the title bar holds them.final actionsWidth = _titleBarActions? 0.0: storeWidth +- cell.width * 8 ++ cell.width * 12 +(showDevices ? devicesWidth : 0) +accountWidth;final leadingWidth = chrome?.leadingWidth(context) ?? 0.0;@@ -8176,6 +8178,7 @@ class _SwarmScreenState extends State<SwarmScreen> {if (!_titleBarActions) ...[_searchButton(theme),_notificationsButton(theme),+ _addPhoneButton(theme),if (showDevices) _devicesButton(context),WorkspaceStoreButton(key: const ValueKey('swarm-store-button'),@@ -8236,6 +8239,31 @@ class _SwarmScreenState extends State<SwarmScreen> {),);+ String get _addPhoneTooltip => _commandTooltip('Add Phone', 'app.add_phone');++ /// Harness ▸ Add Phone…, as a glyph just before Devices ([_addPhone]).+ Widget _addPhoneButton(TerminalTheme theme) => WorkspaceBarControl(+ key: const ValueKey('swarm-add-phone-button'),+ label: 'Add Phone',+ tooltip: _addPhoneTooltip,+ onPressed: _shortcutsEnabled ? () => unawaited(_addPhone()) : null,+ builder: (context, emphasized) => SizedBox(+ width: workspaceBarCellSizeOf(context).width * 4,+ height: workspaceBarControlHeight(context),+ child: Icon(+ AppIcons.smartphoneNfc,+ size: 16,+ color: theme.foreground.withValues(+ alpha: !_shortcutsEnabled+ ? .28+ : emphasized+ ? 1+ : .75,+ ),+ ),+ ),+ );+Widget _notificationsButton(TerminalTheme theme) =>WorkspaceNotificationsButton(key: const ValueKey('workspace-notifications-button'),diff --git a/desktop/lib/shared/theme/app_icons.dart b/desktop/lib/shared/theme/app_icons.dartindex 8bf93d137..eb6bbed5b 100644--- a/desktop/lib/shared/theme/app_icons.dart+++ b/desktop/lib/shared/theme/app_icons.dart@@ -157,6 +157,7 @@ abstract final class AppIcons {static const shieldOff = LucideIcons.shieldOff400;static const slidersHorizontal = LucideIcons.slidersHorizontal400;static const smartphone = LucideIcons.smartphone400;+ static const smartphoneNfc = LucideIcons.smartphoneNfc400;static const snowflake = LucideIcons.snowflake400;static const sparkles = LucideIcons.sparkles400;static const square = LucideIcons.square400;diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 32592ae63..8872dba71 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -7673,6 +7673,14 @@ class AppNotifier extends ChangeNotifier {/// Devices that joined the account and this end had never trusted, not yet dismissed.final List<NewDeviceNotice> newDevices = [];+ /// Each device [_announceDevice] says joined the account, as it is said — never the pending list+ /// rebuilt from the log ([_syncPendingDevices]), which is old news by then. Add Phone listens here+ /// for the phone it is adding (`widgets/add_phone_dialog.dart`). Broadcast: with nobody listening,+ /// a join is dropped, like [spokenTasks].+ final StreamController<NewDeviceNotice> _deviceJoins =+ StreamController<NewDeviceNotice>.broadcast();+ Stream<NewDeviceNotice> get deviceJoins => _deviceJoins.stream;+/// Devices taken out of the account by another device, not yet dismissed. Not persisted: the/// history is the durable record.final List<DeviceRemovalNotice> deviceRemovals = [];@@ -7893,7 +7901,10 @@ class AppNotifier extends ChangeNotifier {final shown = newDevices.any((d) => d.pub == notice.pub);// A daemon's frame can repeat; the viewer's log says each key once ([always]).if (shown && !always) return;- if (!shown) newDevices.add(notice);+ if (!shown) {+ newDevices.add(notice);+ if (!_disposed) _deviceJoins.add(notice);+ }devicesRevision++;systemNotifications.postNotice(id: 'harness-device:${notice.pub}',@@ -17827,6 +17838,7 @@ class AppNotifier extends ChangeNotifier {}unawaited(_spokenTasks.close());unawaited(_deviceWindowRequests.close());+ unawaited(_deviceJoins.close());unawaited(_zooPushes.close());unawaited(_daemonFrames.close());unawaited(_modelsRequests.close());diff --git a/desktop/lib/widgets/add_phone_dialog.dart b/desktop/lib/widgets/add_phone_dialog.dartindex a37d67b40..9f79a5bae 100644--- a/desktop/lib/widgets/add_phone_dialog.dart+++ b/desktop/lib/widgets/add_phone_dialog.dart@@ -11,29 +11,40 @@ import '../shared/widgets/qr_code_view.dart';import '../api/api_client.dart';import '../core/phone_app_links.dart';import '../screens/login_screen.dart' show showSignInSheet;+import '../shared/theme/app_icons.dart';import '../shared/theme/app_theme.dart' as grid;import '../shortcuts/app_keymap.dart';+import '../state/account_devices.dart' show NewDeviceNotice;import '../state/app_state.dart';import '../ws/ws_conn.dart' show WsRequestFailure, WsRequestTimeout;import 'desktop_chrome.dart';import 'desktop_prompt_surface.dart';import 'terminal_prompt.dart';-/// Harness ▸ Add Phone… — a QR the phone scans to sign in to this account AND-/// pair with this computer, end to end encrypted, with no password typed.+/// Harness ▸ Add Phone… — how a phone comes to manage this account's agents.///-/// Three parts, and the QR is only one of them:+/// **The phone signs in, and that is all (owner, 2026-10-12).** The phone's+/// onboarding (mobile `phone_welcome.dart`, `your_computer.dart`) puts a phone+/// on the account by its own sign-in: the account's device key log makes every+/// computer signed in to it trust the phone, so it finds this one with nothing+/// to scan. So the dialog says what to do on the phone — install Harness, sign+/// in with this account — and watches the account for it to join+/// ([AppNotifier.deviceJoins]). A computer with no account signs in first.+///+/// **The QR is the way in for what that does not cover** — a phone app from+/// before the onboarding, or a phone that does not turn up — put away under+/// "Not showing up? Scan a code instead", and armed only while it is up:////// 1. **The QR** ([phonePairLink]) tells the phone who to sign in as, which/// machine to pair with, and the one-time pairing code./// 2. **The sign-in code** ([PhoneSignInCodeCall]), which the QR also carries:/// the phone redeems it for a session of its own, so the scan signs it in-/// with no emailed code. Renewed every minute while the dialog is open —-/// see [_AddPhoneDialogState._renewSignIn].+/// with no emailed code. Renewed every minute while the code is up — see+/// [_AddPhoneDialogState._renewSignIn]./// 3. **Arming the daemon.** The phone, once signed in, sends this machine an/// `e2e_pair_intent`; the daemon runs the handshake only when somebody on/// THIS computer hands it the same code (`POST /api/pair`, the call-/// `harness pair <code>` makes). So while this dialog is open it keeps+/// `harness pair <code>` makes). So while the code is up the dialog keeps/// handing it over — see [_AddPhoneDialogState._loop] — and the code is/// live exactly as long as the QR is on screen.///@@ -248,15 +259,35 @@ class AddPhoneDialog extends StatefulWidget {final PhoneSignInCodeCall signInCode;final VoidCallback? onConnectMachine;- /// Opens Machines — where the account's computers, phones and apps are listed and- /// removed, on every device at once. Null shows no link.+ /// Was "Manage devices…" — Machines — under the code. No longer drawn: a+ /// second way out, in the middle of adding a phone, that nobody adding one+ /// was looking for (owner, 2026-10-12). Kept so the callers that pass it+ /// still build; it goes with them.final VoidCallback? onManageDevices;@overrideState<AddPhoneDialog> createState() => _AddPhoneDialogState();}-class _AddPhoneDialogState extends State<AddPhoneDialog> {+/// What the picture at the top of Add Phone shows: this computer, the phone,+/// and what runs between them.+enum _Link {+ /// No account here: the computer asks to be signed in, and the way to the+ /// phone is locked.+ signIn,++ /// Its sign-in is under way in the browser: the same, at twice the pace.+ signingIn,++ /// Signed in: packets run to the phone, which rings out.+ looking,++ /// The phone is in.+ ready,+}++class _AddPhoneDialogState extends State<AddPhoneDialog>+ with TickerProviderStateMixin {/// With no phone waiting the daemon answers at once, so this is the whole/// cadence of the loop: how soon after the phone's intent lands the/// handshake starts. ⚠️ `NO_INTENT`, `EXPIRED` and `BUSY` are answered@@ -267,14 +298,21 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {static const _rateLimited = Duration(seconds: 60);static const _unexpected = Duration(seconds: 5);- /// How long "Connected" stays up before the dialog closes itself.- static const _connectedHold = Duration(milliseconds: 1500);-/// How often the QR gets a new sign-in code. Shorter than the code's own/// life (90 s at the backend), so the one on screen always has at least/// half a minute left in it when a phone reads it.static const _signInRenew = Duration(seconds: 60);+ /// How long "Looking for your phone" goes before it names what keeps a phone+ /// away most often: signed in, but to another account.+ static const _stillLookingAfter = Duration(minutes: 1);++ /// One beat of the picture — and of the step it points at, and the caret:+ /// the mobile onboarding's breathing pace. Twice as fast while the browser+ /// signs this computer in.+ static const _beat = Duration(milliseconds: 2400);+ static const _quickBeat = Duration(milliseconds: 1200);+AppNotifier get app => widget.app;// Freeze the destination while a QR is visible, even if focus or inventory changes.@@ -309,17 +347,51 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {/// older ask is dropped, so only one chain of renewals ever runs.int _signInRound = 0;- /// This computer had no account while the dialog was open, so the sign-in- /// code it asked for then was refused. When the account lands it asks again- /// at once — see [_appChanged].- bool _awaitingAccount = false;+ /// The QR's sign-in code has been asked for since the code last came up. A+ /// code put away lets its renewal lapse ([_renewSignIn]), and the next+ /// showing asks afresh.+ bool _signInStarted = false;- /// The account landed while the dialog was open — see [_appChanged].- bool _signedInWhileOpen = false;+ /// This computer had no account while the dialog was open. When the account+ /// lands, the lock on the way to the phone opens, and a code that was up+ /// asks for its sign-in code again — see [_appChanged].+ bool _awaitingAccount = false;/// The sign-in sheet raised from here is up — see [_signInHere].bool _signingIn = false;+ /// "On this Mac ▸ Sign in" leads: the computer had no account when this+ /// opened, or lost it since. It stays — ticked — once it signs in, so the+ /// steps under it do not move.+ bool _signInStep = false;++ /// The phone is in: the name it gave, or '' when it gave none. Null while+ /// looking.+ String? _ready;++ /// "Not showing up? Scan a code instead" is open: the code is up, and armed.+ bool _showingCode = false;++ /// A minute of looking and no phone ([_stillLookingAfter]).+ bool _stillLooking = false;+ Timer? _stillTimer;++ StreamSubscription<NewDeviceNotice>? _joins;++ /// The beat ([_beat]): the picture, the ring of the step to do now, and the+ /// caret after "Looking for your phone" keep it.+ late final AnimationController _pulse = AnimationController(+ vsync: this,+ duration: _beat,+ );++ /// The lock on the way to the phone opening — once, when this computer+ /// signs in from here.+ late final AnimationController _unlock = AnimationController(+ vsync: this,+ duration: const Duration(milliseconds: 1800),+ );+/// The code's space — "Preparing your code…", then the code — so it can be/// brought into view ([_codeSpace]).final _codeKey = GlobalKey();@@ -329,7 +401,6 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {/// No pairing to be had from this daemon — asking stopped for good.bool _stopped = false;- String? _connected;String? _message;/// A message that is an instruction to the person ("scan the new code"),@@ -340,18 +411,22 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {@overridevoid initState() {super.initState();- _awaitingAccount = app.isGuest;+ _signInStep = _awaitingAccount = app.isGuest;app.addListener(_appChanged);- _syncLoop();- unawaited(_renewSignIn());+ _joins = app.deviceJoins.listen(_deviceJoined);+ _watchForPhone();}@overridevoid dispose() {_closed = true;app.removeListener(_appChanged);+ unawaited(_joins?.cancel());_timer?.cancel();_signInTimer?.cancel();+ _stillTimer?.cancel();+ _pulse.dispose();+ _unlock.dispose();if (_sleeping case final sleeping? when !sleeping.isCompleted) {sleeping.complete(false);}@@ -368,21 +443,69 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {if (_closed) return;if (app.isGuest) {_awaitingAccount = true;- } else if (_awaitingAccount && _target != null) {- // Signed in while the dialog was open. The code asked for before was- // refused, and the next renewal is a minute off: without asking now,+ _signInStep = true;+ _stillTimer?.cancel();+ _stillTimer = null;+ _stillLooking = false;+ } else if (_awaitingAccount && !app.signingIn) {+ // Signed in while the dialog was open: the lock on the way to the phone+ // opens, once.+ _awaitingAccount = false;+ if (!MediaQuery.disableAnimationsOf(context)) {+ unawaited(_unlock.forward(from: 0));+ }+ // A code that was up asked for its sign-in code without an account and+ // was refused, and the next renewal is a minute off: without asking now,// the first QR the phone can scan has no sign-in in it, and the phone// falls back to an emailed code.- _awaitingAccount = false;- _signedInWhileOpen = true;- _restartSignIn();+ if (_signInStarted) _restartSignIn();}setState(() {});_syncLoop();+ _watchForPhone();+ }++ /// A device joined the account while this was open. A computer is not the+ /// phone; anything else signed in with this account, which is what the steps+ /// ask of the phone.+ void _deviceJoined(NewDeviceNotice device) {+ if (_closed || _ready != null || device.kind == 'machine') return;+ if (app.isGuest) return;+ _phoneIn(device.label);+ }++ /// The phone is in — by its own sign-in, or by the code. The code goes, with+ /// its renewal and the loop that arms it ([_asking]).+ void _phoneIn(String label) {+ _stillTimer?.cancel();+ _stillTimer = null;+ _signInTimer?.cancel();+ setState(() {+ _ready = label.trim();+ _message = null;+ // Back from the stores' codes, if that is where it was: "is ready" is+ // said under the picture.+ _showingStores = false;+ });+ }++ /// Whether there is a phone to look for: an account here, and none in yet.+ bool get _looking => _ready == null && !app.isGuest && !app.signingIn;++ /// Starts the minute before "Still looking" ([_stillLookingAfter]) once+ /// there is a phone to look for.+ void _watchForPhone() {+ if (!_looking || _stillLooking || _stillTimer != null) return;+ _stillTimer = Timer(_stillLookingAfter, () {+ _stillTimer = null;+ if (_closed || !_looking) return;+ setState(() => _stillLooking = true);+ });}/// A guest's way in, raised over this dialog rather than instead of it: the- /// sheet closes itself when the account lands, and the QR comes up here.+ /// sheet closes itself when the account lands, and the steps on the phone+ /// light up here.////// Without Scan with your phone: that way in needs a phone already signed/// in, and the person here is adding one.@@ -395,7 +518,7 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {app,reason:'Sign in to add your phone. Your phone signs in to the same '- 'account when it scans the code.',+ 'account.',offerPhone: false,);} finally {@@ -423,7 +546,16 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {return (email: email, machineId: machineId);}- bool get _asking => !_closed && !_stopped && _connected == null;+ /// The account the phone signs in with, when this computer knows it.+ String? get _accountEmail {+ if (app.isGuest) return null;+ final email = app.currentUser?.email.trim();+ return email != null && email.contains('@') ? email : null;+ }++ /// Only while the code is up: a code nobody can see is a code nobody can+ /// scan, and arming the daemon with it would be for nothing.+ bool get _asking => !_closed && !_stopped && _ready == null && _showingCode;/// Starts the loop when there is a QR worth arming and nothing is asking/// yet. Called again whenever the app changes, so a profile that loads@@ -447,13 +579,8 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {// that finished (or failed) behind a closed window must not touch it.if (_closed) return;if (answer.label case final label?) {- setState(() {- _connected = label;- _message = null;- });- if (await _sleep(_connectedHold) && mounted) {- Navigator.of(context).pop();- }+ // The transports call a phone that gave no name "phone".+ _phoneIn(label == 'phone' ? '' : label);return;}final Duration wait;@@ -466,7 +593,8 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {case 'CODE_MISMATCH':// The phone holds the old code and the daemon has spent it. A new// one — and a new QR — is the only way forward.- _say("That didn't match. Scan the new code.", sticky: true);+ // Under the code, which is the new one by now: "above".+ _say("That code didn't work. Scan the new one above.", sticky: true);setState(() => _code = newPhonePairCode());wait = _poll;case 'RATE_LIMITED':@@ -520,15 +648,19 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {_signIn = next?.code;_signInAsked = true;});- if (_connected != null || _stopped) return;+ if (_ready != null || _stopped) return;final ttl = next?.ttl;final wait = ttl != null && ttl - const Duration(seconds: 30) < _signInRenew? ttl - const Duration(seconds: 30): _signInRenew;- _signInTimer = Timer(- wait > Duration.zero ? wait : _signInRenew,- () => unawaited(_renewSignIn()),- );+ _signInTimer = Timer(wait > Duration.zero ? wait : _signInRenew, () {+ // Put away, the code needs no fresher sign-in: the next showing asks.+ if (!_showingCode) {+ _signInStarted = false;+ return;+ }+ unawaited(_renewSignIn());+ });}/// The renewal from the top, now: the pending one is cancelled, an ask@@ -542,6 +674,20 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {unawaited(_renewSignIn());}+ /// "Not showing up? Scan a code instead", opened or put away. Opened, the+ /// code asks for its sign-in code — fresh unless one is still renewing —+ /// and starts arming the daemon; put away, the loop ends after its answer.+ void _toggleCode() {+ setState(() {+ _showingCode = !_showingCode;+ if (_showingCode && !_signInStarted) {+ _signInStarted = true;+ _restartSignIn();+ }+ });+ _syncLoop();+ }+void _say(String message, {bool sticky = false}) => setState(() {_message = message;_sticky = sticky;@@ -563,179 +709,376 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {Color get _faint => DesktopChrome.muted;+ /// Narrower than a form: one column, the code at its middle.+ static const double _width = 400;++ /// The connect code, under the steps rather than the dialog's subject: still+ /// big enough to scan from across a desk.+ static const double _qrSide = 168;++ /// "App Store · Google Play": the stores' codes are up, in the connect code's+ /// place. One kind of code on screen at a time — Harness reads only the connect+ /// code, the Camera only these — so nobody scans one with the other's.+ bool _showingStores = false;++ _Link get _link {+ if (_ready != null) return _Link.ready;+ if (app.signingIn) return _Link.signingIn;+ if (app.isGuest) return _Link.signIn;+ return _Link.looking;+ }+@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);+ _keepBeat(context);return _dialog(context);}+ /// Runs the beat while something on screen moves to it: not once the phone+ /// is in, not under Reduce Motion, and not while the dialog is hidden.+ void _keepBeat(BuildContext context) {+ final link = _link;+ final moving =+ link != _Link.ready &&+ !MediaQuery.disableAnimationsOf(context) &&+ TickerMode.valuesOf(context).enabled;+ if (!moving) {+ if (_pulse.isAnimating) _pulse.stop();+ return;+ }+ final beat = link == _Link.signingIn ? _quickBeat : _beat;+ if (_pulse.isAnimating && _pulse.duration == beat) return;+ _pulse.duration = beat;+ unawaited(_pulse.repeat());+ }+Widget _dialog(BuildContext context) {return TerminalPromptKeys(cancel: _close,child: DesktopPromptSurface(+ width: _width,body: LayoutBuilder(builder: (context, constraints) => DesktopPromptScrollBody(- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- mainAxisSize: MainAxisSize.min,- children: [- Semantics(- header: true,- child: Text('Add your phone', style: DesktopChrome.heading()),- ),- const SizedBox(height: 18),- // Folded, the step is its one line, in the title's place: signed in, the- // pairing code is what the dialog is for, and at a large text size a- // title over the line pushed it below the fold.- _downloadsShown- ? _AddPhoneStep(- number: 1,- title: Text(- 'Get Harness on your phone',- style: _AddPhoneStep.titleStyle(),- ),- children: _downloads(),- )- : _AddPhoneStep(number: 1, title: _downloadsClosed()),- Divider(- height: 1,- thickness: 1,- color: grid.AppPalette.divider,- ),- _AddPhoneStep(- number: 2,- title: Text(_pairingTitle, style: _AddPhoneStep.titleStyle()),- children: _pairing(- math.min(200, constraints.maxWidth - _AddPhoneStep.indent),- ),- ),- ],- ),+ child: _showingStores+ ? _stores()+ : _connect(math.min(_qrSide, constraints.maxWidth)),),),- actions: [- TextButton(onPressed: _close, child: const Text('Done')),- if (app.isGuest)- FilledButton(- key: const ValueKey('add-phone-sign-in'),- autofocus: true,- onPressed: () => unawaited(_signInHere()),- child: const Text('Sign in…'),- ),- ],+ // None over the store's code: Back and Esc are the ways out of it.+ actions: _showingStores+ ? const []+ : [+ // Cancel while it looks — closing takes the code away — and+ // Done once the phone is in.+ if (_ready != null)+ FilledButton(+ key: const ValueKey('add-phone-done'),+ autofocus: true,+ onPressed: _close,+ child: const Text('Done'),+ )+ else ...[+ TextButton(onPressed: _close, child: const Text('Cancel')),+ if (app.isGuest)+ FilledButton(+ key: const ValueKey('add-phone-sign-in'),+ autofocus: true,+ onPressed: () => unawaited(_signInHere()),+ child: const Text('Sign in…'),+ ),+ ],+ ],),);}- /// Step 1's download codes, opened by hand once they are folded away. Null- /// follows the account: open for a guest, who is likeliest to be new to- /// Harness altogether; folded once signed in, so the one code on screen is- /// the one to scan from the app.- bool? _downloadsOpen;-- bool get _downloadsShown => _downloadsOpen ?? app.isGuest;-- /// The Harness app in its two stores, as codes a phone's camera opens —- /// not links: a link clicked here opens the store on this computer, which- /// cannot install a phone's app.- List<Widget> _downloads() => [- Text('Scan with your phone’s camera.', style: _note()),- Wrap(- spacing: 40,- runSpacing: 16,- children: const [- _StoreCode(- name: 'App Store',- mark: 'assets/stores/app-store.svg',- url: kAppStoreUrl,+ /// What this is for, the picture with how it is going under it, then the+ /// steps — on this computer first while it has no account, then on the+ /// phone — and the code, put away under them.+ ///+ /// ```+ /// Add your phone+ /// Manage all your agents on all your computers from your phone.+ /// [Mac] ·······🔒······· [phone]+ /// Looking for your phone▌+ /// ON THIS MAC (no account when it opened)+ /// (1) Sign in → (✓) Signed in+ /// Your phone signs in with the same As [email protected].+ /// account.+ /// ON YOUR PHONE+ /// (2) Install Harness+ /// App Store · Google Play+ /// (3) Sign in+ /// With [email protected].+ /// ─────────────────────────────────────────+ /// › Not showing up? Scan a code instead+ /// [Cancel] [Sign in…]+ /// ```+ ///+ /// ⚠️ **The phone's words, turned around (owner, 2026-10-12).** The line+ /// under the title is the phone's welcome headline (mobile `OnboardingCopy`),+ /// and the steps on the phone are its "On your computer, go to" seen from+ /// here (`set_up_computer.dart` `goToSteps`): Install Harness, then Sign in,+ /// `With <account>.` Change one, change the other.+ Widget _connect(double qrSide) {+ final asking = app.isGuest || app.signingIn;+ final ready = _ready != null;+ final email = _accountEmail;+ final first = _signInStep ? 2 : 1;+ final phoneMark = asking+ ? _Mark.later+ : ready+ ? _Mark.done+ : _Mark.plain;+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: [+ Semantics(+ header: true,+ child: Text('Add your phone', style: DesktopChrome.heading()),),- _StoreCode(- name: 'Google Play',- mark: 'assets/stores/google-play.svg',- url: kGooglePlayUrl,+ const SizedBox(height: 4),+ Text(+ 'Manage all your agents on all your computers from your phone.',+ style: _note(),+ ),+ const SizedBox(height: 14),+ _LinkPicture(link: _link, beat: _pulse, unlock: _unlock),+ _linkLine(email),+ if (_signInStep) ...[+ _where('On this ${_thisComputer()}'),+ _Step(+ number: 1,+ mark: asking ? _Mark.current : _Mark.done,+ beat: _pulse,+ title: [TextSpan(text: asking ? 'Sign in' : 'Signed in')],+ note: asking || email == null+ ? const [+ TextSpan(+ text: 'Your phone signs in with the same account.',+ ),+ ]+ : [+ const TextSpan(text: 'As '),+ _strong(email),+ const TextSpan(text: '.'),+ ],+ last: true,+ ),+ ],+ _where('On your phone'),+ _Step(+ number: first,+ mark: phoneMark,+ title: const [TextSpan(text: 'Install Harness')],+ link: ready+ ? null+ : _StepLink(+ key: const ValueKey('add-phone-show-downloads'),+ // The stores, not "Get Harness": in the computer's own+ // Harness that read as this app's download.+ label: 'App Store · Google Play',+ onPressed: () => setState(() => _showingStores = true),+ ),),+ _Step(+ number: first + 1,+ mark: phoneMark,+ title: const [TextSpan(text: 'Sign in')],+ note: asking || email == null+ ? const [TextSpan(text: 'With the same account.')]+ : [+ const TextSpan(text: 'With '),+ _strong(email),+ const TextSpan(text: '.'),+ ],+ last: true,+ ),+ if (!asking && !ready) ...[+ _disclosure(),+ if (_showingCode) ...[+ const SizedBox(height: 12),+ ..._codeArea(qrSide),+ ],+ ],],- ),- ];+ );+ }- Widget _downloadsClosed() => Wrap(- crossAxisAlignment: WrapCrossAlignment.center,- spacing: 4,- children: [- Text('Not on your phone yet?', style: _note()),- TextButton(- key: const ValueKey('add-phone-show-downloads'),- onPressed: () => setState(() => _downloadsOpen = true),- child: const Text('Show download codes'),+ /// Where the steps under it happen — this computer, or the phone.+ Widget _where(String text) => Padding(+ padding: const EdgeInsets.only(top: 18, bottom: 8),+ child: Semantics(+ header: true,+ child: Text(+ text.toUpperCase(),+ style: DesktopChrome.metadata().copyWith(+ fontWeight: FontWeight.w600,+ letterSpacing: .7,+ ),),- ],+ ),);- /// A browser with none of the account's computers to pair through.- bool get _connectFirst =>- app.viewer != null &&- !app.signingIn &&- app.currentUser?.email.contains('@') == true;-- String get _pairingTitle {- if (app.isGuest) return 'Sign in on this ${_thisComputer()}';- if (_target == null && _connectFirst) return 'Connect a computer first';- return 'Scan this code with Harness';+ /// The line under the picture, and it is the status: looking — the phone's+ /// "Looking for your computer▌" turned around — then, after a minute, what+ /// keeps a phone away most often, and that it is in. Nothing before there is+ /// an account to look with: the steps say what to do.+ Widget _linkLine(String? email) {+ final Widget line;+ switch (_link) {+ case _Link.signIn || _Link.signingIn:+ return const SizedBox.shrink();+ case _Link.ready:+ final name = _ready!;+ line = Text(+ '${name.isEmpty ? 'Your phone' : name} is ready.',+ key: const ValueKey('add-phone-ready'),+ textAlign: TextAlign.center,+ style: DesktopChrome.heading(),+ );+ case _Link.looking when _stillLooking:+ line = Column(+ key: const ValueKey('add-phone-still-looking'),+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ 'Still looking for your phone',+ textAlign: TextAlign.center,+ style: DesktopChrome.text(color: _faint, size: 13.5),+ ),+ const SizedBox(height: 3),+ Text.rich(+ TextSpan(+ children: [+ const TextSpan(text: 'Your phone has to be signed in with '),+ if (email != null)+ _strong(email)+ else+ const TextSpan(text: 'the same account'),+ const TextSpan(text: '.'),+ ],+ ),+ textAlign: TextAlign.center,+ style: DesktopChrome.metadata(),+ ),+ ],+ );+ case _Link.looking:+ line = Row(+ key: const ValueKey('add-phone-looking'),+ mainAxisSize: MainAxisSize.min,+ children: [+ Flexible(+ child: Text(+ 'Looking for your phone',+ style: DesktopChrome.text(color: _faint, size: 13.5),+ ),+ ),+ _Caret(beat: _pulse),+ ],+ );+ }+ return Padding(+ padding: const EdgeInsets.only(top: 6),+ child: Semantics(liveRegion: true, child: Center(child: line)),+ );}- /// Step 2: what signing in brings — the code, then whether it worked.- List<Widget> _pairing(double qrSide) {- if (app.isGuest) {- return [- Text(- 'A code appears here. Scan it with Harness on your phone.',- style: _note(),+ /// "Not showing up? Scan a code instead": the code, for a phone app from+ /// before the onboarding or a phone that does not turn up — put away until+ /// asked for, and armed only while it is up ([_asking]).+ Widget _disclosure() => Padding(+ padding: const EdgeInsets.only(top: 16),+ child: DecoratedBox(+ decoration: BoxDecoration(+ border: Border(top: BorderSide(color: grid.AppPalette.divider)),+ ),+ child: Padding(+ padding: const EdgeInsets.only(top: 10),+ child: Align(+ alignment: AlignmentDirectional.centerStart,+ child: Semantics(+ expanded: _showingCode,+ child: DesktopPill(+ key: const ValueKey('add-phone-show-code'),+ label: 'Not showing up? Scan a code instead',+ quiet: true,+ foregroundColor: _faint,+ leading: AnimatedRotation(+ turns: _showingCode ? .25 : 0,+ duration: const Duration(milliseconds: 150),+ child: Icon(AppIcons.chevronRight, size: 14, color: _faint),+ ),+ onPressed: _toggleCode,+ ),+ ),),- ];- }+ ),+ ),+ );++ /// The code, under "Not showing up?": the code, where to scan it on the+ /// phone, and what went wrong — or, before there is a code, why not yet, in+ /// a square of the code's own size so nothing moves when it comes.+ List<Widget> _codeArea(double qrSide) {+ // The code's own size at the least, so nothing moves when it comes; taller+ // when what it says (and a button) needs more than the code does.+ Widget room(List<Widget> children) => _codeSpace(+ Center(+ child: Container(+ width: qrSide,+ constraints: BoxConstraints(minHeight: qrSide),+ padding: const EdgeInsets.all(16),+ decoration: BoxDecoration(+ color: DesktopChrome.field,+ borderRadius: BorderRadius.circular(14),+ ),+ child: Center(+ child: Column(mainAxisSize: MainAxisSize.min, children: children),+ ),+ ),+ ),+ );+ Widget say(String text) =>+ Text(text, textAlign: TextAlign.center, style: _note());+final target = _target;if (target == null) {if (_connectFirst) {return [- Text(- 'Your phone pairs with a computer on your account.',- style: _note(),- ),- if (widget.onConnectMachine case final connect?)- Align(- alignment: AlignmentDirectional.centerStart,- child: TextButton(+ room([+ say('Your phone pairs with a computer on your account.'),+ if (widget.onConnectMachine case final connect?) ...[+ const SizedBox(height: 8),+ TextButton(onPressed: () {Navigator.of(context).pop();connect();},child: const Text('Connect a machine'),),- ),+ ],+ ]),];}return [- Text(- app.currentUser?.email.contains('@') == true- ? 'Waiting for Harness on this ${_thisComputer()}…'- : 'Waiting for your account…',- style: _note(),- ),+ room([+ say(+ app.currentUser?.email.contains('@') == true+ ? 'Waiting for Harness on this ${_thisComputer()}…'+ : 'Waiting for your account…',+ ),+ ]),];}// A moment's wait for the sign-in code, in the QR's own space: a QR that// changed right after it appeared would be one scanned without it.if (!_signInAsked) {return [- _codeSpace(- SizedBox(- height: qrSide,- child: Align(- alignment: AlignmentDirectional.centerStart,- child: Text('Preparing your code…', style: _note()),- ),- ),- ),+ room([say('Preparing your code…')]),];}final link = phonePairLink(@@ -744,47 +1087,109 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {code: _code,signIn: _signIn,).toString();+ final message = _message;return [_codeSpace(- Align(- alignment: AlignmentDirectional.centerStart,- // Dimmed once it has done its job, so nobody scans a spent code.+ Center(+ // Dimmed once there is no pairing to be had, so nobody scans it.child: Opacity(- opacity: _connected == null && !_stopped ? 1 : .25,+ opacity: _stopped ? .25 : 1,child: PhonePairQr(data: link, side: qrSide),),),),- if (_remoteMachineId case final machineId?)+ if (_remoteMachineId case final machineId?) ...[+ const SizedBox(height: 8),Text(app.stateOf(machineId)?.machine.displayName ?? 'Computer',+ textAlign: TextAlign.center,style: _note(),),- // One line, and it is the status too: what to do, then that it worked.- _status(),- // Not after a sign-in from here: it rebuilt the screen that opened this- // dialog, and that screen is the one the link would open Settings from.- if (widget.onManageDevices case final manage? when !_signedInWhileOpen)- Align(- alignment: AlignmentDirectional.centerStart,- child: TextButton(- key: const ValueKey('add-phone-manage-devices'),- onPressed: () {- Navigator.of(context).pop();- manage();- },- child: const Text('Manage devices…'),+ ],+ const SizedBox(height: 10),+ // Computers is where the phone scans a code — the new app at its foot+ // ("Or scan the QR code on your computer"), an older one as Connect+ // computer — so the line names the list, not its button.+ Text(+ 'On your phone, open Computers and scan this code.',+ textAlign: TextAlign.center,+ style: _note(),+ ),+ if (message != null) ...[+ const SizedBox(height: 8),+ Semantics(+ liveRegion: true,+ child: Text(+ message,+ key: const ValueKey('add-phone-status'),+ textAlign: TextAlign.center,+ style: _note(Theme.of(context).colorScheme.error),),),+ ],];}+ /// "App Store · Google Play" beside Install Harness: ONE code a phone's+ /// camera opens, which sends an iPhone to the App Store and an Android phone+ /// to Google Play ([kPhoneAppUrl]) — so nobody has to know which store is+ /// theirs. A code, not a link: clicked here a link opens on this computer,+ /// which cannot install a phone's app. Nothing to do here but scan it, so no+ /// buttons (owner, 2026-10-12): Back returns, Esc closes.+ Widget _stores() => Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: [+ Align(+ alignment: AlignmentDirectional.centerStart,+ child: DesktopPill(+ key: const ValueKey('add-phone-hide-downloads'),+ label: '‹ Back',+ quiet: true,+ onPressed: () => setState(() => _showingStores = false),+ ),+ ),+ const SizedBox(height: 8),+ Semantics(+ header: true,+ child: Text(+ 'Get Harness on your phone',+ style: DesktopChrome.heading(),+ ),+ ),+ const SizedBox(height: 4),+ Text('Scan with your phone’s Camera.', style: _note()),+ const SizedBox(height: 20),+ const Center(+ child: QrCodeView(+ data: kPhoneAppUrl,+ side: _qrSide,+ semanticLabel: 'QR code for Harness on the App Store or Google Play',+ ),+ ),+ const SizedBox(height: 12),+ const _StoreMarks(),+ ],+ );++ /// A step's words in bold: what is on the phone's screen, or the account.+ static TextSpan _strong(String text) => TextSpan(+ text: text,+ style: const TextStyle(fontWeight: FontWeight.w600),+ );++ /// A browser with none of the account's computers to pair through.+ bool get _connectFirst =>+ app.viewer != null &&+ !app.signingIn &&+ app.currentUser?.email.contains('@') == true;+/// [child] in the code's space, scrolled into view the first time it appears.///- /// At a large text size or in a short window the steps above push the code —- /// what the dialog is for — below the fold. It is brought up only as far as- /// it takes, so where it already shows nothing moves; and only the once, so- /// a new code or a dimmed one never pulls back a person who scrolled up.+ /// The steps above push the code — opened under them — below the fold of a+ /// short window. It is brought up only as far as it takes, so where it+ /// already shows nothing moves; and only the once, so a new code or a dimmed+ /// one never pulls back a person who scrolled up.Widget _codeSpace(Widget child) {if (!_codeAppeared) {_codeAppeared = true;@@ -805,123 +1210,522 @@ class _AddPhoneDialogState extends State<AddPhoneDialog> {/// A line under a step's title: smaller and quieter than the title.TextStyle _note([Color? color]) =>DesktopChrome.text(color: color ?? _faint, size: 13);+}- Widget _status() {- final connected = _connected;- final (text, color) = connected != null- ? ('✓ Connected $connected', grid.AppPalette.online)- : _message != null- ? (_message!, Theme.of(context).colorScheme.error)- // The phone's own button (mobile `set_up_computer.dart`).- : ('On your phone, open Harness and tap Pair computer.', _faint);- return Semantics(- liveRegion: true,- child: Text(- text,- key: const ValueKey('add-phone-status'),- style: _note(color),- ),- );- }+/// How a step's number is drawn.+enum _Mark {+ /// To do, now: in the accent, its ring keeping the picture's beat.+ current,++ /// To do once the step before it is done: faint, and so are its words.+ later,++ /// To do.+ plain,++ /// Done: a tick.+ done,}-/// One step of Add Phone: its number in a quiet circle, its title beside it,-/// and what the step takes under the title.-class _AddPhoneStep extends StatelessWidget {- const _AddPhoneStep({+/// One step: its number in a ring, a thread down to the next one's, what to+/// do, a quieter line under it where one is needed, and under that a way to do+/// it. The phone's steps (mobile `set_up_computer.dart` `StepsTimeline`), on+/// this side.+class _Step extends StatelessWidget {+ const _Step({required this.number,+ required this.mark,required this.title,- this.children = const [],+ this.note,+ this.link,+ this.beat,+ this.last = false,});- static TextStyle titleStyle() =>- DesktopChrome.text(size: 14).copyWith(fontWeight: FontWeight.w600);+ final int number;+ final _Mark mark;+ final List<InlineSpan> title;+ final List<InlineSpan>? note;- /// The number's circle and the gap after it — where a step's lines start.- static const double indent = _circle + 12;- static const double _circle = 24;+ /// The step's own way to do it ([_StepLink]), under its words — not out at+ /// the row's end, where it read as apart from the step and ran out of room+ /// for its words at a large text size.+ final Widget? link;- final int number;+ /// The picture's beat, which a [_Mark.current] ring keeps.+ final AnimationController? beat;- /// Beside the number: the step's name — or, folded, the line it folds to.- final Widget title;- final List<Widget> children;+ /// No thread under the last step of a group.+ final bool last;++ static const double _ring = 22;@overrideWidget build(BuildContext context) {- return Padding(- padding: const EdgeInsets.symmetric(vertical: 14),+ final faint = grid.AppPalette.textFaint;+ final titleColor = switch (mark) {+ _Mark.later => faint,+ _Mark.done => DesktopChrome.muted,+ _ => DesktopChrome.foreground,+ };+ final noteColor = mark == _Mark.later ? faint : DesktopChrome.muted;+ return IntrinsicHeight(child: Row(- crossAxisAlignment: CrossAxisAlignment.start,+ crossAxisAlignment: CrossAxisAlignment.stretch,children: [- ExcludeSemantics(- child: Container(- width: _circle,- height: _circle,- alignment: Alignment.center,- decoration: BoxDecoration(- color: DesktopChrome.field,- shape: BoxShape.circle,- ),- child: Text(- '$number',- style: DesktopChrome.metadata().copyWith(- fontWeight: FontWeight.w600,- ),- ),+ SizedBox(+ width: _ring,+ child: Column(+ children: [+ ExcludeSemantics(child: _numberRing()),+ if (!last)+ Expanded(+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 3),+ child: Center(+ child: Container(+ width: 1,+ color: grid.AppPalette.divider,+ ),+ ),+ ),+ ),+ ],),),- const SizedBox(width: indent - _circle),+ const SizedBox(width: 10),Expanded(- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- mainAxisSize: MainAxisSize.min,- children: [- // Centred on the circle while it is one line; wraps under itself after.- ConstrainedBox(- constraints: const BoxConstraints(minHeight: _circle),- child: Align(- alignment: AlignmentDirectional.centerStart,- child: title,+ child: Padding(+ padding: EdgeInsets.only(bottom: last ? 0 : 12),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ mainAxisSize: MainAxisSize.min,+ children: [+ // Centred on the ring while it is one line; wraps under itself after.+ ConstrainedBox(+ constraints: const BoxConstraints(minHeight: _ring),+ child: Align(+ alignment: AlignmentDirectional.centerStart,+ child: Text.rich(+ TextSpan(children: title),+ style: DesktopChrome.text(size: 14, color: titleColor),+ ),+ ),),- ),- for (final child in children) ...[- const SizedBox(height: 10),- child,+ if (note case final note?)+ Padding(+ padding: const EdgeInsets.only(top: 1),+ child: Text.rich(+ TextSpan(children: note),+ style: DesktopChrome.text(+ size: 12.5,+ color: noteColor,+ height: 1.4,+ ),+ ),+ ),+ if (link case final link?)+ Padding(+ padding: const EdgeInsets.only(top: 2),+ child: link,+ ),],- ],+ ),),),],),);}++ Widget _numberRing() {+ switch (mark) {+ case _Mark.done:+ final ok = grid.AppPalette.online;+ return Container(+ width: _ring,+ height: _ring,+ decoration: BoxDecoration(+ color: ok.withValues(alpha: .16),+ shape: BoxShape.circle,+ ),+ child: Icon(AppIcons.check, size: 13, color: ok),+ );+ case _Mark.current:+ final accent = DesktopChrome.accent;+ final dot = Container(+ width: _ring,+ height: _ring,+ alignment: Alignment.center,+ decoration: BoxDecoration(color: accent, shape: BoxShape.circle),+ child: Text(+ '$number',+ style: DesktopChrome.metadata(color: Colors.white)+ .copyWith(fontWeight: FontWeight.w600),+ ),+ );+ final beat = this.beat;+ if (beat == null) return dot;+ return AnimatedBuilder(+ animation: beat,+ child: dot,+ builder: (context, child) {+ // A halo out from the ring, gone by 70% of the beat.+ final t = (beat.value / .7).clamp(0.0, 1.0);+ return DecoratedBox(+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ boxShadow: [+ if (beat.isAnimating && t < 1)+ BoxShadow(+ color: accent.withValues(alpha: .55 * (1 - t)),+ spreadRadius: 7 * t,+ ),+ ],+ ),+ child: child,+ );+ },+ );+ case _Mark.later || _Mark.plain:+ final color = mark == _Mark.later+ ? grid.AppPalette.textFaint+ : DesktopChrome.muted;+ return Container(+ width: _ring,+ height: _ring,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ border: Border.all(color: color, width: 1.5),+ ),+ child: Text(+ '$number',+ style: DesktopChrome.metadata(color: color)+ .copyWith(fontWeight: FontWeight.w600, fontSize: 11),+ ),+ );+ }+ }}-/// One store's download code: the code, then the store's own mark and name.-class _StoreCode extends StatelessWidget {- const _StoreCode({required this.name, required this.mark, required this.url});+/// A step's way to do it: its words in the accent, on the step's own edge, and+/// nothing around them — a pill there set the words in from the step's, and a+/// box read as one more button beside the dialog's own. Hover and the keyboard+/// underline them. They wrap, rather than run out of room, at a large text size.+class _StepLink extends StatefulWidget {+ const _StepLink({super.key, required this.label, required this.onPressed});- final String name;+ final String label;+ final VoidCallback onPressed;- /// The store's mark, in its own colours whatever the theme — it is the- /// store's brand, the way the sign-in buttons' marks are.- final String mark;- final String url;+ @override+ State<_StepLink> createState() => _StepLinkState();+}- static const double _side = 120;+class _StepLinkState extends State<_StepLink> {+ var _hovered = false;+ var _focused = false;@overrideWidget build(BuildContext context) {- return Column(- mainAxisSize: MainAxisSize.min,- children: [- QrCodeView(- data: url,- side: _side,- semanticLabel: 'QR code for Harness on $name',+ final active = _hovered || _focused;+ return Semantics(+ button: true,+ child: InkWell(+ onTap: widget.onPressed,+ onHover: (hovered) => setState(() => _hovered = hovered),+ onFocusChange: (focused) => setState(() => _focused = focused),+ mouseCursor: SystemMouseCursors.click,+ borderRadius: BorderRadius.circular(4),+ hoverColor: Colors.transparent,+ focusColor: Colors.transparent,+ highlightColor: Colors.transparent,+ splashFactory: NoSplash.splashFactory,+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 2),+ child: Text(+ widget.label,+ style:+ DesktopChrome.text(+ size: 13,+ medium: true,+ color: DesktopChrome.accent,+ ).copyWith(+ decoration: active ? TextDecoration.underline : null,+ decorationColor: DesktopChrome.accent,+ ),+ ),),- const SizedBox(height: 8),+ ),+ );+ }+}++/// The caret after "Looking for your phone" — the phone's "Looking for your+/// computer▌": on for half of every half beat, and steady when nothing moves.+class _Caret extends StatelessWidget {+ const _Caret({required this.beat});++ final AnimationController beat;++ @override+ Widget build(BuildContext context) => ExcludeSemantics(+ child: Padding(+ padding: const EdgeInsetsDirectional.only(start: 2),+ child: AnimatedBuilder(+ animation: beat,+ builder: (context, _) => Opacity(+ opacity: !beat.isAnimating || (beat.value * 2) % 1 < .5 ? 1 : 0,+ child: Container(width: 7, height: 14, color: DesktopChrome.muted),+ ),+ ),+ ),+ );+}++/// The picture at the top of Add Phone — this computer, the phone, and what+/// runs between them, by [_Link] — the mobile onboarding's picture, small.+class _LinkPicture extends StatelessWidget {+ const _LinkPicture({+ required this.link,+ required this.beat,+ required this.unlock,+ });++ final _Link link;+ final AnimationController beat;+ final AnimationController unlock;++ @override+ Widget build(BuildContext context) => ExcludeSemantics(+ // Its own layer: the beat repaints the picture, never the dialog.+ child: RepaintBoundary(+ child: AspectRatio(+ aspectRatio: _LinkPainter.width / _LinkPainter.height,+ child: CustomPaint(+ painter: _LinkPainter(+ link: link,+ beat: beat,+ unlock: unlock,+ ink: DesktopChrome.muted,+ faint: grid.AppPalette.textFaint,+ accent: DesktopChrome.accent,+ ok: grid.AppPalette.online,+ ),+ ),+ ),+ ),+ );+}++/// Draws [_LinkPicture] in its own units ([width] × [height]), scaled to fit.+///+/// - **Sign in** ([_Link.signIn], [_Link.signingIn]): the computer in the+/// accent, breathing on the beat, a person on its screen with a ring out from+/// them; a lock in the middle of the dotted way to the phone, which is faint.+/// - **The lock opening** ([unlock] running, once, when the computer signs in+/// from here): the shackle lifts, the lock rises and fades, the dots close+/// over where it was, and a tick on the computer's screen comes and goes.+/// - **Looking** ([_Link.looking]): packets run along the dots to the phone,+/// which rings out.+/// - **Ready** ([_Link.ready]): the way is a line, and the phone is ticked.+///+/// With nothing moving (Reduce Motion), each is its still frame: no ring, no+/// packets, the lock simply gone once signed in.+class _LinkPainter extends CustomPainter {+ _LinkPainter({+ required this.link,+ required this.beat,+ required this.unlock,+ required this.ink,+ required this.faint,+ required this.accent,+ required this.ok,+ }) : super(repaint: Listenable.merge([beat, unlock]));++ static const double width = 356;+ static const double height = 76;++ final _Link link;+ final AnimationController beat;+ final AnimationController unlock;+ final Color ink, faint, accent, ok;++ static double _clamp(double v) => v.clamp(0.0, 1.0);++ @override+ void paint(Canvas canvas, Size size) {+ canvas.scale(size.width / width);+ final t = beat.value;+ final moving = beat.isAnimating;+ final asking = link == _Link.signIn || link == _Link.signingIn;+ final ready = link == _Link.ready;+ // The lock opening, 0 to 1, while it runs.+ final u = unlock.isAnimating ? unlock.value : null;+ final pen = Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.5+ ..strokeCap = StrokeCap.round+ ..strokeJoin = StrokeJoin.round;++ // This computer: asking to be signed in, it takes the accent and breathes;+ // just signed in, it is green a moment and settles.+ final breath = moving+ ? .55 + .45 * (.5 - .5 * math.cos(2 * math.pi * t))+ : 1.0;+ pen.color = asking+ ? accent.withValues(alpha: breath)+ : u != null+ ? Color.lerp(ok, ink, _clamp((u - .6) / .4))!+ : ink;+ canvas.drawRRect(+ RRect.fromLTRBR(40, 16, 102, 54, const Radius.circular(3)),+ pen,+ );+ canvas.drawLine(const Offset(30, 60), const Offset(112, 60), pen);++ if (asking) {+ // Whose it is: a person on its screen, and a ring out from them.+ if (moving) {+ pen.color = accent.withValues(alpha: .6 * (1 - t));+ canvas.drawCircle(const Offset(71, 35), 11 * (.6 + 1.3 * t), pen);+ }+ pen.color = accent;+ canvas.drawCircle(const Offset(71, 31), 4, pen);+ canvas.drawPath(+ Path()+ ..moveTo(63.5, 45)+ ..cubicTo(64.7, 40.8, 67.7, 38.5, 71, 38.5)+ ..cubicTo(74.3, 38.5, 77.3, 40.8, 78.5, 45),+ pen,+ );+ }+ if (u != null) {+ // Signed in: a tick on its screen, there and gone.+ final a = u < .2 ? u / .2 : (u < .7 ? 1.0 : 1 - (u - .7) / .3);+ pen.color = ok.withValues(alpha: _clamp(a));+ canvas.drawPath(+ Path()+ ..moveTo(63, 35.5)+ ..lineTo(68, 40.5)+ ..lineTo(78, 29.5),+ pen,+ );+ }++ // The way to the phone: dots, with the lock's gap in them until it opens.+ final gap = asking ? 1.0 : (u == null ? 0.0 : 1 - _clamp((u - .61) / .22));+ if (ready) {+ pen.color = ok.withValues(alpha: .7);+ canvas.drawLine(const Offset(124, 38), const Offset(270, 38), pen);+ } else {+ for (var x = 124.0; x <= 268; x += 8) {+ final inGap = x + 2 > 185 && x < 209;+ final alpha = inGap ? 1 - gap : 1.0;+ if (alpha <= 0) continue;+ pen.color = faint.withValues(alpha: faint.a * alpha);+ canvas.drawLine(Offset(x, 38), Offset(x + 2, 38), pen);+ }+ }++ // The lock: shut while there is no account; opening once when there is.+ final lockAlpha = asking+ ? 1.0+ : (u == null ? 0.0 : 1 - _clamp((u - .375) / .455));+ if (lockAlpha > 0) {+ final rise = u == null ? 0.0 : -5 * _clamp((u - .375) / .455);+ final lift = u == null ? 0.0 : -2.5 * _clamp((u - .083) / .25);+ pen.color = ink.withValues(alpha: ink.a * lockAlpha);+ canvas.save();+ canvas.translate(0, rise);+ canvas.drawRRect(+ RRect.fromLTRBR(191, 37, 203, 46, const Radius.circular(2)),+ pen,+ );+ canvas.drawPath(+ Path()+ ..moveTo(193.5, 37 + lift)+ ..lineTo(193.5, 34 + lift)+ ..arcToPoint(+ Offset(200.5, 34 + lift),+ radius: const Radius.circular(3.5),+ )+ ..lineTo(200.5, 37 + lift),+ pen,+ );+ canvas.restore();+ }++ if (link == _Link.looking) {+ final dot = Paint()..color = accent;+ if (moving) {+ // Packets along the dots, a third of a beat apart.+ for (var k = 0; k < 3; k++) {+ final q = (t + k / 3) % 1;+ final a = q < .15 ? q / .15 : (q > .85 ? (1 - q) / .15 : 1.0);+ dot.color = accent.withValues(alpha: _clamp(a));+ canvas.drawCircle(Offset(140 + 96 * q, 38), 2.2, dot);+ }+ // The phone rings out, twice a beat.+ for (var k = 0; k < 2; k++) {+ final q = (t + k / 2) % 1;+ pen.color = accent.withValues(alpha: .55 * (1 - q));+ canvas.drawCircle(const Offset(293, 38), 26 * (.7 + .8 * q), pen);+ }+ } else {+ pen.color = accent.withValues(alpha: .3);+ canvas.drawCircle(const Offset(293, 38), 26, pen);+ }+ }++ // The phone: faint until there is an account, then waiting, then in.+ final phone = RRect.fromLTRBR(281, 16, 305, 60, const Radius.circular(5));+ if (ready) {+ canvas.drawRRect(phone, Paint()..color = ok.withValues(alpha: .16));+ }+ pen.color = ready ? ok : (asking ? faint : ink);+ canvas.drawRRect(phone, pen);+ canvas.drawLine(const Offset(290, 55), const Offset(296, 55), pen);+ if (ready) {+ canvas.drawPath(+ Path()+ ..moveTo(287, 38)+ ..lineTo(291, 42)+ ..lineTo(299, 33),+ pen,+ );+ }+ }++ @override+ bool shouldRepaint(_LinkPainter old) =>+ old.link != link ||+ old.ink != ink ||+ old.faint != faint ||+ old.accent != accent ||+ old.ok != ok;+}++/// Under the phone app's one code, the two stores it opens — each its own mark+/// and name — so nobody wonders whether theirs is one of them.+class _StoreMarks extends StatelessWidget {+ const _StoreMarks();++ /// Each store's mark, in its own colours whatever the theme — it is the+ /// store's brand, the way the sign-in buttons' marks are.+ static const _stores = [+ ('App Store', 'assets/stores/app-store.svg'),+ ('Google Play', 'assets/stores/google-play.svg'),+ ];++ @override+ Widget build(BuildContext context) => Wrap(+ alignment: WrapAlignment.center,+ spacing: 20,+ runSpacing: 6,+ children: [+ for (final (name, mark) in _stores)Row(mainAxisSize: MainAxisSize.min,children: [@@ -937,9 +1741,8 @@ class _StoreCode extends StatelessWidget {),],),- ],- );- }+ ],+ );}/// "Mac" where the menu says Harness ▸ Add Phone…; the command palette alsodiff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 7d263c7a1..f5829ae5e 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -1927,6 +1927,7 @@ private final class SwarmTabStrip: NSView {fileprivate let pullRequestButton = SwarmContextButton()fileprivate let shareButton = SwarmShareButton()fileprivate let searchButton = SwarmPlainIconButton()+ fileprivate let phoneButton = SwarmPlainIconButton()fileprivate let storeButton = SwarmStoreButton()fileprivate let devicesButton = SwarmStoreButton()fileprivate let accountButton = SwarmAccountButton()@@ -2061,6 +2062,17 @@ private final class SwarmTabStrip: NSView {searchButton.action = #selector(openSearch)searchButton.setAccessibilityLabel("Open Harness")addSubview(searchButton)+ // Add Phone, the glyph just before Devices (Harness ▸ Add Phone…).+ phoneButton.isBordered = false+ phoneButton.focusRingType = .none+ phoneButton.title = ""+ phoneButton.image = HarnessControlSymbols.image("iphone.radiowaves.left.and.right")+ phoneButton.imagePosition = .imageOnly+ phoneButton.isEnabled = false+ phoneButton.target = self+ phoneButton.action = #selector(openAddPhone)+ phoneButton.setAccessibilityLabel("Add Phone")+ addSubview(phoneButton)devicesButton.isBordered = falsedevicesButton.title = "Devices"devicesButton.font = navigationFont@@ -2111,7 +2123,7 @@ private final class SwarmTabStrip: NSView {statusBar.setAccessibilityRole(.group)statusBar.setAccessibilityLabel("Focused pane status")statusBar.setAccessibilityParent(self)- setAccessibilityChildren([scroll, newButton, searchButton, storeButton, statusBar])+ setAccessibilityChildren([scroll, newButton, searchButton, phoneButton, storeButton, statusBar])statusBar.setAccessibilityChildren([harnessMonitorButton, machinesButton, modelsButton, machineResourcesLabel, subscriptionUsageButton, daemonButton, shareButton, voiceLabel, contextButton, pullRequestButton])registerForDraggedTypes([swarmPasteboardType])scroll.contentView.postsBoundsChangedNotifications = true@@ -2231,7 +2243,7 @@ private final class SwarmTabStrip: NSView {accountButton.setAccessibilityLabel(accountKind == .signIn ? SwarmAccountButton.label : "Account")accountButton.setAccessibilityHelp(accountButton.toolTip)}- var children: [Any] = [scroll, newButton, searchButton]+ var children: [Any] = [scroll, newButton, searchButton, phoneButton]if !devicesButton.isHidden { children.append(devicesButton) }children.append(storeButton)if !accountButton.isHidden { children.append(accountButton) }@@ -2260,6 +2272,10 @@ private final class SwarmTabStrip: NSView {searchButton.isEnabled = actionsEnabledsearchButton.toolTip = state["searchTooltip"] as? String ?? "Open Harness"searchButton.setAccessibilityHelp(searchButton.toolTip)+ phoneButton.foreground = palette.navigationForeground+ phoneButton.isEnabled = actionsEnabled+ phoneButton.toolTip = state["addPhoneTooltip"] as? String ?? "Add Phone"+ phoneButton.setAccessibilityHelp(phoneButton.toolTip)storeButton.toolTip = state["storeTooltip"] as? String ?? "Explore Harness Store"storeButton.setAccessibilityHelp(storeButton.toolTip)subscriptionUsageButton.font = barFont@@ -2499,7 +2515,7 @@ private final class SwarmTabStrip: NSView {let toolHeight: CGFloat = 32let capsuleHeight: CGFloat = 28 // AppControl.heightSmall.let iconWidth = cell * 4- // Search, Devices and Store are icons side by side; then, after+ // Search, Add Phone, Devices and Store are icons side by side; then, after// AppDesktop.controlGap, Sign in or the account ends the row.let accountWidth = accountButton.isHidden ? 0 : accountButton.preferredWidthaccountButton.frame = NSRect(x: bounds.width - trailing - accountWidth,@@ -2511,8 +2527,10 @@ private final class SwarmTabStrip: NSView {let devicesWidth = devicesButton.isHidden ? 0 : devicesButton.preferredWidthdevicesButton.frame = NSRect(x: storeButton.frame.minX - devicesWidth,y: (bounds.height - toolHeight) / 2, width: devicesWidth, height: toolHeight)- let searchEdge = devicesButton.isHidden ? storeButton.frame.minX : devicesButton.frame.minX- searchButton.frame = NSRect(x: searchEdge - iconWidth,+ let phoneEdge = devicesButton.isHidden ? storeButton.frame.minX : devicesButton.frame.minX+ phoneButton.frame = NSRect(x: phoneEdge - iconWidth,+ y: (bounds.height - toolHeight) / 2, width: iconWidth, height: toolHeight)+ searchButton.frame = NSRect(x: phoneButton.frame.minX - iconWidth,y: (bounds.height - toolHeight) / 2, width: iconWidth, height: toolHeight)// Only navigation actions share the tab row. Context has the full footer.let tabBudget = max(0, searchButton.frame.minX - cell * 6)@@ -2663,6 +2681,9 @@ private final class SwarmTabStrip: NSView {@objc private func openSearch() {if actionsEnabled && searchButton.isEnabled { emit?("sessions", nil) }}+ @objc private func openAddPhone() {+ if actionsEnabled && phoneButton.isEnabled { emit?("addPhone", nil) }+ }@objc private func openStore() {if actionsEnabled && storeButton.isEnabled { emit?("store", nil) }}diff --git a/desktop/test/add_phone_dialog_test.dart b/desktop/test/add_phone_dialog_test.dartindex 840147365..bd972f666 100644--- a/desktop/test/add_phone_dialog_test.dart+++ b/desktop/test/add_phone_dialog_test.dart@@ -16,8 +16,6 @@ import 'package:harness/shared/widgets/qr_code_view.dart';import 'package:harness/state/app_state.dart';import 'package:harness/widgets/add_phone_dialog.dart';-import 'support/resource_picker.dart' show resourceScope;-import 'swarm_interactions_test.dart' show chord;import 'swarm_screen_test.dart' show mount;import 'swarm_state_test.dart' show createApp, MemoryStore;@@ -75,6 +73,7 @@ Future<void> _open(PhoneSignInCodeCall? signInCode,VoidCallback? onConnectMachine,VoidCallback? onManageDevices,+ bool reduceMotion = false,}) async {tester.view.devicePixelRatio = 1;tester.view.physicalSize = const Size(1280, 800);@@ -83,6 +82,10 @@ Future<void> _open(await tester.pumpWidget(MaterialApp(theme: grid.buildAppTheme(brightness: Brightness.dark),+ builder: (context, child) => MediaQuery(+ data: MediaQuery.of(context).copyWith(disableAnimations: reduceMotion),+ child: child!,+ ),home: const Scaffold(body: SizedBox.expand()),),);@@ -97,6 +100,14 @@ Future<void> _open(),);await tester.pump();+ await tester.pump();+}++/// "Not showing up? Scan a code instead": the code comes up, and — once the+/// sign-in code it waits for has answered — is armed.+Future<void> _showCode(WidgetTester tester) async {+ await tester.tap(find.byKey(const ValueKey('add-phone-show-code')));+ await tester.pump();// The sign-in code's answer, which the QR waits for.await tester.pump();}@@ -104,17 +115,37 @@ Future<void> _open(String _qrData(WidgetTester tester) =>tester.widget<PhonePairQr>(find.byType(PhonePairQr)).data;+/// What went wrong under the code; none while nothing has.String _status(WidgetTester tester) =>tester.widget<Text>(find.byKey(const ValueKey('add-phone-status'))).data!;-/// What the phone is told while the code waits to be scanned: its own button.-const _scanIt = 'On your phone, open Harness and tap Pair computer.';--/// The download codes on screen: what each QR in step 1 says.-Set<String> _storeCodes(WidgetTester tester) => {+/// The download codes on screen: what each one says, other than the pairing+/// code.+List<String> _downloadCodes(WidgetTester tester) => [for (final qr in tester.widgetList<QrCodeView>(find.byType(QrCodeView)))- if (qr.data == kAppStoreUrl || qr.data == kGooglePlayUrl) qr.data,-};+ if (!qr.data.startsWith('https://$kPhonePairHost$kPhonePairPath')) qr.data,+];++/// The phone signing in to the account, as this computer's daemon says it:+/// a `device_key_added` frame, which is what puts up the "New device" band.+///+/// Run outside the fake clock: the frame also re-reads the daemon's pending+/// list, a real request to a loopback port nobody answers here.+Future<void> _joins(+ WidgetTester tester,+ AppNotifier app, {+ String pub = 'pub-phone',+ String label = 'Dee’s iPhone',+ String kind = 'viewer',+}) async {+ app.ownDaemonMachineIdForTest('m');+ await tester.runAsync(+ () => app.handleEventForTest('m', {+ 'type': 'device_key_added',+ 'payload': {'pub': pub, 'label': label, 'kind': kind},+ }),+ );+}void main() {AppNotifier browserApp() {@@ -134,6 +165,194 @@ void main() {..currentUser = const CurrentUserProfile(email: '[email protected]');}+ group('the phone signs in', () {+ testWidgets(+ 'signed in, it says what to do on the phone, with which account, and '+ 'looks for it — nothing armed, no code up',+ (tester) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ final signIn = _FakeSignIn();+ final daemon = _FakeDaemon([]);+ await _open(tester, app, daemon.call, signInCode: signIn.call);++ expect(find.text('Add your phone'), findsOneWidget);+ // The phone's welcome headline, word for word.+ expect(+ find.text(+ 'Manage all your agents on all your computers from your phone.',+ ),+ findsOneWidget,+ );+ expect(find.text('ON YOUR PHONE'), findsOneWidget);+ expect(find.textContaining('ON THIS '), findsNothing);+ expect(find.text('Install Harness'), findsOneWidget);+ expect(find.text('Sign in'), findsOneWidget);+ expect(find.text('With [email protected].'), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-looking')), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-sign-in')), findsNothing);++ // The code is put away, and nothing goes to the daemon or the backend+ // for it until it is asked for.+ expect(find.byType(PhonePairQr), findsNothing);+ expect(daemon.codes, isEmpty);+ expect(signIn.minted, 0);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ },+ );++ testWidgets('a phone that signs in to the account is ready, and the '+ 'beat stops', (tester) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ await _open(tester, app, _FakeDaemon([]).call);+ expect(find.byKey(const ValueKey('add-phone-done')), findsNothing);++ await _joins(tester, app);+ await tester.pump();+ expect(find.byKey(const ValueKey('add-phone-ready')), findsOneWidget);+ expect(find.text('Dee’s iPhone is ready.'), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-looking')), findsNothing);+ expect(find.byKey(const ValueKey('add-phone-show-code')), findsNothing);+ expect(find.text('Cancel'), findsNothing);+ // Nothing moves once the phone is in: the dialog settles.+ await tester.pumpAndSettle();+ expect(find.byType(AddPhoneDialog), findsOneWidget);++ await tester.tap(find.byKey(const ValueKey('add-phone-done')));+ await tester.pumpAndSettle();+ expect(find.byType(AddPhoneDialog), findsNothing);+ });++ testWidgets('a computer joining the account is not the phone', (+ tester,+ ) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ await _open(tester, app, _FakeDaemon([]).call);+ await _joins(+ tester,+ app,+ pub: 'pub-mac',+ label: 'Studio Mac',+ kind: 'machine',+ );+ await tester.pump();+ expect(find.byKey(const ValueKey('add-phone-ready')), findsNothing);+ expect(find.byKey(const ValueKey('add-phone-looking')), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ });++ testWidgets('after a minute it names the account the phone needs', (+ tester,+ ) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ await _open(tester, app, _FakeDaemon([]).call);+ await tester.pump(const Duration(seconds: 59));+ expect(+ find.byKey(const ValueKey('add-phone-still-looking')),+ findsNothing,+ );+ await tester.pump(const Duration(seconds: 1));+ expect(+ find.byKey(const ValueKey('add-phone-still-looking')),+ findsOneWidget,+ );+ expect(find.text('Still looking for your phone'), findsOneWidget);+ expect(+ find.text('Your phone has to be signed in with [email protected].'),+ findsOneWidget,+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ });++ testWidgets('under Reduce Motion nothing keeps the frames busy', (+ tester,+ ) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ await _open(tester, app, _FakeDaemon([]).call, reduceMotion: true);+ await tester.pumpAndSettle();+ expect(find.byKey(const ValueKey('add-phone-looking')), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ });+ });++ group('a computer with no account', () {+ testWidgets('signs in first: its step leads, the phone\'s wait, nothing '+ 'is armed and there is no code to show', (tester) async {+ final app = _signedInApp()..signedIn = false;+ addTearDown(app.dispose);+ final signIn = _FakeSignIn();+ final daemon = _FakeDaemon([]);+ await _open(tester, app, daemon.call, signInCode: signIn.call);+ expect(find.textContaining('ON THIS '), findsOneWidget);+ expect(+ find.text('Your phone signs in with the same account.'),+ findsOneWidget,+ );+ expect(find.text('With the same account.'), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-sign-in')), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-looking')), findsNothing);+ expect(find.byKey(const ValueKey('add-phone-show-code')), findsNothing);+ expect(find.byType(PhonePairQr), findsNothing);+ expect(daemon.codes, isEmpty);+ expect(signIn.minted, 0);+ // The phone that signs in meanwhile is not news yet: there is no+ // account here for it to have joined.+ await _joins(tester, app);+ await tester.pump();+ expect(find.byKey(const ValueKey('add-phone-ready')), findsNothing);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ });++ testWidgets('signed in while it is open: its step is ticked where it '+ 'was, the phone\'s name the account, and the code can come up', (+ tester,+ ) async {+ final app = _signedInApp()..signedIn = false;+ addTearDown(app.dispose);+ final signIn = _FakeSignIn();+ await _open(+ tester,+ app,+ _FakeDaemon(List.filled(4, _failed('NO_INTENT'))).call,+ signInCode: signIn.call,+ );+ // The dialog is centred and grows as a whole; inside it, the phone's+ // steps stay where they were under this computer's.+ double gap() =>+ tester.getTopLeft(find.text('ON YOUR PHONE')).dy -+ tester.getTopLeft(find.textContaining('ON THIS ')).dy;+ final before = gap();++ app.signedIn = true;+ app.notifyListeners();+ await tester.pump();+ await tester.pump(const Duration(seconds: 2));+ expect(gap(), before);+ expect(find.text('Signed in'), findsOneWidget);+ expect(find.text('As [email protected].'), findsOneWidget);+ expect(find.text('With [email protected].'), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-sign-in')), findsNothing);+ expect(find.byKey(const ValueKey('add-phone-looking')), findsOneWidget);++ await _showCode(tester);+ expect(+ Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],+ 'h1',+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ });+ });+testWidgets('browser QR targets a linked computer and keeps that destination',(tester) async {@@ -154,6 +373,7 @@ void main() {app.selectedMachineId = 'b';final daemon = _FakeDaemon(List.filled(3, _failed('NO_INTENT')));await _open(tester, app, daemon.call);+ await _showCode(tester);final before = _qrData(tester);expect(Uri.splitQueryString(Uri.parse(before).fragment)['m'], 'b');expect(find.text('Computer b'), findsOneWidget);@@ -183,9 +403,13 @@ void main() {daemon.call,onConnectMachine: () => opened = true,);+ await _showCode(tester);expect(find.byType(PhonePairQr), findsNothing);expect(daemon.codes, isEmpty);- expect(find.text('Connect a computer first'), findsOneWidget);+ expect(+ find.text('Your phone pairs with a computer on your account.'),+ findsOneWidget,+ );await tester.tap(find.widgetWithText(TextButton, 'Connect a machine'));await tester.pump();expect(opened, isTrue);@@ -278,6 +502,7 @@ void main() {final signIn = _FakeSignIn();final daemon = _FakeDaemon(List.filled(80, _failed('NO_INTENT')));await _open(tester, app, daemon.call, signInCode: signIn.call);+ await _showCode(tester);expect(Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],@@ -297,6 +522,38 @@ void main() {expect(signIn.minted, 2, reason: 'nothing is minted after closing');});+ testWidgets('put away, the code lets its renewal lapse; shown again, a '+ 'fresh one is asked for', (tester) async {+ final app = _signedInApp();+ addTearDown(app.dispose);+ final signIn = _FakeSignIn();+ final daemon = _FakeDaemon(List.filled(80, _failed('NO_INTENT')));+ await _open(tester, app, daemon.call, signInCode: signIn.call);+ await _showCode(tester);+ expect(signIn.minted, 1);++ await tester.tap(find.byKey(const ValueKey('add-phone-show-code')));+ await tester.pump();+ expect(find.byType(PhonePairQr), findsNothing);+ final armed = daemon.codes.length;+ await tester.pump(const Duration(minutes: 3));+ expect(signIn.minted, 1, reason: 'no code up, nothing minted');+ expect(+ daemon.codes.length,+ lessThanOrEqualTo(armed + 1),+ reason: 'the loop ends after the answer it was waiting for',+ );++ await _showCode(tester);+ expect(signIn.minted, 2);+ expect(+ Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],+ 'h2',+ );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ });+testWidgets('without one the QR still pairs — the phone emails a code', (tester,) async {@@ -309,6 +566,7 @@ void main() {daemon.call,signInCode: _FakeSignIn(available: false).call,);+ await _showCode(tester);final fields = Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment);expect(fields.keys, ['e', 'm', 'c']);expect(fields['c'], daemon.codes.single);@@ -319,53 +577,8 @@ void main() {});});- group('the account\'s devices', () {- testWidgets(- 'are one link away — Machines — not a list in here',- (tester) async {- final app = _signedInApp();- addTearDown(app.dispose);- var opened = 0;- await _open(- tester,- app,- _FakeDaemon(List.filled(20, _failed('NO_INTENT'))).call,- onManageDevices: () => opened++,- );- await tester.pump();- final link = find.byKey(const ValueKey('add-phone-manage-devices'));- expect(link, findsOneWidget);- expect(find.text('Manage devices…'), findsOneWidget);- await tester.tap(link);- await tester.pump();- // The dialog makes way for Machines: one is open at a time.- expect(opened, 1);- expect(find.byType(AddPhoneDialog), findsNothing);- await tester.pump(const Duration(seconds: 10));- },- );-- testWidgets('no link when there is nowhere to send it', (tester) async {- final app = _signedInApp();- addTearDown(app.dispose);- await _open(- tester,- app,- _FakeDaemon(List.filled(20, _failed('NO_INTENT'))).call,- );- await tester.pump();- expect(- find.byKey(const ValueKey('add-phone-manage-devices')),- findsNothing,- );- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pump();- await tester.pump(const Duration(seconds: 10));- });- });-group('arming the daemon', () {- testWidgets('retries while no phone is waiting and closes once paired', (+ testWidgets('retries while no phone is waiting; paired, it is ready', (tester,) async {final app = _signedInApp();@@ -376,8 +589,9 @@ void main() {() => const PhonePairAnswer.paired('Dee’s iPhone'),]);await _open(tester, app, daemon.call);+ expect(daemon.codes, isEmpty, reason: 'nothing armed with no code up');+ await _showCode(tester);- expect(find.text('Add your phone'), findsOneWidget);expect(daemon.codes, hasLength(1));final code = daemon.codes.single;expect(@@ -389,20 +603,27 @@ void main() {signIn: 'h1',).toString(),);- expect(_status(tester), _scanIt);+ expect(+ find.text('On your phone, open Computers and scan this code.'),+ findsOneWidget,+ );+ expect(find.byKey(const ValueKey('add-phone-status')), findsNothing);await tester.pump(const Duration(milliseconds: 1500));expect(daemon.codes, [code, code]);await tester.pump(const Duration(milliseconds: 1500));expect(daemon.codes, [code, code, code]);await tester.pump();- expect(_status(tester), '✓ Connected Dee’s iPhone');- expect(find.byType(AddPhoneDialog), findsOneWidget);+ expect(find.text('Dee’s iPhone is ready.'), findsOneWidget);+ expect(find.byType(PhonePairQr), findsNothing);- await tester.pump(const Duration(milliseconds: 1500));- await tester.pump();- expect(find.byType(AddPhoneDialog), findsNothing);+ // It stays, saying so, until Done.+ await tester.pump(const Duration(seconds: 5));+ expect(find.byType(AddPhoneDialog), findsOneWidget);expect(daemon.codes, hasLength(3));+ await tester.tap(find.byKey(const ValueKey('add-phone-done')));+ await tester.pumpAndSettle();+ expect(find.byType(AddPhoneDialog), findsNothing);});testWidgets('a code that did not match is replaced, QR and all', (@@ -416,9 +637,10 @@ void main() {_failed('NO_INTENT'),]);await _open(tester, app, daemon.call);+ await _showCode(tester);await tester.pump();final first = daemon.codes.single;- expect(_status(tester), "That didn't match. Scan the new code.");+ expect(_status(tester), "That code didn't work. Scan the new one above.");expect(_qrData(tester), isNot(contains('c=$first')));await tester.pump(const Duration(milliseconds: 1500));@@ -428,7 +650,7 @@ void main() {expect(_qrData(tester), contains('c=$second&'));// An instruction outlives the "no phone yet" that follows it.await tester.pump();- expect(_status(tester), "That didn't match. Scan the new code.");+ expect(_status(tester), "That code didn't work. Scan the new one above.");await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pump();@@ -448,6 +670,7 @@ void main() {_failed('NO_INTENT'),]);await _open(tester, app, daemon.call);+ await _showCode(tester);await tester.pump();expect(_status(tester), 'Too many tries. Wait a minute.');await tester.pump(const Duration(seconds: 59));@@ -455,7 +678,8 @@ void main() {await tester.pump(const Duration(seconds: 1));await tester.pump();expect(daemon.codes, hasLength(2));- expect(_status(tester), _scanIt);+ // A condition, not an instruction: it goes when the condition does.+ expect(find.byKey(const ValueKey('add-phone-status')), findsNothing);await tester.sendKeyEvent(LogicalKeyboardKey.escape);await tester.pump();});@@ -465,6 +689,7 @@ void main() {addTearDown(app.dispose);final daemon = _FakeDaemon([_failed(PhonePairAnswer.unavailable)]);await _open(tester, app, daemon.call);+ await _showCode(tester);await tester.pump();expect(_status(tester), startsWith('Update Harness on this '));await tester.pump(const Duration(seconds: 30));@@ -481,6 +706,7 @@ void main() {final answer = Completer<PhonePairAnswer>();final daemon = _FakeDaemon([() => answer.future]);await _open(tester, app, daemon.call);+ await _showCode(tester);expect(daemon.codes, hasLength(1));await tester.sendKeyEvent(LogicalKeyboardKey.escape);@@ -493,140 +719,68 @@ void main() {expect(tester.takeException(), isNull);expect(daemon.codes, hasLength(1));});+ });- testWidgets('a guest is asked to sign in, and nothing is armed', (- tester,- ) async {+ group('Get Harness', () {+ testWidgets('beside Install Harness: one code, for either store, with '+ 'nothing to press but Back', (tester) async {final app = _signedInApp()..signedIn = false;addTearDown(app.dispose);- final daemon = _FakeDaemon([]);- await _open(tester, app, daemon.call);- expect(find.textContaining('Sign in on this '), findsOneWidget);+ await _open(tester, app, _FakeDaemon([]).call);+ expect(_downloadCodes(tester), isEmpty);+ // Named by its stores, not "Get Harness", which in the computer's own+ // Harness read as this app's download.+ final open = find.byKey(const ValueKey('add-phone-show-downloads'));expect(- find.text('A code appears here. Scan it with Harness on your phone.'),+ find.descendant(+ of: open,+ matching: find.text('App Store · Google Play'),+ ),findsOneWidget,);- expect(find.byKey(const ValueKey('add-phone-sign-in')), findsOneWidget);- expect(find.byType(PhonePairQr), findsNothing);- expect(daemon.codes, isEmpty);- await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ // Before this computer has an account too: the app can come first.+ await tester.tap(open);await tester.pump();- });- });-- group('the two steps', () {- testWidgets(- 'a guest gets the app from either store first: codes, not links',- (tester) async {- final app = _signedInApp()..signedIn = false;- addTearDown(app.dispose);- await _open(tester, app, _FakeDaemon([]).call);- expect(find.text('Get Harness on your phone'), findsOneWidget);- expect(find.text('Scan with your phone’s camera.'), findsOneWidget);- expect(_storeCodes(tester), {kAppStoreUrl, kGooglePlayUrl});- expect(find.text('App Store'), findsOneWidget);- expect(find.text('Google Play'), findsOneWidget);- // Each code says which store it opens, to a screen reader too.- expect(- find.bySemanticsLabel('QR code for Harness on App Store'),- findsOneWidget,- );- expect(- find.bySemanticsLabel('QR code for Harness on Google Play'),- findsOneWidget,- );- // Step 1 above step 2, and the two codes side by side, apart.- expect(- tester.getTopLeft(find.text('Get Harness on your phone')).dy,- lessThan(- tester.getTopLeft(find.textContaining('Sign in on this ')).dy,- ),- );- // Each code over its store's mark and name: the two side by side, 40 apart.- final stores = [- for (final qr in find.byType(QrCodeView).evaluate())- tester.getRect(- find- .ancestor(- of: find.byWidget(qr.widget),- matching: find.byType(Column),- )- .first,- ),- ];- expect(stores, hasLength(2));- expect(stores[0].top, stores[1].top);- expect(stores[1].left - stores[0].right, 40);- expect(- find.byKey(const ValueKey('add-phone-show-downloads')),- findsNothing,- );- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pump();- },- );+ expect(find.text('Get Harness on your phone'), findsOneWidget);+ expect(find.text('Scan with your phone’s Camera.'), findsOneWidget);- testWidgets(- 'signed in, the download codes fold away, so the one code on screen is '- 'the one to scan from the app — and open again on request',- (tester) async {- final app = _signedInApp();- addTearDown(app.dispose);- await _open(- tester,- app,- _FakeDaemon(List.filled(4, _failed('NO_INTENT'))).call,- );- expect(find.text('Scan this code with Harness'), findsOneWidget);- expect(find.byType(PhonePairQr), findsOneWidget);- expect(_storeCodes(tester), isEmpty);- expect(find.text('Not on your phone yet?'), findsOneWidget);-- await tester.tap(- find.byKey(const ValueKey('add-phone-show-downloads')),- );- await tester.pump();- expect(_storeCodes(tester), {kAppStoreUrl, kGooglePlayUrl});- expect(find.byType(PhonePairQr), findsOneWidget);- expect(find.text('Not on your phone yet?'), findsNothing);- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pump();- },- );+ // One code: the website's, which sends an iPhone to the App Store and+ // an Android phone to Google Play.+ expect(_downloadCodes(tester), ['https://harness.autonomous.ai/app']);+ expect(kPhoneAppUrl, 'https://harness.autonomous.ai/app');+ expect(+ find.bySemanticsLabel(+ 'QR code for Harness on the App Store or Google Play',+ ),+ findsOneWidget,+ );+ // Both stores named under it, so nobody wonders whether theirs is one.+ expect(find.text('App Store'), findsOneWidget);+ expect(find.text('Google Play'), findsOneWidget);+ expect(+ tester.getTopLeft(find.text('App Store')).dy,+ greaterThan(tester.getBottomLeft(find.byType(QrCodeView)).dy),+ );+ // Nothing to press here: no Cancel, no Sign in.+ expect(find.text('Cancel'), findsNothing);+ expect(find.byKey(const ValueKey('add-phone-sign-in')), findsNothing);+ expect(find.byType(FilledButton), findsNothing);- testWidgets(- 'a guest who signs in while it is open: the codes fold, the pairing '- 'code comes up',- (tester) async {- final app = _signedInApp()..signedIn = false;- addTearDown(app.dispose);- final signIn = _FakeSignIn();- await _open(- tester,- app,- _FakeDaemon(List.filled(4, _failed('NO_INTENT'))).call,- signInCode: signIn.call,- );- expect(_storeCodes(tester), hasLength(2));- expect(find.byType(PhonePairQr), findsNothing);+ // Back is the way back to the steps, and their buttons.+ await tester.tap(find.byKey(const ValueKey('add-phone-hide-downloads')));+ await tester.pump();+ expect(_downloadCodes(tester), isEmpty);+ expect(find.text('Install Harness'), findsOneWidget);+ expect(find.text('Cancel'), findsOneWidget);+ expect(find.byKey(const ValueKey('add-phone-sign-in')), findsOneWidget);- app.signedIn = true;- app.notifyListeners();- await tester.pump();- await tester.pump();- expect(_storeCodes(tester), isEmpty);- expect(find.text('Scan this code with Harness'), findsOneWidget);- expect(find.byType(PhonePairQr), findsOneWidget);- // Asked again on landing, so the first code the phone can read signs it in.- expect(- Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],- 'h${signIn.minted}',- );- expect(find.byKey(const ValueKey('add-phone-sign-in')), findsNothing);- await tester.sendKeyEvent(LogicalKeyboardKey.escape);- await tester.pump();- },- );+ // Esc, over the store's code, closes the dialog.+ await tester.tap(open);+ await tester.pump();+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ expect(find.byType(AddPhoneDialog), findsNothing);+ });});group('the way in', () {@@ -684,35 +838,19 @@ void main() {await tester.pumpWidget(const SizedBox());});- testWidgets(- 'Manage devices… makes way for Machines, which opens',- (tester) async {- // The dialog is still this screen's open dialog while it pops, so a- // picker asked for from the link itself was silently refused.- final app = _signedInApp();- addTearDown(app.dispose);- await mount(tester, app);- await chord(tester, LogicalKeyboardKey.keyP, shift: true);- await tester.enterText(- find.byKey(const ValueKey('swarm-search-input')),- '> add phone',- );- await tester.pump();- await tester.sendKeyEvent(LogicalKeyboardKey.enter);- await tester.pump();- await tester.pump(const Duration(milliseconds: 100));- final link = find.byKey(const ValueKey('add-phone-manage-devices'));- expect(link, findsOneWidget);+ testWidgets('the tab row\'s Add Phone opens the dialog', (tester) async {+ final app = createApp()..status = AppStatus.authenticated;+ addTearDown(app.dispose);+ await mount(tester, app);+ await tester.tap(find.byKey(const ValueKey('swarm-add-phone-button')));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 100));+ expect(find.byType(AddPhoneDialog), findsOneWidget);- await tester.tap(link);- await tester.pump();- await tester.pump(const Duration(milliseconds: 500));- expect(find.byType(AddPhoneDialog), findsNothing);- // Machines, where the account's phones and apps are listed now.- expect(resourceScope('@'), findsOneWidget);- await tester.pumpWidget(const SizedBox());- await tester.pump(const Duration(seconds: 10));- },- );+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ expect(find.byType(AddPhoneDialog), findsNothing);+ await tester.pumpWidget(const SizedBox());+ });});}diff --git a/desktop/test/connection_review_render_test.dart b/desktop/test/connection_review_render_test.dartindex 372bd980d..cd9a2a397 100644--- a/desktop/test/connection_review_render_test.dart+++ b/desktop/test/connection_review_render_test.dart@@ -149,14 +149,20 @@ void main() {),);await tester.pumpAndSettle();- expect(find.text('Done').hitTestable(), findsOneWidget);- expect(find.byType(PhonePairQr).hitTestable(), findsOneWidget);+ expect(find.text('Cancel').hitTestable(), findsOneWidget);await capture('add-phone');- // The way to the account's devices stays reachable at every size.- final manage = find.byKey(const ValueKey('add-phone-manage-devices'));- await tester.ensureVisible(manage);- expect(manage.hitTestable(), findsOneWidget);- await tester.tap(find.text('Done'));+ // The code under "Not showing up?" opens, and shows, at every size.+ final showCode = find.byKey(const ValueKey('add-phone-show-code'));+ await tester.ensureVisible(showCode);+ await tester.pumpAndSettle();+ await tester.tap(showCode);+ await tester.pumpAndSettle();+ final code = find.byType(PhonePairQr);+ await tester.ensureVisible(code);+ await tester.pumpAndSettle();+ expect(code.hitTestable(), findsOneWidget);+ await capture('add-phone-code');+ await tester.tap(find.text('Cancel'));await tester.pumpAndSettle();}diff --git a/desktop/test/workspace_account_test.dart b/desktop/test/workspace_account_test.dartindex 5c7296a44..1e5508032 100644--- a/desktop/test/workspace_account_test.dart+++ b/desktop/test/workspace_account_test.dart@@ -29,6 +29,7 @@ Future<void> _capture(WidgetTester tester, String name) =>final _search = find.byKey(const ValueKey('swarm-search-button'));final _bell = find.byKey(const ValueKey('workspace-notifications-button'));+final _phone = find.byKey(const ValueKey('swarm-add-phone-button'));final _devices = find.byKey(const ValueKey('swarm-devices-button'));final _store = find.byKey(const ValueKey('swarm-store-button'));final _signIn = find.byKey(const ValueKey('swarm-sign-in-button'));@@ -79,7 +80,7 @@ Future<void> _mountMenu(void main() {setUpAll(() => loadCaptureFonts(_captureDir));- testWidgets('not signed in, the row ends in Sign in, after three icons', (+ testWidgets('not signed in, the row ends in Sign in, after its icons', (tester,) async {final app = createApp()..signedIn = false;@@ -91,20 +92,20 @@ void main() {// Where this app draws the row it carries the bell too; on a Mac that is// in the menu bar.final order = [- for (final control in [_search, _bell, _devices, _store, _signIn])+ for (final control in [_search, _bell, _phone, _devices, _store, _signIn])tester.getCenter(control).dx,];expect(order,[...order]..sort(),- reason: 'Search, Devices, Store, Sign in',+ reason: 'Search, Add Phone, Devices, Store, Sign in',);// The only control in the row with a word on it.expect(find.descendant(of: _signIn, matching: find.text('Sign in')),findsOneWidget,);- for (final icon in [_search, _devices, _store]) {+ for (final icon in [_search, _phone, _devices, _store]) {expect(find.descendant(of: icon, matching: find.byType(Text)),findsNothing,@@ -112,7 +113,8 @@ void main() {}// Icons sit side by side; nothing is drawn between them and Sign in.expect(tester.getRect(_search).right, tester.getRect(_bell).left);- expect(tester.getRect(_bell).right, tester.getRect(_devices).left);+ expect(tester.getRect(_bell).right, tester.getRect(_phone).left);+ expect(tester.getRect(_phone).right, tester.getRect(_devices).left);expect(tester.getRect(_devices).right, tester.getRect(_store).left);expect(tester.getRect(_signIn).left - tester.getRect(_store).right,diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex a8198fcfb..2f2f7e28b 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -1334,7 +1334,7 @@ private extension SwarmTabStrip {func checkTopActions() throws {var state: [String: Any] = ["enabled": true,- "searchTooltip": "Open Harness · ⌘P", "storeTooltip": "Explore Harness Store · ⌘S",+ "searchTooltip": "Open Harness · ⌘P", "addPhoneTooltip": "Add Phone", "storeTooltip": "Explore Harness Store · ⌘S","tabs": [["id": "work", "name": "Desktop"]], "activeId": "work","focusedContext": ["text": "Office project", "segments": [["text": "Office project"]]]]var calls: [String] = []@@ -1343,12 +1343,14 @@ private extension SwarmTabStrip {setFrameSize(NSSize(width: width, height: 40))update(state)try checkTitlebar(searchButton.isEnabled && searchButton.frame.width > 0 &&- searchButton.frame.maxX == storeButton.frame.minX &&+ phoneButton.isEnabled && phoneButton.frame.width == searchButton.frame.width &&+ searchButton.frame.maxX == phoneButton.frame.minX &&+ phoneButton.frame.maxX == storeButton.frame.minX &&storeButton.frame.width == searchButton.frame.width &&storeButton.frame.maxX == bounds.width - 12 &&newButton.frame.maxX < searchButton.frame.minX &&contextButton.superview === statusBar,- "Search and Store are icons side by side after the tabs at width \(width)")+ "Search, Add Phone and Store are icons side by side after the tabs at width \(width)")try checkTitlebar(accountButton.isHidden && !accountButton.isEnabled &&accessibilityChildren()?.contains(where: { $0 as? NSView === accountButton }) == false,"No account control is drawn until the app says which")@@ -1359,44 +1361,50 @@ private extension SwarmTabStrip {"Devices stays hidden and outside accessibility navigation until opted in")try checkTitlebar(searchButton.toolTip == state["searchTooltip"] as? String &&searchButton.accessibilityHelp() == searchButton.toolTip &&+ phoneButton.toolTip == state["addPhoneTooltip"] as? String &&+ phoneButton.accessibilityHelp() == phoneButton.toolTip &&+ phoneButton.accessibilityLabel() == "Add Phone" &&storeButton.toolTip == state["storeTooltip"] as? String &&storeButton.accessibilityHelp() == storeButton.toolTip,"Top actions retain supplied shortcut hints and accessible help after layout")}searchButton.performClick(nil)+ phoneButton.performClick(nil)storeButton.performClick(nil)- try checkTitlebar(calls == ["sessions", "store"],- "Top actions open the existing search and Store surfaces")+ try checkTitlebar(calls == ["sessions", "addPhone", "store"],+ "Top actions open search, Add Phone (the app menu's own action) and Store")state["devicesVisible"] = truefor width in [CGFloat(360), CGFloat(640), CGFloat(1280)] {setFrameSize(NSSize(width: width, height: 40))update(state)try checkTitlebar(!devicesButton.isHidden && devicesButton.isEnabled &&- searchButton.frame.maxX == devicesButton.frame.minX &&+ searchButton.frame.maxX == phoneButton.frame.minX &&+ phoneButton.frame.maxX == devicesButton.frame.minX &&devicesButton.frame.maxX == storeButton.frame.minX &&devicesButton.frame.width == searchButton.frame.width &&newButton.frame.maxX < searchButton.frame.minX &&devicesButton.font == storeButton.font &&accessibilityChildren()?.contains(where: { $0 as? NSView === devicesButton }) == true,- "Opted-in navigation reads Search, Devices, Store at width \(width)")+ "Opted-in navigation reads Search, Add Phone, Devices, Store at width \(width)")try captureTabPresentation("native-tabs-tools-\(Int(width))")}devicesButton.performClick(nil)- try checkTitlebar(calls == ["sessions", "store", "devices"],+ try checkTitlebar(calls == ["sessions", "addPhone", "store", "devices"],"Devices opens its workspace through the native action")state["enabled"] = falseupdate(state)searchButton.performClick(nil)+ phoneButton.performClick(nil)storeButton.performClick(nil)devicesButton.performClick(nil)- try checkTitlebar(!searchButton.isEnabled && !storeButton.isEnabled &&- !devicesButton.isEnabled && calls.count == 3,+ try checkTitlebar(!searchButton.isEnabled && !phoneButton.isEnabled && !storeButton.isEnabled &&+ !devicesButton.isEnabled && calls.count == 4,"A modal prevents toolbar actions")state["enabled"] = truestate["devicesVisible"] = falseupdate(state)devicesButton.performClick(nil)- try checkTitlebar(devicesButton.isHidden && !devicesButton.isEnabled && calls.count == 3,+ try checkTitlebar(devicesButton.isHidden && !devicesButton.isEnabled && calls.count == 4,"Turning the experiment off removes and disables the native entry")// The row's last control: Sign in while this computer holds no account,// and the account's initial once it does.@@ -1410,17 +1418,18 @@ private extension SwarmTabStrip {accountButton.frame.width == accountButton.preferredWidth &&accountButton.frame.maxX == bounds.width - 12 &&storeButton.frame.maxX + 8 == accountButton.frame.minX &&- searchButton.frame.maxX == devicesButton.frame.minX &&+ searchButton.frame.maxX == phoneButton.frame.minX &&+ phoneButton.frame.maxX == devicesButton.frame.minX &&devicesButton.frame.maxX == storeButton.frame.minX &&newButton.frame.maxX < searchButton.frame.minX &&accountButton.accessibilityLabel() == "Sign in" &&accountButton.toolTip == "Sign in to Harness" &&accessibilityChildren()?.contains(where: { $0 as? NSView === accountButton }) == true,- "Sign in ends the row after Search, Devices and Store at width \(width)")+ "Sign in ends the row after Search, Add Phone, Devices and Store at width \(width)")try captureTabPresentation("native-tabs-sign-in-\(Int(width))")}accountButton.performClick(nil)- try checkTitlebar(calls == ["sessions", "store", "devices", "signIn"],+ try checkTitlebar(calls == ["sessions", "addPhone", "store", "devices", "signIn"],"Sign in opens the sign-in through the native action")state["account"] = ["kind": "avatar", "initial": "Dee", "tooltip": "Dee · [email protected]"]for width in [CGFloat(360), CGFloat(640), CGFloat(1280)] {@@ -1437,7 +1446,7 @@ private extension SwarmTabStrip {try captureTabPresentation("native-tabs-account-\(Int(width))")}accountButton.performClick(nil)- try checkTitlebar(calls == ["sessions", "store", "devices", "signIn", "account"],+ try checkTitlebar(calls == ["sessions", "addPhone", "store", "devices", "signIn", "account"],"The avatar opens the account menu through the native action")state["account"] = ["kind": "avatar", "initial": ""]update(state)@@ -1446,12 +1455,12 @@ private extension SwarmTabStrip {state["enabled"] = falseupdate(state)accountButton.performClick(nil)- try checkTitlebar(!accountButton.isEnabled && calls.count == 5, "A modal prevents the account control")+ try checkTitlebar(!accountButton.isEnabled && calls.count == 6, "A modal prevents the account control")state["enabled"] = truestate["account"] = ["kind": "billing"]update(state)accountButton.performClick(nil)- try checkTitlebar(accountButton.isHidden && !accountButton.isEnabled && calls.count == 5 &&+ try checkTitlebar(accountButton.isHidden && !accountButton.isEnabled && calls.count == 6 &&storeButton.frame.maxX == bounds.width - 12,"A kind this build does not know draws nothing, and Store ends the row")state["account"] = nil@@ -1896,7 +1905,8 @@ private extension SwarmTabStrip {newButton.frame.maxX < searchButton.frame.minX, "Tabs precede the search and Store controls")try checkTitlebar(tabs[0].frame.width < 136 && tabs[0].displayLabel == "code","Overflow tabs keep readable names without persistent number prefixes")- try checkTitlebar(subviews.filter { !$0.isHidden }.count == 4 && devicesButton.isHidden && statusBar.subviews.count == 10 && machineResourcesLabel.isHidden && machinesButton.isHidden && modelsButton.isHidden && pullRequestButton.isHidden && subscriptionUsageButton.isHidden && harnessMonitorButton.isHidden && daemonButton.isHidden && voiceLabel.isHidden && shareButton.isHidden,+ // Tabs, New Tab, search, Add Phone and Store; Devices and the account are hidden here.+ try checkTitlebar(subviews.filter { !$0.isHidden }.count == 5 && devicesButton.isHidden && statusBar.subviews.count == 10 && machineResourcesLabel.isHidden && machinesButton.isHidden && modelsButton.isHidden && pullRequestButton.isHidden && subscriptionUsageButton.isHidden && harnessMonitorButton.isHidden && daemonButton.isHidden && voiceLabel.isHidden && shareButton.isHidden,"Navigation lives in the titlebar and focused context lives in the footer")let controls = [newButton]for control in controls {