From db99b6a9742b07456372dd5250601e343f86ae8f Mon Sep 17 00:00:00 2001
From: panudetjt <3482285+panudetjt@users.noreply.github.com>
Date: Mon, 9 Nov 2026 21:45:41 +0700
Subject: [PATCH 1/5] feat(web): manage the WSL backend from Sharing & access
A Windows desktop runs its WSL backend as its own environment, but Sharing &
access filtered desktop-local backends out of the picker, so T3 Connect could
not be linked for WSL without switching to WSL-only mode.
List those backends in the picker, and once the host is on T3 Connect, point
out a WSL backend that still needs its own link.
---
.../settings/ConnectionsSettings.tsx | 29 ++++++++++++++++++
.../settings/SavedEnvironmentRows.tsx | 30 +++++++++++++++++++
.../settings/useAccessEnvironment.ts | 8 ++---
docs/user/install.md | 6 ++++
4 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx
index da46823292cad..7eeb37d63bc78 100644
--- a/apps/web/src/components/settings/ConnectionsSettings.tsx
+++ b/apps/web/src/components/settings/ConnectionsSettings.tsx
@@ -84,6 +84,8 @@ import {
supportsDesktopAppUpdate,
} from "~/versionSkew";
import { hasCloudPublicConfig } from "~/cloud/publicConfig";
+import { useCloudLinkState } from "~/cloud/cloudLinkState";
+import { isManagedTunnelActive } from "~/cloud/t3ConnectState";
import { RemoveT3ConnectEnvironmentDialog } from "../clerk/RemoveT3ConnectEnvironmentDialog";
import { authEnvironment } from "~/state/auth";
import { environmentCatalog } from "~/connection/catalog";
@@ -135,6 +137,7 @@ import { ITEM_ROW_CLASSNAME } from "./itemRows";
import {
CloudLinkRow,
CloudRemoteEnvironmentRows,
+ LocalBackendConnectRow,
SavedBackendListRow,
} from "./SavedEnvironmentRows";
import { AddEnvironmentDialog } from "./AddEnvironmentDialog";
@@ -230,6 +233,7 @@ function AccessSettings() {
view="access"
accessEnvironmentId={accessEnvironmentId}
accessEnvironmentPicker={picker}
+ onSelectAccessEnvironment={setSelectedEnvironmentId}
/>
);
}
@@ -238,10 +242,12 @@ function ConnectionsSettingsContent({
view,
accessEnvironmentId,
accessEnvironmentPicker = null,
+ onSelectAccessEnvironment,
}: {
readonly view: "environments" | "access";
readonly accessEnvironmentId: EnvironmentId | null;
readonly accessEnvironmentPicker?: ReactNode;
+ readonly onSelectAccessEnvironment?: (environmentId: EnvironmentId) => void;
}) {
const desktopBridge = window.desktopBridge;
const { environments } = useEnvironments();
@@ -267,6 +273,19 @@ function ConnectionsSettingsContent({
const listedEnvironments = savedEnvironments.filter(
(environment) => !isDesktopLocalConnectionTarget(environment.entry.target),
);
+ // Desktop-local backends (WSL) run their own server, so T3 Connect reaches them only through
+ // their own link. Offer that on the host's page once the host itself is on T3 Connect.
+ const accessLinkState = useCloudLinkState(accessEnvironmentId).data;
+ const desktopLocalBackends =
+ isPrimaryAccess &&
+ desktopBridge !== undefined &&
+ accessLinkState !== null &&
+ isManagedTunnelActive(accessLinkState, undefined)
+ ? savedEnvironments.filter(
+ (environment) =>
+ environment.entry.enabled && isDesktopLocalConnectionTarget(environment.entry.target),
+ )
+ : [];
const savedUpdateStates = useAtomValue(
environmentUpdateStatesAtom(
environmentIdsKey(savedEnvironments.map(({ environmentId }) => environmentId)),
@@ -1239,6 +1258,16 @@ function ConnectionsSettingsContent({
canManageRelay={canManageRelay}
/>
) : null}
+ {onSelectAccessEnvironment
+ ? desktopLocalBackends.map((environment) => (
+
+ ))
+ : null}
{accessEnvironment ? (
diff --git a/apps/web/src/components/settings/SavedEnvironmentRows.tsx b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
index 866841b4bc6b7..7ce258e9da53d 100644
--- a/apps/web/src/components/settings/SavedEnvironmentRows.tsx
+++ b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
@@ -51,6 +51,8 @@ import { hasCloudPublicConfig } from "~/cloud/publicConfig";
import { isElectron } from "~/env";
import { useT3ConnectTurnOn } from "~/cloud/useT3ConnectTurnOn";
import { useCloudLinkController } from "~/cloud/useCloudLinkController";
+import { useCloudLinkState } from "~/cloud/cloudLinkState";
+import { isManagedTunnelActive } from "~/cloud/t3ConnectState";
import { useManagedTunnelUsage } from "~/cloud/managedRelayState";
import { useT3ConnectAccountPage } from "../clerk/T3ConnectAccountPages";
import { TunnelLimitAlert, TunnelUsageMeter } from "../cloud/TunnelUsage";
@@ -768,6 +770,34 @@ export function CloudLinkRow({
return ;
}
+/**
+ * A desktop-local backend (WSL) is its own environment, so T3 Connect needs its own link for it.
+ * Shown on the host's page so linking the host does not silently leave the backend behind.
+ */
+export function LocalBackendConnectRow({
+ environmentId,
+ label,
+ onSelect,
+}: {
+ readonly environmentId: EnvironmentId;
+ readonly label: string;
+ readonly onSelect: (environmentId: EnvironmentId) => void;
+}) {
+ const linkState = useCloudLinkState(environmentId).data;
+ if (linkState === null || isManagedTunnelActive(linkState, undefined)) return null;
+ return (
+ onSelect(environmentId)}>
+ Set up
+
+ }
+ />
+ );
+}
+
function EmptyRemoteEnvironments({ cloudEnabled = true }: { readonly cloudEnabled?: boolean }) {
return (
diff --git a/apps/web/src/components/settings/useAccessEnvironment.ts b/apps/web/src/components/settings/useAccessEnvironment.ts
index 6e94e2365ca7d..ce210ac09cc7d 100644
--- a/apps/web/src/components/settings/useAccessEnvironment.ts
+++ b/apps/web/src/components/settings/useAccessEnvironment.ts
@@ -1,14 +1,12 @@
import type { EnvironmentId } from "@t3tools/contracts";
-import { isDesktopLocalConnectionTarget } from "../../connection/desktopLocal";
import { useEnvironments, usePrimaryEnvironmentId } from "../../state/environments";
import { resolveAccessEnvironmentId } from "./ConnectionsSettings.logic";
import { settingsScopeEnvironmentLabel } from "./settingsScopeAxis";
/**
- * The environments Sharing & access manages, the one `requested` resolves to, and its name.
- * The MCP wizard uses the same, so both name an environment alike. A requested environment
- * always counts, so a thread on a second WSL backend opens on that backend.
+ * The environments Sharing & access manages and the one `requested` resolves to. Desktop-local
+ * backends stay listed because a Windows app runs its WSL backend as its own environment.
*/
export function useAccessEnvironment(requested: EnvironmentId | null) {
const { environments } = useEnvironments();
@@ -17,7 +15,7 @@ export function useAccessEnvironment(requested: EnvironmentId | null) {
(environment) =>
environment.environmentId === primaryEnvironmentId ||
environment.environmentId === requested ||
- (environment.entry.enabled && !isDesktopLocalConnectionTarget(environment.entry.target)),
+ environment.entry.enabled,
);
const environmentId = resolveAccessEnvironmentId({
primaryEnvironmentId,
diff --git a/docs/user/install.md b/docs/user/install.md
index 7b28781e69612..a7a0dbe3c7805 100644
--- a/docs/user/install.md
+++ b/docs/user/install.md
@@ -145,6 +145,12 @@ there. Install the provider CLIs inside that distro. T3 Code installs its own
server runtime there automatically; the first launch after an app update can
take longer.
+The WSL environment is separate from the Windows one. To reach it from your phone
+or another device, open **Settings → Sharing & access**. If **Showing access for**
+appears, choose **WSL (distro)** there, then turn on **T3 Connect** for it. Once
+Windows is linked, that page also lists a WSL environment that is still missing
+its own link.
+
### Open a project from a terminal
With the desktop app already running on the same machine:
From a69523a90918a8a155dd90e2e2c0d6bb93a91d77 Mon Sep 17 00:00:00 2001
From: panudetjt <3482285+panudetjt@users.noreply.github.com>
Date: Tue, 10 Nov 2026 19:46:35 +0700
Subject: [PATCH 2/5] fix(server): name the WSL environment apart from its
Windows host
WSL keeps the Windows hostname, so a host and its WSL backend reported the same
environment label and were indistinguishable in T3 Connect and on mobile. Name
the backend `WSL ()` inside WSL, matching the desktop's own label.
---
.../ServerEnvironmentLabel.test.ts | 31 +++++++++++++++++++
.../src/environment/ServerEnvironmentLabel.ts | 16 ++++++++++
2 files changed, 47 insertions(+)
create mode 100644 apps/server/src/environment/ServerEnvironmentLabel.test.ts
diff --git a/apps/server/src/environment/ServerEnvironmentLabel.test.ts b/apps/server/src/environment/ServerEnvironmentLabel.test.ts
new file mode 100644
index 0000000000000..f3e120c54a983
--- /dev/null
+++ b/apps/server/src/environment/ServerEnvironmentLabel.test.ts
@@ -0,0 +1,31 @@
+import * as NodeServices from "@effect/platform-node/NodeServices";
+import * as HostProcess from "@t3tools/shared/HostProcess";
+import { assert, describe, it } from "@effect/vitest";
+import * as Effect from "effect/Effect";
+import * as Layer from "effect/Layer";
+
+import * as ProcessRunner from "../processRunner.ts";
+import { resolveServerEnvironmentLabel } from "./ServerEnvironmentLabel.ts";
+
+const layerTestServices = ProcessRunner.layer.pipe(Layer.provideMerge(NodeServices.layer));
+
+const labelFor = (environment: NodeJS.ProcessEnv) =>
+ resolveServerEnvironmentLabel({ cwdBaseName: "t3code" }).pipe(
+ Effect.provide(layerTestServices),
+ Effect.provideService(HostProcess.Platform, "linux"),
+ Effect.provideService(HostProcess.Environment, environment),
+ );
+
+describe("resolveServerEnvironmentLabel", () => {
+ it.effect("names a WSL backend apart from its Windows host", () =>
+ Effect.gen(function* () {
+ assert.equal(yield* labelFor({ WSL_DISTRO_NAME: "Ubuntu-24.04" }), "WSL (Ubuntu-24.04)");
+ }),
+ );
+
+ it.effect("names WSL without a distro when only the interop socket is present", () =>
+ Effect.gen(function* () {
+ assert.equal(yield* labelFor({ WSL_INTEROP: "/run/WSL/8_interop" }), "WSL");
+ }),
+ );
+});
diff --git a/apps/server/src/environment/ServerEnvironmentLabel.ts b/apps/server/src/environment/ServerEnvironmentLabel.ts
index 73ff4a7639103..f6d99eb5ab76f 100644
--- a/apps/server/src/environment/ServerEnvironmentLabel.ts
+++ b/apps/server/src/environment/ServerEnvironmentLabel.ts
@@ -150,6 +150,17 @@ const runFriendlyLabelCommand = Effect.fn("runFriendlyLabelCommand")(function* (
return normalizeLabel(result.value.stdout);
});
+/**
+ * WSL keeps the Windows hostname, so a Windows host and its WSL backend would otherwise share one
+ * name in T3 Connect and every client that lists environments.
+ */
+function resolveWslLabel(platform: NodeJS.Platform, environment: NodeJS.ProcessEnv): string | null {
+ if (platform !== "linux") return null;
+ const distro = normalizeLabel(environment.WSL_DISTRO_NAME);
+ if (distro) return `WSL (${distro})`;
+ return normalizeLabel(environment.WSL_INTEROP) ? "WSL" : null;
+}
+
const resolveFriendlyHostLabel = Effect.fn("resolveFriendlyHostLabel")(function* () {
const platform = yield* HostProcess.Platform;
if (platform === "darwin") {
@@ -182,6 +193,11 @@ const resolveFriendlyHostLabel = Effect.fn("resolveFriendlyHostLabel")(function*
export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironmentLabel")(function* (
input: ResolveServerEnvironmentLabelInput,
) {
+ const wslLabel = resolveWslLabel(yield* HostProcess.Platform, yield* HostProcess.Environment);
+ if (wslLabel) {
+ return wslLabel;
+ }
+
const friendlyHostLabel = yield* resolveFriendlyHostLabel();
if (friendlyHostLabel) {
return friendlyHostLabel;
From fec850ca557471db33faf6c1795616958f2f6026 Mon Sep 17 00:00:00 2001
From: panudetjt <3482285+panudetjt@users.noreply.github.com>
Date: Tue, 10 Nov 2026 21:06:45 +0700
Subject: [PATCH 3/5] docs(user): clarify WSL access setup in Sharing & access
---
docs/user/install.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/user/install.md b/docs/user/install.md
index a7a0dbe3c7805..3bea1ac60e4eb 100644
--- a/docs/user/install.md
+++ b/docs/user/install.md
@@ -147,9 +147,9 @@ take longer.
The WSL environment is separate from the Windows one. To reach it from your phone
or another device, open **Settings → Sharing & access**. If **Showing access for**
-appears, choose **WSL (distro)** there, then turn on **T3 Connect** for it. Once
-Windows is linked, that page also lists a WSL environment that is still missing
-its own link.
+appears, choose **WSL (distro)** there to set up its access. The row for linking
+WSL appears only in the Windows view, after Windows is linked; switch **Showing
+access for** back to Windows to find it.
### Open a project from a terminal
From cd734751b1dfca54cb0d2ad3c4fe390bb776e211 Mon Sep 17 00:00:00 2001
From: panudetjt <3482285+panudetjt@users.noreply.github.com>
Date: Tue, 10 Nov 2026 21:24:07 +0700
Subject: [PATCH 4/5] docs(user): clarify WSL T3 Connect setup
---
docs/user/install.md | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/docs/user/install.md b/docs/user/install.md
index 3bea1ac60e4eb..a60f42bea9157 100644
--- a/docs/user/install.md
+++ b/docs/user/install.md
@@ -147,9 +147,13 @@ take longer.
The WSL environment is separate from the Windows one. To reach it from your phone
or another device, open **Settings → Sharing & access**. If **Showing access for**
-appears, choose **WSL (distro)** there to set up its access. The row for linking
-WSL appears only in the Windows view, after Windows is linked; switch **Showing
-access for** back to Windows to find it.
+appears, choose **WSL (distro)** there. That only shows the WSL environment's
+access settings; sign in and turn on **T3 Connect** on that page, since T3 Connect
+links one environment at a time.
+
+The Windows view also offers a row for WSL before it is on T3 Connect. The row
+appears only after Windows is linked, so switch **Showing access for** back to
+Windows to find it.
### Open a project from a terminal
From bcd6c2fac27479f6e4541b803884792471989837 Mon Sep 17 00:00:00 2001
From: Julius Marminge
Date: Thu, 12 Nov 2026 20:08:27 +0000
Subject: [PATCH 5/5] fix(server): keep a user-set pretty hostname ahead of the
WSL label
Only the hostname WSL inherits from Windows is ambiguous, so a name the user
set in /etc/machine-info or hostnamectl still wins. Also trims comments and
the WSL access paragraph in the install guide.
AI-assisted; verified with the tests and tools listed above.
Co-Authored-By: Claude Opus 5.5
---
.../src/environment/ServerEnvironmentLabel.ts | 15 ++++++---------
.../components/settings/ConnectionsSettings.tsx | 3 +--
.../components/settings/SavedEnvironmentRows.tsx | 4 ----
.../components/settings/useAccessEnvironment.ts | 5 +++--
docs/user/install.md | 14 +++++---------
5 files changed, 15 insertions(+), 26 deletions(-)
diff --git a/apps/server/src/environment/ServerEnvironmentLabel.ts b/apps/server/src/environment/ServerEnvironmentLabel.ts
index df79918aaa20f..5cac687495bff 100644
--- a/apps/server/src/environment/ServerEnvironmentLabel.ts
+++ b/apps/server/src/environment/ServerEnvironmentLabel.ts
@@ -152,10 +152,7 @@ const runFriendlyLabelCommand = Effect.fn("runFriendlyLabelCommand")(function* (
return normalizeLabel(result.value.stdout);
});
-/**
- * WSL keeps the Windows hostname, so a Windows host and its WSL backend would otherwise share one
- * name in T3 Connect and every client that lists environments.
- */
+// WSL inherits the Windows hostname, so without this a Windows host and its WSL backend share one name.
function resolveWslLabel(platform: NodeJS.Platform, environment: NodeJS.ProcessEnv): string | null {
if (platform !== "linux") return null;
const distro = normalizeLabel(environment.WSL_DISTRO_NAME);
@@ -195,16 +192,16 @@ const resolveFriendlyHostLabel = Effect.fn("resolveFriendlyHostLabel")(function*
export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironmentLabel")(function* (
input: ResolveServerEnvironmentLabelInput,
) {
- const wslLabel = resolveWslLabel(yield* HostProcess.Platform, yield* HostProcess.Environment);
- if (wslLabel) {
- return wslLabel;
- }
-
const friendlyHostLabel = yield* resolveFriendlyHostLabel();
if (friendlyHostLabel) {
return friendlyHostLabel;
}
+ const wslLabel = resolveWslLabel(yield* HostProcess.Platform, yield* HostProcess.Environment);
+ if (wslLabel) {
+ return wslLabel;
+ }
+
const hostname = normalizeLabel(yield* HostProcess.Hostname);
if (hostname) {
return hostname;
diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx
index 7eeb37d63bc78..25dbe59f51a44 100644
--- a/apps/web/src/components/settings/ConnectionsSettings.tsx
+++ b/apps/web/src/components/settings/ConnectionsSettings.tsx
@@ -273,8 +273,7 @@ function ConnectionsSettingsContent({
const listedEnvironments = savedEnvironments.filter(
(environment) => !isDesktopLocalConnectionTarget(environment.entry.target),
);
- // Desktop-local backends (WSL) run their own server, so T3 Connect reaches them only through
- // their own link. Offer that on the host's page once the host itself is on T3 Connect.
+ // A WSL backend runs its own server and needs its own T3 Connect link; point to it from the host.
const accessLinkState = useCloudLinkState(accessEnvironmentId).data;
const desktopLocalBackends =
isPrimaryAccess &&
diff --git a/apps/web/src/components/settings/SavedEnvironmentRows.tsx b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
index 7ce258e9da53d..eebe66046c9c1 100644
--- a/apps/web/src/components/settings/SavedEnvironmentRows.tsx
+++ b/apps/web/src/components/settings/SavedEnvironmentRows.tsx
@@ -770,10 +770,6 @@ export function CloudLinkRow({
return ;
}
-/**
- * A desktop-local backend (WSL) is its own environment, so T3 Connect needs its own link for it.
- * Shown on the host's page so linking the host does not silently leave the backend behind.
- */
export function LocalBackendConnectRow({
environmentId,
label,
diff --git a/apps/web/src/components/settings/useAccessEnvironment.ts b/apps/web/src/components/settings/useAccessEnvironment.ts
index ce210ac09cc7d..737570e5e3466 100644
--- a/apps/web/src/components/settings/useAccessEnvironment.ts
+++ b/apps/web/src/components/settings/useAccessEnvironment.ts
@@ -5,8 +5,9 @@ import { resolveAccessEnvironmentId } from "./ConnectionsSettings.logic";
import { settingsScopeEnvironmentLabel } from "./settingsScopeAxis";
/**
- * The environments Sharing & access manages and the one `requested` resolves to. Desktop-local
- * backends stay listed because a Windows app runs its WSL backend as its own environment.
+ * The environments Sharing & access manages, the one `requested` resolves to, and its name.
+ * The MCP wizard uses the same, so both name an environment alike. A desktop-local WSL backend
+ * is its own environment with its own access, so it is listed too.
*/
export function useAccessEnvironment(requested: EnvironmentId | null) {
const { environments } = useEnvironments();
diff --git a/docs/user/install.md b/docs/user/install.md
index 6a1842c9129fc..068cb5cf53872 100644
--- a/docs/user/install.md
+++ b/docs/user/install.md
@@ -146,15 +146,11 @@ there. Install the provider CLIs inside that distro. T3 Code installs its own
server runtime there automatically; the first launch after an app update can
take longer.
-The WSL environment is separate from the Windows one. To reach it from your phone
-or another device, open **Settings → Sharing & access**. If **Showing access for**
-appears, choose **WSL (distro)** there. That only shows the WSL environment's
-access settings; sign in and turn on **T3 Connect** on that page, since T3 Connect
-links one environment at a time.
-
-The Windows view also offers a row for WSL before it is on T3 Connect. The row
-appears only after Windows is linked, so switch **Showing access for** back to
-Windows to find it.
+The WSL environment is separate from the Windows one and has its own access
+settings. To reach it from your phone or another device, open **Settings →
+Sharing & access**, choose **WSL (distro)** under **Showing access for**, and
+turn on **T3 Connect** there. Once Windows is on T3 Connect, its page also
+points to a WSL environment that is not.
### Open a project from a terminal