TypeScript
fix(server): T3 Connect not-linked fix no longer tells Desktop users to run t3 service restart (#27660)
Julius Marminge607e373e50a7
diff --git a/apps/server/src/cloud/CloudLink.lifecycle.test.ts b/apps/server/src/cloud/CloudLink.lifecycle.test.tsindex 115ac732c51..39971c81d85 100644--- a/apps/server/src/cloud/CloudLink.lifecycle.test.ts+++ b/apps/server/src/cloud/CloudLink.lifecycle.test.ts@@ -140,6 +140,7 @@ describe("releaseManagedTunnelOnShutdown", () => {readonly address?: HttpServer.HttpServer["Service"]["address"];readonly respondEffect?: Effect.Effect<Response>;readonly getExisting?: CliTokenManager.CloudCliTokenManager["Service"]["getExisting"];+ readonly latestReachability?: ConnectReachability.ConnectReachability["Service"]["latest"];}const writeLauncherState = (update: ServiceUpdateRecord) =>@@ -165,7 +166,7 @@ describe("releaseManagedTunnelOnShutdown", () => {ConnectReachability.ConnectReachability,ConnectReachability.ConnectReachability.of({check: Effect.die("unused"),- latest: Effect.succeedNone,+ latest: harness.latestReachability ?? Effect.succeedNone,}),),Effect.provideService(HttpServer.HttpServer, {@@ -1050,4 +1051,57 @@ describe("releaseManagedTunnelOnShutdown", () => {expect(values.has(CLOUD_ENDPOINT_RUNTIME_CONFIG)).toBe(false);}).pipe(provideReleaseHarness({ store: failingStore, applyConfigCalls, requests }));});++ it.effect("does not report a not-linked check once the managed tunnel config is stored", () => {+ const { store } = makeMemorySecretStore(managedLinkSecrets);+ const notLinked = ConnectReachability.classifyReachability(+ {+ managedTunnelConfigured: false,+ connector: null,+ endpoint: null,+ edgeReachable: null,+ exitNode: null,+ },+ "2026-10-29T00:00:00.000Z",+ );++ return Effect.gen(function* () {+ const state = yield* (yield* CloudLink.CloudLink).linkState();++ expect(state.managedTunnelActive).toBe(true);+ expect(state.reachability?.status === "unreachable" && state.reachability.cause).not.toBe(+ "not_linked",+ );+ }).pipe(+ provideReleaseHarness({+ store,+ applyConfigCalls: [],+ requests: [],+ latestReachability: Effect.succeedSome(notLinked),+ }),+ );+ });++ it.effect("reports a check that ran after the managed tunnel config was stored", () => {+ const { store } = makeMemorySecretStore(managedLinkSecrets);+ const reachable = {+ status: "reachable" as const,+ checkedAt: "2026-10-29T00:00:00.000Z",+ readyConnections: 4,+ protocol: "quic",+ };++ return Effect.gen(function* () {+ const state = yield* (yield* CloudLink.CloudLink).linkState();++ expect(state.reachability).toEqual(reachable);+ }).pipe(+ provideReleaseHarness({+ store,+ applyConfigCalls: [],+ requests: [],+ latestReachability: Effect.succeedSome(reachable),+ }),+ );+ });});diff --git a/apps/server/src/cloud/CloudLink.ts b/apps/server/src/cloud/CloudLink.tsindex 322a4b7503b..3d8d9650b22 100644--- a/apps/server/src/cloud/CloudLink.ts+++ b/apps/server/src/cloud/CloudLink.ts@@ -1290,6 +1290,13 @@ const make = Effect.gen(function* () {],{ concurrency: 8 },);+ // A not-linked check predates the stored tunnel config; the next check replaces it.+ const currentReachability = Option.filter(+ latestReachability,+ (result) =>+ Option.isNone(endpointRuntimeConfig) ||+ !(result.status === "unreachable" && result.cause === "not_linked"),+ );return {linked: Option.isSome(cloudUserId),linkRevoked: Option.isSome(cloudUserId) && Option.isSome(revoked),@@ -1302,7 +1309,7 @@ const make = Effect.gen(function* () {: false,holdWebhooksWhileOffline:Option.isSome(holdWebhooks) && bytesToString(holdWebhooks.value) === "true",- ...(Option.isSome(latestReachability) ? { reachability: latestReachability.value } : {}),+ ...(Option.isSome(currentReachability) ? { reachability: currentReachability.value } : {}),} satisfies EnvironmentCloudLinkStateResult;});diff --git a/apps/server/src/cloud/ConnectReachability.test.ts b/apps/server/src/cloud/ConnectReachability.test.tsindex 28735b87378..b6a73ab5dcd 100644--- a/apps/server/src/cloud/ConnectReachability.test.ts+++ b/apps/server/src/cloud/ConnectReachability.test.ts@@ -65,6 +65,13 @@ describe("classifyReachability", () => {classifyReachability(facts({ connector: notConnected, edgeReachable: true }), checkedAt),).toMatchObject({ cause: "connector_not_ready" });});++ it("does not point an unlinked server at a background service it may not have", () => {+ // Desktop and `t3 serve` run the server without a background service.+ const result = classifyReachability(facts({ managedTunnelConfigured: false }), checkedAt);+ expect(result).toMatchObject({ cause: "not_linked" });+ expect(result.status === "unreachable" && result.fix).not.toContain("t3 service");+ });});describe("T3 Connect troubleshooting links", () => {diff --git a/apps/server/src/cloud/ConnectReachability.ts b/apps/server/src/cloud/ConnectReachability.tsindex 17e78f4be17..acb581778d9 100644--- a/apps/server/src/cloud/ConnectReachability.ts+++ b/apps/server/src/cloud/ConnectReachability.ts@@ -68,10 +68,11 @@ export function classifyReachability(const restart = "Restart T3 Code. If it stays, run `t3 connect` again.";if (!facts.managedTunnelConfigured) {+ // A running server reads the link `t3 connect` stores only at startup.return fail("not_linked","The server has not set up a T3 Connect tunnel.",- "Run `t3 connect`, then restart the server (`t3 service restart`) so it applies the link.",+ "Run `t3 connect`, then restart T3 Code so it applies the link.",);}if (connector === null) {diff --git a/docs/user/t3-connect-troubleshooting.md b/docs/user/t3-connect-troubleshooting.mdindex 4abe8bcc5d1..4880ce52a2e 100644--- a/docs/user/t3-connect-troubleshooting.md+++ b/docs/user/t3-connect-troubleshooting.md@@ -108,8 +108,9 @@ an active link between your account and the host.- **T3 Connect is off on the host, or the host only publishes agent activity.**On the host, open **Settings > Sharing & access** and turn **T3 Connect** on, orrun `t3 connect`.-- **The host was linked, but the server did not apply the link yet.** Run- `t3 service restart` on the host, or restart `t3 serve`.+- **The host was linked, but the server did not apply the link yet.** Restart+ the server on the host: quit and reopen the T3 Code desktop app, run+ `t3 service restart`, or stop `t3 serve` and run it again.- **This device's sign-in expired, or the host no longer accepts thisdevice.** Sign out of T3 Connect and sign in again.- **This device is still loading its T3 Connect sign-in.** Wait a moment;