@devries-cameron20 / t3code-1 / commits / d9619adc09
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): stop offering T3 Connect routes for the desktop's own WSL backend (#27479)

Julius Marminge committed Nov 13, 2026 at 21:05 UTC d9619adc0922028dd32d0d0c8aed09d8a531993a
2 files changed +120 -1
apps/web/src/components/cloud/CloudEnvironmentConnectList.browser.test.tsx new
+110
@@ -0,0 +1,110 @@
1 +import { BearerConnectionTarget } from "@t3tools/client-runtime/connection";
2 +import type { Discovery } from "@t3tools/client-runtime/relay";
3 +import { EnvironmentId } from "@t3tools/contracts";
4 +import * as Option from "effect/Option";
5 +import { describe, expect, it, vi } from "vite-plus/test";
6 +
7 +import { render } from "../../../test/render";
8 +
9 +const testState = vi.hoisted(() => ({
10 + discovered: [] as Array<Discovery.RelayDiscoveredEnvironment>,
11 +}));
12 +
13 +vi.mock(import("~/state/environments"), async (original) => ({
14 + ...(await original()),
15 + useRelayEnvironmentDiscovery: (() => ({
16 + environments: new Map(
17 + testState.discovered.map((environment) => [
18 + environment.environment.environmentId,
19 + environment,
20 + ]),
21 + ),
22 + refreshing: false,
23 + offline: false,
24 + error: Option.none(),
25 + })) as never,
26 +}));
27 +vi.mock(import("~/state/use-atom-command"), async (original) => ({
28 + ...(await original()),
29 + useAtomCommand: (() => () => Promise.resolve({ _tag: "Success" })) as never,
30 +}));
31 +
32 +import { CloudEnvironmentConnectRows } from "./CloudEnvironmentConnectList";
33 +
34 +function discovered(
35 + environmentId: EnvironmentId,
36 + label: string,
37 +): Discovery.RelayDiscoveredEnvironment {
38 + return {
39 + environment: {
40 + environmentId,
41 + label,
42 + endpoint: {
43 + httpBaseUrl: `https://${environmentId}.relay.test`,
44 + wsBaseUrl: `wss://${environmentId}.relay.test`,
45 + providerKind: "t3_relay",
46 + },
47 + linkedAt: "2026-10-01T00:00:00.000Z",
48 + },
49 + availability: "online",
50 + status: Option.none(),
51 + error: Option.none(),
52 + };
53 +}
54 +
55 +function saved(environmentId: EnvironmentId, label: string, connectionId: string) {
56 + return {
57 + environmentId,
58 + entry: { target: new BearerConnectionTarget({ environmentId, label, connectionId }) },
59 + connection: { phase: "connected", error: null, traceId: null },
60 + relayManaged: false,
61 + serverConfig: null,
62 + } as const;
63 +}
64 +
65 +const primaryEnvironmentId = EnvironmentId.make("primary");
66 +const wslEnvironmentId = EnvironmentId.make("wsl-ubuntu");
67 +const laptopEnvironmentId = EnvironmentId.make("laptop");
68 +
69 +function setup(discoveredEnvironments: Array<Discovery.RelayDiscoveredEnvironment>) {
70 + testState.discovered = discoveredEnvironments;
71 +}
72 +
73 +describe("CloudEnvironmentConnectRows", () => {
74 + it("does not offer a T3 Connect route for the desktop's own WSL backend", async () => {
75 + setup([
76 + discovered(primaryEnvironmentId, "This PC"),
77 + discovered(wslEnvironmentId, "Ubuntu (WSL)"),
78 + discovered(laptopEnvironmentId, "Laptop"),
79 + ]);
80 + await using screen = await render(
81 + <CloudEnvironmentConnectRows
82 + primaryEnvironmentId={primaryEnvironmentId}
83 + savedEnvironments={[
84 + saved(wslEnvironmentId, "Ubuntu (WSL)", "local:wsl:Ubuntu"),
85 + saved(laptopEnvironmentId, "Laptop", "lan-laptop"),
86 + ]}
87 + />,
88 + );
89 +
90 + await expect.element(screen.getByText("Laptop")).toBeInTheDocument();
91 + await expect.element(screen.getByText("Ubuntu (WSL)")).not.toBeInTheDocument();
92 + await expect.element(screen.getByRole("button", { name: "Add route" })).toBeInTheDocument();
93 + });
94 +
95 + it("shows the empty state when the desktop's own WSL backend is the only saved environment", async () => {
96 + setup([
97 + discovered(primaryEnvironmentId, "This PC"),
98 + discovered(wslEnvironmentId, "Ubuntu (WSL)"),
99 + ]);
100 + await using screen = await render(
101 + <CloudEnvironmentConnectRows
102 + primaryEnvironmentId={primaryEnvironmentId}
103 + savedEnvironments={[saved(wslEnvironmentId, "Ubuntu (WSL)", "local:wsl:Ubuntu")]}
104 + empty={<p>No environments</p>}
105 + />,
106 + );
107 +
108 + await expect.element(screen.getByText("No environments")).toBeInTheDocument();
109 + });
110 +});
apps/web/src/components/cloud/CloudEnvironmentConnectList.tsx
+10 -1
@@ -1,5 +1,6 @@
1 import { findErrorTraceId } from "@t3tools/client-runtime/errors";
2 import {
3 + type ConnectionTarget,
4 type EnvironmentConnectionPresentation,
5 RelayConnectionRegistration,
6 RelayConnectionTarget,
@@ -24,6 +25,7 @@ import * as Option from "effect/Option";
25 import { type ReactNode, useEffect, useEffectEvent, useState } from "react";
26
27 import { environmentCatalog } from "~/connection/catalog";
28 +import { isDesktopLocalConnectionTarget } from "~/connection/desktopLocal";
29 import { cn } from "~/lib/utils";
30 import { relayEnvironmentDiscovery } from "~/state/relay";
31 import { useRelayEnvironmentDiscovery } from "~/state/environments";
@@ -49,6 +51,7 @@ function discoveredCompatibilityError(
51
52 export interface SavedCloudEnvironmentConnection {
53 readonly environmentId: EnvironmentId;
54 + readonly entry: { readonly target: ConnectionTarget };
55 readonly connection: EnvironmentConnectionPresentation;
56 readonly relayManaged: boolean;
57 readonly serverConfig?: Pick<ServerConfig, "environment"> | null;
@@ -122,6 +125,11 @@ export function CloudEnvironmentConnectRows({
125 .filter((environment) => !environment.relayManaged)
126 .map((environment) => environment.environmentId),
127 );
128 + const desktopLocalIds = new Set(
129 + savedEnvironments
130 + .filter((environment) => isDesktopLocalConnectionTarget(environment.entry.target))
131 + .map((environment) => environment.environmentId),
132 + );
133
134 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- fetches relay discovery when its inputs change, unless hidden polling covers it, and reports readiness
135 useEffect(() => {
@@ -189,6 +197,7 @@ export function CloudEnvironmentConnectRows({
197 // Omit machines saved over other routes; onboarding selection must not add a T3 Connect route.
198 const isVisibleEnvironment = (environmentId: EnvironmentId) =>
199 environmentId !== primaryEnvironmentId &&
200 + !desktopLocalIds.has(environmentId) &&
201 (showSavedEnvironments || !savedById.has(environmentId)) &&
202 !(selection && savedWithoutRelay.has(environmentId));
203 const visibleEnvironments = [...environmentsState.environments.values()].filter(
@@ -269,7 +278,7 @@ export function CloudEnvironmentConnectRows({
278 };
279 }, [shouldRefreshWhileEmpty]);
280
272 - const standalone = showSavedEnvironments || savedEnvironments.length === 0;
281 + const standalone = showSavedEnvironments || savedEnvironments.length === desktopLocalIds.size;
282
283 if (
284 !refreshWhileEmpty &&