The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(mobile): add onboarding exits and cut sign-in waits
tonyebec6c1cbf93
diff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dartindex 3b22890f1..98b81ab5f 100644--- a/mobile/lib/phone/agent_home.dart+++ b/mobile/lib/phone/agent_home.dart@@ -299,7 +299,13 @@ class _AgentHomeState extends State<AgentHome> {final notifier = widget.notifier;final machine = notifier.stateOf(machineId);if (machine == null) {- return notifier.machines.isEmpty || notifier.machinesLoading;+ // Not on the list: coming only while the list itself is. ⚠️ An empty list that has ANSWERED+ // is the account's word that the machine is not on it — the record names a computer since+ // removed, or one of another account's (it is never cleared). Read as "not answered yet", it+ // held an account with no computer on "Connecting to your computer…" for the whole+ // [_restoreTimeout] before its set-up page came up.+ return notifier.machinesLoading ||+ (notifier.machines.isEmpty && !notifier.machinesAnswered);}return switch (phoneMachineStatusOf(machine)) {PhoneMachineStatus.needsPassword => false,diff --git a/mobile/lib/phone/link_page.dart b/mobile/lib/phone/link_page.dartindex f55dbce50..a34456071 100644--- a/mobile/lib/phone/link_page.dart+++ b/mobile/lib/phone/link_page.dart@@ -4,6 +4,7 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';import 'phone_shell_scope.dart';+import 'settings_page.dart' show PhoneSettingsButton;import 'tty.dart';import 'tty_controls.dart';import 'welcome/unlock_computer.dart';@@ -119,6 +120,13 @@ class _LinkPageState extends State<LinkPage> {child: TtyBackButton(onPressed: () => Navigator.of(context).maybePop(),),+ )+ else+ // Embedded, this form IS the home screen — the account's one computer, locked — and+ // the person on it may be on the wrong account: Settings, and its Sign out, from here.+ Align(+ alignment: Alignment.centerRight,+ child: PhoneSettingsButton(notifier: widget.notifier),),if (machine != null)Expanded(diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dartindex b3287e702..913a1916c 100644--- a/mobile/lib/phone/machines_tab.dart+++ b/mobile/lib/phone/machines_tab.dart@@ -16,6 +16,7 @@ import 'machine_index.dart';import 'phone_card.dart';import 'phone_navigation.dart';import 'phone_status.dart';+import 'settings_page.dart' show PhoneSettingsButton;/// The machines on the account, grouped by what they need.///@@ -54,18 +55,28 @@ class MachinesTab extends StatelessWidget {onPressed: () => Navigator.of(context).maybePop(),),),- Padding(- padding: EdgeInsets.fromLTRB(- Tty.origin,- large ? 12 : 8,- Tty.origin,- 4,- ),- child: TtyText(- 'Computers',- size: large ? 24 : TtySize.title,- weight: FontWeight.w600,- ),+ Row(+ children: [+ Expanded(+ child: Padding(+ padding: EdgeInsets.fromLTRB(+ Tty.origin,+ large ? 12 : 8,+ Tty.origin,+ 4,+ ),+ child: TtyText(+ 'Computers',+ size: large ? 24 : TtySize.title,+ weight: FontWeight.w600,+ ),+ ),+ ),+ // Large, this is the home screen while no computer is ready — locked, or off —+ // and nothing else on it leads to Settings or Sign out. Pushed (small), it came+ // FROM Settings, and back is the way there.+ if (large) PhoneSettingsButton(notifier: notifier),+ ],),Expanded(child: _Body(notifier: notifier)),],diff --git a/mobile/lib/phone/phone_search_actions.dart b/mobile/lib/phone/phone_search_actions.dartindex 50fb4655d..d541b3fd8 100644--- a/mobile/lib/phone/phone_search_actions.dart+++ b/mobile/lib/phone/phone_search_actions.dart@@ -59,7 +59,7 @@ List<PhoneCommand> phoneSearchCommands(PhoneCommand(id: 'app.help',title: 'Help: how Harness works',- detail: 'Computers, agents, harnesses, swarms and gestures',+ detail: 'Computers, agents, harnesses, tabs and gestures',run: () => openHowItWorks(context),),];diff --git a/mobile/lib/phone/settings_page.dart b/mobile/lib/phone/settings_page.dartindex cec3a87b0..66a3dd59f 100644--- a/mobile/lib/phone/settings_page.dart+++ b/mobile/lib/phone/settings_page.dart@@ -1,6 +1,7 @@import 'dart:async';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:package_info_plus/package_info_plus.dart';@@ -287,32 +288,81 @@ class _Body extends StatelessWidget {icon: LucideIcons.logOut300,label: 'Sign out',destructive: true,- onTap: () => unawaited(_confirmSignOut(context, notifier)),+ onTap: () => unawaited(confirmSignOut(context, notifier)),),],);}+}- /// Asked first, because a sign-out is more than leaving this screen: the phone's key leaves the- /// account's devices ([AppNotifier.logout]), and signing in again makes a new one — which every- /// other device then announces as a new device. One stray tap in the sheet used to be all of it.- Future<void> _confirmSignOut(- BuildContext context,- AppNotifier notifier,- ) async {- final confirmed = await confirmPhoneAction(- context,- // The sheet row's own icon — see [confirmPhoneAction].- icon: LucideIcons.logOut300,- title: 'Sign out?',- detail: notifier.currentUser?.email,- message:- 'Your harnesses keep running on your computers. When you sign in again, '- 'your other devices will see this phone as a new device.',- confirmLabel: 'Sign out',+/// Sign out, asked first — from the account sheet here, and from "Not you? Sign out" on the page a+/// phone waits for its first computer on (`welcome/connect_computer.dart`).+///+/// Asked first, because a sign-out is more than leaving this screen: the phone's key leaves the+/// account's devices ([AppNotifier.logout]), and signing in again makes a new one — which every+/// other device then announces as a new device. One stray tap in the sheet used to be all of it.+Future<void> confirmSignOut(BuildContext context, AppNotifier notifier) async {+ final confirmed = await confirmPhoneAction(+ context,+ // The sheet row's own icon — see [confirmPhoneAction].+ icon: LucideIcons.logOut300,+ title: 'Sign out?',+ detail: notifier.currentUser?.email,+ message:+ 'Your harnesses keep running on your computers. When you sign in again, '+ 'your other devices will see this phone as a new device.',+ confirmLabel: 'Sign out',+ );+ if (!confirmed) return;+ await notifier.logout();+}++/// Settings over the current page — the page Find and a terminal's menu push.+void openPhoneSettings(BuildContext context, AppNotifier notifier) => unawaited(+ Navigator.of(context)+ .push(phoneRoute((_) => SettingsPage(notifier: notifier, large: false))),+);++/// Settings, at the top right of the screens a phone stands on before it can reach any harness:+/// waiting for its first computer, unlocking the only one, the computers list while none is ready,+/// pairing by a scanned code.+///+/// ⚠️ **The only way to Settings from those screens, and so to Sign out.** Find and a terminal's+/// menu are where Settings otherwise opens, and both need a harness: a phone signed in to the wrong+/// account — one with no computer on it — had no way out short of deleting the app.+class PhoneSettingsButton extends StatelessWidget {+ const PhoneSettingsButton({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Semantics(+ button: true,+ label: 'Settings',+ excludeSemantics: true,+ child: GestureDetector(+ key: const ValueKey('phone-settings'),+ behavior: HitTestBehavior.opaque,+ onTap: () {+ HapticFeedback.selectionClick();+ openPhoneSettings(context, notifier);+ },+ // The back chevron's box, mirrored: the same touch target, the glyph on the right gutter.+ child: SizedBox(+ width: 52,+ height: 44,+ child: Padding(+ padding: const EdgeInsets.only(right: Tty.origin - 2),+ child: Align(+ alignment: Alignment.centerRight,+ child: Icon(LucideIcons.settings300, size: 21, color: tty.faint),+ ),+ ),+ ),+ ),);- if (!confirmed) return;- await notifier.logout();}}diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dartindex ae1ab2ada..c17b83730 100644--- a/mobile/lib/phone/welcome/connect_computer.dart+++ b/mobile/lib/phone/welcome/connect_computer.dart@@ -8,6 +8,7 @@ import 'package:flutter/services.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';+import '../settings_page.dart' show PhoneSettingsButton, confirmSignOut;import '../tty.dart';import '../tty_controls.dart';import 'scan_to_connect.dart';@@ -102,7 +103,20 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {/// The code the new computer's Add Phone shows: the phone pairs with it there and then. The/// computer is asked for first — it may have joined the account a moment ago, too recently for/// the list the phone holds.+ ///+ /// ⚠️ **A code is never dropped because this page went.** At home this page is there only while+ /// the account has no computer, so the computer this code is for turning up — in the 5-second+ /// watch while the camera was open, or in the refresh below — takes the page away, and the code+ /// went with it: the person had just scanned, and was shown "Scan its code" again. Gone, the page+ /// hands the code to the home screen instead ([AppNotifier.holdPendingPairing]), which pairs with+ /// it the way it pairs a code scanned at sign-in.Future<void> _scanToPair() async {+ // Read before the camera: once this page is gone, its widget is not to be reached through.+ final notifier = widget.notifier;+ void holdIfGone(String machineId, String pairCode) {+ if (!mounted) notifier.holdPendingPairing(machineId, pairCode);+ }+final code = await scanForCode(context,fallbackLabel: 'Not now',@@ -111,8 +125,14 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {// what setting it up needs anyway.onSignInCode: (code) => unawaited(approveComputerSignIn(context, widget.notifier, code)),);- if (!mounted || code == null) return;+ if (code == null) return;final machineId = code.machineId, pairCode = code.pairCode;+ if (!mounted) {+ if (machineId != null && pairCode != null) {+ holdIfGone(machineId, pairCode);+ }+ return;+ }if (machineId == null || pairCode == null) {_say('That isn’t an Add Phone code. Open Add Phone… on the computer and '@@ -133,7 +153,10 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {// ⚠️ A list that could not be read says nothing about whether the computer is on the// account, so it is not "isn't on your account" — and thrown on from here, it left// "Pairing…" up for good.- if (!mounted) return;+ if (!mounted) {+ holdIfGone(machineId, pairCode);+ return;+ }_say("Couldn't reach your account. Check your connection and scan again.",failed: true,@@ -141,7 +164,12 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {return;}}- if (!mounted) return;+ // The refresh is what most often brings the computer in — and with it, at home, the page that+ // replaces this one.+ if (!mounted) {+ holdIfGone(machineId, pairCode);+ return;+ }if (!widget.notifier.machineStates.containsKey(machineId)) {_say("That computer isn't on your account. Sign in to Harness on it "@@ -177,13 +205,39 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {onBack: widget.onBack,onScan: () => unawaited(_scanToPair()),loadDownloads: widget.loadDownloads,- // The computer has to join this account, so the steps name it.- account: widget.signedIn ? email : null,+ // The computer has to join this account, so the steps name it — from Computers too+ // ("Set up another computer", which does not watch), where a second computer signed in+ // to another account is likeliest.+ account: email,+ // At home there is no back, and this page is where a phone signed in to an account with+ // no computer stays: Settings — and Sign out — has to be reachable from it.+ topTrailing: widget.onBack == null+ ? PhoneSettingsButton(notifier: widget.notifier)+ : null,status: widget.signedIn || scanned != null? Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [if (widget.signedIn) _Watching(account: email),+ // Right under the account it names: the wrong one is the likeliest reason this+ // page never moves on — Continue with Google, and another of the person's+ // Google accounts.+ if (widget.signedIn && email != null)+ Align(+ alignment: Alignment.centerLeft,+ child: Transform.translate(+ // The button's own inset, so its words sit on the gutter.+ offset: const Offset(-12, 0),+ child: TtyTextButton(+ key: const ValueKey('connect-sign-out'),+ label: 'Not you? Sign out',+ color: tty.faint,+ onPressed: () => unawaited(+ confirmSignOut(context, widget.notifier),+ ),+ ),+ ),+ ),if (scanned != null)Padding(padding: const EdgeInsets.only(top: 10),diff --git a/mobile/lib/phone/welcome/pairing_with_code.dart b/mobile/lib/phone/welcome/pairing_with_code.dartindex 43b513a94..23621d49a 100644--- a/mobile/lib/phone/welcome/pairing_with_code.dart+++ b/mobile/lib/phone/welcome/pairing_with_code.dart@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';+import '../settings_page.dart' show PhoneSettingsButton;import '../tty.dart';import '../tty_controls.dart';import 'scan_to_connect.dart';@@ -114,66 +115,74 @@ class _PairingWithCodeState extends State<PairingWithCode> {return Scaffold(backgroundColor: tty.ground,body: SafeArea(- child: Padding(- padding: const EdgeInsets.fromLTRB(Tty.origin, 48, Tty.origin, 24),- // Scrolls when it does not fit — a long computer name at a large text size is more lines- // than a small phone has, and the button was pushed off the foot of an overflowing column.- child: LayoutBuilder(- builder: (context, box) => SingleChildScrollView(- child: ConstrainedBox(- constraints: BoxConstraints(minHeight: box.maxHeight),- child: IntrinsicHeight(- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Text(- error == null- ? 'Connecting to\n$name…'- : 'Couldn’t connect',- style: tty- .style(- size: TtySize.display,- weight: FontWeight.w600,- )- .copyWith(height: 34 / 28, letterSpacing: -0.6),- ),- const SizedBox(height: 12),- // A Text that wraps, not a one-line TtyText: the error here is a sentence, and- // cut at the screen's edge it lost the half that says what to do. Named for the- // computer, not "your Mac" — Add Phone is on Linux too.- Text(- error ?? 'Keep “Add Phone” open on $name.',- style: tty.style(- size: TtySize.row,- color: error == null ? tty.faint : tty.red,- ),- ),- const Spacer(),- if (error != null) ...[- TtyPrimaryButton(- key: const ValueKey('pairing-scan-again'),- label: 'Scan again',- onPressed: _scanning- ? null- : () => unawaited(_scanAgain(name)),- ),- const SizedBox(height: 4),- Center(- child: TtyTextButton(- label: 'Use its password instead',- color: tty.faint,- onPressed: _scanning ? null : _usePassword,- ),- ),- ],- ],+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ // This page is the home screen while it is up: Settings, and Sign out, from here too.+ // Its row stands where the title's top margin was, so the title has not moved.+ Align(+ alignment: Alignment.centerRight,+ child: PhoneSettingsButton(notifier: widget.notifier),+ ),+ Expanded(child: _body(tty, name, error)),+ ],+ ),+ ),+ );+ }++ Widget _body(Tty tty, String name, String? error) => Padding(+ padding: const EdgeInsets.fromLTRB(Tty.origin, 4, Tty.origin, 24),+ // Scrolls when it does not fit — a long computer name at a large text size is more lines+ // than a small phone has, and the button was pushed off the foot of an overflowing column.+ child: LayoutBuilder(+ builder: (context, box) => SingleChildScrollView(+ child: ConstrainedBox(+ constraints: BoxConstraints(minHeight: box.maxHeight),+ child: IntrinsicHeight(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Text(+ error == null ? 'Connecting to\n$name…' : 'Couldn’t connect',+ style: tty+ .style(size: TtySize.display, weight: FontWeight.w600)+ .copyWith(height: 34 / 28, letterSpacing: -0.6),+ ),+ const SizedBox(height: 12),+ // A Text that wraps, not a one-line TtyText: the error here is a sentence, and+ // cut at the screen's edge it lost the half that says what to do. Named for the+ // computer, not "your Mac" — Add Phone is on Linux too.+ Text(+ error ?? 'Keep “Add Phone” open on $name.',+ style: tty.style(+ size: TtySize.row,+ color: error == null ? tty.faint : tty.red,),),- ),+ const Spacer(),+ if (error != null) ...[+ TtyPrimaryButton(+ key: const ValueKey('pairing-scan-again'),+ label: 'Scan again',+ onPressed: _scanning+ ? null+ : () => unawaited(_scanAgain(name)),+ ),+ const SizedBox(height: 4),+ Center(+ child: TtyTextButton(+ label: 'Use its password instead',+ color: tty.faint,+ onPressed: _scanning ? null : _usePassword,+ ),+ ),+ ],+ ],),),),),- );- }+ ),+ );}diff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dartindex 9fe0f81eb..c8baa9ecb 100644--- a/mobile/lib/phone/welcome/phone_welcome.dart+++ b/mobile/lib/phone/welcome/phone_welcome.dart@@ -104,12 +104,18 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {/// ([_emailCodeFromScan]): the step says why an email is in the way. Kept on the code step only.bool _codeFromScan = false;+ /// Where the camera was opened from — the first screen's "Yes", or "Scan to connect ›" on the+ /// set-up page — and so where back from it goes ([_backFrom]). Back from the camera always went+ /// to the first screen, and somebody who had stepped over from set-up — the steps they were+ /// following on it — had to find their way back to them.+ _Step _scanFrom = _Step.hello;+/// Under the scan page's hint. A desktop app opens signed out (its guest mode), and its Add Phone/// then shows no code, only "Sign in to add your phone." beside a Sign in… button. Google or/// Apple by name: the sign-in's third way, "Scan with your phone", needs a phone already signed/// in. Two lines at most — it shares the page with the camera.static const _signInThereFirst =- 'Asks you to sign in? Sign in on the computer with Google or Apple first.';+ 'Computer asks you to sign in? Sign in there with Google or Apple first.';String? _error;int _resendIn = 0;@@ -210,6 +216,12 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {if (step == _Step.hello || step == _Step.setUp || step == _Step.scan) {widget.notifier.pendingComputerSignIn = null;}+ // Only a step that opens the camera says where it was opened from: back from the computer's+ // own sign-in step ([_SignInFirst]) returns to the camera, which still goes back where it was+ // first opened from.+ if (step == _Step.scan && (_step == _Step.hello || _step == _Step.setUp)) {+ _scanFrom = _step;+ }setState(() {_step = step;_error = error;@@ -292,6 +304,7 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {_Step.code => _Step.email,_Step.email when _forComputer => _Step.signInFirst,_Step.signInFirst => _Step.scan,+ _Step.scan => _scanFrom,_ => _Step.hello,};@@ -360,7 +373,7 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {note: _signInThereFirst,signingIn: _signingInWithScan,onUseEmail: () => _go(_Step.email),- onBack: () => _go(_Step.hello),+ onBack: () => _go(_backFrom(_Step.scan)),),_Step.signInFirst => _SignInFirst(onBack: () => _go(_backFrom(_Step.signInFirst)),@@ -379,8 +392,10 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {// The computer is not signed in yet: the account is chosen here, for both.? 'The account to sign this phone and your computer in with. We’ll send you a ''4-digit code.'- : 'The one Harness on your computer is signed in with. We’ll send you a '- '4-digit code.',+ // Not "the one Harness on your computer is signed in with": a desktop app+ // opens signed out, and this step is where its person may be choosing it.+ : 'The account to use on this phone and on your computer. We’ll send you '+ 'a 4-digit code.',],field: TtyField(key: const Key('welcome-email'),diff --git a/mobile/lib/phone/welcome/set_up_computer.dart b/mobile/lib/phone/welcome/set_up_computer.dartindex 651cbc4d0..ec2f25007 100644--- a/mobile/lib/phone/welcome/set_up_computer.dart+++ b/mobile/lib/phone/welcome/set_up_computer.dart@@ -131,8 +131,13 @@ class SetUpComputerPage extends StatefulWidget {this.trailing = const [],this.loadDownloads,this.account,+ this.topTrailing,});+ /// At the right of the top row, across from `‹ Back` — on the home screen, where there is no back,+ /// the way to Settings (`PhoneSettingsButton`).+ final Widget? topTrailing;+/// The account this phone is signed in to, when it is: the computer has to sign in to the same/// one, and the steps say so by name. Null for a phone not signed in yet — its scan signs it in/// to whichever account the computer chose.@@ -223,13 +228,19 @@ class _SetUpComputerPageState extends State<SetUpComputerPage> {return Column(crossAxisAlignment: CrossAxisAlignment.stretch,children: [- if (widget.onBack case final onBack?)- Align(- alignment: Alignment.centerLeft,- child: TtyBackButton(onPressed: onBack),- )- else- const SizedBox(height: 44),+ // One row whatever is in it: the back button's height, so the page starts at the same place+ // with a back, a trailing control, both, or neither.+ SizedBox(+ height: 44,+ child: Row(+ children: [+ if (widget.onBack case final onBack?)+ TtyBackButton(onPressed: onBack),+ const Spacer(),+ ?widget.topTrailing,+ ],+ ),+ ),Expanded(child: ListView(padding: const EdgeInsets.fromLTRB(Tty.origin, 8, Tty.origin, 24),diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 5379cb8d9..e963a103b 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -2014,6 +2014,20 @@ class AppNotifier extends ChangeNotifier {/// dropped with the page that started it. Keyed to the sign-in, so the next one starts over.int? _machinesFetchedFor;+ /// The sign-in whose machine list has come back from the account — unlike [_machinesFetchedFor],+ /// not set by a fetch that failed.+ int? _machinesAnsweredFor;++ /// Whether this sign-in's machine list has come back at least once, empty or not: from then on a+ /// machine missing from [machines] is one the account does not have, not one still on its way.+ ///+ /// ⚠️ An empty [machines] cannot say this alone — it is also what a list not asked for yet looks+ /// like. The home screen read "empty" as "not answered" and held the agent of a previous run (a+ /// record never cleared, `core/last_opened_agent.dart`) as still coming: an account with no+ /// computer — a first sign-in on a phone used before, another account's agent remembered — sat+ /// on "Connecting to your computer…" for the whole 30-second restore wait (`AgentHome`).+ bool get machinesAnswered => _machinesAnsweredFor == _authRevision;+Future<void> refreshMachines() async {final revision = _authRevision;if (!_authWorkCurrent(revision)) return;@@ -2025,6 +2039,12 @@ class AppNotifier extends ChangeNotifier {}try {await _refreshMachines(revision);+ if (_authWorkCurrent(revision) && _machinesAnsweredFor != revision) {+ _machinesAnsweredFor = revision;+ // The list's own notify came before this was set. The first fetch notifies again below+ // (dropping [machinesLoading]); one that answers only after an earlier failure does not.+ if (!machinesLoading) notifyListeners();+ }} finally {if (_authWorkCurrent(revision)) _machinesFetchedFor = revision;// Said out loud: the list's own notify fires before this, so a flag@@ -2611,18 +2631,32 @@ class AppNotifier extends ChangeNotifier {/// screen fell through to the machines list, "locked · scan its code", in between. While this is/// set it waits on a locked machine instead (`phone/agent_home.dart` `_loadingMessage`); once it/// clears, a machine still locked really wants its password.+ ///+ /// ⚠️ **Only the first [_vouchedRedialsHeld] redials count, not all of them.** Every step of+ /// [_vouchedRedialDelays] used to: a machine that never read this phone's key held a fresh sign-in+ /// on "Connecting to your computer…" for the whole schedule — 36s, measured — before its "scan its+ /// code" came up, the one thing that could let the phone in.bool get deviceTrustSettling =>- _registeringDevice || _awaitingVouched.isNotEmpty;+ _registeringDevice ||+ _awaitingVouched.any(+ (id) => (_vouchedRedials[id] ?? 0) <= _vouchedRedialsHeld,+ );bool _registeringDevice = false;/// When this phone's key last went into the log, in this sign-in — see [_vouchedRedialWindow].DateTime? _deviceRegisteredAt;- /// Machines waiting out a [_vouchedRedialDelays] step, and how many each has been through.+ /// Machines waiting out a [_vouchedRedialDelays] step, and how many each has been through (the+ /// step under way included).final Set<String> _awaitingVouched = {};final Map<String, int> _vouchedRedials = {};+ /// How many of [_vouchedRedialDelays] hold the screen ([deviceTrustSettling]): a machine that+ /// reads the log when it hears `device_keys_changed` has read this phone's key by then. The rest+ /// are dialled behind the machine shown locked, and one that lets the phone in opens it by itself.+ static const _vouchedRedialsHeld = 2;+/// [_deviceTrustSettleCap]: a log that never answers still lets the screen move on.static const _deviceTrustSettleCap = Duration(seconds: 20);@@ -2667,10 +2701,14 @@ class AppNotifier extends ChangeNotifier {/// phone's key went in — so the machine, still behind, answered `e2e_denied` to a dial nobody/// retried, and a fresh sign-in sat on "locked" over a machine that would have let it in seconds/// later. Outside [_vouchedRedialWindow] a refusal stands: that is trust revoked, not trust late.+ ///+ /// Past [_vouchedRedialsHeld] the machine stays locked through the redial: on screen it is the+ /// machine to pair by its code, and a dial that gets in unlocks it ([_onConnectionStatus]).Future<void> _redialOnceVouched(String machineId) async {final revision = _authRevision;final attempt = _vouchedRedials[machineId] ?? 0;if (attempt >= _vouchedRedialDelays.length) return;+ final held = attempt < _vouchedRedialsHeld;final registeredAt = _deviceRegisteredAt;final keyIsNew =_registeringDevice ||@@ -2689,11 +2727,14 @@ class AppNotifier extends ChangeNotifier {if (!_authWorkCurrent(revision)) return;_awaitingVouched.remove(machineId);final state = machineStates[machineId];+ // Still locked: a password or a code that linked it meanwhile already redialled it.if (state != null && state.needsLink && state.nodeOnline != false) {- // Unlocked before the socket goes, as [_redialNewlyTrusted] does: the screen reads it as- // connecting from here on, never as locked in between.- state.needsLink = false;- state.agentLoadStatus = AgentLoadStatus.idle;+ if (held) {+ // Unlocked before the socket goes, as [_redialNewlyTrusted] does: the screen reads it as+ // connecting from here on, never as locked in between.+ state.needsLink = false;+ state.agentLoadStatus = AgentLoadStatus.idle;+ }await _pool?.closeMachine(machineId);_connectMachine(state);}@@ -2893,6 +2934,25 @@ class AppNotifier extends ChangeNotifier {notifyListeners();}+ /// A code scanned, signed in, for [machineId] by a page that was gone by the time it could pair+ /// with it — "Waiting for your computer…", taken away under the camera by the very computer it+ /// was waiting for (`phone/welcome/connect_computer.dart`). Held like a code scanned at sign-in:+ /// the home screen pairs with it once that computer is there and locked ([pendingPairing]).+ ///+ /// Not for a computer already open: nothing is left to pair, and a code kept would be spent the+ /// next time it locks, in place of its password form (see where [pendingPairing] is cleared on+ /// connect). Not once signed out either: the page then went because the account did, and its+ /// code is for a computer on that account — a sign-out clears [pendingPairing] for the same reason.+ void holdPendingPairing(String machineId, String code) {+ if (status != AppStatus.authenticated) return;+ if (machineStates[machineId]?.connectionStatus ==+ ConnectionStatus.connected) {+ return;+ }+ pendingPairing = (machineId: machineId, code: code);+ notifyListeners();+ }+/// Pairs with [machineId] by the one-time code its desktop app showed, then reconnects it — the/// QR's way in, where [connectWithPassword] is the password's. Null on success, or what to show.Future<String?> connectWithCode(String machineId, String code) async {