From de57a39df6b298de9c6ca10c439dc550f6de413f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 25 Mar 2026 23:45:47 +0200 Subject: [PATCH] feat(desktop/setup): improve addresses display --- apps/client/src/setup.css | 7 ++++++- apps/client/src/setup.tsx | 13 ++++++++++++- apps/client/src/translations/en/translation.json | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/apps/client/src/setup.css b/apps/client/src/setup.css index 1f678d383b..767fe50c3c 100644 --- a/apps/client/src/setup.css +++ b/apps/client/src/setup.css @@ -311,15 +311,20 @@ body.setup { } .ip-addresses { - min-width: 200px; + min-width: 250px; user-select: text; display: flex; flex-direction: column; font-family: var(--monospace-font-family); + font-size: 0.9em; .tn-card-body { overflow: auto; padding-bottom: 0.5em; + + > :first-child { + font-weight: bold; + } } } } diff --git a/apps/client/src/setup.tsx b/apps/client/src/setup.tsx index 1904faf74f..916671e1b5 100644 --- a/apps/client/src/setup.tsx +++ b/apps/client/src/setup.tsx @@ -378,7 +378,7 @@ function SyncFromDesktop({ setState }: { setState: (state: State) => void }) { {networkAddresses.length > 0 && ( {networkAddresses.map((addr) => ( - {addr} + {`${location.protocol}//${addr}:${location.port}`} ))} )} @@ -484,7 +484,18 @@ function getNetworkAddresses(): string[] { } } + // Sort by likelihood of being the local network address. + addresses.sort((a, b) => networkScore(a) - networkScore(b)); + return addresses; } +function networkScore(addr: string): number { + if (addr.startsWith("192.168.")) return 0; + if (addr.startsWith("10.")) return 1; + if (/^172\.(1[6-9]|2\d|3[01])\./.test(addr)) return 2; + if (addr.includes(":")) return 4; // IPv6 + return 3; +} + main(); diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index d511ed5dc2..dafbb6602c 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2280,6 +2280,6 @@ "wrong-password": "Incorrect password. Please try again.", "language": "Language", "continue": "Continue", - "your-ip-addresses": "Your IP addresses" + "your-ip-addresses": "Addresses for this device" } }