Servers: name a machine after its hostname once it connects

A saved server still named by the app ('My server', 'This server',
'Original legacy server' or its address host/IP) takes the hostname the
machine reports in get_status the first time the app connects; typed
names are kept. New servers (legacy migration, Settings with a blank
name, onboarding) start with the address host. A browser on its page
origin with no saved profile shows the reported hostname too. No server
change: get_status already reports the hostname.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 15:58:28 +00:00
parent 3e817a189b
commit c264f865ff
16 changed files with 654 additions and 24 deletions
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../../core/servers/machine_access.dart';
import '../../core/servers/server_catalog.dart';
import '../../core/servers/server_naming.dart';
import '../../ui/adaptive/segmented_bar.dart';
import '../onboarding/discovery/discovered_server.dart';
import '../onboarding/discovery/discovery_panel.dart';
@@ -72,13 +73,19 @@ class _ServerEditorState extends State<_ServerEditor> {
Future<void> _save() async {
if (_saving) return;
try {
final endpoints = _addresses.text
.split('\n')
.where((line) => line.trim().isNotEmpty)
.toList();
// A blank name is the address's host until the machine reports its
// hostname, which then names it.
final server = SavedServer.validated(
id: _id,
name: _name.text,
name: _name.text.trim().isEmpty && endpoints.isNotEmpty
? temporaryServerName(endpoints.first)
: _name.text,
legacyEndpoint: widget.server?.legacyEndpoint,
endpoints: _addresses.text
.split('\n')
.where((line) => line.trim().isNotEmpty),
endpoints: endpoints,
);
setState(() {
_saving = true;
@@ -173,6 +180,10 @@ class _ServerEditorState extends State<_ServerEditor> {
const SizedBox(height: 16),
],
_field(_name, 'Server name', key: 'server-profile-name'),
const SizedBox(height: 8),
const Text(
'Leave blank to use the machine\'s own name once it connects.',
),
const SizedBox(height: 16),
_field(
_addresses,