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
+27 -5
View File
@@ -767,7 +767,10 @@ class _FixtureAuthenticator extends ChangeNotifier
}
class _FixtureChannel implements WebSocketChannel {
_FixtureChannel();
_FixtureChannel({this.hostname = 'tank'});
/// The machine name this fixture server reports in `get_status`.
final String hostname;
final _incoming = StreamController<dynamic>();
Timer? _runCompletion;
@@ -814,7 +817,13 @@ class _FixtureChannel implements WebSocketChannel {
}
});
}
final reply = probeReply(decoded);
final reply = decoded['type'] == 'get_status'
? {
'id': decoded['id'],
'type': 'status',
'status': {'hostname': hostname},
}
: probeReply(decoded);
final followUps = perfChatFollowUps(decoded);
final subscribe = decoded['chat_subscribe'];
if (subscribe is Map) {
@@ -957,6 +966,17 @@ Future<void> main() async {
if (query != null && query.isNotEmpty) _typeSearchWhenShown(query);
useAppUrlStrategy();
ServerConnections? machines;
// `placeholders=1`: the saved machines still carry names the app chose
// ('My server', an address host); each reports its hostname on connect.
final placeholders = params['placeholders'] == '1';
// `origin=1`: a browser on its page origin with no saved machine.
if (params['origin'] == '1') {
machines = ServerConnections(
store: MemoryServerCatalogStore(),
onSelected: (_) async {},
);
await machines.load();
}
if (params['machines'] == '1' || params['federated'] == '1') {
machines = ServerConnections(
store: MemoryServerCatalogStore(
@@ -964,12 +984,12 @@ Future<void> main() async {
servers: [
SavedServer.validated(
id: 'mac',
name: 'Alan’s Mac',
name: placeholders ? 'My server' : 'Alan’s Mac',
endpoints: ['ws://mac.fixture/connect'],
),
SavedServer.validated(
id: 'linux',
name: 'Linux desktop',
name: placeholders ? 'linux.fixture' : 'Linux desktop',
endpoints: ['ws://linux.fixture/connect'],
),
],
@@ -988,7 +1008,9 @@ Future<void> main() async {
machines,
connect: (machine) async {
final client = PipelinesClient(
channelFactory: (_) => _FixtureChannel(),
channelFactory: (_) => _FixtureChannel(
hostname: machine.id == 'mac' ? 'tank' : 'linux-box',
),
);
await client.connect(Uri.parse(machine.endpoints.first));
return ChatMachineConnection(