The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): remove obsolete cloud listing helpers (#9995)
Julius Marminge committed
Sep 5, 2026 at 00:19 UTC
bf1c1b09756a56a0600faf52561f0fb4ae94e355
2 files changed
-101
apps/web/src/cloud/linkEnvironment.test.ts
-45
@@ -26,10 +26,7 @@ import { remoteHttpClientLayer } from "@t3tools/client-runtime/rpc";
26
import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth";
27
28
import {
29
- collectCloudLinkTargets,
29
linkPrimaryEnvironmentToCloud,
31
- listManagedCloudEnvironments,
32
- normalizeRelayBaseUrl,
30
readPrimaryCloudLinkState,
31
type CloudLinkTarget,
32
unlinkPrimaryEnvironmentFromCloud,
@@ -155,48 +152,6 @@ afterEach(() => {
152
});
153
154
describe("web cloud link environment client", () => {
158
- it("normalizes relay URLs and de-duplicates cloud link targets", () => {
159
- expect(normalizeRelayBaseUrl(" https://relay.example.test/// ")).toBe(
160
- "https://relay.example.test",
161
- );
162
- expect(normalizeRelayBaseUrl(" ")).toBeNull();
163
- expect(
164
- collectCloudLinkTargets({
165
- primary: TARGET,
166
- saved: [TARGET, { ...TARGET, environmentId: "environment-2" }],
167
- }).map((target) => target.environmentId),
168
- ).toEqual(["environment-1", "environment-2"]);
169
- });
170
-
171
- it.effect("lists relay-managed environments through the typed relay client", () =>
172
- Effect.gen(function* () {
173
- const fetchMock = vi.fn().mockResolvedValue(
174
- Response.json({
175
- environments: [
176
- {
177
- environmentId: "environment-1",
178
- label: "Desktop",
179
- endpoint: {
180
- httpBaseUrl: "https://desktop.example.test",
181
- wsBaseUrl: "wss://desktop.example.test",
182
- providerKind: "cloudflare_tunnel",
183
- },
184
- linkedAt: "2026-06-06T00:00:00.000Z",
185
- },
186
- ],
187
- }),
188
- );
189
- vi.stubGlobal("fetch", fetchMock);
190
-
191
- const environments = yield* withServices(
192
- listManagedCloudEnvironments({ clerkToken: "clerk-token" }),
193
- );
194
-
195
- expect(environments).toHaveLength(1);
196
- expect(fetchMock.mock.calls[0]?.[1]?.headers.authorization).toBe("Bearer clerk-token");
197
- }),
198
- );
199
-
155
it.effect("reads primary cloud link state from the explicit target", () =>
156
Effect.gen(function* () {
157
const fetchMock = vi.fn().mockResolvedValue(
apps/web/src/cloud/linkEnvironment.ts
-56
@@ -16,7 +16,6 @@ import {
16
WS_METHODS,
17
} from "@t3tools/contracts";
18
import {
19
- type RelayClientEnvironmentRecord,
19
type RelayEnvironmentLinkResponse,
20
type RelayManagedEndpointProviderKind,
21
} from "@t3tools/contracts/relay";
@@ -33,14 +32,6 @@ import {
32
requestRelayClientInstallConfirmation,
33
} from "./relayClientInstallDialog";
34
36
-export function normalizeRelayBaseUrl(value: string | null | undefined): string | null {
37
- const trimmed = value?.trim();
38
- if (!trimmed) {
39
- return null;
40
- }
41
- return trimmed.replace(/\/+$/g, "");
42
-}
43
-
35
function relayUrl(): string | null {
36
return resolveCloudPublicConfig().relayUrl;
37
}
@@ -194,53 +185,6 @@ export interface CloudLinkTarget {
185
186
export type CloudLinkState = EnvironmentCloudLinkStateResult;
187
197
-export function collectCloudLinkTargets(input: {
198
- readonly primary: CloudLinkTarget | null;
199
- readonly saved: ReadonlyArray<CloudLinkTarget>;
200
-}): ReadonlyArray<CloudLinkTarget> {
201
- const byId = new Map<string, CloudLinkTarget>();
202
- if (input.primary) {
203
- byId.set(input.primary.environmentId, input.primary);
204
- }
205
- for (const environment of input.saved) {
206
- if (!byId.has(environment.environmentId)) {
207
- byId.set(environment.environmentId, environment);
208
- }
209
- }
210
- return [...byId.values()];
211
-}
212
-
213
-export function listManagedCloudEnvironments(input: {
214
- readonly clerkToken: string;
215
-}): Effect.Effect<
216
- ReadonlyArray<RelayClientEnvironmentRecord>,
217
- CloudEnvironmentLinkError,
218
- ManagedRelay.ManagedRelayClient
219
-> {
220
- return Effect.gen(function* () {
221
- const configuredRelayUrl = relayUrl();
222
- if (!configuredRelayUrl) {
223
- return yield* new CloudEnvironmentLinkError({
224
- message: "T3CODE_RELAY_URL is not configured.",
225
- });
226
- }
227
- const relayClient = yield* ManagedRelay.ManagedRelayClient;
228
- return yield* relayClient
229
- .listEnvironments({
230
- clerkToken: input.clerkToken,
231
- })
232
- .pipe(
233
- Effect.mapError(
234
- (cause) =>
235
- new CloudEnvironmentLinkError({
236
- message: "Could not list relay-managed environments.",
237
- cause,
238
- }),
239
- ),
240
- );
241
- });
242
-}
243
-
188
export function readPrimaryCloudLinkState(input: {
189
readonly target: CloudLinkTarget;
190
}): Effect.Effect<CloudLinkState | null, CloudEnvironmentLinkError, HttpClient.HttpClient> {