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.
This commit is contained in:
2026-11-08 23:59:20 +00:00
parent 929e4cc017
commit 079924d19a
40 changed files with 2524 additions and 259 deletions
+31 -3
View File
@@ -77,20 +77,37 @@ class _PipelinesRootState extends State<PipelinesRoot> {
_chatPool =
widget.chatPoolFactory?.call(_servers) ??
ChatServerPool(_servers, web: widget.web);
// Settings asks each new machine for its own password through the pool.
_servers.authenticator = _chatPool;
}
}
ServerProbe get _probe => identical(widget.check, ServerSession.check)
? ServerSession.probe
: probeFromCheck(widget.check);
late final ServerConnections _servers = ServerConnections(
store: widget.catalogStore,
onSelected: _selectServer,
replaceRemovedPrimary: !widget.web,
);
@override
void initState() {
super.initState();
_servers.addListener(_onServersChanged);
_loadServers();
}
/// A native host with no saved machine left has nothing to connect to, so
/// it returns to Add server however the last profile went away. Removing a
/// profile that was not the primary never activated anything before, which
/// stranded the app on "Server endpoint not configured".
void _onServersChanged() {
if (widget.web || _booting || _onboarding) return;
if (_servers.catalog.servers.isEmpty) unawaited(_activate(null));
}
Future<void> _loadServers() async {
await _servers.load(legacyEndpoint: widget.server.uri?.toString() ?? '');
if (!mounted) return;
@@ -211,7 +228,7 @@ class _PipelinesRootState extends State<PipelinesRoot> {
.map(Uri.parse)
.where((uri) => uri != endpoint),
],
check: widget.check,
probe: _probe,
isCurrent: () => mounted && token == _activation,
);
if (!mounted ||
@@ -247,7 +264,11 @@ class _PipelinesRootState extends State<PipelinesRoot> {
});
}
Future<void> _saveOnboardingServer(String url, {String? name}) async {
Future<void> _saveOnboardingServer(
String url, {
String? name,
Iterable<String> aliases = const [],
}) async {
final token = _activation;
SavedServer? target;
for (final server in _servers.catalog.servers) {
@@ -258,7 +279,7 @@ class _PipelinesRootState extends State<PipelinesRoot> {
name: name?.trim().isNotEmpty == true
? name!.trim()
: Uri.parse(url).host,
endpoints: [url],
endpoints: [url, ...aliases],
);
if (!await _servers.save(target, activate: false) ||
!await _servers.select(target.id, activate: false)) {
@@ -278,6 +299,7 @@ class _PipelinesRootState extends State<PipelinesRoot> {
@override
void dispose() {
_activation++;
_servers.removeListener(_onServersChanged);
_chatPool?.dispose();
_servers.dispose();
super.dispose();
@@ -326,8 +348,14 @@ class _PipelinesRootState extends State<PipelinesRoot> {
final flow = OnboardingFlow(
initialServer: _server.uri?.toString() ?? widget.buildDefault,
startAtPassword: _refused,
probe: _probe,
saveServer: _saveOnboardingServer,
saveServerProfile: (url, name) => _saveOnboardingServer(url, name: name),
saveMachine: (endpoints, name) => _saveOnboardingServer(
endpoints.first,
name: name,
aliases: endpoints.skip(1),
),
onDone: _done,
savedServers: SavedServersSection(connections: _servers),
discovery: platformServerDiscovery(web: widget.web),