Compare commits

..

No commits in common. "85ba556af2287d4a25d4ec52133e3799d36d2fdb" and "042d68b237fa112f3d3aff43d8e9ca8e0fe44db4" have entirely different histories.

4 changed files with 16 additions and 36 deletions

View File

@ -181,17 +181,15 @@ Future<bool> _provisionSyncAccount(String home) async {
'--headless=new', '--headless=new',
'--disable-gpu', '--disable-gpu',
'--user-data-dir=${_profileDir(home)}', '--user-data-dir=${_profileDir(home)}',
// Surface the page's own log() output, so a failure inside the app is '--virtual-time-budget=15000',
// visible in the terminal that started the provisioning run. '--dump-dom',
'--enable-logging=stderr',
'http://localhost:$_port', 'http://localhost:$_port',
]); ]);
// No --virtual-time-budget: it makes Chrome SIGKILL itself when the budget final code = await process.exitCode;
// expires, which both reads as a failure (exit -9) and can cut the sync if (code != 0) {
// short. Give the page a real window of wall-clock time, then close it. stderr.writeln('Headless provisioning run exited with $code.');
await Future<void>.delayed(const Duration(seconds: 30)); return false;
process.kill(); }
await process.exitCode;
stdout.writeln( stdout.writeln(
'Provisioning run complete. Launch normally to confirm it is connected.', 'Provisioning run complete. Launch normally to confirm it is connected.',
); );

View File

@ -12,7 +12,6 @@
/// half. On Android there is no such file. /// half. On Android there is no such file.
library; library;
import 'dart:developer';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@ -64,16 +63,9 @@ Future<FirebaseAccount?> loadAccount() async {
final provisioned = await accountFromWrapper(Uri.base); final provisioned = await accountFromWrapper(Uri.base);
if (provisioned != null) await saveAccount(provisioned); if (provisioned != null) await saveAccount(provisioned);
return provisioned; return provisioned;
} on Exception catch (error, stackTrace) { } on Exception {
// Still "not configured" rather than crashing the settings screen -- but // No secret service available: behave as "not configured" rather than
// never silent: this hid *why* provisioning failed, which is // crashing the settings screen.
// indistinguishable from "no account set" until you say so.
log(
'loadAccount failed; treating this device as not configured',
level: 1000,
error: error,
stackTrace: stackTrace,
);
return null; return null;
} }
} }

View File

@ -1,5 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'package:crdt_sync/crdt_sync.dart'; import 'package:crdt_sync/crdt_sync.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
@ -8,7 +8,6 @@ import 'package:todo/data/note.dart';
import 'package:todo/data/note_repository.dart'; import 'package:todo/data/note_repository.dart';
import 'package:todo/data/note_template.dart'; import 'package:todo/data/note_template.dart';
import 'package:todo/frame_stats.dart'; import 'package:todo/frame_stats.dart';
import 'package:todo/sync/firebase_backend.dart';
import 'package:todo/sync/local_backup.dart'; import 'package:todo/sync/local_backup.dart';
import 'package:todo/sync/local_backup_factory.dart'; import 'package:todo/sync/local_backup_factory.dart';
import 'package:todo/sync/run_sync.dart'; import 'package:todo/sync/run_sync.dart';
@ -232,12 +231,7 @@ class _CaptureScreenState extends State<CaptureScreen>
/// lands in the status line so drift can't go unnoticed for days. /// lands in the status line so drift can't go unnoticed for days.
Future<void> _autoSync() async { Future<void> _autoSync() async {
final settings = _settings; final settings = _settings;
if (_autoSyncing || settings == null) return; if (_autoSyncing || settings == null || !settings.isConfigured) return;
// Either backend counts. `isConfigured` means "has a GitHub token", so
// gating on it alone silently skips every sync on a device connected
// only to Firebase -- and once the mirror is retired that is every
// device.
if (!settings.isConfigured && await openFirebase() == null) return;
_autoSyncing = true; _autoSyncing = true;
try { try {
final result = await runSync( final result = await runSync(
@ -291,8 +285,8 @@ class _CaptureScreenState extends State<CaptureScreen>
/// Runs a full sync, routing to settings first if not yet configured. /// Runs a full sync, routing to settings first if not yet configured.
Future<void> _sync() async { Future<void> _sync() async {
final settings = _settings ?? await SyncSettings.load(); final settings = _settings ?? await SyncSettings.load();
if (!settings.isConfigured && await openFirebase() == null) { if (!settings.isConfigured) {
_showSnack('Connect Firebase (or add a GitHub token) in settings'); _showSnack('Add a GitHub token in settings to enable sync');
await _openSettings(); await _openSettings();
return; return;
} }

View File

@ -151,7 +151,7 @@ void main() {
expect(raw.controller!.text, isEmpty); expect(raw.controller!.text, isEmpty);
}); });
testWidgets('tapping Sync while unconfigured prompts to connect a backend', ( testWidgets('tapping Sync while unconfigured prompts for a token', (
tester, tester,
) async { ) async {
await pumpCapture(tester); // empty prefs → no token → not configured await pumpCapture(tester); // empty prefs → no token → not configured
@ -160,11 +160,7 @@ void main() {
await tester.pump(); // settings load + snackbar await tester.pump(); // settings load + snackbar
await tester.pump(); await tester.pump();
// The behaviour that matters is the routing, not the wording: an expect(find.textContaining('Add a GitHub token'), findsOneWidget);
// unconfigured device is sent to settings to connect a backend. Asserting
// on the snackbar text tied this to one phrasing, and the snackbar is
// gone by the time settings has pushed anyway.
expect(find.textContaining('Connect Firebase'), findsWidgets);
}); });
testWidgets('the notes-list button navigates to the list screen', ( testWidgets('the notes-list button navigates to the list screen', (