From 48ff5435d21495233410aa320166a48401ad4366 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 01:48:09 +0000 Subject: [PATCH 1/3] test(server): t3 connect status for an environment linked from the app (#39463) Fails on main: status skips the reachability check and reports Exposure disabled with a Next step to run t3 connect link. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/connect.test.ts | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/apps/server/src/cli/connect.test.ts b/apps/server/src/cli/connect.test.ts index 4fbec456da093..115996d3145e0 100644 --- a/apps/server/src/cli/connect.test.ts +++ b/apps/server/src/cli/connect.test.ts @@ -18,6 +18,7 @@ import { Command } from "effect/cli"; import { makeCli } from "../binCli.ts"; import { CLOUD_CLI_DESIRED_LINK_SECRET } from "../cloud/CliState.ts"; +import { CLOUD_LINKED_USER_ID } from "../cloud/config.ts"; import { makePersistedServerRuntimeState, persistServerRuntimeState, @@ -104,6 +105,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) readonly portFreed?: boolean; readonly command?: "unlink" | "status"; readonly linkMode?: "managed" | "publish_only"; + /** Linked from desktop, web, or mobile: no CLI-desired link is stored. */ + readonly linkedByApp?: boolean; }, ) => Effect.gen(function* () { @@ -143,10 +146,15 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) if (options?.command === "status") { // Status asks the server for reachability only for a managed link. yield* fs.makeDirectory(`${baseDir}/userdata/secrets`, { recursive: true }); - yield* fs.writeFileString( - `${baseDir}/userdata/secrets/${CLOUD_CLI_DESIRED_LINK_SECRET}.bin`, - options.linkMode ?? "managed", - ); + yield* options.linkedByApp + ? fs.writeFileString( + `${baseDir}/userdata/secrets/${CLOUD_LINKED_USER_ID}.bin`, + "user_app_linked", + ) + : fs.writeFileString( + `${baseDir}/userdata/secrets/${CLOUD_CLI_DESIRED_LINK_SECRET}.bin`, + options.linkMode ?? "managed", + ); } yield* Command.runWith(makeCli({ cloudEnabled: true }), { version: "0.0.0" })([ @@ -219,6 +227,19 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) }), ); + it.effect("status checks reachability for an environment linked from the app", () => + Effect.gen(function* () { + const { requests, printed } = yield* runConnect(process.pid, { + command: "status", + linkedByApp: true, + }); + + assert.deepEqual(requests, ["POST /api/connect/reachability"]); + assert.notInclude(printed, "Exposure: disabled"); + assert.notInclude(printed, "Next:"); + }), + ); + it.effect("status does not report a publish-only link as exposed", () => Effect.gen(function* () { const { printed } = yield* runConnect(process.pid, { From 9199ef7de2f1991a9368b36d9ba9344cebf6127e Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 01:55:57 +0000 Subject: [PATCH 2/3] fix(server): t3 connect status reports a link made in the app as on Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/connect.test.ts | 16 ++++++++++----- apps/server/src/cli/connect.ts | 31 ++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/apps/server/src/cli/connect.test.ts b/apps/server/src/cli/connect.test.ts index 115996d3145e0..4d2279f413648 100644 --- a/apps/server/src/cli/connect.test.ts +++ b/apps/server/src/cli/connect.test.ts @@ -18,7 +18,7 @@ import { Command } from "effect/cli"; import { makeCli } from "../binCli.ts"; import { CLOUD_CLI_DESIRED_LINK_SECRET } from "../cloud/CliState.ts"; -import { CLOUD_LINKED_USER_ID } from "../cloud/config.ts"; +import { CLOUD_ENDPOINT_RUNTIME_CONFIG, CLOUD_LINKED_USER_ID } from "../cloud/config.ts"; import { makePersistedServerRuntimeState, persistServerRuntimeState, @@ -147,10 +147,16 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) // Status asks the server for reachability only for a managed link. yield* fs.makeDirectory(`${baseDir}/userdata/secrets`, { recursive: true }); yield* options.linkedByApp - ? fs.writeFileString( - `${baseDir}/userdata/secrets/${CLOUD_LINKED_USER_ID}.bin`, - "user_app_linked", - ) + ? Effect.all([ + fs.writeFileString( + `${baseDir}/userdata/secrets/${CLOUD_LINKED_USER_ID}.bin`, + "user_app_linked", + ), + fs.writeFileString( + `${baseDir}/userdata/secrets/${CLOUD_ENDPOINT_RUNTIME_CONFIG}.bin`, + "{}", + ), + ]) : fs.writeFileString( `${baseDir}/userdata/secrets/${CLOUD_CLI_DESIRED_LINK_SECRET}.bin`, options.linkMode ?? "managed", diff --git a/apps/server/src/cli/connect.ts b/apps/server/src/cli/connect.ts index 787e1c31c741c..9d0128d78e5d8 100644 --- a/apps/server/src/cli/connect.ts +++ b/apps/server/src/cli/connect.ts @@ -36,6 +36,7 @@ import * as CliTokenManager from "../cloud/CliTokenManager.ts"; import { formatReachabilityFailure } from "../cloud/ConnectReachability.ts"; import { filterRelayResponse } from "../cloud/relayResponse.ts"; import { + CLOUD_ENDPOINT_RUNTIME_CONFIG, CLOUD_LINK_REVOKED, CLOUD_LINKED_USER_ID, isAgentActivityPublishingEnabledValue, @@ -199,17 +200,19 @@ function formatCloudStatus( ? "pending server startup" : "not provisioned"; const publishOnly = status.desired && status.linkMode === "publish_only"; - const nextStep = !status.authenticated - ? `Run \`${commands.link}\` to authorize and enable T3 Connect.` - : status.revoked - ? `Run \`${commands.link}\` to link this environment again.` - : !status.desired - ? `Run \`${commands.link}\` to enable T3 Connect.` - : !status.linked - ? publishOnly - ? "Start T3 to provision the environment link." - : "Start T3 to provision the environment link and launch its managed tunnel." - : undefined; + // An app-made link needs no CLI credential once provisioned. + const nextStep = + status.desired && status.linked && !status.revoked + ? undefined + : !status.authenticated + ? `Run \`${commands.link}\` to authorize and enable T3 Connect.` + : status.revoked + ? `Run \`${commands.link}\` to link this environment again.` + : !status.desired + ? `Run \`${commands.link}\` to enable T3 Connect.` + : publishOnly + ? "Start T3 to provision the environment link." + : "Start T3 to provision the environment link and launch its managed tunnel."; return [ "T3 Connect", @@ -672,7 +675,8 @@ const connectStatusCommand = Command.make("status", { const relayClient = yield* RelayClient.RelayClient; const tokens = yield* CliTokenManager.CloudCliTokenManager; const [ - desired, + cliDesired, + managedTunnel, authenticated, cloudUserId, relayUrl, @@ -683,6 +687,7 @@ const connectStatusCommand = Command.make("status", { ] = yield* Effect.all( [ CliState.readCliDesiredCloudLink, + secrets.get(CLOUD_ENDPOINT_RUNTIME_CONFIG), tokens.hasCredential, secrets.get(CLOUD_LINKED_USER_ID), secrets.get(RELAY_URL_SECRET), @@ -693,6 +698,8 @@ const connectStatusCommand = Command.make("status", { ], { concurrency: "unbounded" }, ); + // A link made in the desktop, web, or mobile app saves the tunnel config but no CLI marker. + const desired = cliDesired || Option.isSome(managedTunnel); // A publish-only link has no tunnel for other devices to reach. const reachability = desired && linkMode === "managed" ? yield* checkLiveReachability() : null; From bc4450a999a3f9903c5644a59565be6466990ac1 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 02:19:10 +0000 Subject: [PATCH 3/3] fix(server): t3 connect status counts the relay credential as authorization Co-Authored-By: Claude Opus 5.5 --- apps/server/src/cli/connect.test.ts | 11 ++++++++++- apps/server/src/cli/connect.ts | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/server/src/cli/connect.test.ts b/apps/server/src/cli/connect.test.ts index 4d2279f413648..630fe7cbfbb63 100644 --- a/apps/server/src/cli/connect.test.ts +++ b/apps/server/src/cli/connect.test.ts @@ -18,7 +18,11 @@ import { Command } from "effect/cli"; import { makeCli } from "../binCli.ts"; import { CLOUD_CLI_DESIRED_LINK_SECRET } from "../cloud/CliState.ts"; -import { CLOUD_ENDPOINT_RUNTIME_CONFIG, CLOUD_LINKED_USER_ID } from "../cloud/config.ts"; +import { + CLOUD_ENDPOINT_RUNTIME_CONFIG, + CLOUD_LINKED_USER_ID, + RELAY_ENVIRONMENT_CREDENTIAL_SECRET, +} from "../cloud/config.ts"; import { makePersistedServerRuntimeState, persistServerRuntimeState, @@ -156,6 +160,10 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) `${baseDir}/userdata/secrets/${CLOUD_ENDPOINT_RUNTIME_CONFIG}.bin`, "{}", ), + fs.writeFileString( + `${baseDir}/userdata/secrets/${RELAY_ENVIRONMENT_CREDENTIAL_SECRET}.bin`, + "relay_credential", + ), ]) : fs.writeFileString( `${baseDir}/userdata/secrets/${CLOUD_CLI_DESIRED_LINK_SECRET}.bin`, @@ -242,6 +250,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer)) assert.deepEqual(requests, ["POST /api/connect/reachability"]); assert.notInclude(printed, "Exposure: disabled"); + assert.notInclude(printed, "Authorization: missing"); assert.notInclude(printed, "Next:"); }), ); diff --git a/apps/server/src/cli/connect.ts b/apps/server/src/cli/connect.ts index 9d0128d78e5d8..8ef202c2d014f 100644 --- a/apps/server/src/cli/connect.ts +++ b/apps/server/src/cli/connect.ts @@ -41,6 +41,7 @@ import { CLOUD_LINKED_USER_ID, isAgentActivityPublishingEnabledValue, PUBLISH_AGENT_ACTIVITY_SECRET, + RELAY_ENVIRONMENT_CREDENTIAL_SECRET, RELAY_URL_SECRET, } from "../cloud/config.ts"; import { relayUrlConfig } from "../cloud/publicConfig.ts"; @@ -677,7 +678,8 @@ const connectStatusCommand = Command.make("status", { const [ cliDesired, managedTunnel, - authenticated, + cliAuthenticated, + relayCredential, cloudUserId, relayUrl, publishAgentActivity, @@ -689,6 +691,7 @@ const connectStatusCommand = Command.make("status", { CliState.readCliDesiredCloudLink, secrets.get(CLOUD_ENDPOINT_RUNTIME_CONFIG), tokens.hasCredential, + secrets.get(RELAY_ENVIRONMENT_CREDENTIAL_SECRET), secrets.get(CLOUD_LINKED_USER_ID), secrets.get(RELAY_URL_SECRET), secrets.get(PUBLISH_AGENT_ACTIVITY_SECRET), @@ -700,6 +703,8 @@ const connectStatusCommand = Command.make("status", { ); // A link made in the desktop, web, or mobile app saves the tunnel config but no CLI marker. const desired = cliDesired || Option.isSome(managedTunnel); + // Such a link authorizes the environment with its relay credential, not a CLI sign-in. + const authenticated = cliAuthenticated || Option.isSome(relayCredential); // A publish-only link has no tunnel for other devices to reach. const reachability = desired && linkMode === "managed" ? yield* checkLiveReachability() : null;