Skip to content

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

fix(mobile): a scanned code whose account cannot be read no longer hangs on Pairing…

dee16db98e99114
diff --git a/mobile/lib/phone/welcome/connect_computer.dart b/mobile/lib/phone/welcome/connect_computer.dart
index 753267c92..bbefc5b5d 100644
--- a/mobile/lib/phone/welcome/connect_computer.dart
+++ b/mobile/lib/phone/welcome/connect_computer.dart
@@ -112,10 +112,22 @@ class _ConnectComputerPageState extends State<ConnectComputerPage> {
_say('Pairing…');
if (!widget.notifier.machineStates.containsKey(machineId)) {
// Bounded: a slow network is a reason to say so, not to leave "Pairing…" up for good.
- await widget.notifier.refreshMachines().timeout(
- const Duration(seconds: 5),
- onTimeout: () {},
- );
+ try {
+ await widget.notifier.refreshMachines().timeout(
+ const Duration(seconds: 5),
+ onTimeout: () {},
+ );
+ } catch (_) {
+ // ⚠️ A list that could not be read says nothing about whether the computer is on the
+ // account, so it is not "isn't on your account" — and thrown on from here, it left
+ // "Pairing…" up for good.
+ if (!mounted) return;
+ _say(
+ "Couldn't reach your account. Check your connection and scan again.",
+ failed: true,
+ );
+ return;
+ }
}
if (!mounted) return;
if (!widget.notifier.machineStates.containsKey(machineId)) {
diff --git a/mobile/test/connect_computer_test.dart b/mobile/test/connect_computer_test.dart
index ddf056640..14925708f 100644
--- a/mobile/test/connect_computer_test.dart
+++ b/mobile/test/connect_computer_test.dart
@@ -150,4 +150,22 @@ void main() {
expect(find.textContaining("isn't on your account"), findsOneWidget);
await unmount(tester);
});
+
+ testWidgets('an account that cannot be read is said, not left pairing', (
+ tester,
+ ) async {
+ (app.api as FakeApi).onMachines = () async =>
+ throw StateError('The network connection was lost.');
+ await pump(tester);
+ await scan(
+ tester,
+ ConnectCode.link('[email protected]', machineId: 'studio', pairCode: 'K7QM4XPT'),
+ );
+ await tester.pump();
+ expect(links.codes, isEmpty);
+ expect(backs, isEmpty);
+ expect(find.text('Pairing…'), findsNothing);
+ expect(find.textContaining("Couldn't reach your account"), findsOneWidget);
+ await unmount(tester);
+ });
}