The best way to control Claude Code, Codex and more from any computer or phone
fix(web): show the correct Tailscale URL when switching to port 443 (#24890)
Vibhu Prashar committed
Oct 31, 2026 at 14:10 UTC
1d4c5e023f58a21bed5d50908f10057cd49f901e
3 files changed
+43
-14
apps/web/src/components/settings/ConnectionsSettings.logic.test.ts
+21
@@ -2,6 +2,7 @@ import type { DesktopWslState } from "@t3tools/contracts";
2
import { describe, expect, it, vi } from "vite-plus/test";
3
import {
4
applyWslEnableSelection,
5
+ resolveTailscaleServeBaseUrl,
6
selectQrEndpointOption,
7
togglePairingScopeSelection,
8
} from "./ConnectionsSettings.logic";
@@ -41,6 +42,26 @@ describe("togglePairingScopeSelection", () => {
42
});
43
});
44
45
+describe("resolveTailscaleServeBaseUrl", () => {
46
+ it.each([
47
+ ["https://host.tail.ts.net:441/", 443, "https://host.tail.ts.net"],
48
+ ["https://host.tail.ts.net:441/", 444, "https://host.tail.ts.net:444"],
49
+ ] as const)("previews %s on port %i", (httpBaseUrl, port, expected) => {
50
+ expect(resolveTailscaleServeBaseUrl({ httpBaseUrl }, port, true)).toBe(expected);
51
+ });
52
+
53
+ it("returns null without a pending endpoint", () => {
54
+ expect(resolveTailscaleServeBaseUrl(null, 443, true)).toBeNull();
55
+ });
56
+
57
+ it.each([
58
+ ["https://host.tail.ts.net:441/", 0, false],
59
+ ["not a URL", 443, true],
60
+ ] as const)("preserves %s when port %i cannot be previewed", (httpBaseUrl, port, isPortValid) => {
61
+ expect(resolveTailscaleServeBaseUrl({ httpBaseUrl }, port, isPortValid)).toBe(httpBaseUrl);
62
+ });
63
+});
64
+
65
const baseWslState: DesktopWslState = {
66
enabled: false,
67
distro: null,
apps/web/src/components/settings/ConnectionsSettings.logic.ts
+16
@@ -67,6 +67,22 @@ export function missingTailscaleEndpointDescription(
67
: "Start Tailscale to set up HTTPS access through MagicDNS.";
68
}
69
70
+export function resolveTailscaleServeBaseUrl(
71
+ endpoint: Pick<AdvertisedEndpoint, "httpBaseUrl"> | null,
72
+ port: number,
73
+ isPortValid: boolean,
74
+): string | null {
75
+ if (!endpoint) return null;
76
+ if (!isPortValid) return endpoint.httpBaseUrl;
77
+ try {
78
+ const url = new URL(endpoint.httpBaseUrl);
79
+ url.port = String(port);
80
+ return url.toString().replace(/\/$/u, "");
81
+ } catch {
82
+ return endpoint.httpBaseUrl;
83
+ }
84
+}
85
+
86
export function isWslSettingsRowVisible(input: {
87
readonly state: DesktopWslState | null;
88
readonly error: string | null;
apps/web/src/components/settings/ConnectionsSettings.tsx
+6
-14
@@ -30,6 +30,7 @@ import {
30
isWslSettingsRowVisible,
31
missingTailscaleEndpointDescription,
32
resolveLocalVersionStatusLabel,
33
+ resolveTailscaleServeBaseUrl,
34
} from "./ConnectionsSettings.logic";
35
import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
36
import { LocalEnvironmentSetting } from "./LocalEnvironmentSetting";
@@ -340,20 +341,11 @@ export function ConnectionsSettings({ view }: { readonly view: "environments" |
341
parsedTailscaleServePort >= 1 &&
342
parsedTailscaleServePort <= 65_535;
343
343
- const pendingTailscaleServeBaseUrl = (() => {
344
- if (!pendingTailscaleServeEndpoint) return null;
345
- if (!isTailscaleServePortValid) return pendingTailscaleServeEndpoint.httpBaseUrl;
346
- if (parsedTailscaleServePort === DEFAULT_TAILSCALE_SERVE_PORT) {
347
- return pendingTailscaleServeEndpoint.httpBaseUrl;
348
- }
349
- try {
350
- const url = new URL(pendingTailscaleServeEndpoint.httpBaseUrl);
351
- url.port = String(parsedTailscaleServePort);
352
- return url.toString().replace(/\/$/u, "");
353
- } catch {
354
- return pendingTailscaleServeEndpoint.httpBaseUrl;
355
- }
356
- })();
344
+ const pendingTailscaleServeBaseUrl = resolveTailscaleServeBaseUrl(
345
+ pendingTailscaleServeEndpoint,
346
+ parsedTailscaleServePort,
347
+ isTailscaleServePortValid,
348
+ );
349
350
const handleDesktopServerExposureChange = async (checked: boolean) => {
351
if (