The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat(mobile): new phone onboarding flow
tony32f0dc05c3c4
diff --git a/mobile/android/app/src/main/kotlin/ai/autonomous/harness/android/MainActivity.kt b/mobile/android/app/src/main/kotlin/ai/autonomous/harness/android/MainActivity.ktindex ed52f6409..43c4b74b7 100644--- a/mobile/android/app/src/main/kotlin/ai/autonomous/harness/android/MainActivity.kt+++ b/mobile/android/app/src/main/kotlin/ai/autonomous/harness/android/MainActivity.kt@@ -7,12 +7,16 @@ import android.content.Contextimport android.content.Intentimport android.graphics.Bitmapimport android.graphics.BitmapFactory+import android.media.AudioAttributes+import android.media.AudioManager+import android.media.MediaPlayerimport android.net.Uriimport android.os.Buildimport android.os.Handlerimport android.os.Looperimport android.provider.Settingsimport java.io.ByteArrayOutputStream+import io.flutter.FlutterInjectorimport io.flutter.embedding.android.FlutterActivityimport io.flutter.embedding.engine.FlutterEngineimport io.flutter.plugin.common.MethodChannel@@ -98,6 +102,44 @@ class MainActivity : FlutterActivity() {else -> result.notImplemented()}}++ // `harness/chime` — a short sound the app plays of its own (Dart: `lib/core/chime.dart`): the+ // two glass notes when a computer joins during the onboarding. `play` takes the Flutter asset's+ // name and answers whether it played.+ MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "harness/chime")+ .setMethodCallHandler { call, result ->+ if (call.method != "play") { result.notImplemented(); return@setMethodCallHandler }+ val asset = call.arguments as? String+ result.success(asset != null && playChime(asset))+ }+ }++ /** Plays the Flutter asset [asset] once, as a sonification — the system's own sounds' stream —+ * and only while the ringer is on: muted means silent, and the haptic Dart plays beside it is+ * felt either way. False when it did not play. The player lets itself go when it finishes. */+ private fun playChime(asset: String): Boolean {+ val audio = getSystemService(Context.AUDIO_SERVICE) as? AudioManager ?: return false+ if (audio.ringerMode != AudioManager.RINGER_MODE_NORMAL) return false+ val key = FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(asset)+ val player = MediaPlayer()+ return try {+ player.setAudioAttributes(+ AudioAttributes.Builder()+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)+ .build()+ )+ // A WAV is stored uncompressed in the APK, so it opens as a descriptor into it.+ assets.openFd(key).use { fd -> player.setDataSource(fd.fileDescriptor, fd.startOffset, fd.length) }+ player.setOnCompletionListener { it.release() }+ player.setOnErrorListener { failed, _, _ -> failed.release(); true }+ player.prepare()+ player.start()+ true+ } catch (e: Exception) {+ player.release()+ false+ }}/** Whether the clipboard holds an image, from its description alone — the clip is never opened. */diff --git a/mobile/assets/sound/joined.wav b/mobile/assets/sound/joined.wavnew file mode 100644index 000000000..43eee93b0Binary files /dev/null and b/mobile/assets/sound/joined.wav differdiff --git a/mobile/integration_test/first_run_journey_test.dart b/mobile/integration_test/first_run_journey_test.dartindex b82a73f15..0c93c2cac 100644--- a/mobile/integration_test/first_run_journey_test.dart+++ b/mobile/integration_test/first_run_journey_test.dart@@ -3,13 +3,15 @@ import 'package:flutter_test/flutter_test.dart';import 'package:integration_test/integration_test.dart';import 'package:harness_mobile/main.dart' as app;+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';/// A first-time user's walk through the real app on a fresh simulator, a screenshot at each-/// step: the welcome, Get it and its sample (hints, answering a question, Find, New with a task,-/// the menu), leaving it, and the way in — Connect computer, then the other ways and email.+/// step: ① Welcome — the promise, Google, Apple, and the emailed code under them — then the email,+/// and back (`docs/research/2026-10-11-phone-onboarding`).///-/// Signed out on a clean install, so nothing here can reach a real account or a real machine: the-/// sample is offline by construction (`lib/demo/`).+/// Signed out on a clean install, and nothing here signs in: no account page is opened and no code+/// is sent, so nothing can reach a real account or a real machine. The sample, which this walk used+/// to take from Get it, is Settings' since the onboarding of 2026-10-12 — a signed-in phone's.////// flutter drive -d <simulator> --driver=test_driver/journey_driver.dart \/// --target=integration_test/first_run_journey_test.dart@@ -41,87 +43,22 @@ void main() {}await app.main();- await waitFor(find.text('Your agents\nin your pocket.'));- await shot('welcome');-- // The sample, from Get it: no account, no computer.- await tester.tap(find.byKey(const ValueKey('set-up-get-it')));- await wait(800);- await shot('get-it');- await tester.tap(find.byKey(const ValueKey('get-it-sample')));- await wait(2000);- // "Pick up where you left off": the sessions, a tap from their terminals.- await shot('sample-pick-up');- await tester.tap(find.text('fix-login', findRichText: true).first);+ await waitFor(find.text(OnboardingCopy.welcome));+ // The picture's agents typing, its packets running to the phone.await wait(1500);- await shot('sample-first-time-hints');- // The hints go on the first touch, which also does what it touched.- await tester.tapAt(const Offset(200, 300));- await wait(2500);- await shot('sample-focus-working');+ await shot('welcome');- // Find: swipe right.- await tester.dragFrom(const Offset(40, 400), const Offset(300, 0));+ // The quiet line under the accounts: the emailed code.+ await tester.tap(find.byKey(const ValueKey('welcome-email-way')));await wait(800);- await shot('sample-find');-- // The harness that is asking.- final asking = find.text('refactor-db');- if (asking.evaluate().isNotEmpty) {- await tester.tap(asking.first);- await wait(2000);- await shot('sample-asking');- final yes = find.textContaining('1 yes');- if (yes.evaluate().isNotEmpty) {- await tester.tap(yes.first);- await wait(3000);- await shot('sample-answered');- }- }-- // New: swipe left.- await tester.dragFrom(const Offset(350, 400), const Offset(-300, 0));- await wait(1000);- await shot('sample-new');- await tester.enterText(- find.byType(TextField).last,- 'Add a dark mode toggle',- );+ await shot('sign-in-email');+ await tester.enterText(find.byType(TextField).last, '[email protected]');await wait(300);- await shot('sample-new-task');- await tester.tap(find.text('Start'));- await wait(4000);- await shot('sample-new-harness-working');+ await shot('sign-in-email-typed');- // The menu: a tap on the title; a tap anywhere else puts it away.- await tester.tap(find.byKey(const ValueKey('terminal-title')).first);- await wait(800);- await shot('sample-menu');- await tester.tapAt(const Offset(200, 120));- await wait(600);-- // The end card, once the new harness has run a while — and the way to the real thing.- await waitFor(find.text('Set up my computer'), seconds: 20);- await wait(400);- await shot('sample-end-card');- await tester.tap(find.text('Set up my computer'));- await wait(1500);- // Back on Get it, where the sample was opened.- await shot('get-it-after-sample');+ // Back is the welcome, as it was.await tester.tap(find.bySemanticsLabel('Back'));await wait(800);await shot('back-to-welcome');-- // The way in: Connect computer scans the code the desktop app shows; without one, the camera's- // "Can’t scan?" has the accounts and email.- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await wait(1500);- await shot('scan-to-connect');- await tester.tap(find.text('Can’t scan? Sign in another way'));- await wait(800);- await shot('sign-in-other-ways');- await tester.tap(find.text('Continue with email'));- await wait(800);- await shot('sign-in-email');});}diff --git a/mobile/ios/Runner/AppDelegate.swift b/mobile/ios/Runner/AppDelegate.swiftindex 95a5cb67c..27dd9d4cc 100644--- a/mobile/ios/Runner/AppDelegate.swift+++ b/mobile/ios/Runner/AppDelegate.swift@@ -1,3 +1,4 @@+import AudioToolboximport AuthenticationServicesimport Flutterimport UIKit@@ -20,6 +21,82 @@ import UserNotificationsDeviceNameChannel.register(with: engineBridge.pluginRegistry)ClipboardImageChannel.register(with: engineBridge.pluginRegistry)SignInPageChannel.register(with: engineBridge.pluginRegistry)+ HandoffChannel.register(with: engineBridge.pluginRegistry)+ ChimeChannel.register(with: engineBridge.pluginRegistry)+ }+}++/// `harness/chime` — a short sound the app plays of its own (Dart: `lib/core/chime.dart`): the two+/// glass notes when a computer joins during the onboarding.+///+/// Through System Sound Services, not an audio player: a system sound is silenced by the Ring/Silent+/// switch — muted means silent, as the onboarding asks — and plays without touching the audio+/// session, which belongs to the voice input's recorder. `play` takes the Flutter asset's name, and+/// answers whether it played; each sound is loaded once and kept.+enum ChimeChannel {+ private static var sounds: [String: SystemSoundID] = [:]++ static func register(with registry: FlutterPluginRegistry) {+ guard let registrar = registry.registrar(forPlugin: "HarnessChime") else { return }+ let channel = FlutterMethodChannel(name: "harness/chime", binaryMessenger: registrar.messenger())+ channel.setMethodCallHandler { call, result in+ guard call.method == "play" else { result(FlutterMethodNotImplemented); return }+ guard let asset = call.arguments as? String else { result(false); return }+ if let sound = ChimeChannel.sounds[asset] {+ AudioServicesPlaySystemSound(sound)+ result(true)+ return+ }+ let key = registrar.lookupKey(forAsset: asset)+ guard let path = Bundle.main.path(forResource: key, ofType: nil) else { result(false); return }+ var sound: SystemSoundID = 0+ guard AudioServicesCreateSystemSoundID(URL(fileURLWithPath: path) as CFURL, &sound) == kAudioServicesNoError+ else { result(false); return }+ ChimeChannel.sounds[asset] = sound+ AudioServicesPlaySystemSound(sound)+ result(true)+ }+ }+}++/// `harness/handoff` — a web page offered to the person's other Apple devices (Dart:+/// `lib/core/handoff.dart`). While the onboarding's "On your computer, go to" is up, a Mac nearby+/// signed in to the same Apple account shows the download page in its Dock.+///+/// `offer` takes the page's https address and makes it the current activity; `withdraw` ends it.+/// The activity is held here, since nothing else keeps it alive, and replaced by each `offer` —+/// Dart offers again whenever the app comes back to the front, where iOS has stopped advertising.+enum HandoffChannel {+ private static var activity: NSUserActivity?++ static func register(with registry: FlutterPluginRegistry) {+ guard let messenger = registry.registrar(forPlugin: "HarnessHandoff")?.messenger() else { return }+ let channel = FlutterMethodChannel(name: "harness/handoff", binaryMessenger: messenger)+ channel.setMethodCallHandler { call, result in+ switch call.method {+ case "offer":+ // Only a web page: Handoff opens it in the other device's browser, and that takes https.+ guard let text = call.arguments as? String, let url = URL(string: text),+ url.scheme == "https"+ else {+ result(FlutterError(code: "bad-url", message: "Not an https address", details: nil))+ return+ }+ HandoffChannel.activity?.invalidate()+ let offered = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)+ offered.webpageURL = url+ offered.isEligibleForHandoff = true+ offered.becomeCurrent()+ HandoffChannel.activity = offered+ result(nil)+ case "withdraw":+ HandoffChannel.activity?.invalidate()+ HandoffChannel.activity = nil+ result(nil)+ default:+ result(FlutterMethodNotImplemented)+ }+ }}}diff --git a/mobile/lib/core/chime.dart b/mobile/lib/core/chime.dartnew file mode 100644index 000000000..c9ad35ace--- /dev/null+++ b/mobile/lib/core/chime.dart@@ -0,0 +1,32 @@+import 'dart:async';++import 'package:flutter/foundation.dart' show debugPrint;+import 'package:flutter/services.dart';++/// A short sound the app plays of its own — over `harness/chime` (`ios/Runner/AppDelegate.swift`,+/// `android/…/MainActivity.kt`).+///+/// There is one: [joined], the two soft glass notes when a computer joins during the onboarding —+/// the only sound in setup (`docs/research/2026-10-11-phone-onboarding`).+///+/// ⚠️ **Muted means silent, and the haptics stay.** iOS plays it through System Sound Services,+/// which the Ring/Silent switch silences, and which leaves the audio session — the voice input's+/// recorder's — alone; Android plays it only in the ringer's normal mode. The caller's haptic is+/// felt either way.+abstract final class Chime {+ static const _channel = MethodChannel('harness/chime');++ /// A computer joined: A5 then E6, a fifth apart (`scripts/make_joined_chime.py`).+ static const joined = 'assets/sound/joined.wav';++ /// Plays [asset] once, and does not wait for it. Nothing happens on a runner without the channel.+ static Future<void> play(String asset) async {+ try {+ await _channel.invokeMethod<bool>('play', asset);+ } on MissingPluginException {+ // A test, or a runner from before the chime: the haptic beside it is the whole moment.+ } on PlatformException catch (error) {+ debugPrint('Chime.play($asset): $error');+ }+ }+}diff --git a/mobile/lib/core/handoff.dart b/mobile/lib/core/handoff.dartnew file mode 100644index 000000000..da90ad056--- /dev/null+++ b/mobile/lib/core/handoff.dart@@ -0,0 +1,49 @@+import 'dart:async';+import 'dart:io' show Platform;++import 'package:flutter/foundation.dart' show debugPrint;+import 'package:flutter/services.dart';++/// A web page offered to the person's other Apple devices — Handoff — over `harness/handoff`+/// (`ios/Runner/AppDelegate.swift`).+///+/// While "On your computer, go to" is up, a Mac nearby signed in to the same Apple account shows+/// the download page in its Dock: one click, nothing typed (`docs/research/2026-10-11-phone-+/// onboarding`). iOS only: Android has nothing like it, and there the address is shared or typed.+///+/// ⚠️ **Offered again each time the app comes back to the front.** iOS stops advertising an+/// activity while the app is in the background, and the page that offered it may be up long+/// after — the person away installing Harness.+abstract final class Handoff {+ static const _channel = MethodChannel('harness/handoff');++ /// Whatever is offering the page now. Two screens can offer it at once — home's "On your+ /// computer, go to" and the same step pushed from Computers over it — and the page is withdrawn+ /// only once neither does.+ static final _holders = <Object>{};++ /// Offer [url] — an https page — on behalf of [holder], until it [withdraw]s. Offering again+ /// for the same holder (the app back in front) only offers it again.+ static Future<void> offer(Object holder, Uri url) {+ _holders.add(holder);+ return _call('offer', url.toString());+ }++ /// [holder] no longer offers the page; it is withdrawn once nothing does.+ static Future<void> withdraw(Object holder) {+ if (!_holders.remove(holder) || _holders.isNotEmpty) return Future.value();+ return _call('withdraw');+ }++ static Future<void> _call(String method, [Object? argument]) async {+ if (!Platform.isIOS) return;+ try {+ await _channel.invokeMethod<void>(method, argument);+ } on MissingPluginException {+ // A runner without the channel (an older build, a test): nothing nearby is offered the page,+ // which is all Handoff ever adds.+ } on PlatformException catch (error) {+ debugPrint('Handoff.$method: $error');+ }+ }+}diff --git a/mobile/lib/main.dart b/mobile/lib/main.dartindex 42504e0bd..cb8b771d9 100644--- a/mobile/lib/main.dart+++ b/mobile/lib/main.dart@@ -8,7 +8,6 @@ import 'app_shell.dart';import 'p2p/phone_terminal_p2p.dart';import 'phone/daemon_scope.dart';import 'phone/phone_shell.dart';-import 'demo/sample_mode.dart';import 'phone/welcome/phone_boot.dart';import 'phone/welcome/phone_welcome.dart';@@ -37,8 +36,7 @@ Future<void> main() {// header, fed from the app's own state (`phone/daemon_scope.dart`).authenticatedScreen: (app) =>DaemonHost(notifier: app, child: PhoneShell(notifier: app)),- signedOutScreen: (app) =>- PhoneWelcome(notifier: app, onTrySample: openSampleMode),+ signedOutScreen: (app) => PhoneWelcome(notifier: app),bootScreen: (_) => const PhoneBoot(),transportPlugins: phoneTerminalP2p.create,);diff --git a/mobile/lib/notify/notifications_ask.dart b/mobile/lib/notify/notifications_ask.dartnew file mode 100644index 000000000..aef9728af--- /dev/null+++ b/mobile/lib/notify/notifications_ask.dart@@ -0,0 +1,51 @@+import 'dart:async';+import 'dart:io' show Platform;++import 'package:harness_mobile/core/harness_file_store.dart';+import 'package:harness_mobile/core/local_key_value_store.dart';++/// When the phone asks to notify: once per install, a moment after the first thing it sends to a+/// harness — a Return, a take that went (`phone/terminal_page.dart`).+///+/// ⚠️ **Not during the onboarding, and not with the tips any more** (owner, 2026-10-12). It used to+/// come straight after Focus's first-time tips, before the person had done anything here; now it+/// waits until they have talked to an agent — the moment "a harness asking you something" is worth+/// a notice to them. Asked once and remembered here: iOS would ask only once anyway, but Android+/// asks again each time it is told to, and a phone asking on every launch is nagging.+class NotificationsAsk {+ NotificationsAsk({LocalKeyValueStore? storage})+ : _storage = storage ?? HarnessFileStore.shared;++ static const _key = 'phone_notifications_asked_v1';+ final LocalKeyValueStore _storage;++ /// Shared by every page, so two sends before the first read lands ask once.+ static final shared = NotificationsAsk();++ /// The ask follows the send by this much: the send lands, and is felt, before a system dialog+ /// comes over it.+ static const after = Duration(milliseconds: 1200);++ bool _asked = false;++ /// Something was sent: [ask] — the OS's own prompt — if it has never been asked on this install.+ Future<void> afterSend(Future<void> Function() ask) async {+ if (_asked) return;+ // Settled before any await, so a second send meanwhile does not ask again.+ _asked = true;+ // Under `flutter test` the shared store is the real one in the home directory: never read or+ // write it there.+ if (identical(this, shared) &&+ Platform.environment.containsKey('FLUTTER_TEST')) {+ return;+ }+ try {+ if (await _storage.read(_key) == 'yes') return;+ await _storage.write(_key, 'yes');+ } on Exception {+ // No memory to keep it in: asked this run, and the OS keeps the answer.+ }+ await Future<void>.delayed(after);+ await ask();+ }+}diff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dartindex f3b1b74db..bf2e9c8c6 100644--- a/mobile/lib/phone/agent_home.dart+++ b/mobile/lib/phone/agent_home.dart@@ -3,6 +3,7 @@ import 'dart:async';import 'package:flutter/foundation.dart' show ValueListenable;import 'package:flutter/material.dart';+import 'package:harness_mobile/demo/sample_mode.dart';import 'package:harness_mobile/logging/startup_trace.dart';import 'package:harness_mobile/logging/typing_trace.dart';import 'package:harness_mobile/shared/theme/app_theme.dart';@@ -21,11 +22,13 @@ import 'phone_navigation.dart' show phoneRoute;import 'settings_page.dart' show PhoneSettingsButton;import 'tty_controls.dart';import 'tty.dart';-import 'welcome/connect_computer.dart';+import 'welcome/join_moment.dart';+import 'welcome/onboarding_copy.dart';+import 'welcome/onboarding_frame.dart';+import 'welcome/onboarding_picture.dart';import 'welcome/pairing_with_code.dart';import 'welcome/pick_up_page.dart';--import 'package:harness_mobile/demo/sample_mode.dart';+import 'welcome/your_computer.dart';import 'phone_header.dart';import 'phone_status.dart';@@ -80,7 +83,8 @@ class AgentHome extends StatefulWidget {State<AgentHome> createState() => _AgentHomeState();}-class _AgentHomeState extends State<AgentHome> {+class _AgentHomeState extends State<AgentHome>+ with SingleTickerProviderStateMixin {/// The agent the pager is currently built around, or null while nothing can be opened.////// ⚠️ **Held as state rather than recomputed every build, and it is what keeps the screen still.**@@ -218,6 +222,8 @@ class _AgentHomeState extends State<AgentHome> {_slowTimer?.cancel();_restoreDeadline?.cancel();_terminalWait?.cancel();+ _firstSessionWait?.cancel();+ _moment.dispose();super.dispose();}@@ -247,6 +253,49 @@ class _AgentHomeState extends State<AgentHome> {/// remember, or a computer was just linked; spent the moment a session is picked.bool _welcome = false;+ /// The first session has been put on screen since this phone signed in: the onboarding is over,+ /// and a wait after it is an ordinary one again ([_onboarding]).+ bool _onboardingDone = false;++ /// This phone has nothing of its own to go back to — no session remembered, no tab — read by+ /// [_readLast]: it has never reached a session, whenever it signed in.+ bool _freshPhone = false;++ /// The onboarding is under way: this phone signed in on this run ([AppNotifier.signedInThisRun])+ /// or has never reached a session ([_freshPhone]), and has not reached one yet. Home's waits are+ /// then drawn on the onboarding's picture — eased from the welcome's, so signing in reads as one+ /// screen changing rather than a cut to a spinner — and the computer joining gets its moment+ /// ([_joinStage]) before its session opens by itself.+ ///+ /// ⚠️ **Never in the sample.** Its home is a fresh phone's too — nothing remembered — but it is+ /// not setting a computer up: it opens on its sessions to pick from, and its guide takes it on.+ bool get _onboarding =>+ (widget.notifier.signedInThisRun || _freshPhone) &&+ !_onboardingDone &&+ SampleMode.maybeOf(context) == null;++ /// The computer the onboarding is joining, by its name on the account — the last beat before its+ /// session opens ([_joinStage]). Set once, the first time there is one ([_noticeJoin]).+ ({String machineId, String name})? _joining;++ /// "On your computer, go to" has been on screen: the next computer on the account is the one the+ /// person just set up for this phone, not one the account already had.+ bool _awaitedComputer = false;++ /// The computer joining, before its session opens ([_joinStage]).+ late final JoinMoment _moment = JoinMoment(+ vsync: this,+ onDone: () {+ if (mounted) setState(() {});+ },+ );++ /// How long "… is ready." waits for the computer's first session before it gives way to the+ /// empty state — the desktop's own tour may still be fetching the agents it starts one with.+ static const _firstSessionPatience = Duration(seconds: 90);+ Timer? _firstSessionWait;+ bool _firstSessionGaveUp = false;+void _onAgentRequested() {final requested = widget.openAgent?.value;// Null is the shell resetting before it writes, not a request.@@ -305,6 +354,7 @@ class _AgentHomeState extends State<AgentHome> {_neighboursFor == null &&_requestedAgent == null) {_welcome = true;+ _freshPhone = true;}});_restoreDeadline = Timer(_restoreTimeout, () {@@ -450,6 +500,18 @@ class _AgentHomeState extends State<AgentHome> {final picked = _entryFor(entries, requested);if (picked != null) return picked;}+ // The onboarding's computer, joined: the session used on it last — the one in focus there,+ // which the desktop marks opened as its pane takes focus — and failing that the account's. The+ // phone has no say of its own in which (owner, 2026-10-12): the computer decides.+ final joining = _joining;+ if (joining != null && _onboarding) {+ final pick =+ _lastUsed(+ entries.where((entry) => entry.machineId == joining.machineId),+ ) ??+ _lastUsed(entries);+ if (pick != null) return pick;+ }// A machine just unlocked outranks what is on screen — see [AgentHome.openMachineId]. Until it// has an agent to offer, everything below carries on as usual, so the screen keeps showing// something real while the machine dials rather than blanking to a skeleton.@@ -558,6 +620,30 @@ class _AgentHomeState extends State<AgentHome> {return best;}+ /// The openable agent used last — the later of its conversation moving and an app opening it+ /// ([Agent.lastUsedAt]) — for the onboarding's first session only. Everywhere else the phone+ /// follows the conversation alone ([compareMonitorOrder], owner's call): this one follows the+ /// desktop, whose focused pane is stamped opened, so the phone opens what the computer is on.+ static AgentEntry? _lastUsed(Iterable<AgentEntry> entries) {+ AgentEntry? best;+ for (final entry in entries) {+ if (!entry.agent.terminalAvailable) continue;+ if (best == null) {+ best = entry;+ continue;+ }+ final used = entry.agent.lastUsedAt, bestUsed = best.agent.lastUsedAt;+ final later = switch ((used, bestUsed)) {+ (final a?, final b?) => a.isAfter(b),+ (_?, null) => true,+ (null, _?) => false,+ (null, null) => compareMonitorOrder(entry, best) < 0,+ };+ if (later) best = entry;+ }+ return best;+ }+/// Whether any machine can currently host an agent.////// The gate between the two empty screens, and the same test every `+` in the app applies: an@@ -774,6 +860,7 @@ class _AgentHomeState extends State<AgentHome> {);}}+ _noticeJoin();final entries = visibleAgents(agentIndex(widget.notifier));_openNewAgentIfUnlockedMachineIsEmpty(entries);_dropPagerIfShownAgentWasDeleted(entries);@@ -785,6 +872,10 @@ class _AgentHomeState extends State<AgentHome> {final target = (_readingLast && !_gaveUpWaiting)? null: _target(entries);+ if (_holdForJoin(target)) {+ _endLaunchWait();+ return _joinStage(target);+ }if (target == null) {// ⚠️ Still on its way in and actually empty are two different screens, and the difference// matters more here than it did on a list. A list could show its own shape greyed out while@@ -796,6 +887,7 @@ class _AgentHomeState extends State<AgentHome> {_traceLoading(loading);if (loading != null) {_holdLaunchWait();+ if (_onboarding) return _onboardingWait(loading);return _AgentHomeLoading(message: loading,notifier: widget.notifier,@@ -826,10 +918,7 @@ class _AgentHomeState extends State<AgentHome> {if (_machinesUnreadable) {return MachinesTab(notifier: widget.notifier);}- return ConnectComputerPage(- notifier: widget.notifier,- onTrySample: openSampleMode,- );+ return _goToYourComputer();}// The one computer there is, awake and waiting for its phone password: the unlock// itself, not a list of one to tap through — the moment setup pays off.@@ -853,11 +942,27 @@ class _AgentHomeState extends State<AgentHome> {return _AgentHomeEmpty(notifier: widget.notifier);}_endLaunchWait();- // Nothing remembered, nothing picked: the sessions, each a tap from its terminal.- if (_welcome && _neighboursFor == null && _requestedAgent == null) {+ // The onboarding handing over to the session it was waiting for: it grows in, once.+ final handOver = _onboarding && _joining != null;+ // Nothing remembered, nothing picked: the sessions, each a tap from its terminal — but not at+ // the end of the onboarding, which opens the computer's own session ([_target]).+ if (!handOver &&+ _welcome &&+ _neighboursFor == null &&+ _requestedAgent == null) {+ _onboardingDone = true;return PickUpPage(notifier: widget.notifier);}+ _onboardingDone = true;final chosen = (machineId: target.machineId, agentId: target.agent.id);+ // Its one line by the mic, for the session's page to say until the first send.+ if (handOver) {+ widget.notifier.firstSessionLine = (+ machineId: chosen.machineId,+ agentId: chosen.agentId,+ text: _firstLine(target),+ );+ }// ⚠️ **A swipe stays inside one tab, and this is where that happens.** The// account's tabs are the desk's (`state/phone_desk.dart`); [deskGroups]// fills each one with the agents of it this phone can reach, and the tab@@ -936,29 +1041,227 @@ class _AgentHomeState extends State<AgentHome> {//// So the key changes only when [_target] picks a DIFFERENT agent than the pager was built for,// which happens when the one it opened on can no longer be opened at all.- return AgentSwipeHost(- // The generation is what lets a pager be REBUILT around the same opening agent — see- // [_dropPagerIfShownAgentWasDeleted]; the agent alone would hand Flutter the same key.- key: ValueKey(- '${opened.machineId}/${opened.agentId}#$_pagerGeneration',+ // Always under [_GrowIn], growing or not: the pager's place in the tree stays the same, so a+ // pager already up is never rebuilt for it.+ return _GrowIn(+ grow: handOver,+ child: AgentSwipeHost(+ // The generation is what lets a pager be REBUILT around the same opening agent — see+ // [_dropPagerIfShownAgentWasDeleted]; the agent alone would hand Flutter the same key.+ key: ValueKey(+ '${opened.machineId}/${opened.agentId}#$_pagerGeneration',+ ),+ notifier: widget.notifier,+ machineId: opened.machineId,+ agentId: opened.agentId,+ // ⚠️ **No neighbours: Focus holds ONE agent, and there is no sideways swipe.** The person+ // moves with Find, the sheet the handle at the foot of the terminal brings up (see+ // `docs/plans/2026-09-26-001-mobile-zero-questions.md`). A swipe was hidden — nothing said+ // it was there or what came next — and it fired by accident while scrolling or typing.+ // [_neighbours] is still taken for the tab, but only to pick where to land when the agent+ // on screen is deleted.+ neighbours: null,+ // Told where it has swiped to, so [_showing] follows the pager rather than the pager+ // being dragged back to where this screen last put it.+ onAgentChanged: _onAgentChanged,),- notifier: widget.notifier,- machineId: opened.machineId,- agentId: opened.agentId,- // ⚠️ **No neighbours: Focus holds ONE agent, and there is no sideways swipe.** The person- // moves with Find, the sheet the handle at the foot of the terminal brings up (see- // `docs/plans/2026-09-26-001-mobile-zero-questions.md`). A swipe was hidden — nothing said- // it was there or what came next — and it fired by accident while scrolling or typing.- // [_neighbours] is still taken for the tab, but only to pick where to land when the agent- // on screen is deleted.- neighbours: null,- // Told where it has swiped to, so [_showing] follows the pager rather than the pager being- // dragged back to where this screen last put it.- onAgentChanged: _onAgentChanged,);},);+ /// A wait while the onboarding is still under way ([_onboarding]): the picture looking, and the+ /// step in progress on the line under it — "Looking for your computer" while the account's+ /// computers are not known yet, the ordinary step after that ("Connecting to your computer").+ ///+ /// The same [OnboardingStage] as [_goToYourComputer] and in the same place, so the picture carries+ /// on from one to the other. Settings, and the computers, once the wait is slow — as on+ /// [_AgentHomeLoading].+ Widget _onboardingWait(String step) {+ final notifier = widget.notifier;+ final said = notifier.machines.isEmpty+ ? OnboardingCopy.looking+ : _withoutEllipsis(step);+ return OnboardingStage(+ headline: '',+ scene: OnboardingScene.looking,+ enterFrom: notifier.signedInThisRun ? OnboardingScene.welcome : null,+ status: OnboardingStatus(said),+ trailing: _loadingSlow ? PhoneSettingsButton(notifier: notifier) : null,+ actions: _loadingSlow+ ? Center(+ child: TtyTextButton(+ key: const ValueKey('home-wait-computers'),+ label: 'See your computers ›',+ size: TtySize.meta,+ onPressed: () => unawaited(+ Navigator.of(context).push(+ phoneRoute(+ (_) => MachinesTab(notifier: notifier, large: false),+ ),+ ),+ ),+ ),+ )+ : null,+ );+ }++ /// ② Your computer, at home: an account with no computer yet. "On your computer, go to" and the+ /// address that sends the download, the picture looking, the account watched every few seconds —+ /// the computer turning up takes this away by itself (`welcome/your_computer.dart`).+ ///+ /// Settings at the top right is the way out (Sign out among it): a "looking" with no way out is+ /// one of the things the onboarding leaves out on purpose.+ ///+ /// ⚠️ **The account, said at the foot, until the phone adds the computer itself.** The spec's+ /// computer is added by the waiting phone and never signs in; until that lands (it needs the+ /// desktop and the backend), the computer signs in on its own, and the wrong account there — one+ /// of the person's other Google accounts — is the likeliest reason this screen never moves on.+ Widget _goToYourComputer() {+ final notifier = widget.notifier;+ if (_onboarding) _awaitedComputer = true;+ return OnboardingStage(+ headline: OnboardingCopy.goToHeadline,+ headlineKey: const ValueKey('home-go-to'),+ scene: OnboardingScene.looking,+ enterFrom: notifier.signedInThisRun ? OnboardingScene.welcome : null,+ underHeadline: ComputerWatch(+ notifier: notifier,+ child: const GoAddressButton(),+ ),+ status: const OnboardingStatus(OnboardingCopy.looking),+ trailing: PhoneSettingsButton(notifier: notifier),+ actions: switch (notifier.currentUser?.email) {+ final email? => AccountQuietLine(notifier: notifier, email: email),+ null => null,+ },+ );+ }++ /// A step's words for the status line, whose cursor already says it is still going: the+ /// ellipsis would say it twice.+ static String _withoutEllipsis(String step) =>+ step.endsWith('…') ? step.substring(0, step.length - 1) : step;++ /// Whether the onboarding has a computer to join now, and starts its moment if so. Called from+ /// build; the moment itself starts after the frame.+ ///+ /// Which computer: after "On your computer, go to", the first on the account — the one set up for+ /// this phone, which is also named to the device log as the person's own+ /// ([AppNotifier.welcomeMachine]: no "New device" for it). Signed in to an account that already+ /// had computers, the first of them to answer.+ void _noticeJoin() {+ if (_joining != null || !_onboarding) return;+ final notifier = widget.notifier;+ if (_awaitedComputer) {+ final machine = notifier.machines.firstOrNull;+ if (machine == null) return;+ _joining = (machineId: machine.machineId, name: machine.displayName);+ // After the frame: it may take a "New device" down, which notifies — not during a build.+ final welcomed = machine.machineId;+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted) notifier.welcomeMachine(welcomed);+ });+ } else {+ final ready = filterableMachines(notifier)+ .where(+ (machine) =>+ phoneMachineStatusOf(machine) == PhoneMachineStatus.ready,+ )+ .firstOrNull;+ if (ready == null) return;+ _joining = (+ machineId: ready.machine.machineId,+ name: ready.machine.displayName,+ );+ }+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (mounted) _moment.start();+ });+ }++ /// Whether "… is ready." holds the screen: through the moment, and after it while the computer's+ /// session is still on its way — the computer connecting, its list loading, or, connected and+ /// listed, no session on it yet (its own tour starts one) for up to [_firstSessionPatience]. A+ /// computer that turns out to want a password, or that the account says is down, lets go: what+ /// home shows for those is what to do about them.+ bool _holdForJoin(AgentEntry? target) {+ final joining = _joining;+ if (joining == null || !_onboarding) return false;+ // A session picked by hand meanwhile — in Find, from a notice — is a choice the moment does not+ // stand in front of.+ if (_requestedAgent != null) return false;+ if (!_moment.done) return true;+ if (target != null || _firstSessionGaveUp) return false;+ final notifier = widget.notifier;+ final machine = notifier.stateOf(joining.machineId);+ if (machine == null) return false;+ return switch (phoneMachineStatusOf(machine)) {+ PhoneMachineStatus.needsPassword => notifier.deviceTrustSettling,+ PhoneMachineStatus.offline => phoneAccountSaysOnline(+ machine.machine.status,+ ),+ PhoneMachineStatus.connecting => true,+ PhoneMachineStatus.ready => _waitForFirstSession(),+ };+ }++ /// Arms [_firstSessionPatience] on the first frame that waits for it. Called from build: a timer,+ /// not a rebuild.+ bool _waitForFirstSession() {+ _firstSessionWait ??= Timer(_firstSessionPatience, () {+ if (!mounted) return;+ setState(() => _firstSessionGaveUp = true);+ });+ return true;+ }++ /// "MacBook Pro is ready." — the computer joining, on the same [OnboardingStage] as the wait and+ /// "On your computer, go to" before it, so the picture goes on from where it was: the laptop+ /// draws itself, links to the phone and lights, and the agent about to open types its name on it.+ /// A tap goes on sooner.+ ///+ /// Past the moment, while its session is still on its way, what it waits on is said under the+ /// picture, and Settings comes back — a wait is never without a way out.+ Widget _joinStage(AgentEntry? target) {+ final joining = _joining!;+ final notifier = widget.notifier;+ String? waiting;+ if (_moment.done && target == null) {+ final step = _loadingMessage() ?? _restoreMessage();+ waiting = step == null+ ? OnboardingCopy.waitingForSession+ : _withoutEllipsis(step);+ }+ return OnboardingStage(+ headline: OnboardingCopy.ready(joining.name),+ headlineKey: const ValueKey('home-ready'),+ scene: OnboardingScene.joined,+ enterFrom: OnboardingScene.looking,+ agent: target?.agent.engine,+ join: _moment.picture,+ status: waiting == null ? null : OnboardingStatus(waiting),+ trailing: waiting == null+ ? null+ : PhoneSettingsButton(notifier: notifier),+ onTap: _moment.done ? null : _moment.skip,+ );+ }++ /// What the phone says by the mic as the onboarding's session opens: one line, by what the+ /// computer opened (`docs/research/2026-10-11-phone-onboarding`, "Which session the phone opens").+ String _firstLine(AgentEntry target) {+ // Harness was already on the computer: whatever is on it, talk to it.+ if (!_awaitedComputer) return OnboardingCopy.micTalk;+ final agent = target.agent;+ // A conversation with a past — Claude Code or Codex resumed where it was left.+ if (agent.updatedAt != null) return OnboardingCopy.micPickUp;+ // OpenCode with the desktop's starter task typed into it, not sent.+ if (agent.engine == 'opencode') return OnboardingCopy.micSendIt;+ // A fresh session, at an empty prompt.+ return OnboardingCopy.micSayWhat;+ }+/// Bumped whenever the pager is thrown away and rebuilt, and part of its key.int _pagerGeneration = 0;@@ -1430,3 +1733,62 @@ class _AgentHomeEmpty extends StatelessWidget {);}}++/// The session the onboarding hands over to, growing into the screen — the laptop's lit screen+/// becoming the session, in the spec's words: a 420ms spring from a little smaller, fading in; a+/// 200ms fade under Reduce Motion. Only when [grow] is set as it first comes up; afterwards, and+/// for every other pager, it is the child as it is.+class _GrowIn extends StatefulWidget {+ const _GrowIn({required this.grow, required this.child});++ final bool grow;+ final Widget child;++ @override+ State<_GrowIn> createState() => _GrowInState();+}++class _GrowInState extends State<_GrowIn> with SingleTickerProviderStateMixin {+ late final AnimationController _grow = AnimationController(+ vsync: this,+ duration: const Duration(milliseconds: 420),+ value: widget.grow ? 0 : 1,+ );+ bool _still = false;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ _still = MediaQuery.maybeDisableAnimationsOf(context) ?? false;+ if (_grow.value < 1 && !_grow.isAnimating) {+ _grow.duration = Duration(milliseconds: _still ? 200 : 420);+ unawaited(_grow.forward());+ }+ }++ @override+ void dispose() {+ _grow.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) => AnimatedBuilder(+ animation: _grow,+ child: widget.child,+ builder: (context, child) {+ final t = _grow.value;+ final scale = _still || t >= 1+ ? 1.0+ : 0.9 + 0.1 * Curves.easeOutBack.transform(t);+ // ⚠️ **The same two wrappers at every value, grown included.** Dropped once it had grown,+ // they changed the pager's place in the tree, and Flutter built the pager — the terminal and+ // its attach — over again, half a second after it opened. At 1 they cost nothing: an opaque+ // opacity and an identity scale paint the child as it is.+ return Opacity(+ opacity: Curves.easeOut.transform((t * 2).clamp(0.0, 1.0)),+ child: Transform.scale(scale: scale, child: child),+ );+ },+ );+}diff --git a/mobile/lib/phone/machines_tab.dart b/mobile/lib/phone/machines_tab.dartindex 64512afab..41f43b801 100644--- a/mobile/lib/phone/machines_tab.dart+++ b/mobile/lib/phone/machines_tab.dart@@ -10,6 +10,7 @@ import 'package:harness_mobile/state/app_state.dart';import 'welcome/connect_computer.dart';import 'welcome/set_up_computer.dart' show ComputerSteps;+import 'welcome/your_computer.dart';import 'tty_controls.dart';import 'tty.dart';import 'find_row.dart';@@ -185,7 +186,7 @@ class _Body extends StatelessWidget {action: FilledButton(key: const ValueKey('machines-set-up'),onPressed: () => _setUpComputer(context),- child: const Text('Set up a computer'),+ child: const Text('Add computer'),),);}@@ -281,17 +282,12 @@ class _Body extends StatelessWidget {/// A row whose second line its group's own line says instead — one line, a thumb's height.static const double _gatheredRowHeight = 48;- /// Connect your computer over this list — the download link, the steps, and a scan that pairs —- /// for a computer not on the account yet.+ /// Add computer: the onboarding's "On your computer, go to" over this list — the address that+ /// sends the download, and the account watched for the computer that opens it. A second computer+ /// is set up the way the first was (`welcome/your_computer.dart`).void _setUpComputer(BuildContext context) => unawaited(Navigator.of(context).push(- phoneRoute(- (route) => ConnectComputerPage(- notifier: notifier,- signedIn: false,- onBack: () => Navigator.of(route).maybePop(),- ),- ),+ phoneRoute((_) => YourComputerPage(notifier: notifier)),),);@@ -390,13 +386,13 @@ class _GroupLine extends StatelessWidget {}}-/// The foot of Computers, under the list and kept there however long it grows: Connect computer —-/// the camera at once, for a computer already showing its QR code, the button the desktop's Add-/// Phone tells somebody to tap — and Set up another computer, for one with no Harness on it yet.+/// The foot of Computers, under the list and kept there however long it grows: **Add computer** —+/// the onboarding's own step ② ("On your computer, go to"), the way every computer is added now —+/// and under it, quietly, the camera, for a desktop from before that still pairs by its Add Phone+/// QR code.////// Pinned, not the list's last rows: at the end of a list they sat after every computer, read as/// two more of them, and went below the fold at nine. Down here they are where a thumb already is.-/// The button is Connect your computer's own, so the two screens show one thing by one name.////// How a scan goes is said on a line over the button — under the list, where the computer it pairs/// turns up; once paired, the computer is in the list.@@ -411,11 +407,10 @@ class _ConnectBar extends StatefulWidget {final AppNotifier notifier;/// This list is the home screen, which a computer turning up takes away: the code goes to the- /// home screen to pair by, as on Connect your computer at home — [scanAndPairComputer]'s- /// `handOff`.+ /// home screen to pair by — [scanAndPairComputer]'s `handOff`.final bool home;- /// Set up another computer: Connect your computer, pushed over this list.+ /// Add computer: "On your computer, go to", pushed over this list.final VoidCallback onSetUp;@override@@ -497,26 +492,28 @@ class _ConnectBarState extends State<_ConnectBar> {),),TtyPrimaryButton(- key: const ValueKey('machines-connect-computer'),- icon: LucideIcons.qrCode300,- label: 'Connect computer',- // Green and still while a scan is looked up or paired; the line over it says- // which.- busy: _scanning,- onPressed: () => unawaited(_scan()),+ key: const ValueKey('machines-add-computer'),+ icon: LucideIcons.laptopMinimal300,+ label: 'Add computer',+ onPressed: widget.onSetUp,),- const SizedBox(height: 8),- // "QR code", not "Add Phone code": a desktop menu's name read as a noun stack- // under a button named for the other side — and the camera takes a computer's- // sign-in QR too.- Text(- 'Scan the QR code on your computer.',- style: tty.style(size: TtySize.meta, color: tty.faint),+ // A desktop from before shows its Add Phone QR code rather than an address: the+ // camera pairs with it. "QR code", not "Add Phone code" — a desktop menu's name+ // read as a noun stack under a button named for the other side.+ Center(+ child: TtyTextButton(+ key: const ValueKey('machines-connect-computer'),+ label: _scanning+ ? 'Scanning…'+ : 'Or scan the QR code on your computer',+ size: TtySize.meta,+ color: tty.faint,+ onPressed: _scanning ? null : () => unawaited(_scan()),+ ),),],),),- FindAddRow(label: 'Set up another computer', onTap: widget.onSetUp),],),),diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex 46bed1931..f077fc143 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -65,6 +65,7 @@ import 'terminal_title.dart';import 'welcome/focus_hints.dart';import 'package:harness_mobile/demo/sample_mode.dart';+import 'package:harness_mobile/notify/notifications_ask.dart';import 'voice_input_controller.dart';@@ -826,6 +827,9 @@ class _TerminalPageState extends State<TerminalPage>.paneOfAgent(widget.machineId, widget.agentId)?.session;if (session?.voiceDeliver == _deliverVoice) session?.voiceDeliver = null;+ if (session?.onLineSent == _onLineSent) session?.onLineSent = null;+ // Said once: leaving the session spends the onboarding's line too.+ _spendFirstSessionLine();_barMessageTimer?.cancel();_barMessage.dispose();_scrollback.dispose();@@ -1027,9 +1031,47 @@ class _TerminalPageState extends State<TerminalPage>if (_sampleGuide() case final guide?) {return _StatusLine(text: guide, dot: true);}+ // The onboarding's one line, until the first send — see [AppNotifier.firstSessionLine].+ if (_firstSessionLine() case final line?) {+ return _StatusLine(key: const ValueKey('first-session-line'), text: line);+ }return null;}+ /// The onboarding's line by the mic, when this page is the session it opened on: "Send it, or say+ /// anything." Null on every other page, and once spent.+ String? _firstSessionLine() {+ final line = widget.notifier.firstSessionLine;+ if (line == null ||+ line.machineId != widget.machineId ||+ line.agentId != widget.agentId) {+ return null;+ }+ return line.text;+ }++ /// Takes the onboarding's line away, if it is this page's. True when it was.+ bool _spendFirstSessionLine() {+ if (_firstSessionLine() == null) return false;+ widget.notifier.firstSessionLine = null;+ return true;+ }++ /// A line sent from this page — a Return typed or tapped, a take that went ([TerminalSession+ /// .onLineSent]). The first on this phone asks for notifications, a moment later+ /// ([NotificationsAsk]); and the onboarding's line by the mic has been answered.+ ///+ /// Not in the sample: nothing there reaches a harness, and its notices would be for nothing.+ void _onLineSent() {+ if (!mounted || SampleMode.maybeOf(context) != null) return;+ unawaited(+ NotificationsAsk.shared.afterSend(+ widget.notifier.agentNotices.system.requestPermission,+ ),+ );+ if (_spendFirstSessionLine()) setState(() {});+ }+/// Whether [session] is a kept screen standing in while its stream attaches — drawn like the live/// terminal, and taking no key until the stream is up ([TerminalSession.acceptsInput]).///@@ -1851,6 +1893,9 @@ class _TerminalPageState extends State<TerminalPage>// While the agent's question is open, a voice take answers it — never a paste and a blind// Return into the dialog. See [_answerByVoice].session?.voiceDeliver = _deliverVoice;+ // What this page sends: the first send on the phone asks for notifications, and answers the+ // onboarding's line by the mic. See [_onLineSent].+ session?.onLineSent = _onLineSent;// Read once: the body reserves it, and search subtracts what the body// already took. See [_navigationBar].final navigationBar = _navigationBar;@@ -2376,9 +2421,10 @@ class _TerminalPageState extends State<TerminalPage>setState(() => _showEndCard = false),),),- // The first time a terminal is up: what the swipes and the mic do. Once.- // Not in the sample: its guide line teaches the same by having them done, and the- // hints stay unseen for the real first terminal.+ // What the swipes and the mic do — only when asked for again, Settings ▸ Show+ // the tips again: the first session opens on its own line by the mic instead,+ // and nothing else (owner, 2026-10-12; see [FocusHintsSeen]). Not in the sample:+ // its guide line teaches the same by having them done.if (session != null &&widget.isActive &&!_keyBarUp &&@@ -3676,7 +3722,12 @@ class _AnchoredTerminalState extends State<_AnchoredTerminal> {/// `VoiceNotice`), but not on every phone at every text size — and a warning cut mid-word hid/// what to do. Positioned by its foot, a second line grows up over the terminal, off the mic.class _StatusLine extends StatelessWidget {- const _StatusLine({required this.text, this.color, this.dot = false});+ const _StatusLine({+ super.key,+ required this.text,+ this.color,+ this.dot = false,+ });final String text;final Color? color;diff --git a/mobile/lib/phone/tty_controls.dart b/mobile/lib/phone/tty_controls.dartindex 8ac9b54b9..85abbd8bf 100644--- a/mobile/lib/phone/tty_controls.dart+++ b/mobile/lib/phone/tty_controls.dart@@ -149,6 +149,7 @@ class TtyTextButton extends StatelessWidget {required this.onPressed,this.color,this.weight = FontWeight.w500,+ this.size = TtySize.row,});final String label;@@ -156,6 +157,9 @@ class TtyTextButton extends StatelessWidget {final Color? color;final FontWeight weight;+ /// The onboarding's quiet line is the meta size ("Continue with email").+ final double size;+@overrideWidget build(BuildContext context) {final tty = Tty.of(context);@@ -181,7 +185,7 @@ class TtyTextButton extends StatelessWidget {label,color: onPressed == null ? tty.dim : (color ?? tty.text),weight: weight,- size: TtySize.row,+ size: size,),),),diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dartindex 02d2aa0e8..efbfa4562 100644--- a/mobile/lib/phone/welcome/connect_computer.dart+++ b/mobile/lib/phone/welcome/connect_computer.dart@@ -5,265 +5,28 @@ import 'dart:async';import 'package:flutter/material.dart';import 'package:flutter/services.dart';-import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';-import '../phone_navigation.dart' show phoneRoute;-import '../settings_page.dart' show PhoneSettingsButton, confirmSignOut;-import '../tty.dart';-import '../tty_controls.dart';import 'scan_to_connect.dart';-import 'set_up_computer.dart';--/// Connecting a computer, for a phone that is signed in — the same page as the first screen-/// ([SetUpComputerPage], Connect your computer, with Get it behind it), and the one thing only a-/// signed-in phone can do on it: watch for the computer to appear (every few seconds, since nothing-/// tells the phone) and pair with it by the code its Add Phone shows.-///-/// ```-/// harness▌ ⚙-/// Your agents-/// in your pocket.-/// See every session on your machines. Answer your agents from anywhere.-/// [| Waiting for your computer… ]-/// [email protected] · Not you? Sign out-/// [ ⊞ Connect computer ]-/// ① Open Harness on your computer-/// │ Don’t have it? Get it › (and the sample, while it installs)-/// ② Sign in on your computer-/// │ With the same account.-/// ③ Click Add Phone-/// Mac: Harness menu-/// Linux: Ctrl+Shift+P → add phone-/// ```-///-/// It replaces a page of its own — an email of the steps, a Terminal/Mac tab, four commands to-/// copy — that told a newcomer the same thing a second way, with `harness login` and a phone-/// password the QR has since made unnecessary.-class ConnectComputerPage extends StatefulWidget {- const ConnectComputerPage({- super.key,- required this.notifier,- this.signedIn = true,- this.onBack,- this.onTrySample,- this.scanCamera,- });-- final AppNotifier notifier;-- /// Watch for the computer and say whose account it must be signed in to.- final bool signedIn;-- /// Shown as `‹ Back` when set.- final VoidCallback? onBack;-- /// Opens the sample, from Get it; see `PhoneWelcome.onTrySample`.- final Future<Object?> Function(BuildContext context)? onTrySample;-- /// Stands in for the camera, in tests.- final Widget? scanCamera;-- @override- State<ConnectComputerPage> createState() => _ConnectComputerPageState();-}--class _ConnectComputerPageState extends State<ConnectComputerPage> {- Timer? _watch;-- /// What the last scan came to, while it is worth saying: pairing, or why it did not.- String? _scanned;- bool _scanFailed = false;-- @override- void initState() {- super.initState();- if (widget.signedIn) {- // Nothing pushes a new machine to the phone: ask again every few seconds while this is up.- // A request that fails (offline for a moment) is simply asked again on the next tick — and- // caught here, where it used to reach the zone as an unhandled error every 5 seconds.- _watch = Timer.periodic(const Duration(seconds: 5), (_) {- if (!mounted) return;- unawaited(widget.notifier.refreshMachines().catchError((Object _) {}));- });- }- }-- /// Get it, while it is up over this page — see [_openGetIt].- Route<void>? _getIt;-- @override- void dispose() {- _watch?.cancel();- // ⚠️ At home this page goes when the computer turns up — the 5-second watch — and Get it, pushed- // over it, stayed up over the agents. Taken away after this frame: a navigator is not to be- // changed while the tree is being torn down.- final getIt = _getIt;- if (getIt != null) {- WidgetsBinding.instance.addPostFrameCallback((_) {- final navigator = getIt.navigator;- if (navigator != null && navigator.mounted && getIt.isActive) {- navigator.removeRoute(getIt);- }- });- }- super.dispose();- }-- /// "No Harness on your computer yet? Get it ›": the download sent to the computer, over this- /// page, and its "Connect computer ›" back to this page's scan. One at a time.- void _openGetIt() {- if (_getIt != null) return;- final route = phoneRoute(- (page) => Scaffold(- backgroundColor: Tty.of(page).ground,- body: SafeArea(- child: GetHarnessPage(- onBack: () => Navigator.of(page).maybePop(),- onPair: () {- // ⚠️ `pop`, not `maybePop`: that one waits a microtask, sees the camera pushed over- // Get it meanwhile, and drops the pop — Get it stayed under the camera, and the scan's- // answer (or Computers' back on success) landed on it instead of this page.- Navigator.of(page).pop();- if (mounted) unawaited(_scanToPair());- },- // Over Get it, which its end card's "set up" comes back to.- onTrySample: widget.onTrySample == null- ? null- : () => unawaited(widget.onTrySample!(page)),- ),- ),- ),- );- _getIt = route;- unawaited(- Navigator.of(context).push(route).whenComplete(() => _getIt = null),- );- }-- void _say(String? message, {bool failed = false}) => setState(() {- _scanned = message;- _scanFailed = failed;- });-- /// A scan under way, from the camera to its answer: a second press of "Scan to connect" while- /// one is still being looked up or paired is not a second pairing by the same one-time code.- bool _scanning = false;-- Future<void> _scanToPair() async {- if (_scanning) return;- _scanning = true;- try {- await _scanAndPair();- } finally {- _scanning = false;- }- }-- /// The code the new computer's Add Phone shows: the phone pairs with it. The computer is asked- /// for first — it may have joined the account a moment ago, too recently for the list the phone- /// holds.- ///- /// ⚠️ **At home, the home screen pairs, not this page.** Here this page is up only while the- /// account has no computer, so the computer the code is for turning up — in the 5-second watch- /// while the camera was open, or in the look-up below, which is what most often brings it —- /// takes the page away. A page still pairing then lost its answer: a code that failed showed- /// nothing, and "Scan its code" on the screen that replaced it started a second pairing while the- /// first ran (PAIRING_BUSY). So the code goes to the home screen ([AppNotifier.holdPendingPairing])- /// the moment the computer is known, and its pairing page pairs by it and says how it went —- /// the way a code scanned at sign-in is paired. Pushed from Computers, which nothing takes away,- /// the page pairs itself, and goes back on success. Gone either way, it hands the code over.- Future<void> _scanAndPair() async {- final paired = await scanAndPairComputer(- context,- widget.notifier,- say: _say,- handOff: widget.onBack == null,- camera: widget.scanCamera,- );- // From Computers, the list it came from has the computer now; at home, the shell moves on by- // itself once a computer is ready.- if (paired && mounted) widget.onBack?.call();- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final tty = Tty.of(context);- final email = widget.notifier.currentUser?.email;- final scanned = _scanned;- return Scaffold(- backgroundColor: tty.ground,- body: SafeArea(- child: SetUpComputerPage(- onBack: widget.onBack,- onScan: () => unawaited(_scanToPair()),- onGetIt: _openGetIt,- // 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 the account is watched, and the computer turns up here by itself.- watching: widget.signedIn,- // 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,- // Under the button that started it ([SetUpComputerPage.scanStatus]), not up here.- scanStatus: scanned == null- ? null- : Padding(- padding: const EdgeInsets.only(bottom: 4),- child: Text(- _scanFailed ? '✗ $scanned' : scanned,- key: const ValueKey('connect-scan-status'),- style: tty.style(- size: TtySize.meta,- color: _scanFailed ? tty.red : tty.faint,- ),- ),- ),- status: widget.signedIn- ? Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- if (widget.signedIn) const _Watching(),- // The account, said once, right under the watch: 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)- _AccountLine(- email: email,- onSignOut: () =>- unawaited(confirmSignOut(context, widget.notifier)),- ),- ],- )- : null,- ),- ),- );- }-}/// What a Connect computer press has to say while it runs — `Pairing…`, or why it stopped — on the/// line under the button that started it. Null takes the line away.typedef ConnectComputerSay = void Function(String? message, {bool failed});-/// Connect computer, wherever it is pressed — Connect your computer's button, and the same button-/// at the foot of Computers: the camera, then the computer whose Add Phone code it read, looked up-/// on the account and paired with by the code. True once it is paired here.+/// "Or scan the QR code on your computer", at the foot of Computers: the camera, then the computer+/// whose Add Phone code it read, looked up on the account and paired with by the code. True once it+/// is paired here. For a desktop from before the onboarding of 2026-10-12, which pairs a phone by+/// that code; every other computer is added by "On your computer, go to" (`your_computer.dart`).////// [say] is the caller's line, and is called only while [context] is still mounted.////// [steps]: under the camera's title, the steps on the computer that bring the code up — for a/// caller whose own page does not say them ([ScanToConnectPage.steps]).///-/// [handOff]: [context] is the home screen, which a computer turning up takes away — see-/// [_ConnectComputerPageState._scanAndPair]. The code then goes to the home screen-/// ([AppNotifier.holdPendingPairing]) the moment the computer is known, and its pairing page pairs-/// by it; and so it does whatever [handOff] says when [context] has gone by then.+/// [handOff]: [context] is the home screen, which a computer turning up takes away. The code then+/// goes to the home screen ([AppNotifier.holdPendingPairing]) the moment the computer is known, and+/// its pairing page pairs by it; and so it does whatever [handOff] says when [context] has gone by+/// then.Future<bool> scanAndPairComputer(BuildContext context,AppNotifier notifier, {@@ -383,107 +146,7 @@ Future<_Lookup> _lookUp(: _Lookup.missing;}-/// `Waiting for your computer…` with a terminal spinner — the page is watching.-class _Watching extends StatefulWidget {- const _Watching();-- @override- State<_Watching> createState() => _WatchingState();-}--class _WatchingState extends State<_Watching> {- // The terminal's oldest spinner — every monospace face has these four.- static const _frames = ['|', '/', '-', r'\'];- int _frame = 0;- Timer? _tick;-- @override- void initState() {- super.initState();- _tick = Timer.periodic(const Duration(milliseconds: 150), (_) {- if (mounted) setState(() => _frame = (_frame + 1) % _frames.length);- });- }-- @override- void dispose() {- _tick?.cancel();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Container(- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),- decoration: BoxDecoration(- color: ttyRaised(tty),- borderRadius: BorderRadius.circular(6),- ),- child: Row(- children: [- TtyText(_frames[_frame], color: tty.green, size: TtySize.row),- const SizedBox(width: 10),- Expanded(- child: Text(- 'Waiting for your computer…',- style: tty.style(size: TtySize.meta, color: tty.text),- ),- ),- ],- ),- );- }-}--/// `[email protected] · Not you? Sign out` — the account this phone is signed in to, and the way out of-/// it, on one line that wraps. The whole line signs out (after asking, [confirmSignOut]).-class _AccountLine extends StatelessWidget {- const _AccountLine({required this.email, required this.onSignOut});-- final String email;- final VoidCallback onSignOut;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Semantics(- button: true,- label: 'Signed in as $email. Not you? Sign out',- excludeSemantics: true,- child: GestureDetector(- key: const ValueKey('connect-sign-out'),- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onSignOut();- },- child: ConstrainedBox(- constraints: const BoxConstraints(minHeight: 44),- child: Padding(- padding: const EdgeInsets.symmetric(vertical: 10),- child: Text.rich(- TextSpan(- children: [- TextSpan(text: '$email · '),- TextSpan(- text: 'Not you? Sign out',- style: tty.style(color: tty.text, size: TtySize.meta),- ),- ],- ),- // From the page's edge, with everything else on it (`set_up_computer.dart`).- textAlign: TextAlign.start,- style: tty.style(color: tty.faint, size: TtySize.meta),- ),- ),- ),- ),- );- }-}--/// What the account said of a scanned computer ([_ConnectComputerPageState._lookUp]).+/// What the account said of a scanned computer ([_lookUp]).enum _Lookup {/// On the account.found,diff --git a/mobile/lib/phone/welcome/email_sign_in.dart b/mobile/lib/phone/welcome/email_sign_in.dartnew file mode 100644index 000000000..b4c6fb21e--- /dev/null+++ b/mobile/lib/phone/welcome/email_sign_in.dart@@ -0,0 +1,138 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';++import '../tty.dart';+import '../tty_controls.dart';+import 'onboarding_frame.dart';++/// One step of signing in by email: back, a title, a line or two, a field, the button — on the+/// welcome's left edge and in its headline's face ([OnboardingFrame]).+class SignInForm extends StatelessWidget {+ const SignInForm({+ super.key,+ required this.onBack,+ required this.title,+ required this.lines,+ required this.field,+ required this.button,+ this.error,+ this.footer,+ });++ final VoidCallback onBack;+ final String title;+ final List<String> lines;+ final Widget field;+ final Widget button;+ final String? error;+ final Widget? footer;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Align(+ alignment: Alignment.centerLeft,+ child: TtyBackButton(onPressed: onBack),+ ),+ Expanded(+ child: ListView(+ padding: const EdgeInsets.fromLTRB(+ OnboardingFrame.side,+ 12,+ OnboardingFrame.side,+ 16,+ ),+ children: [+ // A title that wraps: "Check your email" is more than a 320pt phone holds on one line+ // at the largest text size, and a one-line TtyText cut it there.+ Text(title, style: OnboardingFrame.headlineStyle(tty)),+ const SizedBox(height: 12),+ for (final line in lines)+ Padding(+ padding: const EdgeInsets.only(bottom: 6),+ child: Text(+ line,+ style: tty.style(size: TtySize.row, color: tty.faint),+ ),+ ),+ const SizedBox(height: 18),+ AutofillGroup(child: field),+ if (error case final error?)+ Padding(+ padding: const EdgeInsets.only(top: 10),+ child: Text(+ '✗ $error',+ style: tty.style(size: TtySize.meta, color: tty.red),+ ),+ ),+ const SizedBox(height: 16),+ button,+ ?footer,+ ],+ ),+ ),+ ],+ );+ }+}++/// The code, typed into one wide field in big mono digits — it submits itself on the last one.+class SignInCodeField extends StatelessWidget {+ const SignInCodeField({+ super.key,+ required this.controller,+ required this.focus,+ required this.length,+ required this.onFilled,+ });++ final TextEditingController controller;+ final FocusNode focus;+ final int length;+ final VoidCallback onFilled;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Container(+ height: 64,+ decoration: BoxDecoration(+ color: ttyRaised(tty),+ borderRadius: BorderRadius.circular(6),+ ),+ alignment: Alignment.center,+ child: TextField(+ key: const Key('welcome-code'),+ controller: controller,+ focusNode: focus,+ keyboardType: TextInputType.number,+ autofillHints: const [AutofillHints.oneTimeCode],+ textAlign: TextAlign.center,+ maxLength: length,+ inputFormatters: [FilteringTextInputFormatter.digitsOnly],+ cursorColor: tty.green,+ style: tty+ .style(size: 30, weight: FontWeight.w600)+ .copyWith(letterSpacing: 18),+ onChanged: (value) {+ if (value.length == length) onFilled();+ },+ decoration: InputDecoration(+ isCollapsed: true,+ counterText: '',+ filled: false,+ border: InputBorder.none,+ enabledBorder: InputBorder.none,+ focusedBorder: InputBorder.none,+ hintText: '•' * length,+ hintStyle: tty+ .style(size: 30, color: tty.dim)+ .copyWith(letterSpacing: 18),+ ),+ ),+ );+ }+}diff --git a/mobile/lib/phone/welcome/focus_hints.dart b/mobile/lib/phone/welcome/focus_hints.dartindex 07ea3885d..2ebf05e8f 100644--- a/mobile/lib/phone/welcome/focus_hints.dart+++ b/mobile/lib/phone/welcome/focus_hints.dart@@ -10,12 +10,21 @@ import 'package:harness_mobile/core/local_key_value_store.dart';import '../tty.dart';import '../tty_controls.dart';-/// Whether Focus's first-time hints have been seen — once per install.+/// Whether Focus's hints are put away — which, since the onboarding of 2026-10-12, they are unless+/// asked for again (Settings ▸ Show the tips again).+///+/// ⚠️ **No tips before the first look** (owner, 2026-10-12): the first session opens on one line by+/// the mic and nothing else, where four tips and then the notification prompt used to come over it+/// (`docs/research/2026-10-11-phone-onboarding`, appendix). So nothing stored reads as put away, and+/// only [forget] — the person asking — brings them up, once.class FocusHintsSeen {FocusHintsSeen({LocalKeyValueStore? storage}): _storage = storage ?? HarnessFileStore.shared;static const _key = 'phone_focus_hints_v1';++ /// Stored under [_key] by [forget]: asked for again, to come up on the next Focus.+ static const _again = 'again';final LocalKeyValueStore _storage;/// Shared by every Focus page, so a second page opened before the first read lands does not@@ -33,7 +42,7 @@ class FocusHintsSeen {return _seen = true;}try {- _seen = await _storage.read(_key) == 'yes';+ _seen = await _storage.read(_key) != _again;} on Exception {_seen = true; // No memory: never nag.}@@ -44,7 +53,7 @@ class FocusHintsSeen {Future<void> forget() async {_seen = false;try {- await _storage.delete(_key);+ await _storage.write(_key, _again);} on Exception {// Back for this run at least.}diff --git a/mobile/lib/phone/welcome/join_moment.dart b/mobile/lib/phone/welcome/join_moment.dartnew file mode 100644index 000000000..6b345b74b--- /dev/null+++ b/mobile/lib/phone/welcome/join_moment.dart@@ -0,0 +1,94 @@+import 'dart:async';++import 'package:flutter/animation.dart';+import 'package:flutter/services.dart';++import 'package:harness_mobile/core/chime.dart';++import 'onboarding_picture.dart';++/// A computer joining: about two seconds from the laptop's first stroke to its session growing into+/// the screen (`docs/research/2026-10-11-phone-onboarding`, "The Mac joins, frame by frame") — the+/// clock, and what is felt and heard on it. The picture is drawn from [picture]+/// ([OnboardingPicture.join]); the screen goes on when [done].+///+/// ```+/// 0 ms three quickening taps while the laptop's outline draws itself+/// 600 ms the screen lights: the success buzz, and the only sound in setup — two soft glass notes+/// 2200 ms done: the session takes the screen+/// ```+///+/// ⚠️ **Driven by frames, and that is what replays it.** A computer that joins while the app is in+/// the background gets its moment when the app is next in front: no frame, no tick, until then.+///+/// Muted, the notes are silent ([Chime]) and the haptics stay. Reduce Motion changes how the picture+/// draws it, not its clock.+class JoinMoment {+ JoinMoment({required TickerProvider vsync, required VoidCallback onDone})+ : _controller = AnimationController(vsync: vsync, duration: length) {+ _controller+ ..addListener(_beat)+ ..addStatusListener((status) {+ if (status == AnimationStatus.completed && !_done) {+ _done = true;+ onDone();+ }+ });+ }++ final AnimationController _controller;++ /// From the first stroke to the session.+ static const length = Duration(milliseconds: 2200);++ /// The picture's part of it: 0 → 1 over [OnboardingPicture.joinLength], then held.+ late final Animation<double> picture = CurvedAnimation(+ parent: _controller,+ curve: Interval(+ 0,+ OnboardingPicture.joinLength.inMilliseconds / length.inMilliseconds,+ ),+ );++ bool _done = false;++ /// It has run its course — or a tap cut it short.+ bool get done => _done;++ /// How many beats have been played ([_beat]).+ int _beats = 0;++ static const _taps = [0, 160, 270];+ static const _lights = 600;++ /// From the start. Call it after the frame that first draws the joined picture.+ void start() {+ if (_done) return;+ _beats = 0;+ unawaited(_controller.forward(from: 0));+ }++ /// A tap: straight on to [done], with nothing left of the moment to play.+ void skip() {+ if (_done) return;+ _beats = _taps.length + 1;+ _controller.value = 1;+ }++ void dispose() => _controller.dispose();++ /// The beats, played as the clock reaches them — each once, so a frame that jumps several does+ /// not play them over each other out of order.+ void _beat() {+ final ms = _controller.value * length.inMilliseconds;+ while (_beats < _taps.length && ms >= _taps[_beats]) {+ _beats++;+ HapticFeedback.lightImpact();+ }+ if (_beats == _taps.length && ms >= _lights) {+ _beats++;+ HapticFeedback.mediumImpact();+ unawaited(Chime.play(Chime.joined));+ }+ }+}diff --git a/mobile/lib/phone/welcome/onboarding_copy.dart b/mobile/lib/phone/welcome/onboarding_copy.dartnew file mode 100644index 000000000..0ee1a36eb--- /dev/null+++ b/mobile/lib/phone/welcome/onboarding_copy.dart@@ -0,0 +1,55 @@+/// Every word of the phone's onboarding, in one place — the "Every word" table of+/// `docs/research/2026-10-11-phone-onboarding` (agreed with the owner, 2026-10-12).+///+/// ```+/// ① Welcome Manage all your agents on all your computers from your phone.+/// [Continue with Google] [Continue with Apple] Continue with email+/// ② Your computer On your computer, go to [autonomous.ai/go ⇪]+/// under the picture: Looking for your computer▌+/// The Mac joins MacBook Pro is ready.+/// ③ The session by the mic, once: Send it, or say anything.+/// ```+///+/// ⚠️ **One source, because the screens share one story.** The same step is named the same way on+/// every screen it appears on — the welcome, Computers ▸ Add computer, the desktop's `/go` page — and+/// a word changed here is changed everywhere the phone says it. The desktop's own words (its pane+/// title's hover line, "✓ Added by …" at the end of its tour) are the desktop's; keep them in step+/// with these.+///+/// ⚠️ **Nothing else on these screens** (owner, 2026-10-12): no sample link, no tips, no notification+/// prompt, no fallback lines, no page dots, and never the word "network".+abstract final class OnboardingCopy {+ /// ① The welcome's headline: everything lit, the promise.+ static const welcome =+ 'Manage all your agents on all your computers from your phone.';++ /// ① The quiet line under the accounts.+ static const continueWithEmail = 'Continue with email';++ /// ② The headline over the address.+ static const goToHeadline = 'On your computer, go to';++ /// ② The address, as written on the button that sends it: short enough to type off the phone.+ static const goAddress = 'autonomous.ai/go';++ /// ② The address the button sends — the download for whatever computer opens it. The main site+ /// sends `/go` on to Harness's download page (`harness.autonomous.ai/desktop`), which picks the+ /// file for the computer that opens it.+ static const goUrl = 'https://autonomous.ai/go';++ /// ② Under the picture, while the laptop breathes.+ static const looking = 'Looking for your computer';++ /// The moment the computer joins — its own name, as the account knows it.+ static String ready(String computer) => '$computer is ready.';++ /// Under "… is ready.", past the moment, while the computer has no session yet — its own tour+ /// starts one. Not the spec's: its computer always had one by then.+ static const waitingForSession = 'Waiting for its first session';++ /// What the phone says by the mic the first time it opens a session — one line, once.+ static const micSendIt = 'Send it, or say anything.';+ static const micPickUp = 'Pick up where you left off.';+ static const micSayWhat = 'Say what to build.';+ static const micTalk = 'Talk to it.';+}diff --git a/mobile/lib/phone/welcome/onboarding_frame.dart b/mobile/lib/phone/welcome/onboarding_frame.dartnew file mode 100644index 000000000..e00248e29--- /dev/null+++ b/mobile/lib/phone/welcome/onboarding_frame.dart@@ -0,0 +1,387 @@+import 'dart:math' as math;++import 'package:flutter/material.dart';++import '../tty.dart';+import '../tty_controls.dart';+import 'onboarding_picture.dart';++/// The one layout every onboarding screen is drawn on — the welcome, "On your computer, go to" and+/// the computer joining — so that going from one to the next only the words change.+///+/// ```+/// ‹ (leading, trailing)+///+/// Manage all your agents on all headline: 22pt mono semibold, up to three lines+/// your computers from your phone. [underHeadline] — ②'s address+///+/// ┌──────────────────┐+/// │ picture │ the middle, the same place on every screen+/// └──────────────────┘+/// Looking for your computer▌ status+///+/// [ Continue with Google ] actions, at the foot+/// [ Continue with Apple ]+/// Continue with email+/// ```+///+/// ⚠️ **Every slot is measured the same way on every screen**, whatever it holds — the headline's+/// three lines, room for a button under it, the foot's two buttons and quiet line — so the picture+/// sits at one height whichever screen is up, and never moves (`docs/research/2026-10-11-phone-+/// onboarding`, "Type and space"). It only shrinks where the phone is short or the text large.+///+/// Between screens the words rise 8pt into place over 250ms (a 200ms fade under Reduce Motion);+/// what changes in the picture is its own business ([OnboardingPicture]).+class OnboardingFrame extends StatelessWidget {+ const OnboardingFrame({+ super.key,+ required this.headline,+ required this.picture,+ this.headlineKey,+ this.underHeadline,+ this.status,+ this.actions,+ this.leading,+ this.trailing,+ });++ final String headline;+ final Key? headlineKey;++ /// Under the headline, rising with it: "On your computer, go to"'s address.+ final Widget? underHeadline;++ /// The picture, laid out in the middle at its own 320 × 300 proportions.+ final Widget picture;++ /// One centred line under the picture ([OnboardingStatus]).+ final Widget? status;++ /// The foot: the accounts and the quiet line under them.+ final Widget? actions;++ /// Top left, and top right — back, a way out.+ final Widget? leading;+ final Widget? trailing;++ /// The one left edge, and the right.+ static const double side = 35;++ static const double headlineSize = 22;+ static const double _headlineHeight = 1.32;++ /// The headline's face — 22pt mono semibold, set a little tighter than the terminal's — for every+ /// step of onboarding, the email's too.+ static TextStyle headlineStyle(Tty tty) => tty+ .style(size: headlineSize, weight: FontWeight.w600)+ .copyWith(height: _headlineHeight, letterSpacing: -.03 * headlineSize);++ /// The quiet line's size, and the status line's.+ static const double quietSize = TtySize.meta;++ /// The picture may reach wider than the words, as far as this from each edge.+ static const double _pictureSide = 27;++ /// The top row, where back sits.+ static const double _bar = 44;++ @override+ Widget build(BuildContext context) {+ final scaler = MediaQuery.textScalerOf(context);+ final line = scaler.scale(headlineSize) * _headlineHeight;+ // A button is 52pt, or taller when its text is larger ([TtyPrimaryButton]).+ final button = math.max(+ TtyPrimaryButton.height,+ scaler.scale(TtySize.title) * 1.2 + 20,+ );+ final quiet = math.max(44.0, scaler.scale(quietSize) * 1.45);+ // The headline's three lines — or two and a button under them, ②'s address.+ final head = math.max(3 * line, 2 * line + _underGap + button);+ final foot = 2 * button + _buttonGap + quiet + 8;+ // Room for two lines under the picture: a sign-in's failure can run to a second.+ final statusRow = 2 * scaler.scale(quietSize) * 1.45;++ return LayoutBuilder(+ builder: (context, box) {+ final width = box.maxWidth, height = box.maxHeight;+ final headTop = _bar + 16;+ final middleTop = headTop + head + 24;+ final middleBottom = height - foot - 16;+ // The picture and its status line, centred in what is left between the words and the foot.+ final room = math.max(0.0, middleBottom - middleTop - statusRow - 10);+ final pictureWidth = math.max(+ 0.0,+ math.min(width - 2 * _pictureSide, room * 320 / 300),+ );+ final pictureHeight = pictureWidth * 300 / 320;+ final block = pictureHeight + 10 + statusRow;+ final pictureTop =+ middleTop + math.max(0.0, (middleBottom - middleTop - block) / 2);++ return Stack(+ children: [+ Positioned(+ left: 0,+ right: 0,+ top: pictureTop,+ height: pictureHeight,+ child: Center(+ child: SizedBox(+ width: pictureWidth,+ height: pictureHeight,+ child: picture,+ ),+ ),+ ),+ if (status case final status?)+ Positioned(+ left: side,+ right: side,+ top: pictureTop + pictureHeight + 10,+ child: Center(child: status),+ ),+ Positioned(+ left: side,+ right: side,+ top: headTop,+ child: _Words(+ headline: headline,+ headlineKey: headlineKey,+ under: underHeadline,+ ),+ ),+ if (actions case final actions?)+ Positioned(left: side, right: side, bottom: 8, child: actions),+ if (leading case final leading?)+ Positioned(left: 0, top: 0, height: _bar, child: leading),+ if (trailing case final trailing?)+ Positioned(right: 0, top: 0, height: _bar, child: trailing),+ ],+ );+ },+ );+ }++ static const double _underGap = 23;+ static const double _buttonGap = 10;+}++/// An onboarding screen whole: the terminal's ground, the safe area, [OnboardingFrame] and its+/// [OnboardingPicture] — for the screens after sign-in, which home switches between.+///+/// ⚠️ **One widget for each of them, built in the same place, and that is what keeps the picture+/// alive between them.** Home answers its wait, "On your computer, go to" and the computer joining+/// with this same widget, so Flutter keeps the picture's state across the switch and only its+/// [scene] changes — rings going on, the laptop lighting — rather than a new picture starting over.+class OnboardingStage extends StatelessWidget {+ const OnboardingStage({+ super.key,+ required this.headline,+ required this.scene,+ this.headlineKey,+ this.enterFrom,+ this.agent,+ this.join,+ this.underHeadline,+ this.status,+ this.actions,+ this.leading,+ this.trailing,+ this.onTap,+ });++ final String headline;+ final Key? headlineKey;+ final OnboardingScene scene;++ /// See [OnboardingPicture.enterFrom], [OnboardingPicture.agent] and [OnboardingPicture.join].+ final OnboardingScene? enterFrom;+ final String? agent;+ final Animation<double>? join;++ final Widget? underHeadline;+ final Widget? status;+ final Widget? actions;+ final Widget? leading;+ final Widget? trailing;++ /// A tap anywhere that is not a control — the joining's "a tap goes sooner".+ final VoidCallback? onTap;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Scaffold(+ backgroundColor: tty.ground,+ body: SafeArea(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: OnboardingFrame(+ headline: headline,+ headlineKey: headlineKey,+ picture: OnboardingPicture(+ scene: scene,+ enterFrom: enterFrom,+ agent: agent,+ join: join,+ ),+ underHeadline: underHeadline,+ status: status,+ actions: actions,+ leading: leading,+ trailing: trailing,+ ),+ ),+ ),+ );+ }+}++/// The headline, and what goes under it, changing together: the new words rise 8pt into place as+/// the old fade.+class _Words extends StatelessWidget {+ const _Words({required this.headline, this.headlineKey, this.under});++ final String headline;+ final Key? headlineKey;+ final Widget? under;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ final still = MediaQuery.maybeDisableAnimationsOf(context) ?? false;+ return AnimatedSwitcher(+ duration: Duration(milliseconds: still ? 200 : 250),+ switchInCurve: Curves.easeOut,+ switchOutCurve: Curves.easeIn,+ layoutBuilder: (current, previous) => Stack(+ alignment: Alignment.topLeft,+ children: [...previous, ?current],+ ),+ transitionBuilder: (child, animation) => FadeTransition(+ opacity: animation,+ child: still+ ? child+ : AnimatedBuilder(+ animation: animation,+ child: child,+ builder: (context, child) => Transform.translate(+ offset: Offset(0, 8 * (1 - animation.value)),+ child: child,+ ),+ ),+ ),+ child: Column(+ key: ValueKey(headline),+ crossAxisAlignment: CrossAxisAlignment.stretch,+ mainAxisSize: MainAxisSize.min,+ children: [+ Semantics(+ header: true,+ child: Text(+ headline,+ key: headlineKey,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: OnboardingFrame.headlineStyle(tty),+ ),+ ),+ if (under case final under?) ...[+ const SizedBox(height: OnboardingFrame._underGap),+ under,+ ],+ ],+ ),+ );+ }+}++/// The line under the picture — "Looking for your computer▌" — ending in the terminal's block+/// cursor, blinking once a second (steady under Reduce Motion). Said as it changes.+class OnboardingStatus extends StatefulWidget {+ const OnboardingStatus(this.text, {super.key, this.cursor = true});++ final String text;++ /// The block cursor after it: still looking.+ final bool cursor;++ @override+ State<OnboardingStatus> createState() => _OnboardingStatusState();+}++class _OnboardingStatusState extends State<OnboardingStatus>+ with SingleTickerProviderStateMixin {+ late final AnimationController _blink = AnimationController(+ vsync: this,+ duration: const Duration(seconds: 1),+ );++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ final still = MediaQuery.maybeDisableAnimationsOf(context) ?? false;+ if (still) {+ _blink+ ..stop()+ ..value = 0;+ } else if (!_blink.isAnimating) {+ _blink.repeat();+ }+ }++ @override+ void dispose() {+ _blink.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ final scaler = MediaQuery.textScalerOf(context);+ final style = tty.style(+ size: OnboardingFrame.quietSize,+ weight: FontWeight.w500,+ color: Color.alphaBlend(tty.text.withValues(alpha: .85), tty.ground),+ );+ final size = scaler.scale(OnboardingFrame.quietSize);+ return Semantics(+ liveRegion: true,+ label: widget.text,+ excludeSemantics: true,+ child: Text.rich(+ TextSpan(+ text: widget.text,+ children: [+ if (widget.cursor)+ WidgetSpan(+ alignment: PlaceholderAlignment.middle,+ child: Padding(+ padding: const EdgeInsets.only(left: 2),+ child: AnimatedBuilder(+ animation: _blink,+ builder: (context, _) => Opacity(+ // On for the first half of each second, off for the second — steps, as a+ // terminal's cursor blinks, not a fade.+ opacity: _blink.value < .5 ? 1 : 0,+ child: SizedBox(+ width: size * .48,+ height: size,+ child: ColoredBox(color: tty.green),+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ textAlign: TextAlign.center,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: style,+ ),+ );+ }+}diff --git a/mobile/lib/phone/welcome/onboarding_picture.dart b/mobile/lib/phone/welcome/onboarding_picture.dartnew file mode 100644index 000000000..a206f94ab--- /dev/null+++ b/mobile/lib/phone/welcome/onboarding_picture.dart@@ -0,0 +1,835 @@+import 'dart:math' as math;++import 'package:flutter/material.dart';+import 'package:flutter/scheduler.dart';++import '../tty.dart';++/// What the onboarding's one picture shows: three computers around a phone.+///+/// ```+/// welcome all three lit, an agent typing on each, packets running to the phone — the promise+/// looking three dashed outlines, the laptop breathing, rings going out from the phone+/// joined the laptop lit and linked, the others faded, the phone bright+/// ```+enum OnboardingScene { welcome, looking, joined }++/// The onboarding's picture — `docs/research/2026-10-11-phone-onboarding`, drawn on the spec's own+/// 320 × 300 grid so its coordinates read straight across from the page's SVGs.+///+/// ⚠️ **One picture, in the same place on every screen; only its state changes.** A new [scene]+/// eases from the one before (400ms, a 200ms fade under Reduce Motion). A screen that takes over+/// from another — the welcome handing over to "On your computer, go to" when the phone signs in, a+/// different widget tree — passes [enterFrom], so the picture still reads as the same one changing.+///+/// [join] drives the computer joining (`scene: joined`), 0 → 1 over [joinLength]:+///+/// ```+/// 0 ms the laptop's outline draws itself solid+/// 350 ms the link draws from the laptop to the phone+/// 600 ms the laptop's screen lights+/// 800 ms the agent's name appears on it; the first packet lands on the phone, which brightens+/// ```+///+/// Without [join], a joined picture is drawn already joined. The haptics and the sound that go+/// with those beats are the caller's: this only draws.+///+/// Reduce Motion: no packets, no rings, no breathing (held at its peak, as [Pulse] holds), a steady+/// cursor, and every change a 200ms fade.+class OnboardingPicture extends StatefulWidget {+ const OnboardingPicture({+ super.key,+ required this.scene,+ this.enterFrom,+ this.agent,+ this.join,+ });++ final OnboardingScene scene;++ /// The scene the screen before this one showed: the picture eases from it on its first frame.+ final OnboardingScene? enterFrom;++ /// The agent typing on the laptop once it has joined — `opencode`, `claude`. Null draws only the+ /// cursor.+ final String? agent;++ /// The join's progress, 0 → 1 over [joinLength] — see the class comment.+ final Animation<double>? join;++ /// How long [join] runs, from the outline's first stroke to the phone brightening.+ static const joinLength = Duration(milliseconds: 1000);++ @override+ State<OnboardingPicture> createState() => _OnboardingPictureState();+}++class _OnboardingPictureState extends State<OnboardingPicture>+ with TickerProviderStateMixin {+ late final AnimationController _blend = AnimationController(+ vsync: this,+ duration: _blendLength,+ value: 1,+ );++ /// Seconds since the picture came up: the packets', rings', breath's and cursor's clock.+ final _clock = ValueNotifier<double>(0);+ late final Ticker _ticker = createTicker(+ (elapsed) => _clock.value = elapsed.inMicroseconds / 1e6,+ );++ late _Look _from = _Look.of(widget.enterFrom ?? widget.scene);+ late _Look _to = _Look.of(widget.scene);+ bool _still = false;++ static const _blendLength = Duration(milliseconds: 400);+ static const _stillBlendLength = Duration(milliseconds: 200);++ @override+ void initState() {+ super.initState();+ if (widget.enterFrom case final from? when from != widget.scene) {+ _blend.forward(from: 0);+ }+ }++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ _still = MediaQuery.maybeDisableAnimationsOf(context) ?? false;+ _blend.duration = _still ? _stillBlendLength : _blendLength;+ if (_still) {+ if (_ticker.isActive) _ticker.stop();+ } else if (!_ticker.isActive) {+ _ticker.start();+ }+ }++ @override+ void didUpdateWidget(covariant OnboardingPicture oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.scene != widget.scene) {+ // From wherever it is now — a scene changed mid-ease does not jump back to its start.+ _from = _Look.lerp(_from, _to, _blend.value);+ _to = _Look.of(widget.scene);+ _blend.forward(from: 0);+ }+ }++ @override+ void dispose() {+ _ticker.dispose();+ _blend.dispose();+ _clock.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ final join = widget.join;+ return ExcludeSemantics(+ child: RepaintBoundary(+ child: CustomPaint(+ size: Size.infinite,+ painter: _PicturePainter(+ from: _from,+ to: _to,+ blend: _blend,+ clock: _clock,+ join: widget.scene == OnboardingScene.joined ? join : null,+ joined: widget.scene == OnboardingScene.joined,+ welcome: widget.scene == OnboardingScene.welcome,+ agent: widget.agent,+ still: _still,+ colors: _Colors.of(tty),+ text: tty.style(size: 9),+ ),+ ),+ ),+ );+ }+}++/// The picture's colours, from the terminal's own: its text for outlines, its green for what is+/// alive, its ground for the phone's body — so it is at home on Mist as on the dark default.+@immutable+class _Colors {+ const _Colors({+ required this.ink,+ required this.green,+ required this.packet,+ required this.ground,+ required this.dotted,+ });++ factory _Colors.of(Tty tty) => _Colors(+ ink: tty.text,+ green: tty.green,+ // A packet is the green at its brightest: lifted toward white on a dark ground, the green+ // itself on a light one, where lifting it would wash it out.+ packet: tty.isLight+ ? tty.green+ : Color.lerp(tty.green, Colors.white, 0.45)!,+ ground: tty.ground,+ dotted: tty.dim,+ );++ final Color ink;+ final Color green;+ final Color packet;+ final Color ground;+ final Color dotted;++ @override+ bool operator ==(Object other) =>+ other is _Colors &&+ other.ink == ink &&+ other.green == green &&+ other.packet == packet &&+ other.ground == ground &&+ other.dotted == dotted;++ @override+ int get hashCode => Object.hash(ink, green, packet, ground, dotted);+}++/// One scene's values, per computer — laptop, monitor, server — so two scenes ease into each other+/// by plain interpolation.+@immutable+class _Look {+ const _Look({+ required this.lit,+ required this.ghost,+ required this.link,+ required this.dotted,+ required this.breath,+ required this.rings,+ required this.phone,+ });++ /// 1: drawn solid, its screen green, its glow under it, its agent typing. 0: a dashed outline.+ final List<double> lit;++ /// The dashed outline's opacity, where it is not [lit].+ final List<double> ghost;++ /// The link to the phone, solid green.+ final List<double> link;++ /// The link to the phone, a grey dotted line: the way it would go.+ final List<double> dotted;++ /// How much the laptop's dashed outline breathes — looking for it.+ final double breath;++ /// The rings going out from the phone.+ final double rings;++ /// The phone brightened: its glow, screen and lines up.+ final double phone;++ static const welcome = _Look(+ lit: [1, 1, 1],+ ghost: [0, 0, 0],+ link: [1, 1, 1],+ dotted: [0, 0, 0],+ breath: 0,+ rings: 0,+ phone: 0,+ );++ static const looking = _Look(+ lit: [0, 0, 0],+ ghost: [.3, .3, .3],+ link: [0, 0, 0],+ dotted: [1, 1, 1],+ breath: 1,+ rings: 1,+ phone: 0,+ );++ static const joined = _Look(+ lit: [1, 0, 0],+ ghost: [0, .2, .2],+ link: [1, 0, 0],+ dotted: [0, 0, 0],+ breath: 0,+ rings: 0,+ phone: 1,+ );++ static _Look of(OnboardingScene scene) => switch (scene) {+ OnboardingScene.welcome => welcome,+ OnboardingScene.looking => looking,+ OnboardingScene.joined => joined,+ };++ static _Look lerp(_Look a, _Look b, double t) {+ if (t <= 0) return a;+ if (t >= 1) return b;+ List<double> each(List<double> x, List<double> y) => [+ for (var i = 0; i < x.length; i++) _mix(x[i], y[i], t),+ ];+ return _Look(+ lit: each(a.lit, b.lit),+ ghost: each(a.ghost, b.ghost),+ link: each(a.link, b.link),+ dotted: each(a.dotted, b.dotted),+ breath: _mix(a.breath, b.breath, t),+ rings: _mix(a.rings, b.rings, t),+ phone: _mix(a.phone, b.phone, t),+ );+ }+}++double _mix(double a, double b, double t) => a + (b - a) * t;++/// [value] from [start] to [end] as 0 → 1, held at either end.+double _span(double value, double start, double end) =>+ ((value - start) / (end - start)).clamp(0.0, 1.0);++/// The spec's grid, and everything drawn on it.+abstract final class _Grid {+ static const size = Size(320, 300);++ /// The phone's centre — where the rings start.+ static const phoneCentre = Offset(160, 157);++ static Path _box(double x, double y, double w, double h, double r) =>+ Path()..addRRect(RRect.fromLTRBR(x, y, x + w, y + h, Radius.circular(r)));++ /// Each computer's outline, its inner screen, and what it stands on — laptop, monitor, server.+ static final outlines = <List<Path>>[+ [+ _box(14, 22, 98, 64, 6),+ Path()+ ..moveTo(4, 90)+ ..relativeLineTo(118, 0)+ ..relativeLineTo(-8, 7)+ ..relativeLineTo(-102, 0)+ ..close(),+ ],+ [+ _box(208, 18, 98, 64, 6),+ Path()+ ..moveTo(257, 82)+ ..relativeLineTo(0, 12)+ ..moveTo(240, 96)+ ..relativeLineTo(34, 0),+ ],+ [+ _box(108, 232, 104, 23, 4),+ _box(108, 255, 104, 23, 4),+ Path()+ ..moveTo(118, 285)+ ..relativeLineTo(84, 0),+ ],+ ];++ /// The two screens, drawn at half the outline's ink and filled green when lit. The server has none.+ static final screens = <RRect?>[+ RRect.fromLTRBR(20, 28, 106, 80, const Radius.circular(3)),+ RRect.fromLTRBR(214, 24, 300, 76, const Radius.circular(3)),+ null,+ ];++ static final dashedOutlines = [+ for (final (i, paths) in outlines.indexed)+ _dash(+ [...paths, if (screens[i] case final s?) Path()..addRRect(s)],+ 3,+ 3,+ ),+ ];++ /// The glow each lit computer sits on: centre, radii, opacity.+ static const glows = <(Offset, double, double, double)>[+ (Offset(62, 100), 54, 8, .22),+ (Offset(257, 98), 48, 7, .18),+ (Offset(160, 288), 56, 7, .18),+ ];++ /// The server's two lights.+ static const lights = [Offset(200, 244), Offset(200, 266)];++ /// Each computer's link to the phone.+ static final links = <Path>[+ Path()+ ..moveTo(96, 98)+ ..quadraticBezierTo(120, 116, 136, 140),+ Path()+ ..moveTo(240, 98)+ ..quadraticBezierTo(204, 116, 184, 140),+ Path()+ ..moveTo(160, 232)+ ..lineTo(160, 206),+ ];++ /// Each link measured once, for the packets riding it every frame.+ static final linkMetrics = [+ for (final link in links) link.computeMetrics().first,+ ];++ static final dottedLinks = [+ for (final link in links) _dash([link], 1.2, 4),+ ];++ /// The faint lines between the computers: one account, every device seeing every other.+ static final between = _dash(+ [+ Path()+ ..moveTo(112, 50)+ ..lineTo(208, 48),+ Path()+ ..moveTo(60, 100)+ ..lineTo(132, 232),+ Path()+ ..moveTo(260, 98)+ ..lineTo(188, 232),+ ],+ 2,+ 5,+ );++ /// What each computer's agents type in the welcome: text, where its baseline starts, and whether+ /// the cursor follows it.+ static const typing = <List<(String, Offset, bool)>>[+ [('claude', Offset(26, 44), true), ('codex', Offset(26, 56), false)],+ [('opencode', Offset(219, 42), true)],+ [('codex', Offset(122, 247), true)],+ ];++ /// Where the joined laptop's agent types.+ static const joinedTyping = Offset(26, 44);++ static final phoneBody = RRect.fromLTRBR(+ 136,+ 110,+ 184,+ 204,+ const Radius.circular(10),+ );+ static final phoneScreen = RRect.fromLTRBR(+ 141,+ 119,+ 179,+ 193,+ const Radius.circular(5),+ );+ static final phoneNotch = RRect.fromLTRBR(+ 154,+ 113.5,+ 166,+ 116.5,+ const Radius.circular(1.5),+ );++ /// The phone's lines of text: their widths, from x 146, every 8 down from y 128.+ static const phoneLines = <double>[22, 16, 26, 12, 20];++ static Path _dash(List<Path> paths, double on, double off) {+ final out = Path();+ for (final path in paths) {+ for (final metric in path.computeMetrics()) {+ for (var d = 0.0; d < metric.length; d += on + off) {+ out.addPath(+ metric.extractPath(d, math.min(d + on, metric.length)),+ Offset.zero,+ );+ }+ }+ }+ return out;+ }+}++class _PicturePainter extends CustomPainter {+ _PicturePainter({+ required this.from,+ required this.to,+ required this.blend,+ required this.clock,+ required this.join,+ required this.joined,+ required this.welcome,+ required this.agent,+ required this.still,+ required this.colors,+ required this.text,+ }) : super(repaint: Listenable.merge([blend, clock, ?join]));++ final _Look from;+ final _Look to;+ final Animation<double> blend;+ final ValueNotifier<double> clock;+ final Animation<double>? join;+ final bool joined;+ final bool welcome;+ final String? agent;+ final bool still;+ final _Colors colors;+ final TextStyle text;++ static const _stroke = 1.5;++ @override+ void paint(Canvas canvas, Size size) {+ final scale = math.min(+ size.width / _Grid.size.width,+ size.height / _Grid.size.height,+ );+ if (scale <= 0 || !scale.isFinite) return;+ canvas+ ..save()+ ..translate(+ (size.width - _Grid.size.width * scale) / 2,+ (size.height - _Grid.size.height * scale) / 2,+ )+ ..scale(scale);++ final t = clock.value;+ final look = _Look.lerp(from, to, blend.value);+ // The join, in milliseconds; settled (all of it done) when nothing drives it.+ final ms = joined ? (join?.value ?? 1) * 1000 : double.infinity;+ final driven = joined && join != null;++ // The laptop's own values while it joins come from the join's beats, not the ease: its outline+ // and link DRAW themselves. Anything else that changes — a scene easing into another — fades.+ // Under Reduce Motion the join is a fade too: everything of the laptop's comes up together, in+ // 200ms, as its screen lights.+ final fadeIn = _span(ms, 600, 800);+ final outline = driven && !still ? _span(ms, 0, 350) : 1.0;+ final laptopSolid = !driven ? look.lit[0] : (still ? fadeIn : 1.0);+ final linkDrawn = driven && !still ? _span(ms, 350, 600) : 1.0;+ final linkAlpha = !driven ? look.link[0] : (still ? fadeIn : 1.0);+ final screenLit = !driven+ ? look.lit[0]+ : (still ? fadeIn : _span(ms, 600, 750));+ final phone = driven ? _span(ms, 800, 1000) : look.phone;++ _paintBetween(canvas);+ if (!still) _paintRings(canvas, look.rings, t);++ for (var i = 0; i < 3; i++) {+ _paintLink(+ canvas,+ i,+ drawn: i == 0 ? linkDrawn : 1,+ alpha: i == 0 ? linkAlpha : look.link[i],+ dotted: look.dotted[i],+ );+ }+ if (!still) _paintPackets(canvas, look, t, ms, driven: driven);++ for (var i = 0; i < 3; i++) {+ var ghost = look.ghost[i];+ if (i == 0 && look.breath > 0) {+ // Looking: the laptop breathes, .25 ↔ .6 every 2.4s — held at its peak when still.+ final wave = still ? 1.0 : (1 - math.cos(t / 2.4 * 2 * math.pi)) / 2;+ ghost = _mix(ghost, .25 + .35 * wave, look.breath);+ }+ if (i == 0 && driven) {+ // The dashed laptop gives way to the solid one as it draws — or fades in.+ ghost = math.max(ghost, .3 * (1 - (still ? laptopSolid : outline)));+ }+ _paintComputer(+ canvas,+ i,+ drawn: i == 0 ? outline : 1,+ solid: i == 0 ? laptopSolid : look.lit[i],+ lit: i == 0 ? screenLit : look.lit[i],+ ghost: ghost,+ );+ }+ _paintTyping(canvas, look, t, ms, laptop: screenLit);+ _paintPhone(canvas, phone);+ canvas.restore();+ }++ void _paintBetween(Canvas canvas) {+ canvas.drawPath(+ _Grid.between,+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.2+ ..color = colors.ink.withValues(alpha: .07),+ );+ }++ /// Three rings out from the phone, 2.4s each, a third apart.+ void _paintRings(Canvas canvas, double rings, double t) {+ if (rings <= 0) return;+ for (var k = 0; k < 3; k++) {+ final p = ((t - k * .8) % 2.4) / 2.4;+ if (t < k * .8) continue;+ canvas.drawCircle(+ _Grid.phoneCentre,+ _mix(8, 120, p),+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.2+ ..color = colors.green.withValues(alpha: .55 * (1 - p) * rings),+ );+ }+ }++ /// A link to the phone: [drawn] is how much of it has drawn itself (the join), [alpha] how much+ /// of it is there at all (a scene easing in or out).+ void _paintLink(+ Canvas canvas,+ int i, {+ required double drawn,+ required double alpha,+ required double dotted,+ }) {+ if (dotted > 0) {+ canvas.drawPath(+ _Grid.dottedLinks[i],+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.4+ ..strokeCap = StrokeCap.round+ ..color = colors.dotted.withValues(alpha: dotted),+ );+ }+ if (drawn > 0 && alpha > 0) {+ canvas.drawPath(+ _part(_Grid.links[i], drawn),+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.6+ ..strokeCap = StrokeCap.round+ ..color = colors.green.withValues(alpha: .45 * alpha),+ );+ }+ }++ /// The packets running down the links. In the welcome, one on each link every 1.4s, out for the+ /// first half and gone for the second, a third of a beat apart. Joined, one after another down the+ /// laptop's link every 0.7s — and while it joins, the first one leaves as the screen lights and+ /// lands as the phone brightens.+ void _paintPackets(+ Canvas canvas,+ _Look look,+ double t,+ double ms, {+ required bool driven,+ }) {+ if (welcome) {+ const begins = [0.0, .47, .93];+ for (var i = 0; i < 3; i++) {+ if (look.link[i] < 1 || t < begins[i]) continue;+ final p = ((t - begins[i]) % 1.4) / 1.4;+ if (p >= .5) continue;+ _packet(canvas, i, p / .5, look.lit[i]);+ }+ return;+ }+ if (!joined) return;+ if (driven && ms < 800) {+ if (ms >= 600) _packet(canvas, 0, _span(ms, 600, 800), 1);+ return;+ }+ _packet(canvas, 0, (t % .7) / .7, look.link[0]);+ }++ void _packet(Canvas canvas, int link, double along, double alpha) {+ if (alpha <= 0) return;+ final metric = _Grid.linkMetrics[link];+ final at = metric.getTangentForOffset(metric.length * along)?.position;+ if (at == null) return;+ canvas+ ..drawCircle(+ at,+ 4.2,+ Paint()+ ..color = colors.packet.withValues(alpha: .55 * alpha)+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 1.6),+ )+ ..drawCircle(+ at,+ 2.6,+ Paint()..color = colors.packet.withValues(alpha: alpha),+ );+ }++ /// A computer: [drawn] is how much of its solid outline has drawn itself (the join), [solid] how+ /// much of that outline is there (a scene easing), [lit] its screen, glow and lights, [ghost] its+ /// dashed outline.+ void _paintComputer(+ Canvas canvas,+ int i, {+ required double drawn,+ required double solid,+ required double lit,+ required double ghost,+ }) {+ final (centre, rx, ry, glow) = _Grid.glows[i];+ if (lit > 0) {+ canvas.drawOval(+ Rect.fromCenter(center: centre, width: rx * 2, height: ry * 2),+ Paint()+ ..color = colors.green.withValues(alpha: glow * lit)+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 6),+ );+ }+ if (ghost > 0) {+ canvas.drawPath(+ _Grid.dashedOutlines[i],+ _line(colors.ink.withValues(alpha: ghost)),+ );+ }+ if (drawn > 0 && solid > 0) {+ final ink = _line(colors.ink.withValues(alpha: solid));+ for (final path in _Grid.outlines[i]) {+ canvas.drawPath(_part(path, drawn), ink);+ }+ if (_Grid.screens[i] case final screen?) {+ canvas.drawPath(+ _part(Path()..addRRect(screen), drawn),+ _line(colors.ink.withValues(alpha: .5 * solid)),+ );+ }+ }+ if (lit > 0) {+ if (_Grid.screens[i] case final screen?) {+ canvas.drawRRect(+ screen,+ Paint()..color = colors.green.withValues(alpha: .10 * lit),+ );+ }+ if (i == 2) {+ for (final light in _Grid.lights) {+ canvas.drawCircle(+ light,+ 1.7,+ Paint()..color = colors.green.withValues(alpha: lit),+ );+ }+ }+ }+ }++ /// The agents typing — on all three in the welcome, on the laptop once it has joined (from the+ /// join's 800ms), each line ending in the blinking block cursor.+ void _paintTyping(+ Canvas canvas,+ _Look look,+ double t,+ double ms, {+ required double laptop,+ }) {+ final blinkOn = still || (t % 1) < .5;+ void type(String word, Offset baseline, bool cursor, double alpha) {+ if (alpha <= 0) return;+ final green = colors.green.withValues(alpha: alpha);+ var end = baseline.dx;+ if (word.isNotEmpty) {+ final painter = TextPainter(+ text: TextSpan(+ text: word,+ style: text.copyWith(color: green),+ ),+ textDirection: TextDirection.ltr,+ )..layout();+ final ascent = painter.computeDistanceToActualBaseline(+ TextBaseline.alphabetic,+ );+ painter.paint(canvas, baseline - Offset(0, ascent));+ end += painter.width + 1.8;+ painter.dispose();+ } else {+ end += 1.5;+ }+ if (cursor && blinkOn) {+ canvas.drawRect(+ Rect.fromLTWH(end, baseline.dy - 7, 4.6, 8),+ Paint()..color = green,+ );+ }+ }++ if (joined) {+ final shown = ms >= 800 ? (agent ?? '') : '';+ type(shown, _Grid.joinedTyping, true, laptop);+ return;+ }+ for (var i = 0; i < 3; i++) {+ for (final (word, baseline, cursor) in _Grid.typing[i]) {+ type(word, baseline, cursor, look.lit[i]);+ }+ }+ }++ void _paintPhone(Canvas canvas, double phone) {+ canvas+ ..drawOval(+ Rect.fromCenter(center: const Offset(160, 206), width: 68, height: 12),+ Paint()+ ..color = colors.green.withValues(alpha: _mix(.14, .28, phone))+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 6),+ )+ ..drawRRect(_Grid.phoneBody, Paint()..color = colors.ground)+ ..drawRRect(+ _Grid.phoneBody,+ Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = 1.6+ ..color = colors.ink,+ )+ ..drawRRect(+ _Grid.phoneScreen,+ Paint()..color = colors.green.withValues(alpha: _mix(.05, .10, phone)),+ )+ ..drawRRect(+ _Grid.phoneNotch,+ Paint()..color = colors.ink.withValues(alpha: .6),+ );+ final line = Paint()+ ..color = colors.green.withValues(alpha: _mix(.85, 1, phone));+ for (final (k, width) in _Grid.phoneLines.indexed) {+ canvas.drawRRect(+ RRect.fromLTRBR(+ 146,+ 128 + k * 8.0,+ 146 + width,+ 130.4 + k * 8.0,+ const Radius.circular(1.2),+ ),+ line,+ );+ }+ }++ static Paint _line(Color color) => Paint()+ ..style = PaintingStyle.stroke+ ..strokeWidth = _stroke+ ..strokeCap = StrokeCap.round+ ..strokeJoin = StrokeJoin.round+ ..color = color;++ /// The first [fraction] of each of [path]'s strokes — every stroke drawing itself at once.+ static Path _part(Path path, double fraction) {+ if (fraction >= 1) return path;+ final out = Path();+ for (final metric in path.computeMetrics()) {+ out.addPath(metric.extractPath(0, metric.length * fraction), Offset.zero);+ }+ return out;+ }++ @override+ bool shouldRepaint(covariant _PicturePainter old) =>+ old.from != from ||+ old.to != to ||+ old.blend != blend ||+ old.clock != clock ||+ old.join != join ||+ old.joined != joined ||+ old.welcome != welcome ||+ old.agent != agent ||+ old.still != still ||+ old.colors != colors ||+ old.text != text;+}diff --git a/mobile/lib/phone/welcome/phone_welcome.dart b/mobile/lib/phone/welcome/phone_welcome.dartindex c6121d07b..b3d28eb30 100644--- a/mobile/lib/phone/welcome/phone_welcome.dart+++ b/mobile/lib/phone/welcome/phone_welcome.dart@@ -1,7 +1,6 @@import 'dart:async';import 'package:flutter/material.dart';-import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';import 'package:harness_mobile/auth/sign_in_provider.dart';@@ -9,71 +8,63 @@ import 'package:harness_mobile/shared/theme/app_theme.dart';import 'package:harness_mobile/state/app_state.dart';import '../exit_app.dart';-import '../phone_sheet.dart' show phoneSheetRoute;import '../tty.dart';import '../tty_controls.dart';-import 'connect_code.dart';-import 'scan_to_connect.dart';-import 'set_up_computer.dart';+import 'email_sign_in.dart';+import 'onboarding_copy.dart';+import 'onboarding_frame.dart';+import 'onboarding_picture.dart';import 'sign_in_provider_button.dart';-/// The phone's first screen, signed out: Connect your computer ([SetUpComputerPage]) — one button,-/// Connect computer, and Get it for somebody with no Harness on the computer yet ([GetHarnessPage]).+/// The phone's first screen, signed out: ① Welcome — the promise, and signing in right there.////// ```-/// harness▌-/// Your agents in your pocket.-/// [ ⊞ Connect computer ] → the camera → Can’t scan? Sign in another way (a sheet)-/// ① Open Harness on your computer-/// Don’t have it? Get it › → Get it → Installed? Connect computer ›-/// Try the sample while you wait-/// ② Sign in on your computer ③ Click Add Phone+///+/// Manage all your agents on all+/// your computers from your phone.+///+/// ┌─────────────────────┐+/// │ three computers, │ everything lit: agents typing, packets running to the phone+/// │ all lit, a phone │+/// └─────────────────────┘+///+/// [ G Continue with Google ]+/// [ Continue with Apple ]+/// Continue with email → Your email → Check your email/// ```///-/// **Connect computer** scans the code the desktop app shows ([ScanToConnectPage]), and the scan signs-/// the phone in: the QR carries a one-time code the computer's own sign-in minted-/// ([AppNotifier.signInWithScan]). A QR without one — an older computer — or one that has expired-/// names the account instead: the email is filled in and its code sent, so signing in is the four-/// digits (`viewer/email_code_api.dart`, no browser).+/// Signing in is all there is to do here, and it moves on by itself: signed in, the app swaps this+/// for home, which says "On your computer, go to" when the account has no computer yet and opens+/// the computer's session when it has one (`docs/research/2026-10-11-phone-onboarding`, agreed with+/// the owner 2026-10-12).///-/// The accounts — Google, Apple, an emailed code — are in a sheet behind the camera's "Can’t scan?"-/// ([_OtherWaysSheet]): the way in for a computer with only the command line, which shows no code,-/// or a phone that cannot scan — found out there, at the camera, not from a gear on the first screen-/// that read as Settings (owner, 2026-10-09). ⚠️ They used to share the first screen with "Is-/// Harness on your computer? Yes / Not yet": six ways on before anything was explained (owner,-/// 2026-10-08).+/// ⚠️ **Google first, and nothing else on the screen** (owner, 2026-10-12): no camera, no sample, no+/// "Is Harness on your computer?", no tips. The QR the desktop shows only gets the app now — the+/// account does the rest, its device key log making every computer signed in to it trust this phone+/// — so the camera this screen used to open on (2026-10-09) has nothing left to read here.+///+/// ⚠️ **The foot never changes height.** While an account's page is up, the quiet line under the+/// buttons becomes Cancel; why it did not finish is said under the picture — so the picture, in+/// the same place on every onboarding screen ([OnboardingFrame]), never moves for it.class PhoneWelcome extends StatefulWidget {const PhoneWelcome({super.key,required this.notifier,- this.onTrySample,this.sendCode,this.signIn,- this.signInWithScan,- this.scanCamera,});- /// Stands in for the camera on the scan page, in tests and renders. Null opens the real one.- final Widget? scanCamera;-final AppNotifier notifier;/// Stand-ins for the account service, for tests and renders. Null uses [notifier]'s.final Future<void> Function(String email)? sendCode;final Future<void> Function(String email, String code)? signIn;- final Future<void> Function(String code)? signInWithScan;-- /// Opens the offline sample; completes when it is left, with `'set-up'` when it was left to set- /// up a real computer. Null leaves the way out.- final Future<Object?> Function(BuildContext context)? onTrySample;@overrideState<PhoneWelcome> createState() => _PhoneWelcomeState();}-/// [getIt]: Harness onto the computer ([GetHarnessPage]). [signInFirst]: a computer's own sign-in-/// QR was scanned — see [_SignInPage].-enum _Step { hello, getIt, scan, signInFirst, email, code }+enum _Step { hello, email, code }class _PhoneWelcomeState extends State<PhoneWelcome> {_Step _step = _Step.hello;@@ -84,20 +75,6 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {String? _sentTo;bool _busy = false;- /// Between a scan and the session it signs in: the scan page says so.- bool _signingInWithScan = false;-- /// Where the camera was opened from — Connect computer on the first screen, or on Get it — and so- /// where back from it goes ([_backFrom]).- _Step _scanFrom = _Step.hello;-- /// Where the email was chosen from — the other ways' sheet over the first screen or the camera,- /// or a scan that could not sign in by itself — and so where back from it goes.- _Step _emailFrom = _Step.hello;-- /// The other ways to sign in, while their sheet is up — see [_openOtherWays].- ModalBottomSheetRoute<void>? _otherWays;-String? _error;int _resendIn = 0;Timer? _resendTimer;@@ -107,18 +84,6 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {@overridevoid dispose() {- // ⚠️ **The sheet can outlive the page.** Signed in from it, the app swaps this page for home,- // and the sheet — the root navigator's — stayed up over the agents. Taken away after this frame:- // a navigator is not to be changed while the tree is being torn down.- final sheet = _otherWays;- if (sheet != null) {- WidgetsBinding.instance.addPostFrameCallback((_) {- final navigator = sheet.navigator;- if (navigator != null && navigator.mounted && sheet.isActive) {- navigator.removeRoute(sheet);- }- });- }_resendTimer?.cancel();_email.dispose();_code.dispose();@@ -127,77 +92,8 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {super.dispose();}- /// The offline sample, offered on Get it while the computer installs. Its end card leads back.- Future<void> _trySample() async {- final result = await widget.onTrySample!(context);- if (!mounted || result != 'set-up') return;- _go(_Step.getIt);- }-- /// A code the desktop app showed. Its pairing code is held until its computer shows up, when the- /// phone pairs with it instead of asking for a password (`AppNotifier.pendingPairing`). Its- /// sign-in code signs the phone in there and then; without one, or when it has expired, the- /// account's email is filled in and a code sent, so signing in is the four digits.- ///- /// ⚠️ **Read under the other ways' sheet too.** The camera runs on beneath it, so a computer in- /// frame is read while Google's page may be waited on: the scan wins — the sheet goes, the account's- /// page is let go of and waited out ([_signInFree]) — or [AppNotifier.signInWithScan], which does- /// nothing while another sign-in is under way, dropped the code without a word, and the camera,- /// which reads one code, read nothing more.- Future<void> _onScanned(ConnectCode code) async {- _closeOtherWays();- final machineId = code.machineId, pairCode = code.pairCode;- if (machineId != null && pairCode != null) {- widget.notifier.pendingPairing = (machineId: machineId, code: pairCode);- }- _email.text = code.email;- // Past the account's page and its exchange, that sign-in is going in: the code's computer is held- // for it ([AppNotifier.pendingPairing]), and that is all there is left to do with the scan.- if (_entering) return;- final signIn = code.signIn;- if (signIn != null) {- setState(() => _signingInWithScan = true);- try {- if (!await _signInFree()) {- throw StateError('Another sign-in is under way');- }- if (!mounted) return;- await (widget.signInWithScan ?? widget.notifier.signInWithScan)(signIn);- return;- } catch (_) {- // Expired, spent, or a backend that predates it: the email is the way on.- } finally {- if (mounted) setState(() => _signingInWithScan = false);- }- if (!mounted) return;- }- unawaited(_emailCodeFromScan());- }-- /// The scan could not sign the phone in by itself — an older computer's QR has no sign-in code,- /// and one that has may be spent or expired — so the email in it is sent a code instead.- ///- /// The code step says only where the code went (owner, 2026-10-08: little text). And when even the- /// email cannot go — the address in the QR does not pass, the network is down — the email step- /// takes over, with the reason under its field and the address there to correct. ⚠️ Left on the scan page, as it used- /// to be, the failure was said nowhere (that page shows no errors) and its camera, which stops- /// reading after one code, read nothing more: a screen that looked alive and did nothing.- Future<void> _emailCodeFromScan() async {- // Gone from the camera while the scan's own sign-in was tried: the person chose another way.- if (_step != _Step.scan) return;- // The scan page goes on saying "Signing in…" while the code is sent — it is the same sign-in,- // and the page's own title back for that second read as the scan having been dropped.- setState(() => _signingInWithScan = true);- final sent = await _sendCode();- if (!mounted) return;- setState(() => _signingInWithScan = false);- // Left meanwhile for another way in: its failure is not the screen's to take over.- if (sent || _step != _Step.scan) return;- _go(_Step.email, error: _error);- }-/// "Continue with Google / Apple": the account's own sign-in page, in the app. Its failure is- /// said here, under the buttons; a cancel says nothing ([AppNotifier.signInWithProvider]).+ /// said under the picture; a cancel says nothing ([AppNotifier.signInWithProvider]).Future<void> _signInWith(SignInProvider provider) async {if (widget.notifier.signingIn) return;setState(() => _error = null);@@ -213,25 +109,8 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {/// it happened on.void _go(_Step step, {String? error}) {// Leaving for another way in takes the account's page with it: whatever it came back with- // would sign the phone in behind the step the person chose instead. Any step that is left — the- // accounts are offered over the first screen and the camera ([_OtherWaysSheet]) and on- // [_SignInPage].+ // would sign the phone in behind the step the person chose instead.if (step != _step) widget.notifier.cancelProviderSignIn();- // A computer's sign-in code is held only on the way to the sign-in it asked for — its own step,- // and the email and code it may send the person to. Back at the start, at Get it or at the- // camera, it is let go: a sign-in from there must not end in a computer to approve.- if (step == _Step.hello || step == _Step.getIt || step == _Step.scan) {- widget.notifier.pendingComputerSignIn = null;- }- // Where the camera and the email were opened from is where back from them goes. Back from the- // computer's own sign-in step ([_SignInPage]) returns to the camera, which still goes back where- // it was first opened from.- if (step == _Step.scan && (_step == _Step.hello || _step == _Step.getIt)) {- _scanFrom = _step;- }- if (step == _Step.email && (_step == _Step.hello || _step == _Step.scan)) {- _emailFrom = _step;- }setState(() {_step = step;_error = error;@@ -262,9 +141,8 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {_sentTo = email;_code.clear();_startResend();- // ⚠️ On from the step it was sent from only. Back pressed while it went — from the scan page's- // "Signing in…", say — had the first screen jump to "Check your email" a second later, under- // somebody who had just left the email way behind.+ // ⚠️ On from the step it was sent from only: back pressed while it went must not have the+ // first screen jump to "Check your email" a second later.if (_step == from) _go(_Step.code);return true;}@@ -320,106 +198,18 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {/// Where back goes from [step] — the system's back and each page's own `‹ Back` alike._Step _backFrom(_Step step) => switch (step) {_Step.code => _Step.email,- _Step.email => _forComputer ? _Step.signInFirst : _emailFrom,- _Step.signInFirst => _Step.scan,- _Step.scan => _scanFrom,_ => _Step.hello,};- /// A computer's sign-in code is waiting on this sign-in ([AppNotifier.pendingComputerSignIn]).- bool get _forComputer => widget.notifier.pendingComputerSignIn != null;-- /// An account's sign-in is past its page and the exchange: the phone is going in, and there is- /// nothing left to cancel.- bool get _entering =>- widget.notifier.signingIn &&- widget.notifier.status == AppStatus.bootstrapping;-- /// Waits, briefly, for a sign-in already under way to let go — an account's page just cancelled —- /// so the scan's own finds the way clear. False when it did not.- Future<bool> _signInFree() async {- final notifier = widget.notifier;- if (!notifier.signingIn) return true;- final free = Completer<void>();- void check() {- if (!notifier.signingIn && !free.isCompleted) free.complete();- }-- notifier.addListener(check);- try {- await free.future.timeout(const Duration(seconds: 3));- return true;- } on TimeoutException {- return false;- } finally {- notifier.removeListener(check);- }- }-- /// Takes the other ways' sheet down when a code read under it starts a sign-in of its own, and- /// lets go of an account's page still waited on in it.- void _closeOtherWays() {- final sheet = _otherWays;- if (sheet == null) return;- final navigator = sheet.navigator;- if (navigator != null && navigator.mounted && sheet.isActive) {- if (sheet.isCurrent) {- navigator.pop();- } else {- navigator.removeRoute(sheet);- }- }- _otherWays = null;- if (widget.notifier.signInProvider != null && !_entering) {- widget.notifier.cancelProviderSignIn();- }- }-- /// The other ways to sign in — Google, Apple, an emailed code — in a sheet over the camera, from- /// its "Can’t scan?". One at a time.- Future<void> _openOtherWays() async {- if (_otherWays != null) return;- final notifier = widget.notifier;- final sheet = phoneSheetRoute<void>(- context,- builder: (sheetContext) => SafeArea(- child: _OtherWaysSheet(- notifier: notifier,- onEmail: () {- Navigator.of(sheetContext).pop();- _go(_Step.email);- },- ),- ),- );- _otherWays = sheet;- try {- await Navigator.of(context, rootNavigator: true).push(sheet);- } finally {- // Only its own: taken down by [_closeOtherWays], a sheet opened since may be the one up now.- if (identical(_otherWays, sheet)) _otherWays = null;- }- // Put away while an account's page was up: that sign-in goes with it, as it does when any- // step is left ([_go]). Past the page, the phone is already going in and there is nothing to- // cancel. Not when another sheet is up by now — its page is that one's.- if (!mounted || _otherWays != null || notifier.signInProvider == null) {- return;- }- if (!_entering) notifier.cancelProviderSignIn();- }-@overrideWidget build(BuildContext context) {AppTheme.watch(context);final tty = Tty.of(context);- final signingIn = widget.notifier.signingIn;+ final notifier = widget.notifier;+ final signingIn = notifier.signingIn;// Past the page and the exchange, the session is saved and the machines are on their way:// nothing is waited on in the browser any more, and nothing to cancel.- final entering =- signingIn && widget.notifier.status == AppStatus.bootstrapping;- final onProvider = signingIn- ? null- : (SignInProvider provider) => unawaited(_signInWith(provider));+ final entering = signingIn && notifier.status == AppStatus.bootstrapping;return PopScope(// The first screen lets the press go to the system — except on Android, which asks before// the app is left ([confirmExitApp]) and so keeps it here too.@@ -436,53 +226,26 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {backgroundColor: tty.ground,body: SafeArea(child: switch (_step) {- _Step.hello => SetUpComputerPage(- onScan: () => _go(_Step.scan),- onGetIt: () => _go(_Step.getIt),- status: switch (widget.notifier.signedOutReason) {- final reason? => _SignedOutNotice(reason: reason),- null => null,+ _Step.hello => OnboardingFrame(+ headline: OnboardingCopy.welcome,+ headlineKey: const ValueKey('welcome-headline'),+ picture: const OnboardingPicture(scene: OnboardingScene.welcome),+ status: switch ((_error, notifier.signedOutReason)) {+ (final error?, _) => _Said(error, error: true),+ (null, final reason?) => _Said(reason),+ _ => null,},+ actions: _Accounts(+ onProvider: signingIn+ ? null+ : (provider) => unawaited(_signInWith(provider)),+ waitingOn: notifier.signInProvider,+ entering: entering,+ onCancel: notifier.cancelProviderSignIn,+ onEmail: () => _go(_Step.email),+ ),),- _Step.getIt => GetHarnessPage(- onBack: () => _go(_Step.hello),- onPair: () => _go(_Step.scan),- onTrySample: widget.onTrySample == null- ? null- : () => unawaited(_trySample()),- ),- _Step.scan => ScanToConnectPage(- camera: widget.scanCamera,- onCode: (code) => unawaited(_onScanned(code)),- // Taken, not ignored: a phone pointed at a computer's sign-in QR has a person behind it- // who chose "Scan with your phone" there — nothing happening was all they used to get.- // Held for the sign-in this phone needs before it can approve that computer.- onSignInCode: (code) {- // Read under the other ways' sheet, it does not open its step beneath it.- _closeOtherWays();- widget.notifier.pendingComputerSignIn = code.code;- _go(_Step.signInFirst);- },- signingIn: _signingInWithScan,- // The way in without a camera, or for a computer with no code to show: the accounts.- fallbackLabel: 'Can’t scan? Sign in another way',- onUseEmail: () => unawaited(_openOtherWays()),- onBack: () => _go(_backFrom(_Step.scan)),- ),- _Step.signInFirst => _SignInPage(- titleKey: const ValueKey('welcome-sign-in-first'),- onBack: () => _go(_backFrom(_Step.signInFirst)),- title: 'Sign in on this phone first',- lines: const ['Sign in here, then approve your computer.'],- emailLabel: 'Use email instead',- onProvider: onProvider,- waitingOn: widget.notifier.signInProvider,- entering: entering,- onCancel: widget.notifier.cancelProviderSignIn,- onUseEmail: () => _go(_Step.email),- error: _error,- ),- _Step.email => _Form(+ _Step.email => SignInForm(onBack: () => _go(_backFrom(_Step.email)),title: 'Your email',lines: const ['We’ll send you a $_codeLength-digit code.'],@@ -504,13 +267,13 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {onPressed: _sendCode,),),- _Step.code => _Form(+ _Step.code => SignInForm(onBack: () => _go(_Step.email),title: 'Check your email',lines: ['We sent a $_codeLength-digit code to ${_sentTo ?? 'your email'}.',],- field: _CodeField(+ field: SignInCodeField(controller: _code,focus: _codeFocus,length: _codeLength,@@ -555,35 +318,34 @@ class _PhoneWelcomeState extends State<PhoneWelcome> {}}-/// The two accounts the desktop and web sign in with ([SignInProviderButton]), and what goes with-/// them while one is waited on: its button saying so, Cancel under it, and why the last one did not-/// finish. On both [_SignInPage]s.-class _ProviderSignIn extends StatelessWidget {- const _ProviderSignIn({+/// The welcome's foot: Google, then Apple ([SignInProviderButton]), and the quiet line under them —+/// "Continue with email", or Cancel while an account's page is up. One slot for both, so the foot+/// is the same height whatever it says.+class _Accounts extends StatelessWidget {+ const _Accounts({required this.onProvider,required this.onCancel,+ required this.onEmail,this.waitingOn,this.entering = false,- this.error,});/// "Continue with …" pressed. Null while any sign-in is in flight, which both buttons wait out.final ValueChanged<SignInProvider>? onProvider;- /// The account whose page is up — its button says so, and [onCancel] is offered under it.+ /// The account whose page is up — its button says so, and Cancel takes the quiet line.final SignInProvider? waitingOn;/// The page is done with and the phone is going in: the button says so, and there is nothing/// left to cancel.final bool entering;final VoidCallback onCancel;-- /// Why the last account's sign-in did not finish.- final String? error;+ final VoidCallback onEmail;@overrideWidget build(BuildContext context) {final tty = Tty.of(context);+ final waiting = waitingOn != null && !entering;return Column(mainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.stretch,@@ -599,372 +361,69 @@ class _ProviderSignIn extends StatelessWidget {: null,),],- if (error case final error?)- Padding(- padding: const EdgeInsets.only(top: 10),- child: Text(- '✗ $error',- style: tty.style(size: TtySize.meta, color: tty.red),- ),- ),- if (waitingOn != null && !entering) ...[- const SizedBox(height: 4),- Center(- child: TtyTextButton(label: 'Cancel', onPressed: onCancel),- ),- ],- ],- );- }-}--/// A page of the accounts — Google, Apple ([_ProviderSignIn]) and an emailed code under them — with-/// back, a title and a line or two of why: **Sign in on this phone first** ([_Step.signInFirst]),-/// for a computer's own sign-in QR read by a phone that is not signed in — "Scan with your phone" on-/// the desktop app's sign-in sheet. Only a signed-in phone can approve that code, so this one signs-/// in first. The code is held meanwhile ([AppNotifier.pendingComputerSignIn]); once in, the phone-/// asks to approve the computer (`phone_shell.dart`), and the computer then asks its person to-/// confirm the account — this one.-///-/// ```-/// ‹ Back-/// Sign in on this phone first-/// Sign in here, then approve your computer.-///-/// [G Continue with Google]-/// [ Continue with Apple ]-/// Use email instead-/// ```-class _SignInPage extends StatelessWidget {- const _SignInPage({- required this.onBack,- required this.title,- required this.lines,- required this.emailLabel,- required this.onProvider,- required this.onCancel,- required this.onUseEmail,- this.titleKey,- this.waitingOn,- this.entering = false,- this.error,- });-- final VoidCallback onBack;- final String title;- final Key? titleKey;- final List<String> lines;-- /// The emailed code's way in, under the accounts.- final String emailLabel;- final ValueChanged<SignInProvider>? onProvider;- final VoidCallback onCancel;- final VoidCallback onUseEmail;- final SignInProvider? waitingOn;- final bool entering;- final String? error;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- final faint = tty.style(size: TtySize.row, color: tty.faint);- return Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Align(- alignment: Alignment.centerLeft,- child: TtyBackButton(onPressed: onBack),- ),- Expanded(- child: ListView(- padding: const EdgeInsets.fromLTRB(Tty.origin, 12, Tty.origin, 16),- children: [- // A Text and not a TtyText: at a large size the title wraps rather than being cut off.- Text(- title,- key: titleKey,- style: tty.style(size: 24, weight: FontWeight.w600),- ),- for (final (index, line) in lines.indexed) ...[- SizedBox(height: index == 0 ? 12 : 6),- Text(line, style: faint),- ],- const SizedBox(height: 24),- _ProviderSignIn(- onProvider: onProvider,- waitingOn: waitingOn,- entering: entering,- onCancel: onCancel,- error: error,- ),- const SizedBox(height: 8),- Center(- child: TtyTextButton(- label: emailLabel,+ Center(+ child: waiting+ ? TtyTextButton(+ key: const ValueKey('welcome-cancel'),+ label: 'Cancel',+ size: TtySize.meta,+ onPressed: onCancel,+ )+ : TtyTextButton(+ key: const ValueKey('welcome-email-way'),+ label: OnboardingCopy.continueWithEmail,+ size: TtySize.meta,color: tty.faint,- // Not while an account's page is up: the email would sign in behind it.- onPressed: onProvider == null ? null : onUseEmail,+ // Not while an account's page is up, or past it: the email would sign in+ // behind it.+ onPressed: onProvider == null ? null : onEmail,),- ),- ],- ),),],);}}-/// **Sign in another way**, in a sheet: Google, Apple ([_ProviderSignIn]) and an emailed code — for a-/// computer with only the command line, which shows no code, or a phone that cannot scan. Its own-/// sign-in, said in it: the account's page, waited on with Cancel, and why it did not finish.-///-/// ```-/// Sign in another way-/// Use the same account as your computer.-/// [G Continue with Google]-/// [ Continue with Apple ]-/// Continue with email-/// ```-class _OtherWaysSheet extends StatefulWidget {- const _OtherWaysSheet({required this.notifier, required this.onEmail});-- final AppNotifier notifier;-- /// "Continue with email": the sheet goes, and the email step comes.- final VoidCallback onEmail;-- @override- State<_OtherWaysSheet> createState() => _OtherWaysSheetState();-}--class _OtherWaysSheetState extends State<_OtherWaysSheet> {- /// Why the last account's sign-in did not finish; a cancel says nothing.- String? _error;-- Future<void> _signIn(SignInProvider provider) async {- final notifier = widget.notifier;- if (notifier.signingIn) return;- setState(() => _error = null);- try {- await notifier.signInWithProvider(provider);- } catch (e) {- if (!mounted) return;- setState(() => _error = _PhoneWelcomeState._plain(e.toString()));- }- }-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return ListenableBuilder(- listenable: widget.notifier,- builder: (context, _) {- final notifier = widget.notifier;- final signingIn = notifier.signingIn;- // Past the page and the exchange, the phone is going in: nothing to cancel any more.- final entering =- signingIn && notifier.status == AppStatus.bootstrapping;- return SingleChildScrollView(- padding: const EdgeInsets.fromLTRB(Tty.origin, 18, Tty.origin, 12),- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Text(- 'Sign in another way',- key: const ValueKey('welcome-other-ways-title'),- style: tty.style(size: TtySize.title, weight: FontWeight.w600),- ),- const SizedBox(height: 6),- Text(- 'Use the same account as your computer.',- style: tty- .style(color: tty.faint, size: TtySize.meta)- .copyWith(height: 1.5),- ),- const SizedBox(height: 16),- _ProviderSignIn(- onProvider: signingIn- ? null- : (provider) => unawaited(_signIn(provider)),- waitingOn: notifier.signInProvider,- entering: entering,- onCancel: notifier.cancelProviderSignIn,- error: _error,- ),- const SizedBox(height: 4),- Center(- child: TtyTextButton(- label: 'Continue with email',- // Not while an account's page is up: the email would sign in behind it.- onPressed: signingIn ? null : widget.onEmail,- ),- ),- ],- ),- );- },- );- }-}--/// Why a phone that was signed in is back on the welcome: a raised block under the title, the-/// sign-out mark in the terminal's yellow beside the sentence. Not the red of a sign-in's error — the-/// person did nothing wrong, and signing in again is the whole of what to do.-class _SignedOutNotice extends StatelessWidget {- const _SignedOutNotice({required this.reason});+/// A line under the picture, in the status line's place: why an account's sign-in did not finish+/// (the terminal's red ✗), or why a phone that was signed in is back here (the sign-out mark in its+/// yellow — not red: the person did nothing wrong, and signing in again is the whole of what to do).+class _Said extends StatelessWidget {+ const _Said(this.text, {this.error = false});- final String reason;+ final String text;+ final bool error;@overrideWidget build(BuildContext context) {final tty = Tty.of(context);+ final style = tty.style(size: OnboardingFrame.quietSize);return Semantics(liveRegion: true,- child: Container(- key: const ValueKey('welcome-signed-out'),- padding: const EdgeInsets.fromLTRB(14, 12, 14, 12),- decoration: BoxDecoration(- color: ttyRaised(tty),- borderRadius: BorderRadius.circular(10),- ),- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,+ child: Text.rich(+ key: ValueKey(error ? 'welcome-error' : 'welcome-signed-out'),+ TextSpan(children: [- Padding(- padding: const EdgeInsets.only(top: 1),- child: Icon(LucideIcons.logOut300, size: 16, color: tty.yellow),- ),- const SizedBox(width: 10),- Expanded(- child: Text(reason, style: tty.style(size: TtySize.row)),- ),- ],- ),- ),- );- }-}--/// One step of signing in: back, a title, a line or two, a field, the button.-class _Form extends StatelessWidget {- const _Form({- required this.onBack,- required this.title,- required this.lines,- required this.field,- required this.button,- this.error,- this.footer,- });-- final VoidCallback onBack;- final String title;- final List<String> lines;- final Widget field;- final Widget button;- final String? error;- final Widget? footer;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Align(- alignment: Alignment.centerLeft,- child: TtyBackButton(onPressed: onBack),- ),- Expanded(- child: ListView(- padding: const EdgeInsets.fromLTRB(Tty.origin, 12, Tty.origin, 16),- children: [- // A title that wraps: "Check your email" at 24pt is more than a 320pt phone holds at- // the largest text size, and a one-line TtyText cut it there.- Text(title, style: tty.style(size: 24, weight: FontWeight.w600)),- const SizedBox(height: 12),- for (final line in lines)- Padding(- padding: const EdgeInsets.only(bottom: 6),- child: Text(- line,- style: tty.style(size: TtySize.row, color: tty.faint),- ),- ),- const SizedBox(height: 18),- AutofillGroup(child: field),- if (error case final error?)- Padding(- padding: const EdgeInsets.only(top: 10),- child: Text(- '✗ $error',- style: tty.style(size: TtySize.meta, color: tty.red),+ if (error)+ const TextSpan(text: '✗ ')+ else+ WidgetSpan(+ alignment: PlaceholderAlignment.middle,+ child: Padding(+ padding: const EdgeInsets.only(right: 6),+ child: Icon(+ LucideIcons.logOut300,+ size: 14,+ color: tty.yellow,),),- const SizedBox(height: 16),- button,- ?footer,- ],- ),+ ),+ TextSpan(text: text),+ ],),- ],- );- }-}--/// The code, typed into one wide field in big mono digits — it submits itself on the last one.-class _CodeField extends StatelessWidget {- const _CodeField({- required this.controller,- required this.focus,- required this.length,- required this.onFilled,- });-- final TextEditingController controller;- final FocusNode focus;- final int length;- final VoidCallback onFilled;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Container(- height: 64,- decoration: BoxDecoration(- color: ttyRaised(tty),- borderRadius: BorderRadius.circular(6),- ),- alignment: Alignment.center,- child: TextField(- key: const Key('welcome-code'),- controller: controller,- focusNode: focus,- keyboardType: TextInputType.number,- autofillHints: const [AutofillHints.oneTimeCode],textAlign: TextAlign.center,- maxLength: length,- inputFormatters: [FilteringTextInputFormatter.digitsOnly],- cursorColor: tty.green,- style: tty- .style(size: 30, weight: FontWeight.w600)- .copyWith(letterSpacing: 18),- onChanged: (value) {- if (value.length == length) onFilled();- },- decoration: InputDecoration(- isCollapsed: true,- counterText: '',- filled: false,- border: InputBorder.none,- enabledBorder: InputBorder.none,- focusedBorder: InputBorder.none,- hintText: '•' * length,- hintStyle: tty- .style(size: 30, color: tty.dim)- .copyWith(letterSpacing: 18),- ),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: style.copyWith(color: error ? tty.red : tty.text),),);}diff --git a/mobile/lib/phone/welcome/scan_to_connect.dart b/mobile/lib/phone/welcome/scan_to_connect.dartindex 9a428dc7e..29b665eca 100644--- a/mobile/lib/phone/welcome/scan_to_connect.dart+++ b/mobile/lib/phone/welcome/scan_to_connect.dart@@ -36,9 +36,8 @@ const kAddPhoneWhere = 'Mac: Harness menu\nLinux: Ctrl+Shift+P → add phone';/// ```////// ⚠️ **Only the scan here (owner, 2026-10-08).** What has to happen on the computer first — get-/// Harness, open it, sign in, open Add Phone, and where that is — is the page this one is opened-/// from (`set_up_computer.dart`, Connect your computer): the camera at the top and its title are the-/// page. Centred in the room left, the camera had put every word at the foot of the screen under an+/// Harness, open it, sign in, open Add Phone, and where that is — is said by the page this one is+/// opened from, or under its title ([steps]): the camera at the top and its title are the page. Centred in the room left, the camera had put every word at the foot of the screen under an/// empty band.////// The camera runs only while this page is up. A code that is not ours is ignored, so a stray QR@@ -76,8 +75,8 @@ class ScanToConnectPage extends StatefulWidget {final String? step;/// Under the title, from the page's edge: the steps on the computer that bring the code up —- /// `ComputerSteps`, Set up another computer's own — for a camera opened where nothing has said- /// them (Computers' Connect computer). The square shrinks on a short screen to keep them on it,+ /// `ComputerSteps` — for a camera opened where nothing has said them (Computers' "Or scan the QR+ /// code on your computer"). The square shrinks on a short screen to keep them on it,/// and the page scrolls where even that is not enough.final Widget? steps;diff --git a/mobile/lib/phone/welcome/set_up_computer.dart b/mobile/lib/phone/welcome/set_up_computer.dartindex eb58429b5..7e89f2641 100644--- a/mobile/lib/phone/welcome/set_up_computer.dart+++ b/mobile/lib/phone/welcome/set_up_computer.dart@@ -1,455 +1,25 @@-import 'dart:async';-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';-import 'package:lucide_icons_flutter/lucide_icons.dart';-import 'package:share_plus/share_plus.dart';--import 'package:harness_mobile/shared/theme/app_theme.dart';import '../tty.dart';import '../tty_controls.dart';import 'scan_to_connect.dart' show kAddPhoneWhere;-/// Where Harness is downloaded: the website's download page, which offers each computer its own-/// file — the Mac's, Linux's, the command line's.-const kDesktopDownloadUrl = 'https://harness.autonomous.ai/desktop';--/// Where everything on Connect your computer starts, from either side: wider than the terminal's-/// [Tty.origin], since the page is read, top to bottom, not scanned.-const double _gutter = 20;--/// **Connect your computer** — the page a phone with no computer stands on: signed out (the first-/// screen, `phone_welcome.dart`), signed in to an account with none (`connect_computer.dart`), and-/// Computers ▸ Set up another computer. What Harness on a phone is for, one button, and the steps on-/// the computer — the first with the way for somebody who has no Harness there yet ([GetHarnessPage]).-///-/// ```-/// harness▌ (⚙ once signed in: Settings)-///-/// Your agents (from Computers: Set up another computer)-/// in your pocket.-/// See every session on your machines. Answer your agents from anywhere.-/// [status]-/// [ ⊞ Connect computer ]-///-/// ① Open Harness on your computer-/// │ Don’t have it? Get it ›-/// ② Sign in on your computer-/// │ With [email protected]. (signed in only: which account)-/// ③ Click Add Phone-/// Mac: Harness menu-/// Linux: Ctrl+Shift+P → add phone-/// ```-///-/// ⚠️ **One edge (owner, 2026-10-11).** Everything starts at [_gutter] — the wordmark, the words,-/// the button (the page's width) and the steps' numbers. The title, a 300-wide button and "No-/// Harness yet? Get it ›" used to be centred over steps that started at the edge, and the page read-/// as stepping in and out. The words are the desktop's, cut down (`setup_tour.dart`, "Your agents-/// in your pocket."): the page used to say "Harness" without ever saying what it was.-///-/// Nothing else on it, signed out: the other ways to sign in are the camera's "Can’t scan?", where-/// a computer with no code or a phone with no camera finds out it needs them, and the sample is-/// Get it's, for somebody waiting on the computer (owner, 2026-10-09).-///-/// Short on purpose (owner, 2026-10-08): a line under a step only where the step cannot be done-/// without it — where to get Harness, where Add Phone is, which account.-///-/// ⚠️ **One button, after Orca's (owner, 2026-10-08).** The first screen used to ask "Is Harness on-/// your computer?" — Yes to the camera, Not yet to a page of download rows, steps and a second scan —-/// beside Google and Apple: six ways on before anything was explained. Somebody who has Harness-/// presses Connect computer; somebody who has not follows Get it, and comes back to the same button.-class SetUpComputerPage extends StatelessWidget {- const SetUpComputerPage({- super.key,- required this.onScan,- required this.onGetIt,- this.onBack,- this.status,- this.account,- this.watching = false,- this.topTrailing,- this.scanStatus,- });-- /// Connect computer: the camera, for the code the computer's Add Phone shows — it pairs this phone- /// with it (and, signed out, signs it in).- final VoidCallback onScan;-- /// "No Harness yet? Get it ›" — [GetHarnessPage].- final VoidCallback onGetIt;-- /// Null draws the wordmark instead of a back button: the page is a home screen, not a pushed one.- final VoidCallback? onBack;-- /// Under the words, over the button: what is going on — the watch for the computer once signed- /// in, or why the phone was signed out.- final Widget? status;-- /// The account this phone is signed in to, when it is: the computer has to sign in to the same- /// one, and the first step says so by name.- final String? account;-- /// Whether the page is watching the account for the computer (signed in, at home): it then- /// shows up by itself, with no code.- final bool watching;-- /// At the right of the top row, across from the wordmark or `‹ Back` — Settings- /// (`PhoneSettingsButton`) once signed in.- final Widget? topTrailing;-- /// What the last scan came to — pairing, or why it did not — right under Connect computer, the- /// button that started it.- final Widget? scanStatus;-- /// The steps after the first (Harness on the computer, with Get it) — [_stepsAfterOpening], the- /// same signed in or out; only the line under signing in differs: none signed out, the account- /// signed in.- List<({String title, String? note})> get _nextSteps =>- _stepsAfterOpening(switch (account) {- null => null,- // At home the line over the button names the account already.- _ when watching => 'With the same account.',- // From Computers nothing above names it.- final account => 'With $account.',- });-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final next = _nextSteps;- // A tablet's width would stretch the button across the screen: a phone's column, centred.- return Center(- child: ConstrainedBox(- constraints: const BoxConstraints(maxWidth: 480),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- // One row whatever is in it: the back button's height, so the page starts at the same- // place with a back or the wordmark, a trailing control or none.- SizedBox(- height: 44,- child: Row(- children: [- if (onBack case final onBack?)- // Its chevron sits at the terminal's origin: over to the page's edge.- Padding(- padding: const EdgeInsets.only(- left: _gutter - Tty.origin,- ),- child: TtyBackButton(onPressed: onBack),- )- else- const Padding(- padding: EdgeInsets.only(left: _gutter),- child: _Wordmark(),- ),- const Spacer(),- ?topTrailing,- ],- ),- ),- Expanded(- child: ListView(- padding: const EdgeInsets.fromLTRB(_gutter, 36, _gutter, 28),- children: [- // From Computers the agents are on this phone already: the page is the row that- // was pressed.- if (onBack == null)- const _Hero(- title: 'Your agents\nin your pocket.',- body:- 'See every session on your machines. '- 'Answer your agents from anywhere.',- start: true,- )- else- const _Hero(title: 'Set up another computer', start: true),- if (status case final status?) ...[- const SizedBox(height: 18),- status,- ],- const SizedBox(height: 28),- TtyPrimaryButton(- key: const ValueKey('set-up-scan'),- icon: LucideIcons.qrCode300,- label: 'Connect computer',- onPressed: onScan,- ),- if (scanStatus case final scanStatus?) ...[- const SizedBox(height: 10),- scanStatus,- ],- const SizedBox(height: 36),- // Get it where Harness is first said: it used to be a line of its own under the- // steps, centred, for a question the first step raises.- _HowItWorksRow(- number: 1,- title: _openHarness,- link: _StepLink(- key: const ValueKey('set-up-get-it'),- lead: 'Don’t have it? ',- action: 'Get it ›',- onTap: onGetIt,- ),- ),- for (final (i, step) in next.indexed)- _HowItWorksRow(- number: i + 2,- title: step.title,- note: step.note,- last: i == next.length - 1,- ),- ],- ),- ),- ],- ),- ),- );- }-}--/// **Get it** — Harness onto the computer, from the phone: the download page's address, to type-/// into the computer's browser (a phone cannot install it), then back to Connect computer.+/// The steps on a computer that bring up its Add Phone QR code — for the camera opened from+/// Computers, which pairs with a desktop from before the onboarding of 2026-10-12.///-/// ```-/// ‹-/// Get Harness-/// on your computer-/// In your computer’s browser, go to:-/// ┌───────────────────────────────────┐-/// │ harness.autonomous.ai/desktop ⇪ │-/// └───────────────────────────────────┘-/// Or tap to send it with AirDrop or Messages.-///-/// ⋮-/// Installed? Connect computer › ← the foot of the screen: after the computer-/// Try the sample while you wait-/// ```-///-/// ⚠️ **The address is the page (owner, 2026-10-11).** It used to lead with "Send to my computer" —-/// the share sheet — over the address in small print, and somebody new did not know whom to send it-/// to. Typed, the address works on any computer. The share sheet is behind the address itself, for-/// AirDrop to a Mac beside you.-///-/// ⚠️ **But said, not left to be worked out (owner, 2026-10-12).** The title was "Open this on your-/// computer", with nothing between it and the address: it named neither what "this" was for nor-/// what to open it in, and somebody new read the address as a link to tap here. The title now says-/// what the page is for — Get it's own words — the line under it where, and a line under the-/// address what its glyph does, which nothing said either.-///-/// The page gives the website, not a file: it offers each computer its own download (Mac, Linux,-/// the command line), which a phone cannot tell apart.-class GetHarnessPage extends StatelessWidget {- const GetHarnessPage({- super.key,- required this.onBack,- required this.onPair,- this.onTrySample,- });-- final VoidCallback onBack;-- /// "Connect computer ›": the camera, the same as the button on [SetUpComputerPage].- final VoidCallback onPair;-- /// The offline sample — what Harness is like, for somebody waiting on the computer to install.- final VoidCallback? onTrySample;-- /// The share sheet with the download page: AirDrop to the Mac beside you, or Messages or email to- /// yourself, opened on the computer. Anchored to the address for iPad, where the sheet is a popover.- Future<void> _sendLink(BuildContext address) async {- final box = address.findRenderObject() as RenderBox?;- final origin = box == null || !box.attached- ? null- : box.localToGlobal(Offset.zero) & box.size;- try {- await SharePlus.instance.share(- ShareParams(- uri: Uri.parse(kDesktopDownloadUrl),- subject: 'Get Harness for your computer',- sharePositionOrigin: origin,- ),- );- } catch (_) {- // No share sheet came up: the address is still there to type, and can be pressed again.- }- }-- @override- Widget build(BuildContext context) {- AppTheme.watch(context);- final tty = Tty.of(context);- // What a tap on the address brings up, by its names here: there is no AirDrop off Apple.- final shareHint = Theme.of(context).platform == TargetPlatform.iOS- ? 'Or tap to send it with AirDrop or Messages.'- : 'Or tap to send it to yourself.';- // ⚠️ **One edge, the page it is opened from's (owner, 2026-10-12).** Connect your computer- // starts everything at [_gutter] — its title, the button across the page, the steps — and this- // page, centred at the terminal's origin, read as a different app one tap in. The same edge,- // the same headline, the address across the page as the button is, and a tablet's phone column.- return Center(- child: ConstrainedBox(- constraints: const BoxConstraints(maxWidth: 480),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Align(- alignment: Alignment.centerLeft,- // Its chevron sits at the terminal's origin: over to the page's edge, as on Connect- // your computer.- child: Padding(- padding: const EdgeInsets.only(left: _gutter - Tty.origin),- child: TtyBackButton(onPressed: onBack),- ),- ),- Expanded(- // The links at the foot of the screen, apart from the address: they are for after the- // computer, not now. A short screen scrolls instead.- child: LayoutBuilder(- builder: (context, box) => SingleChildScrollView(- child: ConstrainedBox(- constraints: BoxConstraints(- minHeight: box.hasBoundedHeight ? box.maxHeight : 0,- ),- child: IntrinsicHeight(- child: Padding(- padding: const EdgeInsets.fromLTRB(- _gutter,- 36,- _gutter,- 20,- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- // What the page is for, in Get it's words; then where the address- // goes. Broken by hand, as the first screen's title is.- const _Hero(- title: 'Get Harness\non your computer',- body: 'In your computer’s browser, go to:',- start: true,- ),- const SizedBox(height: 28),- Builder(- builder: (address) => _AddressCard(- key: const ValueKey('get-it-send'),- address: kDesktopDownloadUrl.replaceFirst(- 'https://',- '',- ),- onPressed: () => unawaited(_sendLink(address)),- ),- ),- const SizedBox(height: 10),- Text(- shareHint,- key: const ValueKey('get-it-share-hint'),- style: tty- .style(color: tty.faint, size: TtySize.meta)- .copyWith(height: 1.45),- ),- const Spacer(),- const SizedBox(height: 36),- // Nothing about signing in there: the desktop app asks for it itself,- // and opens Add Phone by itself once it is.- _TextLink(- key: const ValueKey('get-it-pair'),- lead: 'Installed? ',- action: 'Connect computer ›',- onTap: onPair,- ),- if (onTrySample case final onTrySample?)- _TextLink(- key: const ValueKey('get-it-sample'),- action: 'Try the sample while you wait',- onTap: onTrySample,- ),- ],- ),- ),- ),- ),- ),- ),- ),- ],- ),- ),- );- }-}--/// A page's title and the sentence under it, when it has one: centred, or from the page's edge-/// ([start]) — larger there, where it is the page's headline (Connect your computer).-class _Hero extends StatelessWidget {- const _Hero({required this.title, this.body, this.start = false});-- final String title;- final String? body;- final bool start;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- final align = start ? TextAlign.start : TextAlign.center;- return Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- Text(- title,- textAlign: align,- style: start- ? tty- .style(size: 28, weight: FontWeight.w700)- .copyWith(height: 1.2, letterSpacing: -0.8)- : tty- .style(size: 24, weight: FontWeight.w600)- .copyWith(height: 1.25, letterSpacing: -0.4),- ),- if (body case final body?) ...[- const SizedBox(height: 12),- Text(- body,- textAlign: align,- style: tty.style(color: tty.faint, size: 14).copyWith(height: 1.55),- ),- ],- ],- );- }-}--/// `harness▌`: the app's name and the terminal's cursor, where a home screen has no back.-class _Wordmark extends StatelessWidget {- const _Wordmark();-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Row(- mainAxisSize: MainAxisSize.min,- children: [- TtyText('harness', size: TtySize.row, weight: FontWeight.w600),- Container(- width: 8,- height: 16,- margin: const EdgeInsets.only(left: 2),- color: tty.green,- ),- ],- );- }-}+/// ⚠️ This file used to be **Connect your computer**, the page a phone with no computer stood on+/// (signed out, signed in with none, and Computers ▸ Set up another computer). The onboarding+/// replaced it (`docs/research/2026-10-11-phone-onboarding`): signed out, the welcome signs in+/// (`phone_welcome.dart`); with no computer, "On your computer, go to" (`your_computer.dart`). Only+/// the steps are left, for the camera's sake./// The first step on the computer, signed in or out.const _openHarness = 'Open Harness on your computer';/// The steps after [_openHarness]: sign in on the computer, then Add Phone and where it is.///-/// ⚠️ **One set, wherever they are shown (owner, 2026-10-12)** — the first screen, Set up another-/// computer, and Connect computer's camera from Computers. They used to be two: signed out "Click+/// ⚠️ **One set, wherever they are shown (owner, 2026-10-12)** — now only the camera's, from+/// Computers. They used to be two: signed out "Click/// Add Phone ③ Scan the QR code", signed in "Sign in on your computer ③ Not showing up? Click Add/// Phone" — one button on one page, and steps that changed under it, and on the camera "Not showing/// up?" was asked of somebody already scanning. Both halves hold either way: Add Phone asks a@@ -464,12 +34,11 @@ List<({String title, String? note})> _stepsAfterOpening(String? signIn) => [(title: 'Click Add Phone', note: kAddPhoneWhere),];-/// The steps on the computer under Connect computer's camera, opened from Computers — where the-/// page it came from says none of them ([ScanToConnectPage.steps]).+/// The steps on the computer under the camera, opened from Computers ▸ "Or scan the QR code on your+/// computer" — where the page it came from says none of them ([ScanToConnectPage.steps]).///-/// Set up another computer's own steps, word for word, so the two pages say one thing; without its-/// Get it, which is that page's — Connect computer is for a computer that has Harness, and the row-/// for one that has not is right under the button.+/// For a desktop from before the onboarding of 2026-10-12, which still pairs a phone by its Add+/// Phone QR code; every other computer is added by "On your computer, go to" (`your_computer.dart`).class ComputerSteps extends StatelessWidget {const ComputerSteps({super.key, required this.account});@@ -498,25 +67,22 @@ class ComputerSteps extends StatelessWidget {}/// One step: its number in a ring, a thread down to the next one's, what to do, and under it a-/// quieter line when one is needed — or a link ([link]: Get it).+/// quieter line when one is needed.class _HowItWorksRow extends StatelessWidget {const _HowItWorksRow({required this.number,required this.title,this.note,- this.link,this.last = false,});final int number;final String title;final String? note;- final Widget? link;final bool last;static const double _ring = 24;- /// Round a note, and a link: the same, so the steps stand the same distance apart either way.static const EdgeInsets noteInsets = EdgeInsets.only(top: 2, bottom: 6);@override@@ -588,7 +154,6 @@ class _HowItWorksRow extends StatelessWidget {.copyWith(height: 1.45),),),- ?link,],),),@@ -598,199 +163,3 @@ class _HowItWorksRow extends StatelessWidget {);}}--/// A step's link, where its note would be — "Don’t have it? Get it ›": faint words, and the part-/// that acts in the terminal's green. All of it acts, with the space round it: one line of small-/// words is little to hit.-class _StepLink extends StatelessWidget {- const _StepLink({- super.key,- required this.lead,- required this.action,- required this.onTap,- });-- final String lead;- final String action;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- return Semantics(- button: true,- label: '$lead$action',- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onTap();- },- child: Padding(- padding: _HowItWorksRow.noteInsets.copyWith(right: 16),- child: Text.rich(- TextSpan(- children: [- TextSpan(text: lead),- TextSpan(- text: action,- style: tty.style(- color: tty.green,- size: TtySize.meta,- weight: FontWeight.w600,- ),- ),- ],- ),- style: tty- .style(color: tty.faint, size: TtySize.meta)- .copyWith(height: 1.45),- ),- ),- ),- );- }-}--/// A small link from the page's edge: faint words, and the part that acts in the terminal's green —-/// "Installed? Connect computer ›". With no [lead] at all the whole link is the faint words ("Try-/// the sample while you wait"). Its touch room is round the words, but not before them: the words-/// start on the edge everything else does.-class _TextLink extends StatelessWidget {- const _TextLink({- super.key,- required this.action,- required this.onTap,- this.lead,- });-- final String? lead;- final String action;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- final lead = this.lead;- return Semantics(- button: true,- label: '${lead ?? ''}$action',- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTap: () {- HapticFeedback.selectionClick();- onTap();- },- child: ConstrainedBox(- constraints: const BoxConstraints(minHeight: 44),- child: Padding(- padding: const EdgeInsets.fromLTRB(0, 10, 8, 10),- child: Text.rich(- TextSpan(- children: [- if (lead != null) TextSpan(text: lead),- TextSpan(- text: action,- style: lead == null- ? null- : tty.style(- color: tty.green,- size: TtySize.meta,- weight: FontWeight.w600,- ),- ),- ],- ),- textAlign: TextAlign.start,- style: tty.style(color: tty.faint, size: TtySize.meta),- ),- ),- ),- ),- );- }-}--/// The download page's address, big enough to read off the phone and type on the computer: the-/// page's one thing. Pressed, the share sheet — AirDrop to the Mac beside you, or a message to-/// yourself — which the icon at its right says.-class _AddressCard extends StatefulWidget {- const _AddressCard({- super.key,- required this.address,- required this.onPressed,- });-- /// Without the scheme: what is typed.- final String address;- final VoidCallback onPressed;-- static const double _iconSize = 18;- static const double _iconGap = 10;-- @override- State<_AddressCard> createState() => _AddressCardState();-}--class _AddressCardState extends State<_AddressCard> {- bool _down = false;-- @override- Widget build(BuildContext context) {- final tty = Tty.of(context);- final raised = ttyRaised(tty);- return Semantics(- button: true,- label: '${widget.address}, Send link',- excludeSemantics: true,- child: GestureDetector(- behavior: HitTestBehavior.opaque,- onTapDown: (_) => setState(() => _down = true),- onTapCancel: () => setState(() => _down = false),- onTapUp: (_) => setState(() => _down = false),- onTap: () {- HapticFeedback.selectionClick();- widget.onPressed();- },- child: Container(- padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 20),- decoration: BoxDecoration(- color: _down- ? Color.alphaBlend(tty.text.withValues(alpha: 0.06), raised)- : raised,- border: Border.all(color: tty.dim.withValues(alpha: 0.6)),- borderRadius: BorderRadius.circular(10),- ),- child: Row(- children: [- // The icon's width on the left too, so the address sits in the middle of the card.- const SizedBox(- width: _AddressCard._iconSize + _AddressCard._iconGap,- ),- // One line on any phone: a narrow one shrinks it rather than breaking the address.- Expanded(- child: FittedBox(- fit: BoxFit.scaleDown,- child: Text(- widget.address,- maxLines: 1,- softWrap: false,- style: tty.style(size: 17, weight: FontWeight.w600),- ),- ),- ),- const SizedBox(width: _AddressCard._iconGap),- Icon(- LucideIcons.share300,- size: _AddressCard._iconSize,- color: tty.faint,- ),- ],- ),- ),- ),- );- }-}diff --git a/mobile/lib/phone/welcome/your_computer.dart b/mobile/lib/phone/welcome/your_computer.dartnew file mode 100644index 000000000..ce6c5f17d--- /dev/null+++ b/mobile/lib/phone/welcome/your_computer.dart@@ -0,0 +1,346 @@+import 'dart:async';++import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:lucide_icons_flutter/lucide_icons.dart';+import 'package:share_plus/share_plus.dart';++import 'package:harness_mobile/core/handoff.dart';+import 'package:harness_mobile/shared/theme/app_theme.dart';+import 'package:harness_mobile/state/app_state.dart';++import '../settings_page.dart' show confirmSignOut;+import '../tty.dart';+import '../tty_controls.dart';+import 'join_moment.dart';+import 'onboarding_copy.dart';+import 'onboarding_frame.dart';+import 'onboarding_picture.dart';++/// ② Your computer: "On your computer, go to", the address, and the phone looking for the computer+/// that opens it.+///+/// ```+/// On your computer, go to+/// [ autonomous.ai/go ⇪ ] the address IS the button: it sends the link+///+/// ┌─────────────────────┐+/// │ dashed computers, │ the laptop breathing, rings out from the phone+/// │ the laptop breathes │+/// └─────────────────────┘+/// Looking for your computer▌+/// ```+///+/// At home this is what an account with no computer stands on (`agent_home.dart`, which builds it+/// from [GoAddressButton] and [ComputerWatch] on its own [OnboardingStage]). This page is the same+/// step pushed from Computers ▸ Add computer, with back: a second computer is set up the way the+/// first was (`docs/research/2026-10-11-phone-onboarding`, "More computers, more phones").+///+/// It watches the account for a computer it has not seen. When one joins, it has its moment —+/// "MacBook Pro is ready.", the laptop drawing itself and lighting, the notes ([JoinMoment]) — and+/// goes back to the list, which has it now; a tap goes back sooner.+class YourComputerPage extends StatefulWidget {+ const YourComputerPage({super.key, required this.notifier});++ final AppNotifier notifier;++ @override+ State<YourComputerPage> createState() => _YourComputerPageState();+}++class _YourComputerPageState extends State<YourComputerPage>+ with SingleTickerProviderStateMixin {+ /// The account's computers when this page came up: a computer joining is one not among them.+ ///+ /// ⚠️ Taken in [initState], not on first read: read first when the account's next answer lands,+ /// that answer — the computer that just joined among it — would be what "already there" means.+ late final Set<String> _known;++ /// The computer that joined, by its name, once one has.+ String? _joined;++ late final JoinMoment _moment = JoinMoment(vsync: this, onDone: _back);++ @override+ void initState() {+ super.initState();+ _known = {+ for (final machine in widget.notifier.machines) machine.machineId,+ };+ widget.notifier.addListener(_lookForNew);+ }++ @override+ void dispose() {+ widget.notifier.removeListener(_lookForNew);+ _moment.dispose();+ super.dispose();+ }++ void _lookForNew() {+ if (!mounted || _joined != null) return;+ final added = widget.notifier.machines+ .where((machine) => !_known.contains(machine.machineId))+ .firstOrNull;+ if (added == null) return;+ setState(() => _joined = added.displayName);+ // After the frame that draws it joined: the moment, and the computer named to the device log+ // as the person's own — no "New device" for the one they are looking at.+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ widget.notifier.welcomeMachine(added.machineId);+ _moment.start();+ });+ }++ bool _leaving = false;++ void _back() {+ if (!mounted || _leaving) return;+ _leaving = true;+ unawaited(+ Navigator.of(context).maybePop().then((popped) {+ if (!popped) _leaving = false;+ }),+ );+ }++ @override+ Widget build(BuildContext context) {+ AppTheme.watch(context);+ final joined = _joined;+ return OnboardingStage(+ headline: joined == null+ ? OnboardingCopy.goToHeadline+ : OnboardingCopy.ready(joined),+ headlineKey: const ValueKey('your-computer-headline'),+ scene: joined == null ? OnboardingScene.looking : OnboardingScene.joined,+ join: joined == null ? null : _moment.picture,+ leading: TtyBackButton(onPressed: _back),+ underHeadline: joined == null+ ? ComputerWatch(+ notifier: widget.notifier,+ child: const GoAddressButton(),+ )+ : null,+ status: joined == null+ ? const OnboardingStatus(OnboardingCopy.looking)+ : null,+ onTap: joined == null ? null : _moment.skip,+ );+ }+}++/// Asks the account for its computers every few seconds while it is up: nothing pushes a new+/// computer to a phone that has none connected, and this is the screen waiting for one.+///+/// A request that fails (offline for a moment) is simply asked again on the next tick — caught+/// here, where it would otherwise reach the zone as an unhandled error every five seconds.+class ComputerWatch extends StatefulWidget {+ const ComputerWatch({super.key, required this.notifier, required this.child});++ final AppNotifier notifier;+ final Widget child;++ static const every = Duration(seconds: 5);++ @override+ State<ComputerWatch> createState() => _ComputerWatchState();+}++class _ComputerWatchState extends State<ComputerWatch> {+ Timer? _watch;++ @override+ void initState() {+ super.initState();+ _watch = Timer.periodic(ComputerWatch.every, (_) {+ if (!mounted) return;+ unawaited(widget.notifier.refreshMachines().catchError((Object _) {}));+ });+ }++ @override+ void dispose() {+ _watch?.cancel();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) => widget.child;+}++/// The address, as the button that sends it: the green of the screen's one action, the address at+/// its left edge and the share mark at its right. Pressed, the share sheet — AirDrop to the Mac+/// beside you first, or a message to yourself.+///+/// While it is up it also offers the page to a Mac nearby by Handoff ([Handoff]): signed in to the+/// same Apple account, the Mac shows it in its Dock, and nothing is typed at all.+class GoAddressButton extends StatefulWidget {+ const GoAddressButton({super.key});++ @override+ State<GoAddressButton> createState() => _GoAddressButtonState();+}++class _GoAddressButtonState extends State<GoAddressButton> {+ bool _down = false;+ late final AppLifecycleListener _lifecycle;++ static final _url = Uri.parse(OnboardingCopy.goUrl);++ @override+ void initState() {+ super.initState();+ unawaited(Handoff.offer(this, _url));+ // iOS stops advertising in the background — the person away installing Harness — so the page+ // is offered again whenever the app is back in front.+ _lifecycle = AppLifecycleListener(+ onResume: () => unawaited(Handoff.offer(this, _url)),+ );+ }++ @override+ void dispose() {+ _lifecycle.dispose();+ unawaited(Handoff.withdraw(this));+ super.dispose();+ }++ /// The share sheet with the address, anchored to the button for iPad, where it is a popover.+ Future<void> _send() async {+ final box = context.findRenderObject() as RenderBox?;+ final origin = box == null || !box.attached+ ? null+ : box.localToGlobal(Offset.zero) & box.size;+ try {+ await SharePlus.instance.share(+ ShareParams(+ uri: _url,+ subject: 'Get Harness for your computer',+ sharePositionOrigin: origin,+ ),+ );+ } catch (_) {+ // No share sheet came up: the address is still there to type, and can be pressed again.+ }+ }++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ final ink = tty.onFill(tty.theme.black);+ return Semantics(+ button: true,+ label: '${OnboardingCopy.goAddress}, Send link',+ excludeSemantics: true,+ child: GestureDetector(+ key: const ValueKey('go-address'),+ behavior: HitTestBehavior.opaque,+ onTapDown: (_) => setState(() => _down = true),+ onTapCancel: () => setState(() => _down = false),+ onTapUp: (_) => setState(() => _down = false),+ onTap: () {+ HapticFeedback.lightImpact();+ unawaited(_send());+ },+ child: Container(+ // At least this tall, and taller when the text is larger — never clipped.+ constraints: const BoxConstraints(minHeight: TtyPrimaryButton.height),+ padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),+ decoration: BoxDecoration(+ // Pressed, it darkens on the finger's way DOWN, as the phone's other buttons do.+ color: _down+ ? Color.alphaBlend(+ Colors.black.withValues(alpha: 0.18),+ tty.green,+ )+ : tty.green,+ borderRadius: BorderRadius.circular(14),+ ),+ child: Row(+ children: [+ // One line on any phone: a narrow one shrinks it rather than breaking the address.+ Expanded(+ child: FittedBox(+ fit: BoxFit.scaleDown,+ alignment: Alignment.centerLeft,+ child: Text(+ OnboardingCopy.goAddress,+ maxLines: 1,+ softWrap: false,+ style: tty.style(+ size: TtySize.title,+ weight: FontWeight.w600,+ color: ink,+ ),+ ),+ ),+ ),+ const SizedBox(width: 12),+ Icon(LucideIcons.share300, size: 20, color: ink),+ ],+ ),+ ),+ ),+ );+ }+}++/// `[email protected] · Not you? Sign out` — the account the computer has to sign in to, on the quiet+/// line at the foot of "On your computer, go to", and the way out of it. The whole line signs out,+/// after asking ([confirmSignOut]).+class AccountQuietLine extends StatelessWidget {+ const AccountQuietLine({+ super.key,+ required this.notifier,+ required this.email,+ });++ final AppNotifier notifier;+ final String email;++ @override+ Widget build(BuildContext context) {+ final tty = Tty.of(context);+ return Semantics(+ button: true,+ label: 'Signed in as $email. Not you? Sign out',+ excludeSemantics: true,+ child: GestureDetector(+ key: const ValueKey('home-sign-out'),+ behavior: HitTestBehavior.opaque,+ onTap: () {+ HapticFeedback.selectionClick();+ unawaited(confirmSignOut(context, notifier));+ },+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: 44),+ child: Center(+ child: Text.rich(+ TextSpan(+ children: [+ TextSpan(text: '$email · '),+ TextSpan(+ text: 'Not you? Sign out',+ style: tty.style(+ color: tty.text,+ size: OnboardingFrame.quietSize,+ ),+ ),+ ],+ ),+ textAlign: TextAlign.center,+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ style: tty.style(+ color: tty.faint,+ size: OnboardingFrame.quietSize,+ ),+ ),+ ),+ ),+ ),+ );+ }+}diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dartindex 83b5c407c..f79f6fe4c 100644--- a/mobile/lib/state/app_state.dart+++ b/mobile/lib/state/app_state.dart@@ -1031,6 +1031,18 @@ class AppNotifier extends ChangeNotifier {/// so the welcome screen's pressed button says what it is waiting on, and only it.SignInProvider? signInProvider;+ /// Signed in on this phone during this run — from the welcome — rather than a session the app+ /// came back with. The onboarding after a sign-in reads it: home draws its waits on the+ /// onboarding's picture, eased from the welcome's, and the computer joining gets its moment+ /// (`phone/welcome/onboarding_frame.dart`). Cleared with the session.+ bool signedInThisRun = false;++ /// The one line the phone says by the mic the first time the onboarding opens a session — "Send+ /// it, or say anything." — and the session it is for. Set by home as it hands over+ /// (`phone/agent_home.dart`), spent by that session's page on its first send or when it goes+ /// (`phone/terminal_page.dart`). Null the rest of the time; cleared with the session.+ ({String machineId, String agentId, String text})? firstSessionLine;+AppNotifier({required AppConfig config,required AuthSession authSession,@@ -1640,6 +1652,9 @@ class AppNotifier extends ChangeNotifier {_lastError = message;_lastErrorRetryable = true;signedOutReason = _signedOutEnded;+ signedInThisRun = false;+ welcomedMachines.clear();+ firstSessionLine = null;status = AppStatus.unauthenticated;notifyListeners();}@@ -1678,6 +1693,7 @@ class AppNotifier extends ChangeNotifier {try {await login.signIn(email: email, code: code);if (!_authWorkCurrent(revision)) return;+ signedInThisRun = true;status = AppStatus.bootstrapping;notifyListeners();await _enterSignedIn(revision);@@ -1709,6 +1725,7 @@ class AppNotifier extends ChangeNotifier {try {await login.signInWithScan(code, label: phoneClientDescriptor().name);if (!_authWorkCurrent(revision)) return;+ signedInThisRun = true;status = AppStatus.bootstrapping;notifyListeners();await _enterSignedIn(revision);@@ -1750,6 +1767,7 @@ class AppNotifier extends ChangeNotifier {// iOS takes its sheet down here; Android's Custom Tab is the person's to close.unawaited(closeSignInPage());if (!_authWorkCurrent(revision)) return;+ signedInThisRun = true;status = AppStatus.bootstrapping;notifyListeners();await _enterSignedIn(revision);@@ -1905,6 +1923,9 @@ class AppNotifier extends ChangeNotifier {expandedMachines.clear();selectedMachineId = null;signedOutReason = reason;+ signedInThisRun = false;+ welcomedMachines.clear();+ firstSessionLine = null;status = AppStatus.unauthenticated;notifyListeners();}@@ -2805,6 +2826,23 @@ class AppNotifier extends ChangeNotifier {/// from the log's persisted `pending` ([_syncPendingDevices]), so a restart does not lose them.final List<DevLogMember> newDevices = [];+ /// Computers this phone was waiting for when they joined the account — the onboarding's "On your+ /// computer, go to" — and so already named on its screen ("MacBook Pro is ready."). The device+ /// log's "New device" for one of them is what the person just did: confirmed as theirs, with no+ /// banner and no notice ([welcomeMachine]). Cleared with the session.+ final Set<String> welcomedMachines = {};++ /// [machineId] joined while this phone waited for it: see [welcomedMachines]. A "New device" for+ /// it the log already announced goes too.+ void welcomeMachine(String machineId) {+ if (!welcomedMachines.add(machineId)) return;+ for (final device in [...newDevices]) {+ if (device.kind == 'machine' && device.machineId == machineId) {+ dismissNewDevice(device.pub);+ }+ }+ }+/// Which of [newDevices] a fork suspended (not trusted here until the list is reviewed), as of the/// last read of the log. "Mine" on the banner cannot lift that, so for these it opens the device's/// page, which says why.@@ -2903,6 +2941,12 @@ class AppNotifier extends ChangeNotifier {onAnnounce: (m) => _whenSignedIn(() {_failedDismissals.remove(m.pub);if (newDevices.any((d) => d.pub == m.pub)) return;+ // The computer the onboarding was waiting for: the person is looking at its name already.+ if (m.kind == 'machine' && welcomedMachines.contains(m.machineId)) {+ _pendingSyncGen++;+ unawaited(_dismissInLog(pubs: [m.pub], confirm: true));+ return;+ }newDevices.add(m);devicesRevision++;final name = m.label.isEmpty ? 'A device' : m.label;diff --git a/mobile/lib/terminal/terminal_session.dart b/mobile/lib/terminal/terminal_session.dartindex 8a85861a8..381d62c20 100644--- a/mobile/lib/terminal/terminal_session.dart+++ b/mobile/lib/terminal/terminal_session.dart@@ -1486,15 +1486,23 @@ class TerminalSession extends ChangeNotifier {/// blind. Set and cleared by the page; null the rest of the time.Future<bool> Function(String text)? voiceDeliver;+ /// Called each time this pane sends a line on the person's behalf: a Return typed or pressed —+ /// it crosses [_onTerminalOutput] — or a composed message that went ([sendComposerText]). Set by+ /// the page showing the pane, which asks for notifications after the phone's first send+ /// (`phone/terminal_page.dart`); null the rest of the time.+ VoidCallback? onLineSent;+Future<bool> sendComposerText(String text) async {if (!acceptsInput) return false;final content = text.trimRight();if (content.trim().isEmpty) return false;- return send('message', {+ final sent = await send('message', {'content': content,'agentId': agentId,'mode': 'auto',});+ if (sent) onLineSent?.call();+ return sent;}/// A clipboard paste made directly into this pane, delivered as one atomic unit instead of going@@ -1696,6 +1704,7 @@ class TerminalSession extends ChangeNotifier {);}if (!acceptsInput || data.isEmpty) return;+ if (data.contains('\r')) onLineSent?.call();data = _spendArmedControl(data);final bytes = utf8.encode(data);final isBoundary =diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yamlindex d696c810b..df5bb1a2a 100644--- a/mobile/pubspec.yaml+++ b/mobile/pubspec.yaml@@ -74,11 +74,12 @@ dependencies:# (`lib/notify/system_notices.dart`). Local only — it fires from the machine socket,# so it reaches a phone whose app is still alive, not one iOS has suspended.flutter_local_notifications: ^22.2.0- # Connecting a computer: the first screen's "scan to connect" reads the code the desktop app- # shows (`phone/welcome/scan_to_connect.dart`). The camera only while that screen is up.+ # Pairing with a desktop from before the 2026-10-12 onboarding, which shows an Add Phone QR code+ # (Computers ▸ "Or scan the QR code on your computer"), and Settings ▸ Sign in a computer+ # (`phone/welcome/scan_to_connect.dart`). The camera only while that screen is up.mobile_scanner: ^7.4.2- # "Send link to my Mac": the system share sheet, so AirDrop, Messages or email carry the- # download link to the computer (`phone/welcome/set_up_computer.dart`).+ # "On your computer, go to": the address is the button, and the system share sheet — AirDrop,+ # Messages or email — carries the download link to the computer (`phone/welcome/your_computer.dart`).share_plus: ^13.3.0# "See how it works": the 30-second recording of the app the set-up page plays# (`phone/welcome/how_it_works_video.dart`, `assets/video/how_it_works.mp4`) — in place of an@@ -120,6 +121,10 @@ flutter:# PNG at 1x/2x/3x for the reason above: drawn from `desktop/assets/sign-in/*.svg` by# `scripts/render_svg.swift` (Apple's 814x1000 mark centred in a square tile first).- assets/sign-in/+ # The onboarding's one sound, when a computer joins (`lib/core/chime.dart`): two glass notes a+ # fifth apart, rendered by `scripts/make_joined_chime.py`. A WAV, which iOS's System Sound+ # Services plays and Android stores uncompressed.+ - assets/sound/# "See how it works" — recorded from the sample on a simulator by# `integration_test/demo_video_test.dart`, trimmed and encoded at 604px, ~630 KB.- assets/video/how_it_works.mp4diff --git a/mobile/scripts/make_joined_chime.py b/mobile/scripts/make_joined_chime.pynew file mode 100644index 000000000..21c3d2ee0--- /dev/null+++ b/mobile/scripts/make_joined_chime.py@@ -0,0 +1,79 @@+#!/usr/bin/env python3+"""Renders `assets/sound/joined.wav`: the onboarding's one sound, when a computer joins.++Two soft glass notes a fifth apart — A5, then E6 110 ms later — each a sine with two quieter,+faster-dying inharmonic partials (the ring of struck glass rather than a beep), a 4 ms attack and+an exponential tail. Mono, 16-bit, 44.1 kHz, about a second: short enough for iOS's System Sound+Services, which play it under the Ring/Silent switch (`ios/Runner/AppDelegate.swift`,+`ChimeChannel`). See `lib/core/chime.dart` and `docs/research/2026-10-11-phone-onboarding`.++ python3 scripts/make_joined_chime.py # writes assets/sound/joined.wav+"""++import math+import os+import struct+import sys+import wave++RATE = 44100+LENGTH = 1.0 # seconds+PEAK = 0.32 # soft: well under full scale, and the two notes overlap++# (start seconds, fundamental Hz, gain)+NOTES = [+ (0.000, 880.00, 1.00), # A5+ (0.110, 1318.51, 0.85), # E6 — a perfect fifth above+]++# Glass: the fundamental, and partials at struck-glass ratios that die out sooner.+PARTIALS = [+ (1.000, 1.00, 0.42), # (ratio, gain, decay seconds)+ (2.756, 0.22, 0.16),+ (5.404, 0.08, 0.07),+]+ATTACK = 0.004+FADE_OUT = 0.08+++def sample(t: float) -> float:+ value = 0.0+ for start, freq, gain in NOTES:+ local = t - start+ if local < 0:+ continue+ attack = min(1.0, local / ATTACK)+ for ratio, partial_gain, decay in PARTIALS:+ value += (+ gain+ * partial_gain+ * attack+ * math.exp(-local / decay)+ * math.sin(2 * math.pi * freq * ratio * local)+ )+ # The tail eased to silence, so the file never ends on a click.+ tail = LENGTH - t+ if tail < FADE_OUT:+ value *= max(0.0, tail / FADE_OUT)+ return value+++def main() -> None:+ root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+ out = os.path.join(root, "assets", "sound", "joined.wav")+ os.makedirs(os.path.dirname(out), exist_ok=True)+ frames = [sample(i / RATE) for i in range(int(RATE * LENGTH))]+ loudest = max(abs(v) for v in frames) or 1.0+ scale = PEAK / loudest+ with wave.open(out, "wb") as wav:+ wav.setnchannels(1)+ wav.setsampwidth(2)+ wav.setframerate(RATE)+ wav.writeframes(+ b"".join(struct.pack("<h", int(round(v * scale * 32767))) for v in frames)+ )+ sys.stdout.write(f"wrote {out}\n")+++if __name__ == "__main__":+ main()diff --git a/mobile/test/connect_computer_test.dart b/mobile/test/connect_computer_test.dartindex 448903c4d..930a134ac 100644--- a/mobile/test/connect_computer_test.dart+++ b/mobile/test/connect_computer_test.dart@@ -8,7 +8,6 @@ import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/welcome/connect_code.dart';import 'package:harness_mobile/phone/welcome/connect_computer.dart';import 'package:harness_mobile/phone/welcome/scan_to_connect.dart';-import 'package:harness_mobile/phone/welcome/set_up_computer.dart';import 'package:harness_mobile/state/app_state.dart';import 'viewer_app_fixture.dart' show FakeApi;@@ -44,13 +43,14 @@ class _Links implements PeerLinkClient {Future<String?> unlink(String machineId) async => null;}-/// Setting up a computer from a signed-in phone is the first screen's Connect your computer, plus-/// what only a signed-in phone can do there: watch for the computer, and pair with it by its code.+/// Computers ▸ "Or scan the QR code on your computer": the camera, for a desktop from before the+/// onboarding of 2026-10-12 that still pairs a phone by its Add Phone code — the computer it names+/// looked up on the account, and paired with by the code ([scanAndPairComputer]).void main() {late _Links links;late AppNotifier app;- late List<bool> backs;- late int samples;+ late List<String?> said;+ late List<bool> paired;setUp(() {links = _Links();@@ -63,25 +63,36 @@ void main() {// The account's REST API, answered in memory: its machines are asked for again before a// scanned computer is looked for, and none is on it unless a test says so.app.api = FakeApi();- backs = [];- samples = 0;+ said = [];+ paired = [];});tearDown(() => app.dispose());+ /// A page with the button that scans, as Computers has it.Future<void> pump(WidgetTester tester) async {tester.view.devicePixelRatio = 1;- tester.view.physicalSize = const Size(430, 1400);+ tester.view.physicalSize = const Size(430, 932);addTearDown(tester.view.reset);await tester.pumpWidget(MaterialApp(- home: ConnectComputerPage(- notifier: app,- onBack: () => backs.add(true),- onTrySample: (_) async {- samples++;- return null;- },- scanCamera: const SizedBox(),+ home: Builder(+ builder: (context) => Scaffold(+ body: Center(+ child: TextButton(+ key: const ValueKey('scan'),+ onPressed: () async => paired.add(+ await scanAndPairComputer(+ context,+ app,+ say: (message, {failed = false}) =>+ said.add(failed ? '✗ $message' : message),+ camera: const SizedBox(),+ ),+ ),+ child: const Text('Scan'),+ ),+ ),+ ),),),);@@ -89,7 +100,7 @@ void main() {}Future<void> scan(WidgetTester tester, String link) async {- await tester.tap(find.byKey(const ValueKey('set-up-scan')));+ await tester.tap(find.byKey(const ValueKey('scan')));await tester.pumpAndSettle();tester.widget<ScanToConnectPage>(find.byType(ScanToConnectPage))@@ -102,42 +113,7 @@ void main() {await tester.pump(const Duration(seconds: 6));}- testWidgets('Connect your computer, watching, and Get it behind it', (- tester,- ) async {- await pump(tester);- expect(find.byType(SetUpComputerPage), findsOneWidget);- expect(find.text('Set up another computer'), findsOneWidget);- expect(find.text('Waiting for your computer…'), findsOneWidget);- // The sample is Get it's, for somebody waiting on the computer to install — not this page's.- expect(find.byKey(const ValueKey('get-it-sample')), findsNothing);- // The old page's second way of saying all this is gone.- expect(find.text('Email me the setup link'), findsNothing);- expect(find.textContaining('remote-password'), findsNothing);-- // No Harness yet: the download to send, and the sample to try meanwhile.- await tester.tap(find.byKey(const ValueKey('set-up-get-it')));- await tester.pumpAndSettle();- expect(find.byType(GetHarnessPage), findsOneWidget);- expect(find.text('Get Harness\non your computer'), findsOneWidget);- await tester.tap(find.byKey(const ValueKey('get-it-sample')));- await tester.pumpAndSettle();- expect(samples, 1);-- // Installed: Get it goes, and the camera comes up over this page — not over Get it.- await tester.tap(find.byKey(const ValueKey('get-it-pair')));- await tester.pumpAndSettle();- expect(find.byType(ScanToConnectPage), findsOneWidget);- expect(find.byType(GetHarnessPage), findsNothing);- tester.widget<ScanToConnectPage>(find.byType(ScanToConnectPage)).onBack();- await tester.pumpAndSettle();- expect(find.byType(ScanToConnectPage), findsNothing);- expect(find.text('Set up another computer'), findsOneWidget);- expect(backs, isEmpty);- await unmount(tester);- });-- testWidgets('scanning the new computer\'s code pairs it and goes back', (+ testWidgets('the computer\'s code pairs it, and says so on the way', (tester,) async {const studio = Machine(@@ -155,7 +131,19 @@ void main() {ConnectCode.link('[email protected]', machineId: 'studio', pairCode: 'K7QM4XPT'),);expect(links.codes, [('studio', 'K7QM4XPT')]);- expect(backs, [true]);+ expect(said, ['Pairing…', null]);+ expect(paired, [true]);+ await unmount(tester);+ });++ testWidgets('a code that is not Add Phone\'s is said to be so', (+ tester,+ ) async {+ await pump(tester);+ await scan(tester, ConnectCode.link('[email protected]'));+ expect(links.codes, isEmpty);+ expect(said, ['✗ That’s not the Add Phone code.']);+ expect(paired, [false]);await unmount(tester);});@@ -167,12 +155,12 @@ void main() {tester,ConnectCode.link('[email protected]', machineId: 'elsewhere', pairCode: 'K7QM4XPT'),);- // The page asks for the list again first, and gives that five seconds.+ // The account is asked for its list again first, and given five seconds.await tester.pump(const Duration(seconds: 6));await tester.pump();expect(links.codes, isEmpty);- expect(backs, isEmpty);- expect(find.textContaining("isn't on your account"), findsOneWidget);+ expect(said.last, contains("isn't on your account"));+ expect(paired, [false]);await unmount(tester);});@@ -188,9 +176,8 @@ void main() {);await tester.pump();expect(links.codes, isEmpty);- expect(backs, isEmpty);- expect(find.text('Pairing…'), findsNothing);- expect(find.textContaining("Couldn't reach your account"), findsOneWidget);+ expect(said.last, contains("Couldn't reach your account"));+ expect(paired, [false]);await unmount(tester);});}diff --git a/mobile/test/first_computer_flow_test.dart b/mobile/test/first_computer_flow_test.dartindex 03b73741f..a00f87722 100644--- a/mobile/test/first_computer_flow_test.dart+++ b/mobile/test/first_computer_flow_test.dart@@ -5,6 +5,7 @@ import 'package:harness_mobile/core/config.dart';import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';import 'package:harness_mobile/state/app_state.dart';import 'package:harness_mobile/ws/ws_conn.dart';@@ -28,10 +29,11 @@ class _Conn extends WsConn {}) async => {};}-/// A new account's first minutes on the phone, signed in: no computer yet → how to set one up;-/// the computer appears, locked → its unlock, right there; unlocked with nothing running → New.+/// A new account's first minutes on the phone, signed in: no computer yet → "On your computer, go+/// to"; the computer appears → its moment ("studio is ready."); locked → its unlock, right there;+/// unlocked with nothing running → New.void main() {- testWidgets('no computer, then a locked one, then an empty one', (+ testWidgets('no computer, then one joining locked, then an empty one', (tester,) async {final app = AppNotifier(@@ -66,8 +68,12 @@ void main() {}await settle();- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);- expect(find.text('Waiting for your computer…'), findsOneWidget);+ expect(find.text(OnboardingCopy.goToHeadline), findsOneWidget);+ expect(find.text('autonomous.ai/go'), findsOneWidget);+ expect(+ find.textContaining(OnboardingCopy.looking, findRichText: true),+ findsOneWidget,+ );// It appears — awake, and waiting for its phone password.const studio = Machine(@@ -81,6 +87,13 @@ void main() {..needsLink = true..agentLoadStatus = AgentLoadStatus.needsLink;app.notifyListeners();+ await tester.pump();+ // The computer the phone waited for: its moment first, named as the person's own…+ expect(find.text(OnboardingCopy.ready('studio')), findsOneWidget);+ await tester.pump();+ expect(app.welcomedMachines, contains('studio'));+ // …then, as it wants its password, the unlock.+ await tester.pump(const Duration(milliseconds: 2300));await settle();expect(find.text('Unlock studio'), findsOneWidget);diff --git a/mobile/test/notify/phone_on_screen_test.dart b/mobile/test/notify/phone_on_screen_test.dartindex e77c4ba6d..bee036ac7 100644--- a/mobile/test/notify/phone_on_screen_test.dart+++ b/mobile/test/notify/phone_on_screen_test.dart@@ -40,7 +40,8 @@ void main() {),);await tester.pump();- // A new phone opens on its sessions to pick from (`PickUpPage`): `a` is picked there.+ // A new phone has its computer's moment ("Test host is ready."): `a`, picked by hand meanwhile,+ // opens at once.request.value = (machineId: 'm', agentId: 'a');await tester.pump();return app;diff --git a/mobile/test/phone/phone_shell_device_notice_test.dart b/mobile/test/phone/phone_shell_device_notice_test.dartindex 2c021e0a6..b9c74cc11 100644--- a/mobile/test/phone/phone_shell_device_notice_test.dart+++ b/mobile/test/phone/phone_shell_device_notice_test.dart@@ -89,7 +89,10 @@ void main() {expect(find.textContaining('Not trusted here'), findsOneWidget);await tester.tap(find.byKey(const Key('device-detail-mine')));- await tester.pumpAndSettle();+ // Not `pumpAndSettle`: the page goes back to home, which with no computer on the account is+ // "On your computer, go to" — its picture looks for the computer for as long as it is up.+ await tester.pump();+ await tester.pump(const Duration(seconds: 1));expect(app.dismissed, [(pub: m.pub, liftSuspension: true)]);});diff --git a/mobile/test/phone_edge/welcome_behavior_test.dart b/mobile/test/phone_edge/welcome_behavior_test.dartindex 6d62a30df..3b2d5f4da 100644--- a/mobile/test/phone_edge/welcome_behavior_test.dart+++ b/mobile/test/phone_edge/welcome_behavior_test.dart@@ -5,13 +5,13 @@ import 'package:harness_mobile/phone/new_agent_page.dart';import 'package:harness_mobile/phone/tty_controls.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/phone/welcome/connect_code.dart';-import 'package:harness_mobile/phone/welcome/connect_computer.dart';import 'package:harness_mobile/phone/welcome/focus_hints.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';import 'package:harness_mobile/phone/welcome/phone_welcome.dart';import 'package:harness_mobile/phone/welcome/pick_up_page.dart';import 'package:harness_mobile/phone/welcome/scan_to_connect.dart';-import 'package:harness_mobile/phone/welcome/set_up_computer.dart';import 'package:harness_mobile/phone/welcome/unlock_computer.dart';+import 'package:harness_mobile/phone/welcome/your_computer.dart';import 'package:harness_mobile/core/local_key_value_store.dart';import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/state/app_state.dart';@@ -20,9 +20,9 @@ import 'package:mobile_scanner/mobile_scanner.dart';import '../voice_fakes.dart';import 'edge_fixture.dart';-/// The first-run flow as somebody walks it: wrong email, short code, Back, a scanned code that-/// signs in and one that has expired, a password that fails and one that works, the hints over a-/// first terminal, and the ways to a first harness.+/// The first-run flow as somebody walks it: wrong email, short code, Back, the address sent to the+/// computer, a password that fails and one that works, the hints only when asked for, and the+/// ways to a first harness.////// ⚠️ The camera, the share sheet, Mail and the account service are all answered here — no screen/// under test reaches the real one.@@ -66,49 +66,36 @@ void main() {}group('signing in', () {- Future<({AppNotifier app, List<String> sent, List<String> scans})> welcome(- WidgetTester tester, {- Object? sample,- bool scanFails = false,- }) async {+ Future<({AppNotifier app, List<String> sent})> welcome(+ WidgetTester tester,+ ) async {setPhone(tester, largePhone);final app = edgeApp(noMachines: true);final sent = <String>[];- final scans = <String>[];await tester.pumpWidget(phoneApp(PhoneWelcome(notifier: app,- onTrySample: (_) async => sample,sendCode: (email) async => sent.add(email),signIn: (_, code) async {if (code != '4242') throw Exception('That code is not right.');},- signInWithScan: (code) async {- scans.add(code);- if (scanFails) throw StateError('expired');- },- scanCamera: const SizedBox(),),),);await frames(tester);- return (app: app, sent: sent, scans: scans);+ return (app: app, sent: sent);}- /// Connect computer, then the camera's "Can’t scan?" sheet, then its email.+ /// The welcome's quiet line, under the accounts.Future<void> toEmail(WidgetTester tester) async {- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await frames(tester);- await tester.tap(find.text('Can’t scan? Sign in another way'));- await frames(tester);- await tester.tap(find.text('Continue with email'));+ await tester.tap(find.byKey(const ValueKey('welcome-email-way')));await frames(tester);}testWidgets('a wrong email, then a short code, then a wrong one, then the ''right one', (tester) async {- final (:app, :sent, scans: _) = await welcome(tester);+ final (:app, :sent) = await welcome(tester);await toEmail(tester);await tester.enterText(find.byType(TextField), 'not-an-email');@@ -143,24 +130,20 @@ void main() {await frames(tester);expect(sent, hasLength(2));- // Change email, then Back all the way out: the camera the email was chosen over, then the- // first screen.+ // Change email, then Back: the welcome it was chosen on.await tester.tap(find.text('Change email'));await frames(tester);expect(find.text('Your email'), findsOneWidget);await tester.binding.handlePopRoute();await frames(tester);- expect(find.text('Scan the code on your computer'), findsOneWidget);- await tester.binding.handlePopRoute();- await frames(tester);- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);+ expect(find.text(OnboardingCopy.welcome), findsOneWidget);await close(tester, app);});testWidgets('Back from the code goes to the email, not out', (tester,) async {- final (:app, sent: _, scans: _) = await welcome(tester);+ final (:app, sent: _) = await welcome(tester);await toEmail(tester);await tester.enterText(find.byType(TextField), '[email protected]');await tester.testTextInput.receiveAction(TextInputAction.go);@@ -170,37 +153,6 @@ void main() {expect(find.text('Your email'), findsOneWidget);await close(tester, app);});-- testWidgets('Get it first, then Connect computer from there, then back', (- tester,- ) async {- final (:app, sent: _, scans: _) = await welcome(tester);- await tapInView(tester, find.byKey(const ValueKey('set-up-get-it')));- await frames(tester);- await tapInView(tester, find.byKey(const ValueKey('get-it-pair')));- await frames(tester);- expect(find.text('Scan the code on your computer'), findsOneWidget);- // Back from the camera is Get it, where it was opened, and back from that the first screen.- await tester.tap(find.bySemanticsLabel(RegExp('Back')).first);- await frames(tester);- expect(find.text('Get Harness\non your computer'), findsOneWidget);- await tester.tap(find.bySemanticsLabel(RegExp('Back')).first);- await frames(tester);- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);- await close(tester, app);- });-- testWidgets('the sample, on Get it, leads back to Get it', (tester) async {- final (:app, sent: _, scans: _) = await welcome(tester, sample: 'set-up');- // Not on the first screen: it is for somebody waiting on the computer to install.- expect(find.text('Try the sample while you wait'), findsNothing);- await tapInView(tester, find.byKey(const ValueKey('set-up-get-it')));- await frames(tester);- await tapInView(tester, find.text('Try the sample while you wait'));- await frames(tester);- expect(find.text('Get Harness\non your computer'), findsOneWidget);- await close(tester, app);- });});group('scanning', () {@@ -245,100 +197,19 @@ void main() {await tester.pumpWidget(const SizedBox());await tester.pump(const Duration(seconds: 3));});-- testWidgets('a scanned sign-in code signs in; an expired one sends an '- 'email code instead', (tester) async {- setPhone(tester, largePhone);- for (final fails in [false, true]) {- final app = edgeApp(noMachines: true);- final sent = <String>[];- final scans = <String>[];- await tester.pumpWidget(- phoneApp(- PhoneWelcome(- notifier: app,- sendCode: (email) async => sent.add(email),- signIn: (_, _) async {},- signInWithScan: (code) async {- scans.add(code);- if (fails) throw StateError('expired');- },- scanCamera: const SizedBox(),- ),- ),- );- await frames(tester);- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await frames(tester);- tester- .widget<ScanToConnectPage>(find.byType(ScanToConnectPage))- .onCode(- ConnectCode.parse(- ConnectCode.link(- '[email protected]',- machineId: 'm',- pairCode: '777',- signIn: 'h-1',- ),- )!,- );- await frames(tester);- expect(scans, ['h-1']);- expect(app.pendingPairing, (machineId: 'm', code: '777'));- expect(sent, fails ? ['[email protected]'] : isEmpty);- await close(tester, app);- }- });});- // The old page (email the steps, a Terminal/Mac tab, four commands) is Connect your computer- // now, with the sample on Get it — see connect_computer_test.dart for the signed-in half.- testWidgets(- 'set up your computer: Get it, and the sample while you wait',- (tester) async {- setPhone(tester, largePhone);- final app = edgeApp(noMachines: true);- var samples = 0;- await tester.pumpWidget(- phoneApp(- ConnectComputerPage(- notifier: app,- signedIn: false,- onTrySample: (_) async => samples++,- ),- ),- );- await frames(tester);- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);- // Not watching: nothing says it is waiting for the computer.- expect(find.text('Waiting for your computer…'), findsNothing);- expect(find.text('Email me the setup link'), findsNothing);- await tapInView(tester, find.byKey(const ValueKey('set-up-get-it')));- await frames(tester);- await tapInView(tester, find.text('Try the sample while you wait'));- await frames(tester);- expect(samples, 1);- await close(tester, app);- },- );-- testWidgets('Get it: the download page goes to the share sheet', (+ testWidgets('On your computer, go to: the address goes to the share sheet', (tester,) async {setPhone(tester, largePhone);- await tester.pumpWidget(- phoneApp(- Scaffold(- body: GetHarnessPage(onBack: () {}, onPair: () {}),- ),- ),- );+ final app = edgeApp(noMachines: true);+ await tester.pumpWidget(phoneApp(YourComputerPage(notifier: app)));await frames(tester);- await tester.tap(find.byKey(const ValueKey('get-it-send')));+ await tester.tap(find.byKey(const ValueKey('go-address')));await frames(tester);expect(platformCalls.where((call) => call.contains('share')), hasLength(1));- await tester.pumpWidget(const SizedBox());- await tester.pump(const Duration(seconds: 3));+ await close(tester, app);});group('unlocking a computer', () {@@ -404,42 +275,54 @@ void main() {});});- group('the first-time hints', () {- testWidgets('shown once: a touch puts them away for good', (tester) async {- setPhone(tester, largePhone);- final storage = MemoryKeyValueStore();- var done = 0;- Widget hints() => phoneApp(- FocusHints(- micBottom: 60,- store: FocusHintsSeen(storage: storage),- onDone: () => done++,- ),- );- await tester.pumpWidget(hints());- await frames(tester);- expect(find.text('→ swipe right'), findsOneWidget);- await tester.tapAt(const Offset(200, 400));- await tester.pump();- expect(find.text('→ swipe right'), findsNothing);- expect(done, 1);- expect(storage.values.values, contains('yes'));+ group('the hints over Focus', () {+ testWidgets(+ 'not before the first look: only when asked for again, then once',+ (tester) async {+ setPhone(tester, largePhone);+ final storage = MemoryKeyValueStore();+ var done = 0;+ Widget hints() => phoneApp(+ FocusHints(+ micBottom: 60,+ store: FocusHintsSeen(storage: storage),+ onDone: () => done++,+ ),+ );+ // A first terminal: nothing over it (owner, 2026-10-12).+ await tester.pumpWidget(hints());+ await frames(tester);+ expect(find.text('→ swipe right'), findsNothing);- // The next Focus, on the same install: nothing.- await tester.pumpWidget(const SizedBox());- await tester.pumpWidget(hints());- await frames(tester);- expect(find.text('→ swipe right'), findsNothing);- });+ // Settings ▸ Show the tips again.+ await FocusHintsSeen(storage: storage).forget();+ await tester.pumpWidget(const SizedBox());+ await tester.pumpWidget(hints());+ await frames(tester);+ expect(find.text('→ swipe right'), findsOneWidget);+ await tester.tapAt(const Offset(200, 400));+ await tester.pump();+ expect(find.text('→ swipe right'), findsNothing);+ expect(done, 1);+ expect(storage.values.values, contains('yes'));++ // The next Focus, on the same install: nothing.+ await tester.pumpWidget(const SizedBox());+ await tester.pumpWidget(hints());+ await frames(tester);+ expect(find.text('→ swipe right'), findsNothing);+ },+ );- test('forgotten, they come back; a store that fails never nags', () async {- final storage = MemoryKeyValueStore()- ..values['phone_focus_hints_v1'] = 'yes';+ test('nothing stored is put away; asked for, they come back; a store that fails never nags', () async {+ final storage = MemoryKeyValueStore();final seen = FocusHintsSeen(storage: storage);expect(await seen.seen(), isTrue);await seen.forget();expect(await seen.seen(), isFalse);- expect(storage.values, isEmpty);+ expect(storage.values['phone_focus_hints_v1'], 'again');+ await seen.markSeen();+ expect(await FocusHintsSeen(storage: storage).seen(), isTrue);final broken = FocusHintsSeen(storage: _Failing());expect(await broken.seen(), isTrue);diff --git a/mobile/test/phone_edge/welcome_layout_test.dart b/mobile/test/phone_edge/welcome_layout_test.dartindex f6d7ba408..3017c6907 100644--- a/mobile/test/phone_edge/welcome_layout_test.dart+++ b/mobile/test/phone_edge/welcome_layout_test.dart@@ -1,16 +1,17 @@import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/core/models.dart';+import 'package:harness_mobile/phone/agent_home.dart';+import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/phone/tty.dart';-import 'package:harness_mobile/phone/welcome/connect_computer.dart';import 'package:harness_mobile/phone/welcome/focus_hints.dart';import 'package:harness_mobile/phone/welcome/how_it_works.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';import 'package:harness_mobile/phone/welcome/pairing_with_code.dart';import 'package:harness_mobile/phone/welcome/phone_boot.dart';import 'package:harness_mobile/phone/welcome/phone_welcome.dart';import 'package:harness_mobile/phone/welcome/pick_up_page.dart';import 'package:harness_mobile/phone/welcome/scan_to_connect.dart';-import 'package:harness_mobile/phone/welcome/set_up_computer.dart';import 'package:harness_mobile/phone/welcome/unlock_computer.dart';import 'package:harness_mobile/state/app_state.dart';@@ -40,38 +41,36 @@ void main() {Widget welcome(AppNotifier app) => PhoneWelcome(notifier: app,- onTrySample: (_) async => null,sendCode: (_) async {},signIn: (_, _) async => throw Exception('That code has expired. Ask for a new one and try again within ten minutes.',),- signInWithScan: (_) async {},- scanCamera: const SizedBox(),);- testWidgets('the first screen', (tester) async {+ /// Home as the shell mounts it, for an account with no computer yet.+ Widget home(AppNotifier app) => PhoneShellScope(+ onMachineLinked: (_) {},+ onOpenAgent: (_, _) {},+ child: AgentHome(notifier: app),+ );++ testWidgets('the first screen, and why it was signed out', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {- final app = edgeApp(noMachines: true);+ final app = edgeApp(noMachines: true)+ ..signedOutReason =+ 'You were signed out because this phone was removed from your account on another device.';addTearDown(app.dispose);await pump(tester, welcome(app), scale, brightness);- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);- await tester.drag(find.byType(ListView), const Offset(0, -2000));- await frames(tester);+ expect(find.text(OnboardingCopy.welcome), findsOneWidget);});});- testWidgets('scan, the other ways, then email, then a code that fails', (- tester,- ) async {+ testWidgets('the email, then a code that fails', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {final app = edgeApp(noMachines: true);addTearDown(app.dispose);await pump(tester, welcome(app), scale, brightness);- await tapInView(tester, find.byKey(const ValueKey('set-up-scan')));- await frames(tester);- await tapInView(tester, find.text('Can’t scan? Sign in another way'));- await frames(tester);- await tapInView(tester, find.text('Continue with email'));+ await tapInView(tester, find.byKey(const ValueKey('welcome-email-way')));await frames(tester);await tester.enterText(find.byType(TextField),@@ -90,24 +89,34 @@ void main() {});});- testWidgets('Get it', (tester) async {- await expectNoLayoutErrors(tester, (scale, brightness) async {- final app = edgeApp(noMachines: true);- addTearDown(app.dispose);- await pump(tester, welcome(app), scale, brightness);- await tapInView(tester, find.byKey(const ValueKey('set-up-get-it')));- await frames(tester);- expect(find.text('Get Harness\non your computer'), findsOneWidget);- await tester.drag(- find.descendant(- of: find.byType(GetHarnessPage),- matching: find.byType(SingleChildScrollView),- ),- const Offset(0, -2000),- );- await frames(tester);- });- });+ testWidgets(+ 'On your computer, go to — a long account — then a computer with a long name joining',+ (tester) async {+ await expectNoLayoutErrors(tester, (scale, brightness) async {+ final app = edgeApp(noMachines: true)+ ..currentUser = const CurrentUserProfile(+ id: 'u',+ name: longName,+ email: '[email protected]',+ );+ addTearDown(app.dispose);+ // ⚠️ Kept under five seconds of the test's clock: the page re-reads the account's machines+ // every five.+ await pump(tester, home(app), scale, brightness);+ expect(find.text(OnboardingCopy.goToHeadline), findsOneWidget);++ const joining = Machine(+ machineId: 'm',+ authMode: MachineAuthMode.remote,+ name: longMachine,+ );+ app.machines = [joining];+ app.notifyListeners();+ await frames(tester);+ expect(find.text(OnboardingCopy.ready(longMachine)), findsOneWidget);+ });+ },+ );testWidgets('scanning, signing in', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {@@ -130,33 +139,6 @@ void main() {});});- testWidgets('set up your computer, signed in, both ways', (tester) async {- await expectNoLayoutErrors(tester, (scale, brightness) async {- final app = edgeApp(noMachines: true);- addTearDown(app.dispose);- app.currentUser = const CurrentUserProfile(- id: 'u',- name: longName,- email:- '[email protected]',- );- // ⚠️ Kept under five seconds of the test's clock: the page re-reads the account's machines- // every five, and that read is the real service's.- await pump(- tester,- ConnectComputerPage(- notifier: app,- onBack: () {},- onTrySample: (_) async => null,- ),- scale,- brightness,- );- await tester.drag(find.byType(ListView), const Offset(0, -2000));- await frames(tester, count: 1);- });- });-testWidgets('unlocking a computer with a long name', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {final app = edgeApp(machineName: longMachine);@@ -217,7 +199,7 @@ void main() {});});- testWidgets('the first-time hints over Focus', (tester) async {+ testWidgets('the hints over Focus, asked for again', (tester) async {await expectNoLayoutErrors(tester, (scale, brightness) async {await pump(tester,@@ -226,7 +208,10 @@ void main() {color: Tty.of(context).ground,child: FocusHints(micBottom: 34 + 4 + 30,- store: FocusHintsSeen(storage: MemoryKeyValueStore()),+ store: FocusHintsSeen(+ storage: MemoryKeyValueStore()+ ..values['phone_focus_hints_v1'] = 'again',+ ),),),),diff --git a/mobile/test/phone_launch_tab_test.dart b/mobile/test/phone_launch_tab_test.dartindex 3ed40154b..c354c8f45 100644--- a/mobile/test/phone_launch_tab_test.dart+++ b/mobile/test/phone_launch_tab_test.dart@@ -3,7 +3,9 @@ import 'dart:convert';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/phone/agent_home.dart';+import 'package:harness_mobile/core/models.dart';import 'package:harness_mobile/phone/agent_swipe.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';import 'package:harness_mobile/phone/welcome/pick_up_page.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/state/app_state.dart';@@ -93,24 +95,41 @@ void main() {await tester.pump(const Duration(seconds: 11));});- testWidgets(- 'or, with nothing remembered at all, the sessions to pick from',- (tester) async {- await pumpHome(- tester,- tabs: [- deskTab('t1', 'Empty', ['gone']),- deskTab('t2', 'Docker', ['c', 'd']),- ],- );+ testWidgets('or, with nothing remembered at all, the computer\'s moment, then the session used on it '+ 'last — not a tab', (tester) async {+ final app = await pumpHome(+ tester,+ tabs: [+ deskTab('t1', 'Empty', ['gone']),+ deskTab('t2', 'Docker', ['c', 'd']),+ ],+ );+ // The desktop opened `a` last: its pane took focus there (`lastOpenedAt`).+ app.stateOf('m')!.agents = [+ for (final id in pagerAgentIds)+ Agent(+ id: id,+ name: id,+ engine: 'claude',+ project: const AgentProject(name: 'work', cwd: '/work'),+ terminalAvailable: true,+ lastOpenedAt: id == 'a' ? DateTime(2026, 10, 12, 9) : null,+ ),+ ];+ app.notifyListeners();+ await tester.pump();- // A new phone opens on "Pick up where you left off", not on a session guessed for it.- expect(find.byType(PickUpPage), findsOneWidget);- expect(find.byType(AgentSwipeHost), findsNothing);- // Its list reaches the machines as Find does (`reachAllMachines`): let the timers run out.- await tester.pumpWidget(const SizedBox());- await tester.pump(const Duration(seconds: 30));- },- );+ // A new phone signed in to an account that had the computer: "Test host is ready.", not+ // "Pick up where you left off", and not a tab's first agent.+ expect(find.text(OnboardingCopy.ready('Test host')), findsOneWidget);+ expect(find.byType(PickUpPage), findsNothing);+ await tester.pump(const Duration(milliseconds: 2300));+ await tester.pump(const Duration(milliseconds: 500));+ expect(pager(tester).agentId, 'a');+ expect(app.firstSessionLine?.text, OnboardingCopy.micTalk);+ // The record and the machines' reach run on timers: let them run out.+ await tester.pumpWidget(const SizedBox());+ await tester.pump(const Duration(seconds: 30));+ });});}diff --git a/mobile/test/phone_restore_last_agent_test.dart b/mobile/test/phone_restore_last_agent_test.dartindex 5aa120c55..c0bee9011 100644--- a/mobile/test/phone_restore_last_agent_test.dart+++ b/mobile/test/phone_restore_last_agent_test.dart@@ -7,6 +7,7 @@ import 'package:harness_mobile/phone/agent_home.dart';import 'package:harness_mobile/phone/agent_swipe.dart';import 'package:harness_mobile/phone/phone_shell_scope.dart';import 'package:harness_mobile/state/app_state.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';import 'package:harness_mobile/phone/welcome/pick_up_page.dart';import 'agent_pager_fixture.dart';@@ -131,30 +132,63 @@ void main() {expect(openedAgent(tester), 'c');});- testWidgets(- 'a new phone opens on its sessions; the one picked is recorded for the next launch',- (tester) async {- final storage = MemoryKeyValueStore();- final notifier = await app(tester, storage: storage);- machineLists(notifier, [- for (final id in pagerAgentIds) agent(id, terminal: true),- ]);- await pumpHome(tester, notifier);- // Nothing remembered: "Pick up where you left off", not a session guessed for it.- expect(find.byType(PickUpPage), findsOneWidget);- expect(storage.values['phone_last_agent_v1'], isNull);-- // A row tapped there opens through the shell, as Find's do.- picked!.value = (machineId: 'm', agentId: 'b');- await tester.pump();- await tester.pump(const Duration(milliseconds: 700));- expect(openedAgent(tester), 'b');- expect(storage.values['phone_last_agent_v1'], contains('"agentId":"b"'));- // The welcome's list reaches the machines, and the storage persists: let the timers run out.- await tester.pumpWidget(const SizedBox());- await tester.pump(const Duration(seconds: 30));- },- );+ testWidgets('a new phone has its computer\'s moment, then opens the session used there last, and '+ 'records it for the next launch', (tester) async {+ final storage = MemoryKeyValueStore();+ final notifier = await app(tester, storage: storage);+ final now = DateTime.now();+ machineLists(notifier, [+ for (final id in pagerAgentIds)+ Agent(+ id: id,+ name: id,+ engine: 'claude',+ project: const AgentProject(name: 'work', cwd: '/work'),+ terminalAvailable: true,+ // `c` moved last, but `b` is the one the desktop has in focus — opened since.+ updatedAt: id == 'c'+ ? now.subtract(const Duration(minutes: 5))+ : null,+ lastOpenedAt: id == 'b'+ ? now.subtract(const Duration(minutes: 1))+ : null,+ ),+ ]);+ await pumpHome(tester, notifier);+ // Nothing remembered: not "Pick up where you left off", and no session guessed — the+ // computer's moment, then what the computer is on.+ expect(find.byType(PickUpPage), findsNothing);+ expect(find.text(OnboardingCopy.ready('Test host')), findsOneWidget);+ expect(storage.values['phone_last_agent_v1'], isNull);++ await tester.pump(const Duration(milliseconds: 1600));+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 700));+ expect(openedAgent(tester), 'b');+ expect(storage.values['phone_last_agent_v1'], contains('"agentId":"b"'));+ // The machines' reach and the storage persist on timers: let them run out.+ await tester.pumpWidget(const SizedBox());+ await tester.pump(const Duration(seconds: 30));+ });++ testWidgets('a session picked by hand during the moment opens at once', (+ tester,+ ) async {+ final notifier = await app(tester, storage: MemoryKeyValueStore());+ machineLists(notifier, [+ for (final id in pagerAgentIds) agent(id, terminal: true),+ ]);+ await pumpHome(tester, notifier);+ expect(find.text(OnboardingCopy.ready('Test host')), findsOneWidget);++ // From a notice, or Find, while "Test host is ready." is still up.+ picked!.value = (machineId: 'm', agentId: 'c');+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 700));+ expect(openedAgent(tester), 'c');+ await tester.pumpWidget(const SizedBox());+ await tester.pump(const Duration(seconds: 30));+ });testWidgets('the next launch opens the agent picked last, not the first', (tester,diff --git a/mobile/test/phone_welcome_first_screen_test.dart b/mobile/test/phone_welcome_first_screen_test.dartindex 0e04ff3cf..79580a069 100644--- a/mobile/test/phone_welcome_first_screen_test.dart+++ b/mobile/test/phone_welcome_first_screen_test.dart@@ -1,20 +1,19 @@-import 'dart:async';-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness_mobile/auth/auth_session.dart';+import 'package:harness_mobile/auth/sign_in_provider.dart';import 'package:harness_mobile/core/config.dart';import 'package:harness_mobile/phone/tty_controls.dart';import 'package:harness_mobile/phone/welcome/connect_code.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';+import 'package:harness_mobile/phone/welcome/onboarding_picture.dart';import 'package:harness_mobile/phone/welcome/phone_welcome.dart';import 'package:harness_mobile/phone/welcome/scan_to_connect.dart';-import 'package:harness_mobile/phone/welcome/set_up_computer.dart';+import 'package:harness_mobile/phone/welcome/sign_in_provider_button.dart';import 'package:harness_mobile/state/app_state.dart';-/// The first screen: Connect your computer — one button, Connect computer, that scans the code the-/// desktop app shows; Get it behind it for a computer with no Harness yet; and the other ways to sign-/// in behind the camera's "Can’t scan?".+/// The first screen: ① Welcome — the promise, the two accounts, the emailed code under them, and+/// nothing else (`docs/research/2026-10-11-phone-onboarding`).void main() {group('ConnectCode', () {test('reads the desktop app\'s link, all of it in the fragment', () {@@ -56,9 +55,7 @@ void main() {late AppNotifier notifier;late List<String> sent;- late List<String> scanned;- Object? scanFails;- Completer<void>? scanGate;+ late List<(String, String)> signedIn;setUp(() {notifier = AppNotifier(@@ -67,284 +64,150 @@ void main() {configStore: null,);sent = [];- scanned = [];- scanFails = null;- scanGate = null;+ signedIn = [];});tearDown(() => notifier.dispose());- Future<void> pump(- WidgetTester tester, {- Widget? camera,- Future<Object?> Function(BuildContext context)? onTrySample,- }) async {- // A phone's height, so the whole page is on screen.+ /// The welcome as the app mounts it: rebuilt whenever the notifier moves (`RootShell`).+ Future<void> pump(WidgetTester tester) async {tester.view.devicePixelRatio = 1;- tester.view.physicalSize = const Size(430, 1400);+ tester.view.physicalSize = const Size(430, 932);addTearDown(tester.view.reset);await tester.pumpWidget(MaterialApp(- home: PhoneWelcome(- notifier: notifier,- onTrySample: onTrySample,- sendCode: (email) async => sent.add(email),- signIn: (_, _) async {},- signInWithScan: (code) async {- scanned.add(code);- await scanGate?.future;- if (scanFails case final error?) throw error;- },- scanCamera: camera ?? const SizedBox(),+ home: ListenableBuilder(+ listenable: notifier,+ builder: (_, _) => PhoneWelcome(+ notifier: notifier,+ sendCode: (email) async => sent.add(email),+ signIn: (email, code) async => signedIn.add((email, code)),+ ),),),);await tester.pump();}- Future<void> pairComputer(WidgetTester tester) async {- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await tester.pump();- expect(find.byType(ScanToConnectPage), findsOneWidget);- }-- ScanToConnectPage camera(WidgetTester tester) =>- tester.widget<ScanToConnectPage>(find.byType(ScanToConnectPage));+ Rect picture(WidgetTester tester) =>+ tester.getRect(find.byType(OnboardingPicture));- Future<void> openOtherWays(WidgetTester tester) async {- await tester.tap(find.text('Can’t scan? Sign in another way'));- await tester.pumpAndSettle();- expect(find.byKey(const ValueKey('welcome-other-ways-title')), findsOneWidget);- }-- testWidgets('one button, how it works, Get it, and nothing else', (- tester,- ) async {- await pump(tester, onTrySample: (_) async => null);- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);- expect(find.text('Connect computer'), findsOneWidget);- for (final line in [- 'Open Harness on your computer',- 'Sign in on your computer',- 'Click Add Phone',- kAddPhoneWhere,- ]) {- expect(find.text(line), findsOneWidget, reason: line);- }- // The scan is the button above the steps, not a step of its own.- expect(find.text('Scan the QR code'), findsNothing);- expect(find.byKey(const ValueKey('set-up-get-it')), findsOneWidget);- // The accounts are behind the camera's "Can’t scan?", and the sample behind Get it.- expect(find.text('Continue with Google'), findsNothing);- expect(find.text('Continue with email'), findsNothing);- expect(find.byKey(const ValueKey('get-it-sample')), findsNothing);- expect(find.text('Is Harness on your computer?'), findsNothing);- });+ SignInProviderButton account(WidgetTester tester, SignInProvider provider) =>+ tester+ .widgetList<SignInProviderButton>(find.byType(SignInProviderButton))+ .firstWhere((button) => button.provider == provider);testWidgets(- 'Get it: the download page, sent to the computer, then back to Connect computer',+ 'the promise, the two accounts, the emailed code — and nothing else',(tester) async {- String? shared;- tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(- const MethodChannel('dev.fluttercommunity.plus/share'),- (call) async {- shared = (call.arguments as Map)['uri'] as String?;- return 'dev.fluttercommunity.plus/share/dismissed';- },- );- addTearDown(- () => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(- const MethodChannel('dev.fluttercommunity.plus/share'),- null,- ),- );await pump(tester);- await tester.tap(find.byKey(const ValueKey('set-up-get-it')));- await tester.pump();- expect(find.byType(GetHarnessPage), findsOneWidget);- expect(find.text('Get Harness\non your computer'), findsOneWidget);+ expect(find.text(OnboardingCopy.welcome), findsOneWidget);expect(- find.textContaining('harness.autonomous.ai/desktop'),- findsOneWidget,+ tester.widget<OnboardingPicture>(find.byType(OnboardingPicture)).scene,+ OnboardingScene.welcome,+ );+ expect(find.text('Continue with Google'), findsOneWidget);+ expect(find.text('Continue with Apple'), findsOneWidget);+ expect(find.text(OnboardingCopy.continueWithEmail), findsOneWidget);+ // Google first.+ expect(+ tester.getTopLeft(find.text('Continue with Google')).dy,+ lessThan(tester.getTopLeft(find.text('Continue with Apple')).dy),);- // No sample to offer, no link to it.- expect(find.byKey(const ValueKey('get-it-sample')), findsNothing);-- // The page goes, not a file: the computer's browser picks its own download.- await tester.tap(find.byKey(const ValueKey('get-it-send')));- await tester.pump();- await tester.pump();- expect(shared, kDesktopDownloadUrl);- expect(kDesktopDownloadUrl, 'https://harness.autonomous.ai/desktop');- // Installed: the camera, and back from it is Get it, and back from that the first screen.- await tester.tap(find.byKey(const ValueKey('get-it-pair')));- await tester.pump();- expect(find.byType(ScanToConnectPage), findsOneWidget);- await tester.tap(find.bySemanticsLabel('Back'));- await tester.pump();- expect(find.byType(GetHarnessPage), findsOneWidget);- await tester.tap(find.bySemanticsLabel('Back'));- await tester.pump();- expect(find.text('Your agents\nin your pocket.'), findsOneWidget);+ // Not the camera, the sample, or the steps on the computer of the first screen before it.+ expect(find.byType(ScanToConnectPage), findsNothing);+ expect(find.text('Connect computer'), findsNothing);+ expect(find.text('Can’t scan? Sign in another way'), findsNothing);+ expect(find.text('Try the sample while you wait'), findsNothing);+ expect(find.text('Your agents\nin your pocket.'), findsNothing);},);- testWidgets('a scanned code fills in the account and sends its code', (- tester,- ) async {- await pump(tester);- await pairComputer(tester);- camera(- tester,- ).onCode(ConnectCode.parse(ConnectCode.link('[email protected]'))!);- await tester.pump();- await tester.pump();- expect(sent, ['[email protected]']);- expect(find.text('Check your email'), findsOneWidget);- expect(find.textContaining('[email protected]'), findsOneWidget);- });-testWidgets(- 'a code that carries a sign-in signs in by the scan: no email, no digits',+ 'an account\'s page up: its button says so, and Cancel takes the quiet line',(tester) async {- scanGate = Completer<void>();await pump(tester);- await pairComputer(tester);- camera(tester).onCode(- ConnectCode.parse(- ConnectCode.link(- '[email protected]',- machineId: 'mac',- pairCode: 'K7QM4XPT9D2W',- signIn: 'hnh_one',- ),- )!,- );+ final before = picture(tester);++ notifier+ ..signingIn = true+ ..signInProvider = SignInProvider.google+ ..status = AppStatus.unauthenticated;+ notifier.notifyListeners();+ await tester.pump();+ expect(find.text('Waiting for Google…'), findsOneWidget);+ expect(find.byKey(const ValueKey('welcome-cancel')), findsOneWidget);+ expect(find.byKey(const ValueKey('welcome-email-way')), findsNothing);+ // The other account waits it out.+ expect(account(tester, SignInProvider.apple).onPressed, isNull);+ // The foot is the same height whatever it says: the picture has not moved.+ expect(picture(tester), before);++ // Past the page, going in: nothing left to cancel, and the email cannot sign in behind it.+ notifier.status = AppStatus.bootstrapping;+ notifier.notifyListeners();await tester.pump();expect(find.text('Signing in…'), findsOneWidget);- // Not while the scan signs in: the other way would start a second.+ expect(find.byKey(const ValueKey('welcome-cancel')), findsNothing);expect(tester.widget<TtyTextButton>(- find.widgetWithText(- TtyTextButton,- 'Can’t scan? Sign in another way',- ),+ find.byKey(const ValueKey('welcome-email-way')),).onPressed,isNull,);- scanGate!.complete();- await tester.pump();- expect(scanned, ['hnh_one']);- expect(sent, isEmpty);- expect(find.text('Check your email'), findsNothing);- expect(notifier.pendingPairing, (machineId: 'mac', code: 'K7QM4XPT9D2W'));+ expect(picture(tester), before);},);- testWidgets('an expired sign-in in the code falls back to the emailed code', (+ testWidgets('why the phone was signed out is said under the picture', (tester,) async {- scanFails = Exception('That code has expired. Scan the new one.');await pump(tester);- await pairComputer(tester);- camera(tester).onCode(- ConnectCode.parse(- ConnectCode.link('[email protected]', signIn: 'hnh_old'),- )!,- );+ final before = picture(tester);+ notifier.signedOutReason = 'You were signed out on another device.';+ notifier.notifyListeners();await tester.pump();- await tester.pump();- await tester.pump();- expect(scanned, ['hnh_old']);- expect(sent, ['[email protected]']);- expect(find.text('Check your email'), findsOneWidget);+ expect(find.byKey(const ValueKey('welcome-signed-out')), findsOneWidget);+ expect(+ find.textContaining('You were signed out on another device.'),+ findsOneWidget,+ );+ expect(picture(tester), before);});- testWidgets('can’t scan: the other ways, in a sheet over the camera', (+ testWidgets('the emailed code: the address, then the four digits, and back', (tester,) async {await pump(tester);- await pairComputer(tester);- await openOtherWays(tester);- expect(find.text('Continue with Google'), findsOneWidget);- expect(find.text('Continue with Apple'), findsOneWidget);- await tester.tap(find.text('Continue with email'));- await tester.pumpAndSettle();- expect(find.byKey(const ValueKey('welcome-other-ways-title')), findsNothing);+ await tester.tap(find.text(OnboardingCopy.continueWithEmail));+ await tester.pump();expect(find.text('Your email'), findsOneWidget);- // Back from the email is the camera it was chosen over.- await tester.binding.handlePopRoute();- await tester.pumpAndSettle();- expect(find.byType(ScanToConnectPage), findsOneWidget);- });- testWidgets('a code read under the sheet takes it down and signs in', (- tester,- ) async {- await pump(tester);- await pairComputer(tester);- await openOtherWays(tester);- // The camera runs on under the sheet.- camera(tester).onCode(- ConnectCode.parse(- ConnectCode.link(- '[email protected]',- machineId: 'mac',- pairCode: 'K7QM4XPT9D2W',- signIn: 'hnh_one',- ),- )!,- );- await tester.pumpAndSettle();- expect(find.byKey(const ValueKey('welcome-other-ways-title')), findsNothing);- expect(scanned, ['hnh_one']);- expect(sent, isEmpty);- expect(notifier.pendingPairing, (machineId: 'mac', code: 'K7QM4XPT9D2W'));- });-- testWidgets(- 'a computer\'s own sign-in QR read under the sheet: the sheet goes, then sign in first',- (tester) async {- await pump(tester);- await pairComputer(tester);- await openOtherWays(tester);- final code = 'hnq_${'a' * 43}';- camera(tester).onSignInCode!(SignInCode(code));- await tester.pumpAndSettle();- expect(- find.byKey(const ValueKey('welcome-other-ways-title')),- findsNothing,- );- expect(- find.byKey(const ValueKey('welcome-sign-in-first')),- findsOneWidget,- );- expect(notifier.pendingComputerSignIn, code);- // Back is the camera, and the computer's code is let go there.- await tester.binding.handlePopRoute();- await tester.pumpAndSettle();- expect(find.byType(ScanToConnectPage), findsOneWidget);- expect(notifier.pendingComputerSignIn, isNull);- },- );+ await tester.enterText(find.byType(TextField), '[email protected]');+ await tester.tap(find.text('Send code'));+ await tester.pump();+ await tester.pump();+ expect(sent, ['[email protected]']);+ expect(find.text('Check your email'), findsOneWidget);+ expect(find.textContaining('[email protected]'), findsOneWidget);- testWidgets('the sample, from Get it, comes back to Get it', (tester) async {- var samples = 0;- await pump(- tester,- onTrySample: (_) async {- samples++;- return 'set-up';- },- );- await tester.tap(find.byKey(const ValueKey('set-up-get-it')));+ // The last digit signs in by itself.+ await tester.enterText(find.byType(TextField), '4242');await tester.pump();- await tester.tap(find.byKey(const ValueKey('get-it-sample')));await tester.pump();+ expect(signedIn, [('[email protected]', '4242')]);++ // Back from the code is the email, and back from that the welcome.+ await tester.binding.handlePopRoute();await tester.pump();- expect(samples, 1);- expect(find.byType(GetHarnessPage), findsOneWidget);+ expect(find.text('Your email'), findsOneWidget);+ await tester.binding.handlePopRoute();+ await tester.pump();+ expect(find.text(OnboardingCopy.welcome), findsOneWidget);++ // The resend clock runs out before the test ends.+ await tester.pump(const Duration(seconds: 31));});}diff --git a/mobile/test/render/phone_screens_render_test.dart b/mobile/test/render/phone_screens_render_test.dartindex 3dd8a186b..fbb776706 100644--- a/mobile/test/render/phone_screens_render_test.dart+++ b/mobile/test/render/phone_screens_render_test.dart@@ -15,10 +15,8 @@ import 'package:harness_mobile/core/local_key_value_store.dart';import 'package:harness_mobile/phone/welcome/focus_hints.dart';import 'package:harness_mobile/phone/link_page.dart';import 'package:harness_mobile/phone/machines_tab.dart';-import 'package:harness_mobile/phone/welcome/connect_computer.dart';import 'package:harness_mobile/phone/welcome/phone_welcome.dart';-import 'package:harness_mobile/phone/welcome/set_up_computer.dart';-import 'package:harness_mobile/phone/tty.dart';+import 'package:harness_mobile/phone/welcome/your_computer.dart';import 'package:harness_mobile/phone/settings_page.dart';import 'package:harness_mobile/phone/terminal_page.dart';import 'package:harness_mobile/phone/voice_input_controller.dart';@@ -358,50 +356,26 @@ void main() {voice: voice,);- testWidgets('welcome', skip: skip, (tester) async {- final key = await pumpScreen(- tester,- PhoneWelcome(notifier: notifier, onTrySample: (_) async => null),- );- await shoot(tester, key, '0-welcome');- });-PhoneWelcome welcome() => PhoneWelcome(notifier: notifier,- onTrySample: (_) async => null,sendCode: (_) async {},signIn: (_, _) async {},- scanCamera: const SizedBox(),);- /// Connect computer, then the camera's "Can’t scan?": the other ways to sign in, in a sheet.- Future<void> otherWays(WidgetTester tester) async {- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await tester.pump(const Duration(milliseconds: 300));- await tester.tap(find.text('Can’t scan? Sign in another way'));- await tester.pump(const Duration(milliseconds: 300));- await tester.pump(const Duration(milliseconds: 300));- }-- testWidgets('welcome, scan', skip: skip, (tester) async {+ testWidgets('welcome', skip: skip, (tester) async {final key = await pumpScreen(tester, welcome());- await tester.tap(find.byKey(const ValueKey('set-up-scan')));- await tester.pump(const Duration(milliseconds: 300));- // [shoot] takes the screen down after it: one capture per test.- await shoot(tester, key, '0a-welcome-scan');+ await shoot(tester, key, '0-welcome');});- testWidgets('welcome, other ways', skip: skip, (tester) async {- final key = await pumpScreen(tester, welcome());- await otherWays(tester);- await shoot(tester, key, '0a-welcome-other-ways');- });+ /// The welcome's quiet line: the emailed code.+ Future<void> toEmail(WidgetTester tester) async {+ await tester.tap(find.byKey(const ValueKey('welcome-email-way')));+ await tester.pump(const Duration(milliseconds: 300));+ }testWidgets('welcome, email', skip: skip, (tester) async {final key = await pumpScreen(tester, welcome());- await otherWays(tester);- await tester.tap(find.text('Continue with email'));- await tester.pump(const Duration(milliseconds: 300));+ await toEmail(tester);await tester.enterText(find.byKey(const Key('welcome-email')).last,@@ -411,19 +385,8 @@ void main() {});testWidgets('welcome, code', skip: skip, (tester) async {- final key = await pumpScreen(- tester,- PhoneWelcome(- notifier: notifier,- onTrySample: (_) async => null,- sendCode: (_) async {},- signIn: (_, _) async {},- scanCamera: const SizedBox(),- ),- );- await otherWays(tester);- await tester.tap(find.text('Continue with email'));- await tester.pump(const Duration(milliseconds: 300));+ final key = await pumpScreen(tester, welcome());+ await toEmail(tester);await tester.enterText(find.byType(TextField), '[email protected]');await tester.tap(find.text('Send code'));await tester.pump(const Duration(milliseconds: 300));@@ -432,34 +395,26 @@ void main() {await shoot(tester, key, '0c-welcome-code');});- testWidgets('set up your computer', skip: skip, (tester) async {- final key = await pumpScreen(- tester,- ConnectComputerPage(- notifier: notifier,- onTrySample: (_) async => null,- ),- );- await shoot(tester, key, '0d-connect-computer');+ testWidgets('on your computer, go to', skip: skip, (tester) async {+ final key = await pumpScreen(tester, YourComputerPage(notifier: notifier));+ await shoot(tester, key, '0d-your-computer');});- testWidgets('get it', skip: skip, (tester) async {- final key = await pumpScreen(- tester,- Builder(- builder: (context) => Scaffold(- backgroundColor: Tty.of(context).ground,- body: SafeArea(- child: GetHarnessPage(- onBack: () {},- onPair: () {},- onTrySample: () {},- ),- ),- ),- ),+ testWidgets('your computer, ready', skip: skip, (tester) async {+ final key = await pumpScreen(tester, YourComputerPage(notifier: notifier));+ const studio = Machine(+ machineId: 'studio',+ authMode: MachineAuthMode.remote,+ name: 'MacBook Pro',);- await shoot(tester, key, '0e-get-it');+ notifier.machines = [...notifier.machines, studio];+ notifier.notifyListeners();+ // Past the laptop lighting, before the page goes back. The moment's clock starts on the frame+ // after the one that draws it joined.+ await tester.pump();+ await tester.pump();+ await tester.pump(const Duration(milliseconds: 1200));+ await shoot(tester, key, '0e-your-computer-ready');});void addOtherComputers() {@@ -589,7 +544,10 @@ void main() {Positioned.fill(child: FocusHints(micBottom: 34 + 4 * 15.6,- store: FocusHintsSeen(storage: _MemoryStore()),+ // Asked for again (Settings ▸ Show the tips again): never by themselves.+ store: FocusHintsSeen(+ storage: _MemoryStore()..write('phone_focus_hints_v1', 'again'),+ ),),),],diff --git a/mobile/test/terminal_session_protocol_test.dart b/mobile/test/terminal_session_protocol_test.dartindex 8b0335885..5218f6739 100644--- a/mobile/test/terminal_session_protocol_test.dart+++ b/mobile/test/terminal_session_protocol_test.dart@@ -1086,6 +1086,38 @@ void main() {expect(await s.pasteText('hi'), isFalse);});+ test('a line sent — a Return, or a message that went — is said, once each', () async {+ final (s, _) = await live();+ var sent = 0;+ s.onLineSent = () => sent++;++ s.terminal.textInput('l');+ s.terminal.textInput('s');+ await Future<void>.delayed(const Duration(milliseconds: 10));+ expect(sent, 0, reason: 'keys typed are not a line sent');+ s.terminal.textInput('\r');+ await Future<void>.delayed(const Duration(milliseconds: 10));+ expect(sent, 1);++ expect(await s.sendComposerText(' '), isFalse);+ expect(sent, 1, reason: 'nothing went');+ expect(await s.sendComposerText('fix it'), isTrue);+ expect(sent, 2);+ });++ test('a line that cannot go is not said', () async {+ final s = session();+ await s.open();+ await ready(s, readOnly: true);+ var sent = 0;+ s.onLineSent = () => sent++;++ s.terminal.textInput('ls\r');+ await Future<void>.delayed(const Duration(milliseconds: 10));+ expect(await s.sendComposerText('hi'), isFalse);+ expect(sent, 0);+ });+test('a paste is one frame; one that cannot be sent is a lost stream',() async {diff --git a/mobile/test/your_computer_test.dart b/mobile/test/your_computer_test.dartnew file mode 100644index 000000000..d6bf0a3ec--- /dev/null+++ b/mobile/test/your_computer_test.dart@@ -0,0 +1,217 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness_mobile/auth/auth_session.dart';+import 'package:harness_mobile/core/models.dart';+import 'package:harness_mobile/phone/welcome/onboarding_copy.dart';+import 'package:harness_mobile/phone/welcome/onboarding_picture.dart';+import 'package:harness_mobile/phone/welcome/your_computer.dart';+import 'package:harness_mobile/state/app_state.dart';++import 'phone_edge/edge_fixture.dart';++/// ② Your computer, pushed from Computers ▸ Add computer: "On your computer, go to", the address+/// that sends the download, the account watched for the computer that opens it — and, when one+/// joins, its moment, then back to the list.+void main() {+ late List<String?> shared;+ late List<String?> chimes;+ late List<String?> haptics;++ setUp(() {+ shared = [];+ chimes = [];+ haptics = [];+ final messenger =+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;+ messenger.setMockMethodCallHandler(+ const MethodChannel('dev.fluttercommunity.plus/share'),+ (call) async {+ shared.add((call.arguments as Map)['uri'] as String?);+ return 'dev.fluttercommunity.plus/share/dismissed';+ },+ );+ messenger.setMockMethodCallHandler(const MethodChannel('harness/chime'), (+ call,+ ) async {+ chimes.add(call.arguments as String?);+ return true;+ });+ messenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {+ if (call.method == 'HapticFeedback.vibrate') {+ haptics.add(call.arguments as String?);+ }+ return null;+ });+ });++ tearDown(() {+ final messenger =+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;+ for (final channel in const [+ MethodChannel('dev.fluttercommunity.plus/share'),+ MethodChannel('harness/chime'),+ SystemChannels.platform,+ ]) {+ messenger.setMockMethodCallHandler(channel, null);+ }+ });++ const studio = Machine(+ machineId: 'studio',+ authMode: MachineAuthMode.remote,+ name: 'studio',+ );++ /// The list Computers is, with the page pushed over it — as Add computer pushes it.+ Future<AppNotifier> pump(WidgetTester tester, {AppNotifier? app}) async {+ setPhone(tester, largePhone);+ final notifier = app ?? edgeApp(noMachines: true);+ addTearDown(notifier.dispose);+ await tester.pumpWidget(+ phoneApp(+ Builder(+ builder: (context) => Scaffold(+ body: Center(+ child: TextButton(+ onPressed: () => Navigator.of(context).push(+ MaterialPageRoute<void>(+ builder: (_) => YourComputerPage(notifier: notifier),+ ),+ ),+ child: const Text('Computers'),+ ),+ ),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Computers'));+ await frames(tester);+ return notifier;+ }++ /// A computer joins the account: the account's next answer has it.+ Future<void> join(WidgetTester tester, AppNotifier app) async {+ app.machines = [...app.machines, studio];+ app.notifyListeners();+ await tester.pump();+ }++ OnboardingScene scene(WidgetTester tester) =>+ tester.widget<OnboardingPicture>(find.byType(OnboardingPicture)).scene;++ testWidgets('On your computer, go to: the address, and the phone looking', (+ tester,+ ) async {+ await pump(tester);+ expect(find.text(OnboardingCopy.goToHeadline), findsOneWidget);+ expect(find.text('autonomous.ai/go'), findsOneWidget);+ expect(+ find.textContaining(OnboardingCopy.looking, findRichText: true),+ findsOneWidget,+ );+ expect(scene(tester), OnboardingScene.looking);+ expect(find.bySemanticsLabel('Back'), findsOneWidget);+ await unmount(tester);+ });++ testWidgets('the address is the button: it sends the link', (tester) async {+ await pump(tester);+ await tester.tap(find.byKey(const ValueKey('go-address')));+ await frames(tester);+ expect(shared, ['https://autonomous.ai/go']);+ expect(OnboardingCopy.goUrl, 'https://autonomous.ai/go');+ await unmount(tester);+ });++ testWidgets('the account is asked for its computers every five seconds', (+ tester,+ ) async {+ final app = edgeApp(noMachines: true);+ final api = _CountingApi(app);+ app.api = api;+ await pump(tester, app: app);+ expect(api.asked, 0);+ await tester.pump(ComputerWatch.every);+ expect(api.asked, 1);+ await tester.pump(ComputerWatch.every);+ expect(api.asked, 2);+ await unmount(tester);+ });++ testWidgets(+ 'a computer joins: its moment — taps, the buzz and the notes — then back to the list',+ (tester) async {+ final app = await pump(tester);+ haptics.clear();+ await join(tester, app);+ expect(find.text(OnboardingCopy.ready('studio')), findsOneWidget);+ expect(scene(tester), OnboardingScene.joined);+ // Named as the person's own: no "New device" for the computer they are looking at.+ await tester.pump();+ expect(app.welcomedMachines, contains('studio'));++ // Three quickening taps while the laptop draws itself…+ await tester.pump(const Duration(milliseconds: 300));+ expect(+ haptics.where((h) => h == 'HapticFeedbackType.lightImpact'),+ hasLength(3),+ );+ expect(chimes, isEmpty);+ // …then, as its screen lights, the buzz and the only sound in setup.+ await tester.pump(const Duration(milliseconds: 350));+ expect(haptics.last, 'HapticFeedbackType.mediumImpact');+ expect(chimes, ['assets/sound/joined.wav']);++ // About two seconds in all, and the page goes back to the list by itself.+ await tester.pump(const Duration(milliseconds: 1600));+ await frames(tester);+ expect(find.byType(YourComputerPage), findsNothing);+ expect(find.text('Computers'), findsOneWidget);+ expect(chimes, hasLength(1), reason: 'the notes are played once');+ await unmount(tester);+ },+ );++ testWidgets(+ 'a tap during the moment goes back sooner, and plays nothing more',+ (tester) async {+ final app = await pump(tester);+ await join(tester, app);+ await tester.pump(const Duration(milliseconds: 100));+ await tester.tap(find.text(OnboardingCopy.ready('studio')));+ await tester.pump();+ await frames(tester);+ expect(find.byType(YourComputerPage), findsNothing);+ expect(chimes, isEmpty);+ await unmount(tester);+ },+ );++ testWidgets('a computer already on the account is not one joining', (+ tester,+ ) async {+ final app = edgeApp(machineName: 'old-mac');+ await pump(tester, app: app);+ // The account answers again, with only what it had.+ app.notifyListeners();+ await frames(tester);+ expect(find.text(OnboardingCopy.goToHeadline), findsOneWidget);+ expect(find.text(OnboardingCopy.ready('old-mac')), findsNothing);+ await unmount(tester);+ });+}++/// The account's API, counting how often it is asked for its computers.+class _CountingApi extends EdgeApi {+ _CountingApi(AppNotifier app) : super(app, AuthSession());++ int asked = 0;++ @override+ Future<List<Machine>> machines() {+ asked++;+ return super.machines();+ }+}