From 43b67f09f3e6c4b7ce3a507d24c03312cbf94df6 Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Mon, 26 Oct 2026 01:39:40 +0000 Subject: [PATCH 01/16] fix(client): relay unlink failures say why and keep their trace ManagedRelayRequestFailedError.message dropped the decoded relay error, so a failed unlink only said "Could not unlink relay environment." It now appends relayRequestFailureDetail (relay reason, or the unexpected HTTP status). The transport hint and the separate traceId/status fields are unchanged. The desktop/web unlink logged and swallowed a failed relay DELETE after the local unlink, so the environment stayed registered with no error shown. It now fails through decodedRelayClientError with the reason and trace ID. Refs #25179 Co-Authored-By: Claude Opus 5.5 --- apps/web/src/cloud/linkEnvironment.test.ts | 47 ++++++++++++++++- apps/web/src/cloud/linkEnvironment.ts | 8 +-- .../src/relay/managedRelay.test.ts | 52 +++++++++++++++++++ .../client-runtime/src/relay/managedRelay.ts | 6 ++- 4 files changed, 106 insertions(+), 7 deletions(-) diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts index 7a09f928dbeb5..791962103a6ec 100644 --- a/apps/web/src/cloud/linkEnvironment.test.ts +++ b/apps/web/src/cloud/linkEnvironment.test.ts @@ -26,7 +26,7 @@ import { ManagedRelay } from "@t3tools/client-runtime/relay"; import { layerRemoteHttpClient } from "@t3tools/client-runtime/rpc"; import { __resetDesktopPrimaryAuthForTests } from "../environments/primary/desktopAuth"; -import { readCloudLinkState } from "./linkEnvironment"; +import { readCloudLinkState, unlinkEnvironmentFromCloud } from "./linkEnvironment"; const TARGET = { environmentId: "environment-1", @@ -239,4 +239,49 @@ describe("web cloud link environment client", () => { } }), ); + + it.effect("reports why the relay kept the environment after a local unlink", () => + Effect.gen(function* () { + const fetchMock = vi.fn((input: RequestInfo | URL) => + Promise.resolve( + String(input).startsWith("https://relay.example.test/") + ? Response.json( + { + _tag: "RelayInternalError", + code: "internal_error", + reason: "upstream_unavailable", + traceId: "trace-unlink", + }, + { status: 500 }, + ) + : Response.json({ ok: true, endpointRuntimeStatus: null }), + ), + ); + vi.stubGlobal("fetch", fetchMock); + vi.stubGlobal("window", { + location: { origin: "t3code://app" }, + desktopBridge: { + getLocalEnvironmentBearerToken: vi.fn().mockResolvedValue("desktop-bearer-token"), + } as unknown as DesktopBridge, + }); + + const error = yield* withServices( + unlinkEnvironmentFromCloud({ + target: { environmentId: EnvironmentId.make(TARGET.environmentId) }, + clerkToken: "clerk-token", + }), + ).pipe(Effect.flip); + + expect(fetchMock.mock.calls.map(([input]) => String(input))).toEqual([ + "http://127.0.0.1:3000/api/connect/unlink", + "https://relay.example.test/v1/client/environment-links/environment-1", + ]); + expect(error).toMatchObject({ + _tag: "CloudEnvironmentLinkError", + message: + "Disconnected locally, but T3 Connect did not confirm it removed this environment: Relay encountered an internal error (upstream_unavailable).", + traceId: "trace-unlink", + }); + }), + ); }); diff --git a/apps/web/src/cloud/linkEnvironment.ts b/apps/web/src/cloud/linkEnvironment.ts index 8673e06d20c94..8c9697b6908c5 100644 --- a/apps/web/src/cloud/linkEnvironment.ts +++ b/apps/web/src/cloud/linkEnvironment.ts @@ -309,10 +309,10 @@ export const unlinkEnvironmentFromCloud: (input: { environmentId: input.target.environmentId, }) .pipe( - Effect.catch((cause) => - Effect.logWarning("Could not revoke cloud environment link after local unlink.", { - cause, - }), + Effect.mapError( + decodedRelayClientError( + "Disconnected locally, but T3 Connect did not confirm it removed this environment", + ), ), ); } diff --git a/packages/client-runtime/src/relay/managedRelay.test.ts b/packages/client-runtime/src/relay/managedRelay.test.ts index 76c6cb905a7a9..0c947b6d47f99 100644 --- a/packages/client-runtime/src/relay/managedRelay.test.ts +++ b/packages/client-runtime/src/relay/managedRelay.test.ts @@ -8,6 +8,7 @@ import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; +import { NETWORK_BLOCKING_HINT } from "../errors/network.ts"; import { RELAY_GATEWAY_TIMEOUT_MESSAGE, relayRequestFailureDetail } from "./errorPresentation.ts"; import * as ManagedRelay from "./managedRelay.ts"; import * as RpcHttp from "../rpc/http.ts"; @@ -419,6 +420,57 @@ describe("ManagedRelayClient", () => { }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); }); + it.effect("names the relay's reason when unlinking fails and keeps its trace ID", () => { + const fetchFn = (() => + Promise.resolve( + Response.json( + { + _tag: "RelayInternalError", + code: "internal_error", + reason: "upstream_unavailable", + traceId: "trace-unlink", + }, + { status: 500 }, + ), + )) satisfies typeof globalThis.fetch; + + return Effect.gen(function* () { + const relayClient = yield* ManagedRelay.ManagedRelayClient; + const error = yield* relayClient + .unlinkEnvironment({ + clerkToken: "clerk-token", + environmentId: EnvironmentId.make("env-1"), + }) + .pipe(Effect.flip); + + expect(error).toMatchObject({ + _tag: "ManagedRelayRequestFailedError", + traceId: "trace-unlink", + relayError: { _tag: "RelayInternalError", reason: "upstream_unavailable" }, + }); + expect(error.message).toBe( + "Could not unlink relay environment: Relay encountered an internal error (upstream_unavailable).", + ); + }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); + }); + + it("keeps an undeclared relay status and the network hint in the message", () => { + expect( + new ManagedRelay.ManagedRelayRequestFailedError({ + action: "unlink relay environment", + cause: new Error("Bad Gateway"), + status: 502, + }).message, + ).toBe("Could not unlink relay environment: Relay returned an unexpected HTTP 502."); + expect( + new ManagedRelay.ManagedRelayRequestFailedError({ + action: "unlink relay environment", + transportFailed: true, + cause: new TypeError("Failed to fetch"), + }).message, + ).toBe(`Could not unlink relay environment. ${NETWORK_BLOCKING_HINT}`); + }); + it.effect("accepts generic DPoP errors from relays without the optional reason", () => { const fetchFn = (() => Promise.resolve( diff --git a/packages/client-runtime/src/relay/managedRelay.ts b/packages/client-runtime/src/relay/managedRelay.ts index a99e090314ae7..c10e2d5a5eca5 100644 --- a/packages/client-runtime/src/relay/managedRelay.ts +++ b/packages/client-runtime/src/relay/managedRelay.ts @@ -47,6 +47,7 @@ import * as HttpClientError from "effect/http/HttpClientError"; import type * as HttpMethod from "effect/http/HttpMethod"; import * as HttpApiClient from "effect/http-api/HttpApiClient"; import { NETWORK_BLOCKING_HINT } from "../errors/network.ts"; +import { relayRequestFailureDetail } from "./errorPresentation.ts"; export interface ManagedRelayDpopProofInput { readonly method: HttpMethod.HttpMethod; @@ -159,8 +160,9 @@ export class ManagedRelayRequestFailedError extends Schema.TaggedError Date: Mon, 26 Oct 2026 01:44:33 +0000 Subject: [PATCH 02/16] fix(web): refresh relay discovery after a failed unlink --- .../useCloudLinkController.browser.test.tsx | 30 +++++++++++++++++++ apps/web/src/cloud/useCloudLinkController.ts | 1 + 2 files changed, 31 insertions(+) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index 20e1fc71d29ba..2b14339c30fae 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -254,4 +254,34 @@ describe("useCloudLinkController", () => { expect(screen.controller()?.operationError).toBeNull(); expect(testState.toast).not.toHaveBeenCalled(); }); + + it("refreshes both states after unlink fails without replacing its error", async () => { + using _setup = setup(); + await using screen = await mountController(); + const message = "Disconnected locally, but relay cleanup failed (upstream_unavailable)."; + testState.unlink.mockResolvedValueOnce( + AsyncResult.failure( + Cause.fail(Object.assign(new Error(message), { traceId: "unlink-trace" })), + ), + ); + testState.refreshDiscovery.mockResolvedValueOnce( + AsyncResult.failure(Cause.fail(new Error("Discovery unavailable"))), + ); + + expect(await screen.reconcile({ managedTunnel: false, publish: false })).toBe(false); + expect(testState.refreshLink).toHaveBeenCalledOnce(); + expect(testState.refreshDiscovery).toHaveBeenCalledOnce(); + expect(testState.toast).toHaveBeenCalledOnce(); + expect(testState.toast).toHaveBeenCalledWith( + expect.objectContaining({ + description: message, + data: { + secondaryActionProps: { + children: "Copy trace ID", + onClick: expect.any(Function), + }, + }, + }), + ); + }); }); diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 0e94b0e7e7bbe..2fca9396ccc88 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -160,6 +160,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { reportUpdateFailure(squashAtomCommandFailure(unlinkResult)); } cloudLinkState.refresh(); + await refreshRelayEnvironments(); return false; } } else { From e216710ca8f5b3c7464995890c03c9fc298f21a0 Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Wed, 28 Oct 2026 10:40:41 +0000 Subject: [PATCH 03/16] fix(connect): preserve network hints after local unlink --- apps/web/src/cloud/linkEnvironment.test.ts | 28 ++++++++++++++++++++++ apps/web/src/cloud/linkEnvironment.ts | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts index 791962103a6ec..182a76a434520 100644 --- a/apps/web/src/cloud/linkEnvironment.test.ts +++ b/apps/web/src/cloud/linkEnvironment.test.ts @@ -284,4 +284,32 @@ describe("web cloud link environment client", () => { }); }), ); + + it.effect("preserves the network hint when relay cleanup fails after local unlink", () => + Effect.gen(function* () { + const fetchMock = vi.fn((input: RequestInfo | URL) => + String(input).startsWith("https://relay.example.test/") + ? Promise.reject(new TypeError("Failed to fetch")) + : Promise.resolve(Response.json({ ok: true, endpointRuntimeStatus: null })), + ); + vi.stubGlobal("fetch", fetchMock); + + const error = yield* withServices( + unlinkPrimaryEnvironmentFromCloud({ target: TARGET, clerkToken: "clerk-token" }), + ).pipe(Effect.flip); + + expect(fetchMock.mock.calls.map(([input]) => String(input))).toEqual([ + "http://127.0.0.1:3000/api/connect/unlink", + "https://relay.example.test/v1/client/environment-links/environment-1", + ]); + expect(error.message).toContain( + "Disconnected locally, but T3 Connect did not confirm it removed this environment", + ); + expect(error.message).toContain("Your DNS or firewall may be blocking T3 Connect."); + expect(error.cause).toMatchObject({ + _tag: "ManagedRelayRequestFailedError", + transportFailed: true, + }); + }), + ); }); diff --git a/apps/web/src/cloud/linkEnvironment.ts b/apps/web/src/cloud/linkEnvironment.ts index 8c9697b6908c5..74e0b0bf146f2 100644 --- a/apps/web/src/cloud/linkEnvironment.ts +++ b/apps/web/src/cloud/linkEnvironment.ts @@ -121,7 +121,7 @@ function decodedRelayClientError(message: string) { return (cause: ManagedRelay.ManagedRelayClientError) => { const failed = cause._tag === "ManagedRelayRequestFailedError" ? cause : undefined; const traceId = failed?.traceId; - const detail = failed ? relayRequestFailureDetail(failed) : null; + const detail = failed ? (relayRequestFailureDetail(failed) ?? failed.message) : null; return new CloudEnvironmentLinkError({ message: detail ? `${message}: ${detail}` : message, cause, From d83423ba8f11b34deaec38e2bccfa02640054d9d Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Wed, 28 Oct 2026 11:01:32 +0000 Subject: [PATCH 04/16] fix(connect): preserve relay timeout details after unlink --- apps/web/src/cloud/linkEnvironment.test.ts | 42 ++++++++++++++++++++++ apps/web/src/cloud/linkEnvironment.ts | 4 +-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts index 182a76a434520..dcfc977d19ed3 100644 --- a/apps/web/src/cloud/linkEnvironment.test.ts +++ b/apps/web/src/cloud/linkEnvironment.test.ts @@ -6,11 +6,14 @@ import { } from "@t3tools/contracts"; import { RelayWebClientId } from "@t3tools/contracts/relay"; import { describe, expect, it } from "@effect/vitest"; +import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; +import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Stream from "effect/Stream"; import * as SubscriptionRef from "effect/SubscriptionRef"; +import * as TestClock from "effect/testing/TestClock"; import { HttpClient } from "effect/http"; import { afterEach, beforeEach, vi } from "vite-plus/test"; import { @@ -312,4 +315,43 @@ describe("web cloud link environment client", () => { }); }), ); + + it.effect("preserves the timeout reason, network hint and trace after local unlink", () => + Effect.gen(function* () { + const relayStarted = yield* Deferred.make(); + const fetchMock = vi.fn((input: RequestInfo | URL) => { + if (String(input).startsWith("https://relay.example.test/")) { + Deferred.doneUnsafe(relayStarted, Effect.void); + return new Promise(() => {}); + } + return Promise.resolve(Response.json({ ok: true, endpointRuntimeStatus: null })); + }); + vi.stubGlobal("fetch", fetchMock); + + const unlink = yield* withServices( + unlinkEnvironmentFromCloud({ + target: { environmentId: EnvironmentId.make(TARGET.environmentId) }, + clerkToken: "clerk-token", + }), + ).pipe(Effect.flip, Effect.forkChild); + yield* Deferred.await(relayStarted); + yield* TestClock.adjust(ManagedRelay.MANAGED_RELAY_REQUEST_TIMEOUT_MS); + const error = yield* Fiber.join(unlink); + + expect(fetchMock.mock.calls.map(([input]) => String(input))).toEqual([ + "http://127.0.0.1:3000/api/connect/unlink", + "https://relay.example.test/v1/client/environment-links/environment-1", + ]); + expect(error.message).toContain( + "Disconnected locally, but T3 Connect did not confirm it removed this environment", + ); + expect(error.message).toContain("Relay environment unlinking timed out."); + expect(error.message).toContain("Your DNS or firewall may be blocking T3 Connect."); + expect(error.traceId).toEqual(expect.any(String)); + expect(error.cause).toMatchObject({ + _tag: "ManagedRelayRequestTimeoutError", + traceId: error.traceId, + }); + }), + ); }); diff --git a/apps/web/src/cloud/linkEnvironment.ts b/apps/web/src/cloud/linkEnvironment.ts index 74e0b0bf146f2..a25ce76730a11 100644 --- a/apps/web/src/cloud/linkEnvironment.ts +++ b/apps/web/src/cloud/linkEnvironment.ts @@ -120,8 +120,8 @@ const isEnvironmentCloudApiError = Schema.is( function decodedRelayClientError(message: string) { return (cause: ManagedRelay.ManagedRelayClientError) => { const failed = cause._tag === "ManagedRelayRequestFailedError" ? cause : undefined; - const traceId = failed?.traceId; - const detail = failed ? (relayRequestFailureDetail(failed) ?? failed.message) : null; + const traceId = "traceId" in cause ? cause.traceId : undefined; + const detail = failed ? (relayRequestFailureDetail(failed) ?? failed.message) : cause.message; return new CloudEnvironmentLinkError({ message: detail ? `${message}: ${detail}` : message, cause, From ee4ae47208c8060279a644de5977f07a50a4fb17 Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Thu, 29 Oct 2026 02:36:10 +0000 Subject: [PATCH 05/16] fix(web): make relay unlink errors readable --- .../useCloudLinkController.browser.test.tsx | 15 ++++--- apps/web/src/cloud/useCloudLinkController.ts | 45 ++++++++++++------- .../clerk/T3ConnectUserProfilePage.tsx | 35 +++++++++------ 3 files changed, 62 insertions(+), 33 deletions(-) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index 2b14339c30fae..837c70abf9d6e 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -274,12 +274,17 @@ describe("useCloudLinkController", () => { expect(testState.toast).toHaveBeenCalledOnce(); expect(testState.toast).toHaveBeenCalledWith( expect.objectContaining({ - description: message, + description: "T3 Connect couldn't finish disconnecting. Try again.", + actionProps: { + children: "Copy trace ID", + onClick: expect.any(Function), + }, data: { - secondaryActionProps: { - children: "Copy trace ID", - onClick: expect.any(Function), - }, + actionLayout: "stacked-end", + actionVariant: "outline", + hideCopyButton: true, + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, }, }), ); diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 2fca9396ccc88..9981641c0b436 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -18,6 +18,7 @@ import * as Schema from "effect/Schema"; import { useState } from "react"; import { toastManager } from "../components/ui/toast"; +import { stackedThreadToast } from "../components/ui/toastHelpers"; import { relayEnvironmentDiscovery } from "../state/relay"; import { readEnvironmentScope } from "../state/session"; import { useAtomCommand } from "../state/use-atom-command"; @@ -84,24 +85,35 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { const [operationError, setOperationError] = useState(null); const [tunnelLimit, setTunnelLimit] = useState(null); - const reportUpdateFailure = (cause: unknown) => { + const reportUpdateFailure = ( + cause: unknown, + description = "T3 Connect couldn't save this change. See the details and try again.", + ) => { const message = cause instanceof Error ? cause.message : "Could not update T3 Connect access."; const traceId = findErrorTraceId(cause); console.error("[t3-connect] Could not update T3 Connect", { message, traceId, cause }); setOperationError(traceId ? `${message} Trace ID: ${traceId}` : message); - toastManager.add({ - type: "error", - title: "Could not update T3 Connect", - description: message, - data: traceId - ? { - secondaryActionProps: { - children: "Copy trace ID", - onClick: () => void navigator.clipboard?.writeText(traceId), - }, - } - : undefined, - }); + toastManager.add( + stackedThreadToast({ + type: "error", + title: "Could not update T3 Connect", + description, + ...(traceId + ? { + actionProps: { + children: "Copy trace ID", + onClick: () => void navigator.clipboard?.writeText(traceId), + }, + } + : {}), + actionVariant: "outline", + data: { + hideCopyButton: true, + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, + }, + }), + ); }; const linkData = cloudLinkState.data; @@ -157,7 +169,10 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { refreshManagedTunnelUsage(); if (unlinkResult._tag === "Failure") { if (!isAtomCommandInterrupted(unlinkResult)) { - reportUpdateFailure(squashAtomCommandFailure(unlinkResult)); + reportUpdateFailure( + squashAtomCommandFailure(unlinkResult), + "T3 Connect couldn't finish disconnecting. Try again.", + ); } cloudLinkState.refresh(); await refreshRelayEnvironments(); diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index e02186af9e6fd..d5e1e4a9394f8 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -20,6 +20,7 @@ import { Button, InlineButton } from "../ui/button"; import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible"; import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty"; import { toastManager } from "../ui/toast"; +import { stackedThreadToast } from "../ui/toastHelpers"; import { ClerkUserProfilePage, ClerkUserProfileRefreshButton, @@ -220,19 +221,27 @@ export function T3ConnectUserProfilePage() { traceId, cause, }); - toastManager.add({ - type: "error", - title: "Could not deregister server", - description: message, - data: traceId - ? { - secondaryActionProps: { - children: "Copy trace ID", - onClick: () => void navigator.clipboard?.writeText(traceId), - }, - } - : undefined, - }); + toastManager.add( + stackedThreadToast({ + type: "error", + title: "Could not deregister server", + description: "T3 Connect couldn't confirm removal. Try again.", + ...(traceId + ? { + actionProps: { + children: "Copy trace ID", + onClick: () => void navigator.clipboard?.writeText(traceId), + }, + } + : {}), + actionVariant: "outline", + data: { + hideCopyButton: true, + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, + }, + }), + ); }; const removedEnvironmentLinkedAt = From c01851e345c70cc0461cfac7b45e6a92ae4792bf Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Thu, 29 Oct 2026 12:05:04 +0000 Subject: [PATCH 06/16] fix(web): keep relay unlink toasts short with the copy error button Co-Authored-By: Claude Opus 5.5 --- .../src/cloud/useCloudLinkController.browser.test.tsx | 5 +---- apps/web/src/cloud/useCloudLinkController.ts | 9 ++------- .../src/components/clerk/T3ConnectUserProfilePage.tsx | 7 +------ 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index 837c70abf9d6e..c167c5e784068 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -274,7 +274,7 @@ describe("useCloudLinkController", () => { expect(testState.toast).toHaveBeenCalledOnce(); expect(testState.toast).toHaveBeenCalledWith( expect.objectContaining({ - description: "T3 Connect couldn't finish disconnecting. Try again.", + description: "Could not finish disconnecting. Try again.", actionProps: { children: "Copy trace ID", onClick: expect.any(Function), @@ -282,9 +282,6 @@ describe("useCloudLinkController", () => { data: { actionLayout: "stacked-end", actionVariant: "outline", - hideCopyButton: true, - expandableContent: message, - expandableLabels: { expand: "Show more", collapse: "Show less" }, }, }), ); diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 9981641c0b436..b0a0c17e4e582 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -87,7 +87,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { const reportUpdateFailure = ( cause: unknown, - description = "T3 Connect couldn't save this change. See the details and try again.", + description = "Could not save this change. Try again.", ) => { const message = cause instanceof Error ? cause.message : "Could not update T3 Connect access."; const traceId = findErrorTraceId(cause); @@ -107,11 +107,6 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { } : {}), actionVariant: "outline", - data: { - hideCopyButton: true, - expandableContent: message, - expandableLabels: { expand: "Show more", collapse: "Show less" }, - }, }), ); }; @@ -171,7 +166,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { if (!isAtomCommandInterrupted(unlinkResult)) { reportUpdateFailure( squashAtomCommandFailure(unlinkResult), - "T3 Connect couldn't finish disconnecting. Try again.", + "Could not finish disconnecting. Try again.", ); } cloudLinkState.refresh(); diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index d5e1e4a9394f8..d8575c4cdcdf4 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -225,7 +225,7 @@ export function T3ConnectUserProfilePage() { stackedThreadToast({ type: "error", title: "Could not deregister server", - description: "T3 Connect couldn't confirm removal. Try again.", + description: "Could not remove this server. Try again.", ...(traceId ? { actionProps: { @@ -235,11 +235,6 @@ export function T3ConnectUserProfilePage() { } : {}), actionVariant: "outline", - data: { - hideCopyButton: true, - expandableContent: message, - expandableLabels: { expand: "Show more", collapse: "Show less" }, - }, }), ); }; From 06175d66e0559395c03798b2f8e4091631cf496d Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Thu, 29 Oct 2026 12:45:39 +0000 Subject: [PATCH 07/16] fix(web): expose deregistration error details on demand --- apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index d8575c4cdcdf4..dada760b579bc 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -235,6 +235,10 @@ export function T3ConnectUserProfilePage() { } : {}), actionVariant: "outline", + data: { + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, + }, }), ); }; From 1ae817cdfa1c46b47e014c028e56b12fd6c39bed Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Thu, 29 Oct 2026 13:01:06 +0000 Subject: [PATCH 08/16] fix(web): expose unlink error details in the toast --- apps/web/src/cloud/useCloudLinkController.browser.test.tsx | 2 ++ apps/web/src/cloud/useCloudLinkController.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index c167c5e784068..29ee3cd695ce7 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -282,6 +282,8 @@ describe("useCloudLinkController", () => { data: { actionLayout: "stacked-end", actionVariant: "outline", + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, }, }), ); diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index b0a0c17e4e582..770322fc997b8 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -107,6 +107,10 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { } : {}), actionVariant: "outline", + data: { + expandableContent: message, + expandableLabels: { expand: "Show more", collapse: "Show less" }, + }, }), ); }; From 3da86519e96d0e6ce138d5e7837e0897ec55ff75 Mon Sep 17 00:00:00 2001 From: PR Batch Tester Date: Thu, 29 Oct 2026 13:21:15 +0000 Subject: [PATCH 09/16] fix(web): copy full details from short error toasts --- .../useCloudLinkController.browser.test.tsx | 1 + apps/web/src/cloud/useCloudLinkController.ts | 1 + .../clerk/T3ConnectUserProfilePage.tsx | 1 + .../src/components/ui/toast.browser.test.tsx | 19 ++++++++++++++++++- apps/web/src/components/ui/toast.tsx | 6 ++++-- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index 29ee3cd695ce7..a6e290db66eb2 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -282,6 +282,7 @@ describe("useCloudLinkController", () => { data: { actionLayout: "stacked-end", actionVariant: "outline", + copyErrorText: message, expandableContent: message, expandableLabels: { expand: "Show more", collapse: "Show less" }, }, diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 770322fc997b8..c35ffa6590142 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -108,6 +108,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { : {}), actionVariant: "outline", data: { + copyErrorText: message, expandableContent: message, expandableLabels: { expand: "Show more", collapse: "Show less" }, }, diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index dada760b579bc..960686cd22224 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -236,6 +236,7 @@ export function T3ConnectUserProfilePage() { : {}), actionVariant: "outline", data: { + copyErrorText: message, expandableContent: message, expandableLabels: { expand: "Show more", collapse: "Show less" }, }, diff --git a/apps/web/src/components/ui/toast.browser.test.tsx b/apps/web/src/components/ui/toast.browser.test.tsx index d826ab6bdc40a..644495be64395 100644 --- a/apps/web/src/components/ui/toast.browser.test.tsx +++ b/apps/web/src/components/ui/toast.browser.test.tsx @@ -1,10 +1,27 @@ -import { describe, expect, it } from "vite-plus/test"; +import { describe, expect, it, vi } from "vite-plus/test"; import { page } from "vite-plus/test/browser"; import { render } from "../../../test/render"; import { ToastProvider, toastManager } from "./toast"; describe("toastManager", () => { + it("copies the full error when the description is a short summary", async () => { + await using _screen = await render({null}); + using writeText = vi.spyOn(navigator.clipboard, "writeText").mockResolvedValue(); + const message = "Relay encountered an internal error (upstream_unavailable)."; + const id = toastManager.add({ + type: "error", + title: "Could not update T3 Connect", + description: "Could not finish disconnecting. Try again.", + data: { copyErrorText: message }, + }); + using _toast = { [Symbol.dispose]: () => toastManager.close(id) }; + + await page.getByRole("button", { name: "Copy error", exact: true }).click(); + + await vi.waitFor(() => expect(writeText).toHaveBeenCalledWith(message)); + }); + it("shows a toast added before any provider mounted", async () => { toastManager.add({ type: "info", title: "Raised before the first render" }); diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx index acf7cf11934bf..0f36f0b69a1bc 100644 --- a/apps/web/src/components/ui/toast.tsx +++ b/apps/web/src/components/ui/toast.tsx @@ -35,6 +35,7 @@ export type ThreadToastData = { onClose?: (() => void) | undefined; dismissAfterVisibleMs?: number; hideCopyButton?: boolean; + copyErrorText?: string; additionalActions?: ReadonlyArray<{ id: string; props: ComponentPropsWithoutRef<"button">; @@ -306,9 +307,10 @@ function deriveToastBodyDescriptor(toast: { toast.data?.actionVariant ?? "default"; const secondaryActionVariant: NonNullable = toast.data?.secondaryActionVariant ?? "outline"; + const errorText = toast.data?.copyErrorText ?? toast.description; const copyErrorText = - toast.type === "error" && typeof toast.description === "string" && !toast.data?.hideCopyButton - ? toast.description + toast.type === "error" && typeof errorText === "string" && !toast.data?.hideCopyButton + ? errorText : null; const hasAdditionalActions = (toast.data?.additionalActions?.length ?? 0) > 0; const hasSecondaryAction = toast.data?.secondaryActionProps !== undefined; From 6cd26913db08ee68a488ed62b0600c3ef2942ceb Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:49:13 +0000 Subject: [PATCH 10/16] fix(web): close deregister confirmation when the request fails The open confirmation dialog's header sat over the error toast and swallowed clicks on Show more and Copy, so the failure details were unreachable. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index 960686cd22224..323b46d6ca37a 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -193,9 +193,9 @@ export function T3ConnectUserProfilePage() { }); mutationPendingRef.current = false; setDeregisteringEnvironmentId(null); + setConfirmingEnvironmentId(null); if (result._tag === "Success") { - setConfirmingEnvironmentId(null); setRemovedEnvironments((current) => { const linkedAtById = new Map(current.accountId === accountId ? current.linkedAtById : []); linkedAtById.set(environment.environmentId, environment.linkedAt); From bf39436e0ed7e39b6e64aa7610975d42a4582c27 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:54:50 +0000 Subject: [PATCH 11/16] fix(web): keep account error toasts above the Clerk modal --- apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx | 2 +- apps/web/src/components/clerk/clerkAppearance.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index 323b46d6ca37a..960686cd22224 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -193,9 +193,9 @@ export function T3ConnectUserProfilePage() { }); mutationPendingRef.current = false; setDeregisteringEnvironmentId(null); - setConfirmingEnvironmentId(null); if (result._tag === "Success") { + setConfirmingEnvironmentId(null); setRemovedEnvironments((current) => { const linkedAtById = new Map(current.accountId === accountId ? current.linkedAtById : []); linkedAtById.set(environment.environmentId, environment.linkedAt); diff --git a/apps/web/src/components/clerk/clerkAppearance.ts b/apps/web/src/components/clerk/clerkAppearance.ts index 31b22995faf0b..119ec7124db41 100644 --- a/apps/web/src/components/clerk/clerkAppearance.ts +++ b/apps/web/src/components/clerk/clerkAppearance.ts @@ -29,7 +29,7 @@ export const clerkAppearance = { colorRing: "var(--ring)", }, elements: { - modalBackdrop: "dialog-backdrop", + modalBackdrop: "dialog-backdrop z-50", cardBox: "dialog-glass rounded-2xl border", card: "border-0 bg-transparent shadow-none", footer: "bg-transparent bg-none", From 977f02116429ca67af46049f4ec3201c1b19dd52 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:22:17 +0000 Subject: [PATCH 12/16] fix(web): make relay error toasts expand from their summary The unlink and deregister error toasts put a hand-styled "Show more" button between the summary and the outline "Copy trace ID" button. They now use the toast's existing description expand trigger, so one row holds the copy and trace controls, and the expanded diagnostic reads in the description's muted style. Also drops tests that repeat the same failure or only mirror toast props. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/cloud/linkEnvironment.test.ts | 28 ------------------- apps/web/src/cloud/linkEnvironment.ts | 2 +- .../useCloudLinkController.browser.test.tsx | 17 +---------- apps/web/src/cloud/useCloudLinkController.ts | 1 + .../clerk/T3ConnectUserProfilePage.tsx | 1 + .../src/components/ui/toast.browser.test.tsx | 19 +------------ apps/web/src/components/ui/toast.tsx | 2 +- .../src/relay/managedRelay.test.ts | 18 ------------ 8 files changed, 6 insertions(+), 82 deletions(-) diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts index dcfc977d19ed3..f81ff7a9c512c 100644 --- a/apps/web/src/cloud/linkEnvironment.test.ts +++ b/apps/web/src/cloud/linkEnvironment.test.ts @@ -288,34 +288,6 @@ describe("web cloud link environment client", () => { }), ); - it.effect("preserves the network hint when relay cleanup fails after local unlink", () => - Effect.gen(function* () { - const fetchMock = vi.fn((input: RequestInfo | URL) => - String(input).startsWith("https://relay.example.test/") - ? Promise.reject(new TypeError("Failed to fetch")) - : Promise.resolve(Response.json({ ok: true, endpointRuntimeStatus: null })), - ); - vi.stubGlobal("fetch", fetchMock); - - const error = yield* withServices( - unlinkPrimaryEnvironmentFromCloud({ target: TARGET, clerkToken: "clerk-token" }), - ).pipe(Effect.flip); - - expect(fetchMock.mock.calls.map(([input]) => String(input))).toEqual([ - "http://127.0.0.1:3000/api/connect/unlink", - "https://relay.example.test/v1/client/environment-links/environment-1", - ]); - expect(error.message).toContain( - "Disconnected locally, but T3 Connect did not confirm it removed this environment", - ); - expect(error.message).toContain("Your DNS or firewall may be blocking T3 Connect."); - expect(error.cause).toMatchObject({ - _tag: "ManagedRelayRequestFailedError", - transportFailed: true, - }); - }), - ); - it.effect("preserves the timeout reason, network hint and trace after local unlink", () => Effect.gen(function* () { const relayStarted = yield* Deferred.make(); diff --git a/apps/web/src/cloud/linkEnvironment.ts b/apps/web/src/cloud/linkEnvironment.ts index a25ce76730a11..1adfb24e406fd 100644 --- a/apps/web/src/cloud/linkEnvironment.ts +++ b/apps/web/src/cloud/linkEnvironment.ts @@ -121,7 +121,7 @@ function decodedRelayClientError(message: string) { return (cause: ManagedRelay.ManagedRelayClientError) => { const failed = cause._tag === "ManagedRelayRequestFailedError" ? cause : undefined; const traceId = "traceId" in cause ? cause.traceId : undefined; - const detail = failed ? (relayRequestFailureDetail(failed) ?? failed.message) : cause.message; + const detail = (failed && relayRequestFailureDetail(failed)) ?? cause.message; return new CloudEnvironmentLinkError({ message: detail ? `${message}: ${detail}` : message, cause, diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index a6e290db66eb2..3ea8ab34830a8 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -272,21 +272,6 @@ describe("useCloudLinkController", () => { expect(testState.refreshLink).toHaveBeenCalledOnce(); expect(testState.refreshDiscovery).toHaveBeenCalledOnce(); expect(testState.toast).toHaveBeenCalledOnce(); - expect(testState.toast).toHaveBeenCalledWith( - expect.objectContaining({ - description: "Could not finish disconnecting. Try again.", - actionProps: { - children: "Copy trace ID", - onClick: expect.any(Function), - }, - data: { - actionLayout: "stacked-end", - actionVariant: "outline", - copyErrorText: message, - expandableContent: message, - expandableLabels: { expand: "Show more", collapse: "Show less" }, - }, - }), - ); + expect(screen.controller()?.operationError).toBe(`${message} Trace ID: unlink-trace`); }); }); diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index c35ffa6590142..91d3376e68845 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -110,6 +110,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { data: { copyErrorText: message, expandableContent: message, + expandableDescriptionTrigger: true, expandableLabels: { expand: "Show more", collapse: "Show less" }, }, }), diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index 960686cd22224..921b0d677afe7 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -238,6 +238,7 @@ export function T3ConnectUserProfilePage() { data: { copyErrorText: message, expandableContent: message, + expandableDescriptionTrigger: true, expandableLabels: { expand: "Show more", collapse: "Show less" }, }, }), diff --git a/apps/web/src/components/ui/toast.browser.test.tsx b/apps/web/src/components/ui/toast.browser.test.tsx index 644495be64395..d826ab6bdc40a 100644 --- a/apps/web/src/components/ui/toast.browser.test.tsx +++ b/apps/web/src/components/ui/toast.browser.test.tsx @@ -1,27 +1,10 @@ -import { describe, expect, it, vi } from "vite-plus/test"; +import { describe, expect, it } from "vite-plus/test"; import { page } from "vite-plus/test/browser"; import { render } from "../../../test/render"; import { ToastProvider, toastManager } from "./toast"; describe("toastManager", () => { - it("copies the full error when the description is a short summary", async () => { - await using _screen = await render({null}); - using writeText = vi.spyOn(navigator.clipboard, "writeText").mockResolvedValue(); - const message = "Relay encountered an internal error (upstream_unavailable)."; - const id = toastManager.add({ - type: "error", - title: "Could not update T3 Connect", - description: "Could not finish disconnecting. Try again.", - data: { copyErrorText: message }, - }); - using _toast = { [Symbol.dispose]: () => toastManager.close(id) }; - - await page.getByRole("button", { name: "Copy error", exact: true }).click(); - - await vi.waitFor(() => expect(writeText).toHaveBeenCalledWith(message)); - }); - it("shows a toast added before any provider mounted", async () => { toastManager.add({ type: "info", title: "Raised before the first render" }); diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx index 0f36f0b69a1bc..43d0f0879bc3f 100644 --- a/apps/web/src/components/ui/toast.tsx +++ b/apps/web/src/components/ui/toast.tsx @@ -163,7 +163,7 @@ function CopyErrorButton({ text }: { text: string }) { } const toastExpandablePanelClassName = - "mt-2 max-h-40 min-h-0 overflow-y-auto overscroll-contain pr-0.5 select-text"; + "mt-2 max-h-40 min-h-0 overflow-y-auto overscroll-contain pr-0.5 select-text wrap-break-word text-muted-foreground"; function ToastExpandableSection({ children, diff --git a/packages/client-runtime/src/relay/managedRelay.test.ts b/packages/client-runtime/src/relay/managedRelay.test.ts index 0c947b6d47f99..be14d2d69ab6c 100644 --- a/packages/client-runtime/src/relay/managedRelay.test.ts +++ b/packages/client-runtime/src/relay/managedRelay.test.ts @@ -8,7 +8,6 @@ import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; -import { NETWORK_BLOCKING_HINT } from "../errors/network.ts"; import { RELAY_GATEWAY_TIMEOUT_MESSAGE, relayRequestFailureDetail } from "./errorPresentation.ts"; import * as ManagedRelay from "./managedRelay.ts"; import * as RpcHttp from "../rpc/http.ts"; @@ -454,23 +453,6 @@ describe("ManagedRelayClient", () => { }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); }); - it("keeps an undeclared relay status and the network hint in the message", () => { - expect( - new ManagedRelay.ManagedRelayRequestFailedError({ - action: "unlink relay environment", - cause: new Error("Bad Gateway"), - status: 502, - }).message, - ).toBe("Could not unlink relay environment: Relay returned an unexpected HTTP 502."); - expect( - new ManagedRelay.ManagedRelayRequestFailedError({ - action: "unlink relay environment", - transportFailed: true, - cause: new TypeError("Failed to fetch"), - }).message, - ).toBe(`Could not unlink relay environment. ${NETWORK_BLOCKING_HINT}`); - }); - it.effect("accepts generic DPoP errors from relays without the optional reason", () => { const fetchFn = (() => Promise.resolve( From ec856fd14d63fc1e2cb65858fb4b6a0576c3c521 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Wed, 4 Nov 2026 12:08:43 +0000 Subject: [PATCH 13/16] fix(connect): dismiss deregistration confirmation after failure --- apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index 921b0d677afe7..95be040da2fa9 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -193,9 +193,9 @@ export function T3ConnectUserProfilePage() { }); mutationPendingRef.current = false; setDeregisteringEnvironmentId(null); + setConfirmingEnvironmentId(null); if (result._tag === "Success") { - setConfirmingEnvironmentId(null); setRemovedEnvironments((current) => { const linkedAtById = new Map(current.accountId === accountId ? current.linkedAtById : []); linkedAtById.set(environment.environmentId, environment.linkedAt); From 5ef44f0d02dfb309b9a1d234037a1ee58a692195 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Sat, 7 Nov 2026 14:24:03 +0000 Subject: [PATCH 14/16] test(connect): trim unlink tests to the cases that fail on main Co-Authored-By: Claude Opus 5.5 --- .../useCloudLinkController.browser.test.tsx | 20 ----------- .../src/relay/managedRelay.test.ts | 33 +------------------ 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx index 3ea8ab34830a8..20e1fc71d29ba 100644 --- a/apps/web/src/cloud/useCloudLinkController.browser.test.tsx +++ b/apps/web/src/cloud/useCloudLinkController.browser.test.tsx @@ -254,24 +254,4 @@ describe("useCloudLinkController", () => { expect(screen.controller()?.operationError).toBeNull(); expect(testState.toast).not.toHaveBeenCalled(); }); - - it("refreshes both states after unlink fails without replacing its error", async () => { - using _setup = setup(); - await using screen = await mountController(); - const message = "Disconnected locally, but relay cleanup failed (upstream_unavailable)."; - testState.unlink.mockResolvedValueOnce( - AsyncResult.failure( - Cause.fail(Object.assign(new Error(message), { traceId: "unlink-trace" })), - ), - ); - testState.refreshDiscovery.mockResolvedValueOnce( - AsyncResult.failure(Cause.fail(new Error("Discovery unavailable"))), - ); - - expect(await screen.reconcile({ managedTunnel: false, publish: false })).toBe(false); - expect(testState.refreshLink).toHaveBeenCalledOnce(); - expect(testState.refreshDiscovery).toHaveBeenCalledOnce(); - expect(testState.toast).toHaveBeenCalledOnce(); - expect(screen.controller()?.operationError).toBe(`${message} Trace ID: unlink-trace`); - }); }); diff --git a/packages/client-runtime/src/relay/managedRelay.test.ts b/packages/client-runtime/src/relay/managedRelay.test.ts index be14d2d69ab6c..31ca49c009111 100644 --- a/packages/client-runtime/src/relay/managedRelay.test.ts +++ b/packages/client-runtime/src/relay/managedRelay.test.ts @@ -416,39 +416,8 @@ describe("ManagedRelayClient", () => { expect( error._tag === "ManagedRelayRequestFailedError" ? relayRequestFailureDetail(error) : null, ).toBe(RELAY_GATEWAY_TIMEOUT_MESSAGE); - }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); - }); - - it.effect("names the relay's reason when unlinking fails and keeps its trace ID", () => { - const fetchFn = (() => - Promise.resolve( - Response.json( - { - _tag: "RelayInternalError", - code: "internal_error", - reason: "upstream_unavailable", - traceId: "trace-unlink", - }, - { status: 500 }, - ), - )) satisfies typeof globalThis.fetch; - - return Effect.gen(function* () { - const relayClient = yield* ManagedRelay.ManagedRelayClient; - const error = yield* relayClient - .unlinkEnvironment({ - clerkToken: "clerk-token", - environmentId: EnvironmentId.make("env-1"), - }) - .pipe(Effect.flip); - - expect(error).toMatchObject({ - _tag: "ManagedRelayRequestFailedError", - traceId: "trace-unlink", - relayError: { _tag: "RelayInternalError", reason: "upstream_unavailable" }, - }); expect(error.message).toBe( - "Could not unlink relay environment: Relay encountered an internal error (upstream_unavailable).", + `Could not link relay environment: ${RELAY_GATEWAY_TIMEOUT_MESSAGE}`, ); }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); }); From 8591917df50b1fddf3385c153ad84b4f98003e00 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Sun, 8 Nov 2026 04:53:10 +0000 Subject: [PATCH 15/16] fix(web): show relay unlink failures as a short standard toast Drop the expandable detail and copy-error icon. The toast now says why in one line (T3 Connect unavailable, timed out, or unreachable) with a Copy trace ID action, and the tests are cut to the case that fails on main. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/cloud/linkEnvironment.test.ts | 42 ------------------- apps/web/src/cloud/relayFailureReason.ts | 23 ++++++++++ apps/web/src/cloud/useCloudLinkController.ts | 22 +++------- .../clerk/T3ConnectUserProfilePage.tsx | 12 ++---- apps/web/src/components/ui/toast.tsx | 8 ++-- .../src/relay/managedRelay.test.ts | 3 -- 6 files changed, 36 insertions(+), 74 deletions(-) create mode 100644 apps/web/src/cloud/relayFailureReason.ts diff --git a/apps/web/src/cloud/linkEnvironment.test.ts b/apps/web/src/cloud/linkEnvironment.test.ts index f81ff7a9c512c..791962103a6ec 100644 --- a/apps/web/src/cloud/linkEnvironment.test.ts +++ b/apps/web/src/cloud/linkEnvironment.test.ts @@ -6,14 +6,11 @@ import { } from "@t3tools/contracts"; import { RelayWebClientId } from "@t3tools/contracts/relay"; import { describe, expect, it } from "@effect/vitest"; -import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; -import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Stream from "effect/Stream"; import * as SubscriptionRef from "effect/SubscriptionRef"; -import * as TestClock from "effect/testing/TestClock"; import { HttpClient } from "effect/http"; import { afterEach, beforeEach, vi } from "vite-plus/test"; import { @@ -287,43 +284,4 @@ describe("web cloud link environment client", () => { }); }), ); - - it.effect("preserves the timeout reason, network hint and trace after local unlink", () => - Effect.gen(function* () { - const relayStarted = yield* Deferred.make(); - const fetchMock = vi.fn((input: RequestInfo | URL) => { - if (String(input).startsWith("https://relay.example.test/")) { - Deferred.doneUnsafe(relayStarted, Effect.void); - return new Promise(() => {}); - } - return Promise.resolve(Response.json({ ok: true, endpointRuntimeStatus: null })); - }); - vi.stubGlobal("fetch", fetchMock); - - const unlink = yield* withServices( - unlinkEnvironmentFromCloud({ - target: { environmentId: EnvironmentId.make(TARGET.environmentId) }, - clerkToken: "clerk-token", - }), - ).pipe(Effect.flip, Effect.forkChild); - yield* Deferred.await(relayStarted); - yield* TestClock.adjust(ManagedRelay.MANAGED_RELAY_REQUEST_TIMEOUT_MS); - const error = yield* Fiber.join(unlink); - - expect(fetchMock.mock.calls.map(([input]) => String(input))).toEqual([ - "http://127.0.0.1:3000/api/connect/unlink", - "https://relay.example.test/v1/client/environment-links/environment-1", - ]); - expect(error.message).toContain( - "Disconnected locally, but T3 Connect did not confirm it removed this environment", - ); - expect(error.message).toContain("Relay environment unlinking timed out."); - expect(error.message).toContain("Your DNS or firewall may be blocking T3 Connect."); - expect(error.traceId).toEqual(expect.any(String)); - expect(error.cause).toMatchObject({ - _tag: "ManagedRelayRequestTimeoutError", - traceId: error.traceId, - }); - }), - ); }); diff --git a/apps/web/src/cloud/relayFailureReason.ts b/apps/web/src/cloud/relayFailureReason.ts new file mode 100644 index 0000000000000..0a2d8c232347e --- /dev/null +++ b/apps/web/src/cloud/relayFailureReason.ts @@ -0,0 +1,23 @@ +import { ManagedRelay, relayRequestFailureDetail } from "@t3tools/client-runtime/relay"; +import * as Schema from "effect/Schema"; + +const isRequestFailed = Schema.is(ManagedRelay.ManagedRelayRequestFailedError); +const isRequestTimeout = Schema.is(ManagedRelay.ManagedRelayRequestTimeoutError); + +/** One short line for an error toast saying why a T3 Connect request failed. */ +export function relayFailureReason(cause: unknown): string | null { + for (let current = cause, depth = 0; current instanceof Error && depth < 4; depth += 1) { + if (isRequestTimeout(current) || (isRequestFailed(current) && current.status === 504)) { + return "T3 Connect timed out. Try again."; + } + if (isRequestFailed(current)) { + if (current.transportFailed) return "Could not reach T3 Connect. Check your network."; + if (current.relayError?._tag === "RelayInternalError" || (current.status ?? 0) >= 500) { + return "T3 Connect is unavailable. Try again."; + } + return relayRequestFailureDetail(current); + } + current = current.cause; + } + return null; +} diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 91d3376e68845..2946c12460818 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -19,6 +19,7 @@ import { useState } from "react"; import { toastManager } from "../components/ui/toast"; import { stackedThreadToast } from "../components/ui/toastHelpers"; +import { relayFailureReason } from "./relayFailureReason"; import { relayEnvironmentDiscovery } from "../state/relay"; import { readEnvironmentScope } from "../state/session"; import { useAtomCommand } from "../state/use-atom-command"; @@ -85,10 +86,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { const [operationError, setOperationError] = useState(null); const [tunnelLimit, setTunnelLimit] = useState(null); - const reportUpdateFailure = ( - cause: unknown, - description = "Could not save this change. Try again.", - ) => { + const reportUpdateFailure = (cause: unknown) => { const message = cause instanceof Error ? cause.message : "Could not update T3 Connect access."; const traceId = findErrorTraceId(cause); console.error("[t3-connect] Could not update T3 Connect", { message, traceId, cause }); @@ -97,22 +95,17 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { stackedThreadToast({ type: "error", title: "Could not update T3 Connect", - description, + description: relayFailureReason(cause) ?? message, ...(traceId ? { actionProps: { children: "Copy trace ID", onClick: () => void navigator.clipboard?.writeText(traceId), }, + actionVariant: "outline", } : {}), - actionVariant: "outline", - data: { - copyErrorText: message, - expandableContent: message, - expandableDescriptionTrigger: true, - expandableLabels: { expand: "Show more", collapse: "Show less" }, - }, + data: { hideCopyButton: true }, }), ); }; @@ -170,10 +163,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { refreshManagedTunnelUsage(); if (unlinkResult._tag === "Failure") { if (!isAtomCommandInterrupted(unlinkResult)) { - reportUpdateFailure( - squashAtomCommandFailure(unlinkResult), - "Could not finish disconnecting. Try again.", - ); + reportUpdateFailure(squashAtomCommandFailure(unlinkResult)); } cloudLinkState.refresh(); await refreshRelayEnvironments(); diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index 95be040da2fa9..fdf0f47132ac5 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -13,6 +13,7 @@ import { useManagedRelayEnvironments, useManagedTunnelUsage, } from "../../cloud/managedRelayState"; +import { relayFailureReason } from "../../cloud/relayFailureReason"; import { relayEnvironmentDiscovery } from "../../state/relay"; import { useAtomCommand } from "../../state/use-atom-command"; import { T3CHAT_SUBSCRIPTION_URL, TunnelUsageMeter, tunnelUpgradeCopy } from "../cloud/TunnelUsage"; @@ -225,22 +226,17 @@ export function T3ConnectUserProfilePage() { stackedThreadToast({ type: "error", title: "Could not deregister server", - description: "Could not remove this server. Try again.", + description: relayFailureReason(cause) ?? message, ...(traceId ? { actionProps: { children: "Copy trace ID", onClick: () => void navigator.clipboard?.writeText(traceId), }, + actionVariant: "outline", } : {}), - actionVariant: "outline", - data: { - copyErrorText: message, - expandableContent: message, - expandableDescriptionTrigger: true, - expandableLabels: { expand: "Show more", collapse: "Show less" }, - }, + data: { hideCopyButton: true }, }), ); }; diff --git a/apps/web/src/components/ui/toast.tsx b/apps/web/src/components/ui/toast.tsx index 43d0f0879bc3f..acf7cf11934bf 100644 --- a/apps/web/src/components/ui/toast.tsx +++ b/apps/web/src/components/ui/toast.tsx @@ -35,7 +35,6 @@ export type ThreadToastData = { onClose?: (() => void) | undefined; dismissAfterVisibleMs?: number; hideCopyButton?: boolean; - copyErrorText?: string; additionalActions?: ReadonlyArray<{ id: string; props: ComponentPropsWithoutRef<"button">; @@ -163,7 +162,7 @@ function CopyErrorButton({ text }: { text: string }) { } const toastExpandablePanelClassName = - "mt-2 max-h-40 min-h-0 overflow-y-auto overscroll-contain pr-0.5 select-text wrap-break-word text-muted-foreground"; + "mt-2 max-h-40 min-h-0 overflow-y-auto overscroll-contain pr-0.5 select-text"; function ToastExpandableSection({ children, @@ -307,10 +306,9 @@ function deriveToastBodyDescriptor(toast: { toast.data?.actionVariant ?? "default"; const secondaryActionVariant: NonNullable = toast.data?.secondaryActionVariant ?? "outline"; - const errorText = toast.data?.copyErrorText ?? toast.description; const copyErrorText = - toast.type === "error" && typeof errorText === "string" && !toast.data?.hideCopyButton - ? errorText + toast.type === "error" && typeof toast.description === "string" && !toast.data?.hideCopyButton + ? toast.description : null; const hasAdditionalActions = (toast.data?.additionalActions?.length ?? 0) > 0; const hasSecondaryAction = toast.data?.secondaryActionProps !== undefined; diff --git a/packages/client-runtime/src/relay/managedRelay.test.ts b/packages/client-runtime/src/relay/managedRelay.test.ts index 31ca49c009111..76c6cb905a7a9 100644 --- a/packages/client-runtime/src/relay/managedRelay.test.ts +++ b/packages/client-runtime/src/relay/managedRelay.test.ts @@ -416,9 +416,6 @@ describe("ManagedRelayClient", () => { expect( error._tag === "ManagedRelayRequestFailedError" ? relayRequestFailureDetail(error) : null, ).toBe(RELAY_GATEWAY_TIMEOUT_MESSAGE); - expect(error.message).toBe( - `Could not link relay environment: ${RELAY_GATEWAY_TIMEOUT_MESSAGE}`, - ); }).pipe(Effect.provide(layerManagedRelayTest(fetchFn))); }); From 79c3c2927bb02549ddd47c63ae94573f900c8325 Mon Sep 17 00:00:00 2001 From: shivam <91240327+shivamhwp@users.noreply.github.com> Date: Sun, 8 Nov 2026 05:33:27 +0000 Subject: [PATCH 16/16] fix(connect): keep specific relay errors and say where to finish a failed unlink Co-Authored-By: Claude Opus 5.5 --- apps/web/src/cloud/relayFailureReason.ts | 12 +++++++----- apps/web/src/cloud/useCloudLinkController.ts | 16 +++++++++++++--- .../clerk/T3ConnectUserProfilePage.tsx | 2 ++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/apps/web/src/cloud/relayFailureReason.ts b/apps/web/src/cloud/relayFailureReason.ts index 0a2d8c232347e..805fb53a29051 100644 --- a/apps/web/src/cloud/relayFailureReason.ts +++ b/apps/web/src/cloud/relayFailureReason.ts @@ -7,14 +7,16 @@ const isRequestTimeout = Schema.is(ManagedRelay.ManagedRelayRequestTimeoutError) /** One short line for an error toast saying why a T3 Connect request failed. */ export function relayFailureReason(cause: unknown): string | null { for (let current = cause, depth = 0; current instanceof Error && depth < 4; depth += 1) { - if (isRequestTimeout(current) || (isRequestFailed(current) && current.status === 504)) { - return "T3 Connect timed out. Try again."; - } + if (isRequestTimeout(current)) return "T3 Connect timed out. Try again."; if (isRequestFailed(current)) { if (current.transportFailed) return "Could not reach T3 Connect. Check your network."; - if (current.relayError?._tag === "RelayInternalError" || (current.status ?? 0) >= 500) { - return "T3 Connect is unavailable. Try again."; + if (current.relayError) { + return current.relayError._tag === "RelayInternalError" + ? "T3 Connect is unavailable. Try again." + : relayRequestFailureDetail(current); } + if (current.status === 504) return "T3 Connect timed out. Try again."; + if ((current.status ?? 0) >= 500) return "T3 Connect is unavailable. Try again."; return relayRequestFailureDetail(current); } current = current.cause; diff --git a/apps/web/src/cloud/useCloudLinkController.ts b/apps/web/src/cloud/useCloudLinkController.ts index 2946c12460818..d47572891037c 100644 --- a/apps/web/src/cloud/useCloudLinkController.ts +++ b/apps/web/src/cloud/useCloudLinkController.ts @@ -53,6 +53,7 @@ function isManagedTunnelActive( } const isManagedRelayRequestFailedError = Schema.is(ManagedRelay.ManagedRelayRequestFailedError); +const isManagedRelayClientError = Schema.is(ManagedRelay.ManagedRelayClientError); /** The account's tunnel cap when the relay refused a new tunnel for being at it. */ function tunnelLimitFromLinkFailure(cause: unknown): number | null { @@ -86,7 +87,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { const [operationError, setOperationError] = useState(null); const [tunnelLimit, setTunnelLimit] = useState(null); - const reportUpdateFailure = (cause: unknown) => { + const reportUpdateFailure = (cause: unknown, reason?: string) => { const message = cause instanceof Error ? cause.message : "Could not update T3 Connect access."; const traceId = findErrorTraceId(cause); console.error("[t3-connect] Could not update T3 Connect", { message, traceId, cause }); @@ -95,7 +96,7 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { stackedThreadToast({ type: "error", title: "Could not update T3 Connect", - description: relayFailureReason(cause) ?? message, + description: reason ?? relayFailureReason(cause) ?? message, ...(traceId ? { actionProps: { @@ -163,7 +164,16 @@ export function useCloudLinkController(environmentId: EnvironmentId | null) { refreshManagedTunnelUsage(); if (unlinkResult._tag === "Failure") { if (!isAtomCommandInterrupted(unlinkResult)) { - reportUpdateFailure(squashAtomCommandFailure(unlinkResult)); + const cause = squashAtomCommandFailure(unlinkResult); + // Only the relay delete fails with a relay error, and it runs after the local unlink. + const relayKeptLink = + isCloudEnvironmentLinkError(cause) && isManagedRelayClientError(cause.cause); + reportUpdateFailure( + cause, + relayKeptLink + ? "Disconnected here, but T3 Connect still lists it. Remove it in Account." + : undefined, + ); } cloudLinkState.refresh(); await refreshRelayEnvironments(); diff --git a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx index fdf0f47132ac5..8a863c61b5c33 100644 --- a/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx +++ b/apps/web/src/components/clerk/T3ConnectUserProfilePage.tsx @@ -213,6 +213,8 @@ export function T3ConnectUserProfilePage() { } if (isAtomCommandInterrupted(result)) return; + // The relay may have removed it before failing. + environmentsState.refresh(); const cause = squashAtomCommandFailure(result); const message = cause instanceof Error ? cause.message : "Could not deregister the server."; const traceId = findErrorTraceId(cause);