The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): local network pairing links skip idle bridges and tunnels (#18085)
Co-authored-by: TinBane <363069+TinBane@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
TinBane committed
Oct 19, 2026 at 06:13 UTC
8832d5c320ffc30e393cb995950167dc80afb873
2 files changed
+56
-12
apps/desktop/src/backend/DesktopServerExposure.test.ts
+33
@@ -211,6 +211,39 @@ describe("DesktopServerExposure", () => {
211
),
212
);
213
214
+ it.effect("advertises the Wi-Fi or Ethernet address ahead of bridges and tunnels", () =>
215
+ withHarness(
216
+ {
217
+ bridge0: [{ address: "192.168.2.1", family: "IPv4", internal: false }],
218
+ utun4: [{ address: "10.8.0.2", family: "IPv4", internal: false }],
219
+ en0: [{ address: "192.168.1.20", family: "IPv4", internal: false }],
220
+ },
221
+ Effect.gen(function* () {
222
+ const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
223
+ yield* serverExposure.configureFromSettings({ port: 4173 });
224
+
225
+ const change = yield* serverExposure.setMode("network-accessible");
226
+ assert.equal(change.state.advertisedHost, "192.168.1.20");
227
+ }),
228
+ ),
229
+ );
230
+
231
+ it.effect("keeps a host bridge's LAN address ahead of later adapters", () =>
232
+ withHarness(
233
+ {
234
+ vmbr0: [{ address: "192.168.1.30", family: "IPv4", internal: false }],
235
+ enx00e04c680001: [{ address: "192.168.42.10", family: "IPv4", internal: false }],
236
+ },
237
+ Effect.gen(function* () {
238
+ const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
239
+ yield* serverExposure.configureFromSettings({ port: 4173 });
240
+
241
+ const change = yield* serverExposure.setMode("network-accessible");
242
+ assert.equal(change.state.advertisedHost, "192.168.1.30");
243
+ }),
244
+ ),
245
+ );
246
+
247
it.effect("persists tailscale serve preferences atomically and reports no-op updates", () =>
248
withHarness(
249
emptyNetworkInterfaces,
apps/desktop/src/backend/DesktopServerExposure.ts
+23
-12
@@ -70,6 +70,18 @@ const isUsableLanIpv4Address = (address: string): boolean =>
70
!address.startsWith("169.254.") &&
71
!isTailscaleIpv4Address(address);
72
73
+/**
74
+ * Bridges, tunnels and VM adapters whose private address other devices on the
75
+ * LAN usually cannot reach: macOS's Thunderbolt Bridge (`bridge0`, which can
76
+ * keep a manual address while nothing is plugged in) and Internet Sharing
77
+ * bridges, VPN tunnels, and container or VM networks. Their addresses are only
78
+ * advertised when no other interface has one. Host bridges such as `br0`,
79
+ * Proxmox's `vmbr0` and Hyper-V's `vEthernet` external switches often carry
80
+ * the LAN address, so they are not listed.
81
+ */
82
+const HOST_ONLY_INTERFACE =
83
+ /^(bridge\d|utun|ipsec|ppp|tun|tap|wg|docker|br-|veth|virbr|vmnet|vboxnet|VirtualBox|VMware)/;
84
+
85
const isHttpsEndpointUrl = (value: string): boolean => {
86
try {
87
return new URL(value).protocol === "https:";
@@ -87,18 +99,17 @@ const resolveLanAdvertisedHost = (
99
return normalizedExplicitHost;
100
}
101
90
- for (const interfaceAddresses of Object.values(networkInterfaces)) {
91
- if (!interfaceAddresses) continue;
92
-
93
- for (const address of interfaceAddresses) {
94
- if (address.internal) continue;
95
- if (address.family !== "IPv4") continue;
96
- if (!isUsableLanIpv4Address(address.address)) continue;
97
- return address.address;
98
- }
99
- }
100
-
101
- return null;
102
+ const lanAddresses = Object.entries(networkInterfaces).flatMap(([name, addresses]) =>
103
+ (addresses ?? [])
104
+ .filter(
105
+ (address) =>
106
+ !address.internal && address.family === "IPv4" && isUsableLanIpv4Address(address.address),
107
+ )
108
+ .map((address) => ({ name, address: address.address })),
109
+ );
110
+ const preferred =
111
+ lanAddresses.find(({ name }) => !HOST_ONLY_INTERFACE.test(name)) ?? lanAddresses[0];
112
+ return preferred?.address ?? null;
113
};
114
115
const resolveDesktopServerExposure = (input: {