GeezerVison is showing github.com — fix(web): Copy MCP URL uses the T3 Connect address (#32937) · adampeterhiggins/t3code@7fe1310
File treeExpand file treeCollapse file tree Open diff view settings packages/client-runtime/src/connection
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/user/outside-agents.md +3-2Lines changed: 3 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -16,8 +16,9 @@ example: | 16 | 16 | https://<environment-address>/mcp | 17 | 17 | ``` | 18 | 18 |
| 19 | | -The copied URL uses the route this device is connected over, so an agent on the | 20 | | -same device can reach it. | | 19 | +When T3 Connect serves the environment, the copied URL is its T3 Connect | | 20 | +address, which agents can reach from anywhere. Otherwise it uses the route this | | 21 | +device is connected over, so an agent on the same device can reach it. | 21 | 22 |
| 22 | 23 | - **An agent on your own computers** can use `localhost` on the host, T3 | 23 | 24 | Connect, or any `https` address, such as | |
Collapse file Copy file name to clipboardExpand all lines: packages/client-runtime/src/connection/presentation.test.ts +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,7 +50,7 @@ function supervisorState(overrides: Partial<SupervisorConnectionState>): Supervi | 50 | 50 | } | 51 | 51 |
| 52 | 52 | describe("connection presentation", () => { | 53 | | - it("copies the MCP address of the route this device is connected over", () => { | | 53 | + it("copies the T3 Connect MCP address first, then the route this device is connected over", () => { | 54 | 54 | const route = (connectionId: string, httpBaseUrl: string): ConnectionRoute => { | 55 | 55 | const target = new BearerConnectionTarget({ ...TARGET, connectionId }); | 56 | 56 | return { | @@ -80,6 +80,13 @@ describe("connection presentation", () => { | 80 | 80 | "http://100.115.1.44:3773/mcp", | 81 | 81 | ); | 82 | 82 | expect(environmentMcpUrl({ entry })).toBe("http://192.168.4.53:3773/mcp"); | | 83 | + expect( | | 84 | + environmentMcpUrl({ | | 85 | + entry, | | 86 | + connectedTarget: lan.target, | | 87 | + relayHttpBaseUrl: "https://tunnel.example.test", | | 88 | + }), | | 89 | + ).toBe("https://tunnel.example.test/mcp"); | 83 | 90 | }); | 84 | 91 |
| 85 | 92 | // regression: #16909 Copy MCP URL falls back to an alternate route when the relay route has no address | |
Collapse file Copy file name to clipboardExpand all lines: packages/client-runtime/src/connection/presentation.ts +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -95,24 +95,24 @@ export function connectionStatusTitle(connection: EnvironmentConnectionPresentat | 95 | 95 | } | 96 | 96 |
| 97 | 97 | /** | 98 | | - * SSH connections ride a local forward that disappears with the client, so they have no stable | 99 | | - * address. | | 98 | + * The T3 Connect address wins whenever it is known: it works for agents anywhere, while the | | 99 | + * connected route is often a LAN or loopback address. SSH routes ride a local forward that | | 100 | + * disappears with the client, so they have no stable address. | 100 | 101 | */ | 101 | 102 | export function environmentMcpUrl(input: { | 102 | 103 | readonly entry: ConnectionCatalogEntry; | 103 | 104 | readonly relayHttpBaseUrl?: string | undefined; | 104 | 105 | readonly connectedTarget?: ConnectionTarget | null | undefined; | 105 | 106 | }): string | null { | | 107 | + const relayMcpUrl = input.relayHttpBaseUrl ? mcpUrlFromBase(input.relayHttpBaseUrl) : null; | | 108 | + if (relayMcpUrl !== null) return relayMcpUrl; | 106 | 109 | const connectedRouteId = input.connectedTarget ? connectionRouteId(input.connectedTarget) : null; | 107 | 110 | const routes = connectionRoutes(input.entry); | 108 | 111 | const connectedRoute = routes.find( | 109 | 112 | (route) => connectionRouteId(route.target) === connectedRouteId, | 110 | 113 | ); | 111 | 114 | for (const route of connectedRoute ? [connectedRoute, ...routes] : routes) { | 112 | | - const httpBaseUrl = | 113 | | - route.target._tag === "RelayConnectionTarget" | 114 | | - ? (input.relayHttpBaseUrl ?? null) | 115 | | - : routeHttpBaseUrl(route); | | 115 | + const httpBaseUrl = routeHttpBaseUrl(route); | 116 | 116 | const mcpUrl = httpBaseUrl === null ? null : mcpUrlFromBase(httpBaseUrl); | 117 | 117 | if (mcpUrl !== null) return mcpUrl; | 118 | 118 | } | |
|