Files
alan 079924d19a Recover from zero servers, sign each machine in on its own, offer every route
- Removing the primary machine hands pipelines/runs to the next saved machine
  on native hosts; removing the last machine returns to the connect screen
  instead of stranding the app on "Server endpoint not configured".
- Add server probes the new machine and asks for its own password in the same
  page; Settings rows show Connected / Sign in required / Unreachable with the
  reason and offer Sign in; no other machine's credential is ever reused.
- Unreachable addresses explain why: a TLS failure against an IP points at the
  Tailscale name, a non-Pipelines answer points at the port.
- Discovered machines list every advertised route (LAN, Tailscale IP, Tailscale
  name) as a checklist; chosen routes are saved as one machine.
- tool/connection_probe.dart replays the native login and websocket against
  real addresses for diagnosis.
2026-11-08 23:59:20 +00:00

42 lines
1.4 KiB
Dart

import 'package:flutter/foundation.dart';
import 'server_catalog.dart';
/// Whether this device can use one saved machine right now.
enum MachineAccess {
/// Its connection is open, or its kept sign-in is accepted.
connected,
/// The machine wants its own password; no other machine's sign-in applies.
needsPassword,
/// Nothing answered, or what answered is not a Pipelines server.
unreachable,
}
/// One access verdict with the sentence to show for it.
class MachineAccessResult {
const MachineAccessResult(this.access, {this.detail});
final MachineAccess access;
final String? detail;
bool get needsPassword => access == MachineAccess.needsPassword;
bool get connected => access == MachineAccess.connected;
}
/// Authenticates saved machines independently of one another. Settings and
/// the server editor use it to ask a new machine for its own password and to
/// show each machine's live state; the chat pool implements it.
abstract interface class MachineAuthenticator implements Listenable {
/// The live verdict for a saved machine, null while it is still connecting
/// or unknown to the pool.
MachineAccessResult? status(String id);
/// Asks [server] whether this device may use it without a new password.
Future<MachineAccessResult> probe(SavedServer server);
/// Signs in to [server] with its own password; null on success.
Future<String?> authenticate(SavedServer server, String password);
}