@devries-cameron20 / t3code Mirror · read-only / commits / a92c43b80b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 20:30 UTC

fix(client-runtime): relay disconnects no longer show as thread errors (#15470)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Julius Marminge committed Oct 3, 2026 at 22:40 UTC a92c43b80ba307f112e0ae03bf64d841475cf326
2 files changed +25 -3
packages/client-runtime/src/errors/transport.test.ts
+15
@@ -1,5 +1,6 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 +import { NETWORK_BLOCKING_HINT } from "./network.ts";
4 import { isTransportConnectionErrorMessage, sanitizeThreadErrorMessage } from "./transport.ts";
5
6 describe("isTransportConnectionErrorMessage", () => {
@@ -30,6 +31,20 @@ describe("isTransportConnectionErrorMessage", () => {
31 expect(isTransportConnectionErrorMessage("ClientProtocolError: socket closed")).toBe(true);
32 });
33
34 + it("recognizes relay connection errors that carry the network hint", () => {
35 + for (const sentence of [
36 + "Relay environment disconnected.",
37 + "Relay environment could not establish a WebSocket connection.",
38 + ]) {
39 + expect(isTransportConnectionErrorMessage(`${sentence} ${NETWORK_BLOCKING_HINT}`)).toBe(true);
40 + }
41 + expect(
42 + isTransportConnectionErrorMessage(
43 + "Your ChatGPT connection expired or was disconnected. Sign in again.",
44 + ),
45 + ).toBe(false);
46 + });
47 +
48 it("returns true for the T3 server WebSocket message", () => {
49 expect(isTransportConnectionErrorMessage("Unable to connect to the T3 server WebSocket.")).toBe(
50 true,
packages/client-runtime/src/errors/transport.ts
+10 -3
@@ -1,11 +1,18 @@
1 +import { NETWORK_BLOCKING_HINT } from "./network.ts";
2 +
3 +const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4 +
5 const TRANSPORT_ERROR_PATTERNS = [
6 /\bSocketCloseError\b/i,
7 /\bSocketOpenError\b/i,
8 /\bSocket is not connected\b/i,
9 /Unable to connect to the T3 server WebSocket\./i,
6 - /\bis not connected\.$/i,
7 - /\bdisconnected\.$/i,
8 - /\bcould not establish a WebSocket connection\.$/i,
10 + // The RPC session appends the network hint for relay connections. Any other
11 + // trailing text means a different error that the user should still see.
12 + new RegExp(
13 + `\\b(?:is not connected|disconnected|could not establish a WebSocket connection)\\.(?: ${escapeRegExp(NETWORK_BLOCKING_HINT)})?$`,
14 + "i",
15 + ),
16 /\bClientProtocolError\b/i,
17 /\bRpcClientError\b/i,
18 /\bping timeout\b/i,