Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(desktop): QR-first Add Phone, hide phone icon once account has one

tony06058911f28c
diff --git a/desktop/design/workspace-status-bar.md b/desktop/design/workspace-status-bar.md
index a899e1072..c0c55d6d4 100644
--- a/desktop/design/workspace-status-bar.md
+++ b/desktop/design/workspace-status-bar.md
@@ -29,7 +29,13 @@ signed in, then Add Phone, Appearance,
Notifications, Settings and Sign out, each opening what the app already has.
Nothing is drawn between the icons and the account control; `controlGap`
separates them. A narrow window drops Devices first; the account control
-always stays. A viewer build (the browser) draws none of this. Flutter draws it
+always stays. Add Phone (the plain phone glyph, before Devices) shows only
+while the account has no phone (owner, 2026-10-13): the row is for what is
+used every day, and a phone is added once. It goes by the account, not the
+computer, since a phone finds every computer on its account by itself; it
+comes back when the account's last phone is removed, and stays while the
+device list cannot be read. Harness ▸ Add Phone…, the account menu,
+`> add phone` and Machines still open Add Phone (`state/account_phones.dart`). A viewer build (the browser) draws none of this. Flutter draws it
with `WorkspaceStoreButton`, `WorkspaceSignInButton` and `WorkspaceAvatarButton`,
AppKit with `SwarmStoreButton` and `SwarmAccountButton`; the menu is
`widgets/account_menu.dart` on both. Run `workspace_account_test.dart`.
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index 846553d50..642e9b2c5 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -50,6 +50,7 @@ import '../shortcuts/keymap_commands.dart';
import '../shortcuts/keymap_host.dart';
import '../shortcuts/keymap_native.dart';
import '../shortcuts/keymap_settings.dart';
+import '../state/account_phones.dart';
import '../state/app_state.dart';
import '../state/notification_inbox.dart';
import '../state/status_menu.dart';
@@ -579,6 +580,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
_pullRequest = WorkspacePullRequest(app)..addListener(_statusPrefsChanged);
_harnessMonitor = HarnessMonitor(app, sampleResources: false)
..addListener(_monitorChanged);
+ _accountPhones = AccountPhones(app)..addListener(_accountPhonesChanged);
app.reviewSessionClose = _reviewSessionClose;
app.changeCompanionAgent = _changeCompanionAgent;
app.canChangeCompanionAgent = _canChangeCompanionAgent;
@@ -799,6 +801,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
void dispose() {
_devicesHarness.dispose();
_harnessMonitor.dispose();
+ _accountPhones.removeListener(_accountPhonesChanged);
+ _accountPhones.dispose();
if (app.reviewSessionClose == _reviewSessionClose) {
app.reviewSessionClose = null;
}
@@ -1487,6 +1491,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
if (_menuHost) _syncNative();
}
+ /// Whether the account has a phone: Add Phone's icon leaves the tab row once
+ /// it does. Why, and when it comes back, is in `state/account_phones.dart`.
+ late final AccountPhones _accountPhones;
+ void _accountPhonesChanged() {
+ if (!mounted) return;
+ // The Flutter tab strip and Linux's title bar draw it from build; macOS
+ // from the native payload.
+ setState(() {});
+ if (_menuHost) _syncNative();
+ }
+
WorkspaceSubscriptionUsage get _subscriptionUsage =>
WorkspaceSubscriptionUsage.fromRows(_modelsMenu?.rows ?? const []);
@@ -1823,6 +1838,8 @@ class _SwarmScreenState extends State<SwarmScreen> {
'activeId': app.activeSwarmId,
'searchTooltip': _commandTooltip('Open Harness', 'harnesses.list'),
'addPhoneTooltip': _addPhoneTooltip,
+ // Not once the account has a phone: see `state/account_phones.dart`.
+ 'addPhoneVisible': _accountPhones.showsAddPhone,
'storeTooltip': _commandTooltip('Explore Harness Store', 'app.store'),
'devicesVisible': app.devicesEnabled,
// The row's last control: Sign in, or whose account this is.
@@ -2984,10 +3001,10 @@ class _SwarmScreenState extends State<SwarmScreen> {
Future<void> _addPhone() async {
// Open, from its card or by hand, it is this computer's offer
// ([_phoneOfferCard]) spent for good — and a sign-in made from inside it
- // (its "Sign in…") must not bring the card back once it closes, so the
- // offer is dropped on the way out too.
+ // (its Continue with…) must not bring the card back once it closes, so
+ // the offer is dropped on the way out too.
app.dropPhoneOffer();
- // "Manage devices…" pops the dialog and asks for Machines, but this
+ // "See your phones" pops the dialog and asks for Machines, but this
// [_dialog] is still open until the pop lands — a picker opened from
// the callback would be refused. So it is remembered, and opened after.
var manageDevices = false;
@@ -7101,7 +7118,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
children: [
_searchButton(theme),
_notificationsButton(theme),
- _addPhoneButton(theme),
+ if (_accountPhones.showsAddPhone) _addPhoneButton(theme),
if (app.devicesEnabled) _devicesButton(context),
WorkspaceStoreButton(
key: const ValueKey('swarm-store-button'),
@@ -7944,8 +7961,10 @@ class _SwarmScreenState extends State<SwarmScreen> {
final showDevices = app.devicesEnabled && room >= devicesWidth;
// Add Phone likewise, and it goes before Devices: a phone is added once,
// and the account menu, the Harness menu and `> add phone` still open it.
+ // Not at all once the account has a phone (`state/account_phones.dart`).
final addPhoneWidth = cell.width * 4;
final showAddPhone =
+ _accountPhones.showsAddPhone &&
room >= addPhoneWidth + (showDevices ? devicesWidth : 0);
// Search, notifications, Add Phone, Devices, Store and the account —
// none of it here when the title bar holds them.
@@ -8198,8 +8217,11 @@ class _SwarmScreenState extends State<SwarmScreen> {
builder: (context, emphasized) => SizedBox(
width: workspaceBarCellSizeOf(context).width * 4,
height: workspaceBarControlHeight(context),
+ // The plain phone the account menu and Harness ▸ Add Phone… show: one
+ // silhouette everywhere (design/icon-design-system.md). Its old radio
+ // waves read as NFC, and were the row's one busy glyph.
child: Icon(
- AppIcons.smartphoneNfc,
+ AppIcons.smartphone,
size: 16,
color: theme.foreground.withValues(
alpha: !_shortcutsEnabled
diff --git a/desktop/lib/state/account_phones.dart b/desktop/lib/state/account_phones.dart
new file mode 100644
index 000000000..0f56ecec1
--- /dev/null
+++ b/desktop/lib/state/account_phones.dart
@@ -0,0 +1,117 @@
+import 'dart:async';
+
+import 'package:flutter/foundation.dart';
+
+import 'app_state.dart';
+
+/// Whether the account already has a phone — which decides whether the tab row
+/// offers Add Phone's icon ([showsAddPhone]).
+///
+/// ⚠️ **The icon goes once the account has a phone (owner, 2026-10-13).** The
+/// tab row is for what is used every day; a phone is added once, and after
+/// that the icon would only sit there taking room. Hidden, the row is tidier.
+///
+/// **By the account, not by this computer.** A phone signed in to the account
+/// finds every computer on it by itself, so a second or a third computer has no
+/// phone to add either — its icon goes too, though Add Phone was never opened
+/// there.
+///
+/// When the icon shows, and when it does not:
+/// - **Hidden** while the account has any device that is not a computer and not
+/// this end: a phone. The device log calls phones and browsers alike
+/// `viewer`, so a browser signed in to the account counts as one too.
+/// - **Shown** while the account has only computers on it.
+/// - **Shown** while that is not known: before the list can be read (no daemon
+/// yet), when the read fails, or with a daemon that predates `/api/devices`.
+/// A way in stays rather than vanish on a guess.
+/// - **Back by itself** when the account's last phone goes (Remove in Machines,
+/// or the phone signing out): every change to the account's devices
+/// ([AppNotifier.devicesRevision]) reads the list again.
+/// - **Forgotten** on sign-out and when the account changes, then read again for
+/// the next one.
+///
+/// Adding a second phone does not need the icon: Harness ▸ Add Phone…, the
+/// account menu, `> add phone` and Add phone at the foot of Machines all open
+/// Add Phone whatever this says.
+class AccountPhones extends ChangeNotifier {
+ AccountPhones(this.app) {
+ app.addListener(_appChanged);
+ _appChanged();
+ }
+
+ final AppNotifier app;
+
+ /// Null while not known.
+ bool? _has;
+
+ /// Whether the tab row shows Add Phone's icon: not once the account is known
+ /// to have a phone.
+ bool get showsAddPhone => _has != true;
+
+ /// The account and the devices' revision the answer is wanted for; null
+ /// while there is nothing to read.
+ ({String account, int revision})? _wanted;
+ bool _reading = false;
+ bool _disposed = false;
+
+ ({String account, int revision})? get _current {
+ if (app.isGuest || app.signingIn || !app.accountDevicesReadable) {
+ return null;
+ }
+ final email = app.currentUser?.email.trim();
+ // `CurrentUserProfile.local()` says "local terminal": not an account.
+ if (email == null || !email.contains('@')) return null;
+ return (account: email, revision: app.devicesRevision);
+ }
+
+ void _appChanged() {
+ final wanted = _current;
+ if (wanted == _wanted) return;
+ // Another account's answer is not this one's: forgotten at once. The same
+ // account's keeps showing until its new read lands, so the icon does not
+ // blink in and out on every change to the list.
+ if (wanted?.account != _wanted?.account) _set(null);
+ _wanted = wanted;
+ if (wanted != null) unawaited(_read());
+ }
+
+ /// One read at a time; one that lands after what is wanted moved on reads
+ /// again for that, rather than say something about a list that is gone.
+ Future<void> _read() async {
+ if (_reading) return;
+ _reading = true;
+ try {
+ while (!_disposed) {
+ final asked = _wanted;
+ if (asked == null) return;
+ bool? has;
+ try {
+ final listing = await app.loadDevices();
+ has = listing?.devices.any((d) => !d.isMachine && !d.self);
+ } catch (_) {
+ // Unreadable now: what was known stays, and the next change reads.
+ has = null;
+ }
+ if (_disposed) return;
+ if (asked != _wanted) continue;
+ if (has != null) _set(has);
+ return;
+ }
+ } finally {
+ _reading = false;
+ }
+ }
+
+ void _set(bool? has) {
+ if (_has == has) return;
+ _has = has;
+ if (!_disposed) notifyListeners();
+ }
+
+ @override
+ void dispose() {
+ _disposed = true;
+ app.removeListener(_appChanged);
+ super.dispose();
+ }
+}
diff --git a/desktop/lib/widgets/add_phone_dialog.dart b/desktop/lib/widgets/add_phone_dialog.dart
index 9f79a5bae..b47614b34 100644
--- a/desktop/lib/widgets/add_phone_dialog.dart
+++ b/desktop/lib/widgets/add_phone_dialog.dart
@@ -9,8 +9,8 @@ import 'package:flutter_svg/flutter_svg.dart';
import '../shared/widgets/qr_code_view.dart';
import '../api/api_client.dart';
+import '../auth/sign_in_provider.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';
@@ -19,21 +19,32 @@ import '../state/app_state.dart';
import '../ws/ws_conn.dart' show WsRequestFailure, WsRequestTimeout;
import 'desktop_chrome.dart';
import 'desktop_prompt_surface.dart';
+import 'quiet_link.dart';
+import 'sign_in_provider_button.dart';
import 'terminal_prompt.dart';
/// Harness ▸ Add Phone… — how a phone comes to manage this account's agents.
///
-/// **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 code first, and few words (owner, 2026-10-13).** Desktop asks for an
+/// account before its workspace opens, so Add Phone opens on its QR: the code,
+/// "Scan with the Harness app.", and the stores for a phone without the app.
+/// The phone's welcome leads with Scan QR code (mobile `phone_welcome.dart`):
+/// the scan signs it in to this account with nothing to type, so it cannot
+/// land on another account. No steps, no picture, no "Looking for your phone"
+/// while it waits — that read as this computer searching, and people waited
+/// instead of scanning. A phone that signs in with this account by itself does
+/// as well: the account's device key log makes every computer on it trust the
+/// phone, and the dialog watches the account for it ([AppNotifier.deviceJoins]).
///
-/// **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:
+/// Then "`<phone>` is ready.", Done, and See your phones — Machines, at its
+/// phones ([AddPhoneDialog.onManageDevices]).
+///
+/// With no account here — a session the server stopped renewing while this was
+/// open — the required sign-in page's ways in stand where the code will be:
+/// Continue with Google, Continue with Apple, Continue with email
+/// ([AppNotifier.signInFromStep]). The code comes up once the account lands.
+///
+/// The code is armed only while it is on screen:
///
/// 1. **The QR** ([phonePairLink]) tells the phone who to sign in as, which
/// machine to pair with, and the one-time pairing code.
@@ -259,35 +270,18 @@ class AddPhoneDialog extends StatefulWidget {
final PhoneSignInCodeCall signInCode;
final VoidCallback? onConnectMachine;
- /// 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.
+ /// "See your phones", beside Done once the phone is in: Machines, at its
+ /// phones, where it can be named, removed, or a second one added. Only
+ /// then — while adding one it was a second way out nobody was looking for
+ /// (owner, 2026-10-12). Not "devices": the tab row's Devices is the Harness
+ /// hardware. The dialog closes; the caller opens Machines after.
final VoidCallback? onManageDevices;
@override
State<AddPhoneDialog> createState() => _AddPhoneDialogState();
}
-/// 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 {
+class _AddPhoneDialogState extends State<AddPhoneDialog> {
/// 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
@@ -303,16 +297,6 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
/// 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.
@@ -353,52 +337,19 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
bool _signInStarted = 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].
+ /// lands, 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.
+ /// the code is up.
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;
+ /// The stores' code is up in the Harness code's place ([_stores]).
+ bool _showingStores = false;
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();
-
- /// The code's space has appeared once; after that, the scroll is the person's.
- bool _codeAppeared = false;
-
/// No pairing to be had from this daemon — asking stopped for good.
bool _stopped = false;
String? _message;
@@ -411,10 +362,12 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
@override
void initState() {
super.initState();
- _signInStep = _awaitingAccount = app.isGuest;
+ _awaitingAccount = _signedOut;
app.addListener(_appChanged);
_joins = app.deviceJoins.listen(_deviceJoined);
- _watchForPhone();
+ // Signed in — as Desktop is before its workspace opens — the code is up
+ // from the first frame: nothing to read or press before it.
+ _codeChanged();
}
@override
@@ -424,9 +377,6 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
unawaited(_joins?.cancel());
_timer?.cancel();
_signInTimer?.cancel();
- _stillTimer?.cancel();
- _pulse.dispose();
- _unlock.dispose();
if (_sleeping case final sleeping? when !sleeping.isCompleted) {
sleeping.complete(false);
}
@@ -439,91 +389,83 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
super.dispose();
}
+ /// No account here, or its sign-in is under way: the ways in, not the code.
+ bool get _signedOut => app.isGuest || app.signingIn;
+
void _appChanged() {
if (_closed) return;
- if (app.isGuest) {
+ if (_signedOut) {
_awaitingAccount = true;
- _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.
+ } else if (_awaitingAccount) {
+ // Signed in while the dialog was open. A sign-in code asked for without
+ // an account 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;
- 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.
if (_signInStarted) _restartSignIn();
}
setState(() {});
- _syncLoop();
- _watchForPhone();
+ _codeChanged();
}
/// 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.
+ /// phone; anything else signed in with this account is.
void _deviceJoined(NewDeviceNotice device) {
if (_closed || _ready != null || device.kind == 'machine') return;
- if (app.isGuest) return;
+ if (_signedOut) return;
_phoneIn(device.label);
}
- /// The phone is in — by its own sign-in, or by the code. The code goes, with
+ /// The phone is in — by the code, or by its own sign-in. 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);
- });
- }
+ /// The Harness code is what the dialog shows: an account here, no phone in
+ /// yet, and not the stores' code in its place.
+ bool get _codeUp => !_signedOut && _ready == null && !_showingStores;
- /// A guest's way in, raised over this dialog rather than instead of it: the
- /// 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.
- Future<void> _signInHere() async {
- if (_signingIn || _closed) return;
- _signingIn = true;
- try {
- await showSignInSheet(
- context,
- app,
- reason:
- 'Sign in to add your phone. Your phone signs in to the same '
- 'account.',
- offerPhone: false,
- );
- } finally {
- _signingIn = false;
+ /// 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 && _codeUp;
+
+ /// The code came up, or went: up, it asks for its sign-in code — fresh
+ /// unless one is still renewing — and starts arming the daemon; gone, the
+ /// loop ends after its answer and the renewal lapses.
+ void _codeChanged() {
+ if (_codeUp && !_signInStarted) {
+ _signInStarted = true;
+ _restartSignIn();
}
+ _syncLoop();
+ }
+
+ /// "App Store · Google Play" and Back: the stores' code in the Harness
+ /// code's place, or the Harness code again. One kind of code on screen at a
+ /// time — Harness reads only its own, the Camera only the stores' — so
+ /// nobody scans one with the other's.
+ void _showStores(bool showing) {
+ setState(() => _showingStores = showing);
+ _codeChanged();
+ }
+
+ /// One of the sign-in's ways in. They stay live while the browser is open,
+ /// as on the required sign-in page: the same one again reopens its page,
+ /// another one switches. [provider] null is Continue with email.
+ void _signInWith(SignInProvider? provider) =>
+ unawaited(app.signInFromStep(provider));
+
+ /// See your phones: Machines, at its phones, once this has closed — the
+ /// caller opens it ([AddPhoneDialog.onManageDevices]).
+ void _seePhones() {
+ widget.onManageDevices?.call();
+ _close();
}
/// Who and what the QR is for, or null while there is nothing to show yet.
@@ -535,7 +477,7 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
({String email, String machineId})? get _target {
// Mid sign-in the daemon moves onto the account, and this computer's id
// with it (`AppNotifier.login`): nothing to show or arm until it lands.
- if (app.isGuest || app.signingIn) return null;
+ if (_signedOut) return null;
final email = app.currentUser?.email.trim();
final machineId = app.viewer == null
? app.localMachineState?.machine.machineId
@@ -546,17 +488,6 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
return (email: email, machineId: machineId);
}
- /// 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
/// after the dialog opened arms it then.
@@ -655,7 +586,7 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
: _signInRenew;
_signInTimer = Timer(wait > Duration.zero ? wait : _signInRenew, () {
// Put away, the code needs no fresher sign-in: the next showing asks.
- if (!_showingCode) {
+ if (!_codeUp) {
_signInStarted = false;
return;
}
@@ -674,20 +605,6 @@ 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;
@@ -707,338 +624,187 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
void _close() => Navigator.of(context).maybePop();
- 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;
- }
+ /// The code, the dialog's subject: big enough to scan from across a desk.
+ static const double _qrSide = 200;
@override
Widget 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) {
+ final ready = _ready != null;
return TerminalPromptKeys(
cancel: _close,
child: DesktopPromptSurface(
width: _width,
body: LayoutBuilder(
- builder: (context, constraints) => DesktopPromptScrollBody(
- child: _showingStores
- ? _stores()
- : _connect(math.min(_qrSide, constraints.maxWidth)),
- ),
- ),
- // 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…'),
+ builder: (context, constraints) {
+ final qrSide = math.min(_qrSide, constraints.maxWidth);
+ return DesktopPromptScrollBody(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Semantics(
+ header: true,
+ child: Text(
+ 'Add your phone',
+ textAlign: TextAlign.center,
+ style: DesktopChrome.heading(),
),
+ ),
+ const SizedBox(height: 20),
+ if (ready)
+ _done()
+ else if (_signedOut)
+ _waysIn()
+ else if (_showingStores)
+ _stores(qrSide)
+ else
+ ..._codeArea(qrSide),
],
- ],
+ ),
+ );
+ },
+ ),
+ actions: [
+ if (ready) ...[
+ if (widget.onManageDevices != null)
+ // The link sits on the button's line, not at its top.
+ SizedBox(
+ height: DesktopChrome.controlHeight,
+ child: Center(
+ child: _InlineLink(
+ key: const ValueKey('add-phone-see-phones'),
+ label: 'See your phones',
+ onPressed: _seePhones,
+ ),
+ ),
+ ),
+ FilledButton(
+ key: const ValueKey('add-phone-done'),
+ autofocus: true,
+ onPressed: _close,
+ child: const Text('Done'),
+ ),
+ ] else if (_signedOut)
+ TextButton(
+ key: const ValueKey('add-phone-cancel'),
+ onPressed: _close,
+ child: const Text('Cancel'),
+ )
+ else
+ // Close, not Cancel: nothing is undone by it. The phone that
+ // scanned is in all the same; only the code goes.
+ TextButton(
+ key: const ValueKey('add-phone-close'),
+ onPressed: _close,
+ child: const Text('Close'),
+ ),
+ ],
),
);
}
- /// 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()),
- ),
- 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,
+ /// The phone is in: a tick and its name, nothing else to read.
+ Widget _done() {
+ final ok = grid.AppPalette.online;
+ final name = _ready!;
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 12),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ExcludeSemantics(
+ child: Container(
+ width: 56,
+ height: 56,
+ decoration: BoxDecoration(
+ color: ok.withValues(alpha: .16),
+ shape: BoxShape.circle,
+ ),
+ child: Icon(AppIcons.check, size: 24, color: ok),
+ ),
+ ),
+ const SizedBox(height: 14),
+ Semantics(
+ liveRegion: true,
+ child: Text(
+ '${name.isEmpty ? 'Your phone' : name} is ready.',
+ key: const ValueKey('add-phone-ready'),
+ textAlign: TextAlign.center,
+ style: DesktopChrome.heading(),
+ ),
),
],
- _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),
- ],
- ],
- ],
+ ),
);
}
- /// 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,
- ),
- ),
- ),
- );
-
- /// 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'),
+ /// No account here: the required sign-in page's ways in, and no words
+ /// around them (owner, 2026-10-13). The pressed one says what it waits on.
+ Widget _waysIn() {
+ final waiting = app.pendingAuthorizeUrl == null
+ ? 'Signing in…'
+ : 'Waiting for your browser';
+ final error = app.loginBrowserError;
+ return Center(
+ child: IntrinsicWidth(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
+ spacing: 10,
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: '.'),
- ],
+ for (final provider in SignInProvider.values)
+ SignInProviderButton(
+ provider: provider,
+ // Return signs in with the first.
+ autofocus: provider == SignInProvider.values.first,
+ onPressed: () => _signInWith(provider),
+ busyLabel: app.signingIn && app.signInProvider == provider
+ ? waiting
+ : null,
),
- 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),
+ Center(
+ child: QuietLink(
+ key: const ValueKey('add-phone-sign-in-email'),
+ label: 'Continue with email',
+ onPressed: () => _signInWith(null),
),
),
- _Caret(beat: _pulse),
- ],
- );
- }
- return Padding(
- padding: const EdgeInsets.only(top: 6),
- child: Semantics(liveRegion: true, child: Center(child: line)),
- );
- }
-
- /// "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),
+ if (error != null)
+ Semantics(
+ liveRegion: true,
+ child: Text(
+ error,
+ textAlign: TextAlign.center,
+ style: _note(Theme.of(context).colorScheme.error),
+ ),
),
- 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.
+ /// The code, one line under it, and the stores for a phone without the app
+ /// — or, before there is a code, why not yet, in a square of the code's own
+ /// size so nothing moves when it comes. What went wrong, only when it did.
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 room(List<Widget> children) => 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),
),
),
);
@@ -1046,58 +812,54 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
Text(text, textAlign: TextAlign.center, style: _note());
final target = _target;
- if (target == null) {
- if (_connectFirst) {
- return [
- 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'),
- ),
- ],
- ]),
- ];
- }
+ if (target == null && _connectFirst) {
return [
room([
- say(
- app.currentUser?.email.contains('@') == true
- ? 'Waiting for Harness on this ${_thisComputer()}…'
- : 'Waiting for your account…',
- ),
+ 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'),
+ ),
+ ],
]),
];
}
- // 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 [
- room([say('Preparing your code…')]),
- ];
+ final Widget code;
+ if (target == null) {
+ code = room([
+ say(
+ app.currentUser?.email.contains('@') == true
+ ? 'Waiting for Harness on this ${_thisComputer()}…'
+ : 'Waiting for your account…',
+ ),
+ ]);
+ } else if (!_signInAsked) {
+ // 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.
+ code = room([say('Preparing your code…')]);
+ } else {
+ final link = phonePairLink(
+ email: target.email,
+ machineId: target.machineId,
+ code: _code,
+ signIn: _signIn,
+ ).toString();
+ code = Center(
+ // Dimmed once there is no pairing to be had, so nobody scans it.
+ child: Opacity(
+ opacity: _stopped ? .25 : 1,
+ child: PhonePairQr(data: link, side: qrSide),
+ ),
+ );
}
- final link = phonePairLink(
- email: target.email,
- machineId: target.machineId,
- code: _code,
- signIn: _signIn,
- ).toString();
final message = _message;
return [
- _codeSpace(
- Center(
- // Dimmed once there is no pairing to be had, so nobody scans it.
- child: Opacity(
- opacity: _stopped ? .25 : 1,
- child: PhonePairQr(data: link, side: qrSide),
- ),
- ),
- ),
+ code,
if (_remoteMachineId case final machineId?) ...[
const SizedBox(height: 8),
Text(
@@ -1106,17 +868,32 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
style: _note(),
),
],
- 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.
+ const SizedBox(height: 14),
+ // The phone's welcome leads with Scan QR code: "the Harness app" is
+ // where to scan, so nobody reaches for the Camera.
Text(
- 'On your phone, open Computers and scan this code.',
+ 'Scan with the Harness app.',
textAlign: TextAlign.center,
- style: _note(),
+ style: DesktopChrome.text(size: 15, medium: true),
+ ),
+ const SizedBox(height: 4),
+ Wrap(
+ alignment: WrapAlignment.center,
+ crossAxisAlignment: WrapCrossAlignment.center,
+ spacing: 4,
+ children: [
+ Text('No app yet?', style: _note()),
+ _InlineLink(
+ 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: () => _showStores(true),
+ ),
+ ],
),
if (message != null) ...[
- const SizedBox(height: 8),
+ const SizedBox(height: 10),
Semantics(
liveRegion: true,
child: Text(
@@ -1130,300 +907,56 @@ class _AddPhoneDialogState extends State<AddPhoneDialog>
];
}
- /// "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,
+ /// "App Store · Google Play": 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 — in the
+ /// Harness code's place. A code, not a link: clicked here a link opens on
+ /// this computer, which cannot install a phone's app. Back returns.
+ Widget _stores(double qrSide) => Column(
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',
- ),
+ QrCodeView(
+ data: kPhoneAppUrl,
+ side: qrSide,
+ semanticLabel: 'QR code for Harness on the App Store or Google Play',
),
const SizedBox(height: 12),
const _StoreMarks(),
+ const SizedBox(height: 10),
+ _InlineLink(
+ key: const ValueKey('add-phone-hide-downloads'),
+ label: '‹ Back',
+ onPressed: () => _showStores(false),
+ ),
],
);
- /// 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.
- ///
- /// 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;
- WidgetsBinding.instance.addPostFrameCallback((_) {
- final space = _codeKey.currentContext;
- if (_closed || space == null) return;
- unawaited(
- Scrollable.ensureVisible(
- space,
- alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd,
- ),
- );
- });
- }
- return KeyedSubtree(key: _codeKey, child: child);
- }
-
- /// A line under a step's title: smaller and quieter than the title.
+ /// A quiet line: smaller and fainter than what it is under.
TextStyle _note([Color? color]) =>
- DesktopChrome.text(color: color ?? _faint, size: 13);
+ DesktopChrome.text(color: color ?? DesktopChrome.muted, size: 13);
}
-/// 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: 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.note,
- this.link,
- this.beat,
- this.last = false,
- });
-
- final int number;
- final _Mark mark;
- final List<InlineSpan> title;
- final List<InlineSpan>? note;
-
- /// 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;
-
- /// The picture's beat, which a [_Mark.current] ring keeps.
- final AnimationController? beat;
-
- /// No thread under the last step of a group.
- final bool last;
-
- static const double _ring = 22;
-
- @override
- Widget build(BuildContext context) {
- 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.stretch,
- children: [
- 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: 10),
- Expanded(
- 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),
- ),
- ),
- ),
- 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),
- ),
- );
- }
- }
-}
-
-/// 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});
+/// A link in a line of words: the words in the accent and nothing around them
+/// — 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 _InlineLink extends StatefulWidget {
+ const _InlineLink({super.key, required this.label, required this.onPressed});
final String label;
final VoidCallback onPressed;
@override
- State<_StepLink> createState() => _StepLinkState();
+ State<_InlineLink> createState() => _InlineLinkState();
}
-class _StepLinkState extends State<_StepLink> {
+class _InlineLinkState extends State<_InlineLink> {
var _hovered = false;
var _focused = false;
@@ -1462,251 +995,6 @@ class _StepLinkState extends State<_StepLink> {
}
}
-/// 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 {
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 516e5dc81..d0cf5b285 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -7,9 +7,17 @@ import ImageIO
enum HarnessControlSymbols {
static let size: CGFloat = 16
static let configuration = NSImage.SymbolConfiguration(pointSize: size, weight: .regular)
- static func image(_ name: String, description: String? = nil) -> NSImage? {
+ /// The same, in one ink. Device symbols such as `iphone` also carry a filled
+ /// screen layer that the default rendering tints grey, so beside the plain
+ /// outlines around them they read as blurred; monochrome keeps the outline
+ /// alone. macOS 12 has no such rendering and keeps the default.
+ static let outlineConfiguration: NSImage.SymbolConfiguration = {
+ if #available(macOS 13.0, *) { return configuration.applying(.preferringMonochrome()) }
+ return configuration
+ }()
+ static func image(_ name: String, description: String? = nil, outline: Bool = false) -> NSImage? {
NSImage(systemSymbolName: name, accessibilityDescription: description)?
- .withSymbolConfiguration(configuration)
+ .withSymbolConfiguration(outline ? outlineConfiguration : configuration)
}
}
@@ -285,7 +293,8 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
addPhone.target = self
addPhone.representedObject = "addPhone"
addPhone.identifier = NSUserInterfaceItemIdentifier(HarnessKeymapMenu.actionPrefix + "addPhone")
- addPhone.image = HarnessControlSymbols.image("iphone")
+ // The outline only, as the title bar's Add Phone draws it.
+ addPhone.image = HarnessControlSymbols.image("iphone", outline: true)
appMenu.insertItem(addPhone, at: appMenu.index(of: settings) + 1)
let customize = NSMenuItem(title: "Appearance…", action: #selector(menuAction(_:)), keyEquivalent: "")
customize.target = self
@@ -2065,7 +2074,13 @@ private final class SwarmTabStrip: NSView {
phoneButton.isBordered = false
phoneButton.focusRingType = .none
phoneButton.title = ""
- phoneButton.image = HarnessControlSymbols.image("iphone.radiowaves.left.and.right")
+ // The plain phone of Harness ▸ Add Phone… and the account menu: one
+ // silhouette everywhere (design/icon-design-system.md), no radio waves —
+ // and its outline only, as clear as Search beside it. The button keeps the
+ // outline configuration too: its draw() applies its own, and the default
+ // would bring the grey screen back.
+ phoneButton.image = HarnessControlSymbols.image("iphone", outline: true)
+ phoneButton.symbolConfiguration = HarnessControlSymbols.outlineConfiguration
phoneButton.imagePosition = .imageOnly
phoneButton.isEnabled = false
phoneButton.target = self
@@ -2238,6 +2253,11 @@ private final class SwarmTabStrip: NSView {
statusBar.setAccessibilityHidden(passiveFooter || statusBar.isHidden)
devicesButton.isHidden = state["devicesVisible"] as? Bool != true
devicesButton.setAccessibilityHidden(devicesButton.isHidden)
+ // Add Phone leaves the row once the account has a phone (Dart's
+ // `state/account_phones.dart` says why and when). Absent is shown, as it
+ // was before the key existed.
+ phoneButton.isHidden = state["addPhoneVisible"] as? Bool == false
+ phoneButton.setAccessibilityHidden(phoneButton.isHidden)
// The row's last control: Sign in, or whose account this is. Absent (a
// viewer build, teardown), nothing is drawn.
let account = state["account"] as? [String: Any]
@@ -2257,7 +2277,8 @@ private final class SwarmTabStrip: NSView {
accountButton.setAccessibilityLabel(accountKind == .signIn ? SwarmAccountButton.label : "Account")
accountButton.setAccessibilityHelp(accountButton.toolTip)
}
- var children: [Any] = [scroll, newButton, searchButton, phoneButton]
+ var children: [Any] = [scroll, newButton, searchButton]
+ if !phoneButton.isHidden { children.append(phoneButton) }
if !devicesButton.isHidden { children.append(devicesButton) }
children.append(storeButton)
if !accountButton.isHidden { children.append(accountButton) }
@@ -2287,7 +2308,7 @@ private final class SwarmTabStrip: NSView {
searchButton.toolTip = state["searchTooltip"] as? String ?? "Open Harness"
searchButton.setAccessibilityHelp(searchButton.toolTip)
phoneButton.foreground = palette.navigationForeground
- phoneButton.isEnabled = actionsEnabled
+ phoneButton.isEnabled = actionsEnabled && !phoneButton.isHidden
phoneButton.toolTip = state["addPhoneTooltip"] as? String ?? "Add Phone"
phoneButton.setAccessibilityHelp(phoneButton.toolTip)
storeButton.toolTip = state["storeTooltip"] as? String ?? "Explore Harness Store"
@@ -2541,7 +2562,9 @@ private final class SwarmTabStrip: NSView {
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,
+ // Hidden, Add Phone gives its place to Search.
+ let searchEdge = phoneButton.isHidden ? phoneEdge : phoneButton.frame.minX
+ searchButton.frame = NSRect(x: searchEdge - 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)
diff --git a/desktop/test/add_phone_dialog_test.dart b/desktop/test/add_phone_dialog_test.dart
index bd972f666..97e3f2498 100644
--- a/desktop/test/add_phone_dialog_test.dart
+++ b/desktop/test/add_phone_dialog_test.dart
@@ -9,6 +9,7 @@ import 'package:harness/core/models.dart';
import 'package:harness/core/config.dart';
import 'package:harness/core/phone_app_links.dart';
import 'package:harness/auth/auth_session.dart';
+import 'package:harness/auth/sign_in_provider.dart';
import 'package:harness/viewer/viewer_services.dart';
import 'package:harness/viewer/viewer_key_store.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
@@ -36,7 +37,10 @@ AppNotifier _signedInApp() {
/// A scripted daemon: answers in order, records every code it was handed.
class _FakeDaemon {
- _FakeDaemon(this.answers);
+ /// Copied: a fixed-length `List.filled` cannot be answered from, and the
+ /// dialog would say "Could not pair" instead of asking again.
+ _FakeDaemon(Iterable<FutureOr<PhonePairAnswer> Function()> answers)
+ : answers = [...answers];
final List<FutureOr<PhonePairAnswer> Function()> answers;
final codes = <String>[];
@@ -103,14 +107,9 @@ Future<void> _open(
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();
-}
+/// The sign-in code's answer, which the QR waits for: the code is up — and
+/// armed — from the first frame, and shows once its sign-in code is in.
+Future<void> _codeUp(WidgetTester tester) => tester.pump();
String _qrData(WidgetTester tester) =>
tester.widget<PhonePairQr>(find.byType(PhonePairQr)).data;
@@ -165,57 +164,78 @@ 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();
- },
- );
+ group('signed in, the code is the dialog', () {
+ testWidgets('it is up and armed at once, under one line and the stores — '
+ 'nothing else to read', (tester) async {
+ final app = _signedInApp();
+ addTearDown(app.dispose);
+ final signIn = _FakeSignIn();
+ final daemon = _FakeDaemon(List.filled(3, _failed('NO_INTENT')));
+ await _open(tester, app, daemon.call, signInCode: signIn.call);
+ await _codeUp(tester);
+
+ expect(find.text('Add your phone'), findsOneWidget);
+ expect(find.byType(PhonePairQr), findsOneWidget);
+ expect(
+ Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],
+ 'h1',
+ );
+ expect(find.text('Scan with the Harness app.'), findsOneWidget);
+ expect(find.text('No app yet?'), findsOneWidget);
+ expect(
+ find.descendant(
+ of: find.byKey(const ValueKey('add-phone-show-downloads')),
+ matching: find.text('App Store · Google Play'),
+ ),
+ findsOneWidget,
+ );
+ expect(find.byKey(const ValueKey('add-phone-close')), findsOneWidget);
+ // Few words (owner, 2026-10-13): no headline, no steps, no status.
+ expect(
+ find.text(
+ 'Manage all your agents on all your computers from your phone.',
+ ),
+ findsNothing,
+ );
+ expect(find.text('Install Harness'), findsNothing);
+ expect(find.textContaining('Looking for your phone'), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-status')), findsNothing);
+ expect(find.text('Cancel'), findsNothing);
+ // Armed with the code on screen.
+ expect(signIn.minted, 1);
+ expect(daemon.codes, hasLength(1));
+
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(find.byType(AddPhoneDialog), findsNothing);
+ expect(daemon.tokens.single.isCancelled, isTrue);
+ });
- testWidgets('a phone that signs in to the account is ready, and the '
- 'beat stops', (tester) async {
+ testWidgets('a phone that signs in to the account is ready; Done closes', (
+ tester,
+ ) async {
final app = _signedInApp();
addTearDown(app.dispose);
- await _open(tester, app, _FakeDaemon([]).call);
+ await _open(
+ tester,
+ app,
+ _FakeDaemon(List.filled(3, _failed('NO_INTENT'))).call,
+ onManageDevices: () {},
+ );
+ await _codeUp(tester);
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);
+ expect(find.byType(PhonePairQr), findsNothing);
+ expect(find.text('Scan with the Harness app.'), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-close')), findsNothing);
+ expect(
+ find.byKey(const ValueKey('add-phone-see-phones')),
+ findsOneWidget,
+ );
// Nothing moves once the phone is in: the dialog settles.
await tester.pumpAndSettle();
expect(find.byType(AddPhoneDialog), findsOneWidget);
@@ -225,81 +245,113 @@ void main() {
expect(find.byType(AddPhoneDialog), findsNothing);
});
- testWidgets('a computer joining the account is not the phone', (
+ testWidgets('See your phones closes it and hands Machines to the caller', (
tester,
) async {
final app = _signedInApp();
addTearDown(app.dispose);
- await _open(tester, app, _FakeDaemon([]).call);
- await _joins(
+ var manage = 0;
+ await _open(
tester,
app,
- pub: 'pub-mac',
- label: 'Studio Mac',
- kind: 'machine',
+ _FakeDaemon(List.filled(3, _failed('NO_INTENT'))).call,
+ onManageDevices: () => manage++,
);
+ await _codeUp(tester);
+ await _joins(tester, app);
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();
+ expect(find.text('See your phones'), findsOneWidget);
+
+ await tester.tap(find.byKey(const ValueKey('add-phone-see-phones')));
+ await tester.pumpAndSettle();
+ expect(manage, 1);
+ expect(find.byType(AddPhoneDialog), findsNothing);
});
- testWidgets('after a minute it names the account the phone needs', (
+ testWidgets('without a way to Machines, ready says so with Done alone', (
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 _open(
+ tester,
+ app,
+ _FakeDaemon(List.filled(3, _failed('NO_INTENT'))).call,
);
- await tester.pump(const Duration(seconds: 1));
- expect(
- find.byKey(const ValueKey('add-phone-still-looking')),
- findsOneWidget,
+ await _codeUp(tester);
+ await _joins(tester, app);
+ await tester.pump();
+ expect(find.byKey(const ValueKey('add-phone-ready')), findsOneWidget);
+ expect(find.byKey(const ValueKey('add-phone-see-phones')), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-done')), findsOneWidget);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ });
+
+ testWidgets('a computer joining the account is not the phone', (
+ tester,
+ ) async {
+ final app = _signedInApp();
+ addTearDown(app.dispose);
+ await _open(
+ tester,
+ app,
+ _FakeDaemon(List.filled(3, _failed('NO_INTENT'))).call,
);
- expect(find.text('Still looking for your phone'), findsOneWidget);
- expect(
- find.text('Your phone has to be signed in with [email protected].'),
- findsOneWidget,
+ await _codeUp(tester);
+ 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.byType(PhonePairQr), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
});
- testWidgets('under Reduce Motion nothing keeps the frames busy', (
- tester,
- ) async {
+ testWidgets('waiting says nothing more: no status after minutes, and '
+ 'nothing keeps the frames busy', (tester) async {
final app = _signedInApp();
addTearDown(app.dispose);
- await _open(tester, app, _FakeDaemon([]).call, reduceMotion: true);
+ await _open(
+ tester,
+ app,
+ _FakeDaemon(List.filled(200, _failed('NO_INTENT'))).call,
+ );
+ await _codeUp(tester);
await tester.pumpAndSettle();
- expect(find.byKey(const ValueKey('add-phone-looking')), findsOneWidget);
+ await tester.pump(const Duration(minutes: 2));
+ expect(find.textContaining('Looking'), findsNothing);
+ expect(find.textContaining('Still looking'), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-status')), findsNothing);
+ expect(find.byType(PhonePairQr), 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 {
+ testWidgets('the sign-in\'s ways in, with no words around them: nothing '
+ 'is armed and there is no code', (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('Add your phone'), findsOneWidget);
+ expect(find.byKey(const Key('login-continue-google')), findsOneWidget);
+ expect(find.byKey(const Key('login-continue-apple')), findsOneWidget);
expect(
- find.text('Your phone signs in with the same account.'),
+ find.byKey(const ValueKey('add-phone-sign-in-email')),
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.byKey(const ValueKey('add-phone-cancel')), findsOneWidget);
+ expect(find.text('Sign in first'), findsNothing);
+ expect(find.text('Scan with the Harness app.'), findsNothing);
expect(find.byType(PhonePairQr), findsNothing);
expect(daemon.codes, isEmpty);
expect(signIn.minted, 0);
@@ -312,42 +364,60 @@ void main() {
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', (
+ testWidgets('the way pressed says what it waits on; the others stay', (
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,
+ await _open(tester, app, _FakeDaemon([]).call);
+ app
+ ..signingIn = true
+ ..signInProvider = SignInProvider.apple
+ ..pendingAuthorizeUrl = 'https://auth.example.test/authorize';
+ app.notifyListeners();
+ await tester.pump();
+ expect(
+ find.descendant(
+ of: find.byKey(const Key('login-continue-apple')),
+ matching: find.text('Waiting for your browser'),
+ ),
+ findsOneWidget,
+ );
+ expect(
+ find.descendant(
+ of: find.byKey(const Key('login-continue-google')),
+ matching: find.text('Continue with Google'),
+ ),
+ findsOneWidget,
);
- // 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();
+ expect(find.byType(PhonePairQr), findsNothing);
+ app.signingIn = false;
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ });
+
+ testWidgets('signed in while it is open: the code comes up in the same '
+ 'dialog, with its sign-in code', (tester) async {
+ final app = _signedInApp()..signedIn = false;
+ addTearDown(app.dispose);
+ final signIn = _FakeSignIn();
+ final daemon = _FakeDaemon(List.filled(4, _failed('NO_INTENT')));
+ await _open(tester, app, daemon.call, signInCode: signIn.call);
+ expect(find.byType(PhonePairQr), findsNothing);
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);
+ await _codeUp(tester);
+ expect(find.byKey(const Key('login-continue-google')), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-close')), findsOneWidget);
+ expect(find.byType(PhonePairQr), findsOneWidget);
+ expect(signIn.minted, 1);
expect(
Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],
'h1',
);
+ expect(daemon.codes, hasLength(1));
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
});
@@ -373,7 +443,7 @@ void main() {
app.selectedMachineId = 'b';
final daemon = _FakeDaemon(List.filled(3, _failed('NO_INTENT')));
await _open(tester, app, daemon.call);
- await _showCode(tester);
+ await _codeUp(tester);
final before = _qrData(tester);
expect(Uri.splitQueryString(Uri.parse(before).fragment)['m'], 'b');
expect(find.text('Computer b'), findsOneWidget);
@@ -403,7 +473,7 @@ void main() {
daemon.call,
onConnectMachine: () => opened = true,
);
- await _showCode(tester);
+ await _codeUp(tester);
expect(find.byType(PhonePairQr), findsNothing);
expect(daemon.codes, isEmpty);
expect(
@@ -502,7 +572,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);
+ await _codeUp(tester);
expect(
Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],
@@ -522,17 +592,17 @@ 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 {
+ testWidgets('the stores\' code in its place, the code lets its renewal '
+ 'lapse; back, 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);
+ await _codeUp(tester);
expect(signIn.minted, 1);
- await tester.tap(find.byKey(const ValueKey('add-phone-show-code')));
+ await tester.tap(find.byKey(const ValueKey('add-phone-show-downloads')));
await tester.pump();
expect(find.byType(PhonePairQr), findsNothing);
final armed = daemon.codes.length;
@@ -544,7 +614,9 @@ void main() {
reason: 'the loop ends after the answer it was waiting for',
);
- await _showCode(tester);
+ await tester.tap(find.byKey(const ValueKey('add-phone-hide-downloads')));
+ await tester.pump();
+ await _codeUp(tester);
expect(signIn.minted, 2);
expect(
Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment)['h'],
@@ -566,7 +638,7 @@ void main() {
daemon.call,
signInCode: _FakeSignIn(available: false).call,
);
- await _showCode(tester);
+ await _codeUp(tester);
final fields = Uri.splitQueryString(Uri.parse(_qrData(tester)).fragment);
expect(fields.keys, ['e', 'm', 'c']);
expect(fields['c'], daemon.codes.single);
@@ -589,10 +661,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);
+ await _codeUp(tester);
- expect(daemon.codes, hasLength(1));
+ expect(daemon.codes, hasLength(1), reason: 'armed with the code up');
final code = daemon.codes.single;
expect(
_qrData(tester),
@@ -603,10 +674,7 @@ void main() {
signIn: 'h1',
).toString(),
);
- expect(
- find.text('On your phone, open Computers and scan this code.'),
- findsOneWidget,
- );
+ expect(find.text('Scan with the Harness app.'), findsOneWidget);
expect(find.byKey(const ValueKey('add-phone-status')), findsNothing);
await tester.pump(const Duration(milliseconds: 1500));
@@ -637,7 +705,7 @@ void main() {
_failed('NO_INTENT'),
]);
await _open(tester, app, daemon.call);
- await _showCode(tester);
+ await _codeUp(tester);
await tester.pump();
final first = daemon.codes.single;
expect(_status(tester), "That code didn't work. Scan the new one above.");
@@ -670,7 +738,7 @@ void main() {
_failed('NO_INTENT'),
]);
await _open(tester, app, daemon.call);
- await _showCode(tester);
+ await _codeUp(tester);
await tester.pump();
expect(_status(tester), 'Too many tries. Wait a minute.');
await tester.pump(const Duration(seconds: 59));
@@ -689,7 +757,7 @@ void main() {
addTearDown(app.dispose);
final daemon = _FakeDaemon([_failed(PhonePairAnswer.unavailable)]);
await _open(tester, app, daemon.call);
- await _showCode(tester);
+ await _codeUp(tester);
await tester.pump();
expect(_status(tester), startsWith('Update Harness on this '));
await tester.pump(const Duration(seconds: 30));
@@ -706,7 +774,7 @@ void main() {
final answer = Completer<PhonePairAnswer>();
final daemon = _FakeDaemon([() => answer.future]);
await _open(tester, app, daemon.call);
- await _showCode(tester);
+ await _codeUp(tester);
expect(daemon.codes, hasLength(1));
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
@@ -721,12 +789,17 @@ void main() {
});
});
- 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;
+ group('App Store · Google Play', () {
+ testWidgets('one code, for either store, in the Harness code\'s place; '
+ 'Back brings it back', (tester) async {
+ final app = _signedInApp();
addTearDown(app.dispose);
- await _open(tester, app, _FakeDaemon([]).call);
+ await _open(
+ tester,
+ app,
+ _FakeDaemon(List.filled(5, _failed('NO_INTENT'))).call,
+ );
+ await _codeUp(tester);
expect(_downloadCodes(tester), isEmpty);
// Named by its stores, not "Get Harness", which in the computer's own
// Harness read as this app's download.
@@ -738,16 +811,15 @@ void main() {
),
findsOneWidget,
);
- // Before this computer has an account too: the app can come first.
await tester.tap(open);
await tester.pump();
- expect(find.text('Get Harness on your phone'), findsOneWidget);
- expect(find.text('Scan with your phone’s Camera.'), findsOneWidget);
// One code: the website's, which sends an iPhone to the App Store and
- // an Android phone to Google Play.
+ // an Android phone to Google Play. One kind of code on screen at a
+ // time: the Harness code goes while it is up.
expect(_downloadCodes(tester), ['https://harness.autonomous.ai/app']);
expect(kPhoneAppUrl, 'https://harness.autonomous.ai/app');
+ expect(find.byType(PhonePairQr), findsNothing);
expect(
find.bySemanticsLabel(
'QR code for Harness on the App Store or Google Play',
@@ -761,18 +833,16 @@ void main() {
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);
+ // Few words: no heading or caption of its own; Close stays.
+ expect(find.text('Get Harness on your phone'), findsNothing);
+ expect(find.text('Scan with the Harness app.'), findsNothing);
+ expect(find.byKey(const ValueKey('add-phone-close')), findsOneWidget);
- // 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();
+ await _codeUp(tester);
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);
+ expect(find.byType(PhonePairQr), findsOneWidget);
// Esc, over the store's code, closes the dialog.
await tester.tap(open);
diff --git a/desktop/test/connection_review_render_test.dart b/desktop/test/connection_review_render_test.dart
index cd9a2a397..cab3206b6 100644
--- a/desktop/test/connection_review_render_test.dart
+++ b/desktop/test/connection_review_render_test.dart
@@ -149,20 +149,18 @@ void main() {
),
);
await tester.pumpAndSettle();
- expect(find.text('Cancel').hitTestable(), findsOneWidget);
- await capture('add-phone');
- // 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();
+ // The code is the dialog: up at once, and whole, at every size.
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'));
+ expect(find.text('Scan with the Harness app.'), findsOneWidget);
+ final close = find.byKey(const ValueKey('add-phone-close'));
+ await tester.ensureVisible(close);
+ await tester.pumpAndSettle();
+ expect(close.hitTestable(), findsOneWidget);
+ await capture('add-phone');
+ await tester.tap(close);
await tester.pumpAndSettle();
}